13. Input device¶
Group assignment¶
- probe an input device’s analog levels and digital signals
Documentation at: Fablab Taipei
individual assignment¶
- measure something: add a sensor to a microcontroller board that you have designed and read it
This week I started with trying the input device that I am very interested: the step response. According to professor Neil it has do many sensing functions and only require 2 resistors! Also want to try different ways to detect checker moving related to my final project.
I reused my Attiny45 core board from week 10, and you can download the latest version in week 14.
Software debugging¶
I started with simple bread board connecting. This is a quick way to test but I got some problem with software issue here.
To use Neil’s hello.txrx.45.py code, I need to got all libraries needed installed.
- tkinter
- serial
- sys
You can test the python code with python3 hello.txrx.45.py
in the folder have this file.
Trouble shooting step by step
tkinter¶
First my terminal show error says ModuleNotFoundError: No module named '_tkinter'
. To solve it just run:
$ brew install python-tk
reference. And if you have any permission denied
problem when running this, just do sudo chown -R $(whoami) xxx
(xxx is the path you need permission) which I mentioned in Week 1. If still error, give yourself the permission of the parent folder.
pyserial¶
Second my terminal show error says ModuleNotFoundError: No module named 'serial
. Which should be easy to solve with
$ pip install pyserial
But I still got error after it. It turns out that brew
and pip
have package install in different place and I even got several python version installed, so that;s the reason. To solve it first link the right python version
$ brew unlink python@3.9 && brew link python@3.10
And specify the python version you want to download using pip.
$ python3.10 -m pip install pyserial
And you may also encounter another problem that says “…which is not on PATH.”, and you can create it yourself with this
$ export PATH="${PATH}:/Users/caio.hc.oliveira/Library/Python/3.10/bin"
reference and with these all, pyserial should works finally.
sys¶
Third there’s still a strange stuff happen, terminal says “sys is not defined”… well, this is pretty simple to solve, just add import sys
and that’s all three libraries needed in this .py file.
from tkinter import *
import serial
import sys
That’s all, now you can use ls /Dev/tty.*
(learned in week8)to know your device path and run
$ python3 hello.txrx.45.py (your_device_path)
Step response testing¶
I got my step response works with just dupont wires solder to copper tape! I found out that you don’t really need to touch the copper, even get close to it they can sense you
First version use “txrx” version, which is quite precise (result from 2 pads are the same).
And I also tried the “load” version to test step response, the result is that “sense” pad is not that precise, the “shield” pad is much better.
Test 2 with “load” is even more weird… the number runs the opposite and only when press it heavily the number increase. “txrx” version is more precise in conclusion.
Resistor color code¶
Because I got to use lots of resistors, it’s necessary to understand how their value are decided. There are 2 types of common resistor color code: 4 bands and 5 bands, and their system shows below.