Input devices
Week 11 - Input devices
Here you will find my work description during this eleventh week
General info
Class notes
Assignments
Input board from Neil class
This week’s assignment was to make some sensor boards, flash them with the c code and finally display their values using python script.
I know that I want to use a capacitive sensor, but for now I do not feel confident enough to design the final project board, I need some practice, that is why I am going to analyze the board Neil propose.
The idea is to try to make it generic based on atiny45.
The goal is to have like a generic tiny board where we can change the sensor. something like a tiny version of the arduino. The main board expose its pins, and we can have like tiny shields.
Let’s do it with the Hello.load.45, adding some sockets.
Open Eagle and create new project, you should have 2 files, schematics and board.
Add the following components :
- Attiny45
- Ftdi connector
- R 10k
- R 1M
- C 1uF
- 2x3 connector (ISP)
- 2x2 connector (sensor)
- 1 8x1 female header connector (throughole)
- 1 8x1 male header connector (throughole)
- .
- 2x R 0 (jumpers)
Route as you want 2 boards
Here is the result
Export top layer as monochrome image with high resolution
Import image in photoshop, remove thos littles marks in the hole, and the oulines
Using mods
I used mods to create toolpathes for the milling machine.
generated toolpathes
Milling
I used the roland SRM-20 to mill the traces and the outlines
Then solder components.
First fail:
The holes made have 3mm space instead of the 2.54mm (0.1inch) standard. So the basic header we wanted to use does not fit. I decided to bread the header and solder every pin. That way I cannot use this interface as a standard as I wanted.
Burn the boolader
I decided to use arduino to burn the fuses. You can see the details in the picture
but it fails …
Second fail
Solder the pins this way was difficult because the copper is on top of the board and the pins avec a little bit of black plastic. Inspecting the routes, I realize that suring the soldering operatin, I soldered 2 traces together. Using some solder wig allowed me to remove this unwanted bridge.
Burning the bootlaoder again, and it worked.
Programming
The challenge was to able to compile and upload the code using the AVR-toolchain.
I get the code from neil example provided in class
I was under my Pine64 book thas is a ARM 64bits (architecture arm64 different armh of the rasberry pi) running under xenial mate a lightweight tiny computer powered by a single board call pine64. This environment (official package lists) allowed me to install Arduino IDE, but an old version. My challenge here was to simply use a basic text edit like vi to program the board in pure C and using only tools from AVR toolchain.
Commands to launch
Check python version: python -- version
- install python serial library :
sudo apt install pyhon-pip
pip install pyserial
- Get USB port:
ls /dev/tty.*
Load
-
Compile and upload C program :
make -f hello.load.45.make program-usbtiny
-
Run python serial application from Neil :
python python hello.load.45.py /dev/ttyUSB0
Third fail
During the testing I remove and put again the capacitive copper foil cable but at one time it broke. The trace unstick from the board. I resolder it as I can using resistor legs.
Here is the result, this assignemnt does not look difficult but it was laborious for my second board. I think I learn a lot.
Files to download
Click here to download C & python code
Click here to PCB files including photoshop files
EDIT : final project input tests
Or how I used what I learnt during this assignment for final project.
Rotary encoder
First try with a rotary encoder module. My first thougth was to use this king of input device to let user choose their level of happiness by turning the top ring.
So I studied how they work. You have 2 ways to use this encode, using built in interupt pin (best option if you have an interrupt pin available, that was not my case). Or reading the states of the 2 pins DT and CLK (SW is used as a switch if you want to click on the shaft).
I used the oscilloscope to analyse the states when I turn clockwise and counterclockwise.
You will find an excellent explaination on Youtube How to Mechatronics channel.
When turning we can observe a phase offset, depending on the combination HIGH+LOW or HIGH+HIGH we can gess the way.
Used code in arduino IDE
#define STEP 9
int pinA = A2;
int pinB = A3;
int lastValue = LOW;
int currentValue = LOW;
int n = 0;
void setup() {
// rotary encoder init
pinMode(pinA, INPUT);
pinMode(pinB, INPUT);
lastValue = digitalRead(pinA);
}
void loop(){
currentValue = digitalRead(pinA);
// if state has changed
if ((lastValue == LOW) && (currentValue == HIGH)) {
// check other pin state
if (digitalRead(pinB) == LOW) {
n-= STEP; // decrement CCW
} else {
n += STEP; // increment CW
}
}
Finally I gave up the idea of using this sensor because it would force me to use an extra slip ring and to modify the design of the final project.
Capacitive sensor
Finally for final project I used a capacitive sensor that works similar than the load sensor. Using conductive Ink and bigger resistors.
For more informations visit final project development page
To download capacitive sensor code, download final project code
Stay in touch
Hi, I'm
Joris Navarro, from Perpignan (France), a proud dad, a fab director/manager, a teacher, a ceo, a FabAcademy student, but not only. Click here to know more about me.
Check my work for FabAcademy on FabCloud GitLab
@joris.navarro.
Want to say Hi ? Please send me a message.