Input Devices

Week 4

This week our group assignment is to probe an input device's analog levels and digital signals(Link: The Group Assignment is Here! ). Individually we have to measure something: add a sensor to a microcontroller board that we have designed and read it.

Tools: PCB Mill (Clank), Soldering Iron, Eagle
Date: 10.01.2020
Capacitive sensing
The presence of a hand must trigger the circuit.
To do this, i read up about capacitive sensing on arduino library .https://playground.arduino.cc/Main/CapacitiveSensor/ So the logic is that the capacitive sensor’s second capacitor plate is the human hand. I put a resistor of 1MOhm such that the capacitor takes a longer time to charge. Once it charges, the presence of the hand will finish capacitor circuit and decrease current flowing through that part of the circuit and hence reduce the values of current flowing. The physical hardware is pretty straightforward for this part. Put a large metal plate across a resistor and connect it to two pins on the tiny. One would think this would be enough, but barely. I guess experience is a great teacher. Windows incompatibility with the entire setup - my new computer gave me interesting problems and challenges, it wouldn’t read the board, no matter what I tried. The ports would just ont get recognized by the device manager or arduino ports or couldn’t even be found on git bash. So i had to go on a wild goose chase to get the usb-c to usb 2.0 hub.


I learned a lot about coding trying to use the arduino library for capacitive sensing. I couldn’t find one for attiny 1614, so used the ones i found but it would simply not interact with my physical hardware.


This took a few days of troubleshooting, as anything in the circuit could have been the culprit - the tiny not working, there being a shorting issue with the tiny pins, etc etc I even tried code used by my colleague Alejandro Diaz for his capacitive sensing journey with the tiny, you can find it here - Link: Alejandro's Capacitive Sensing Page!. To no avail! I attempted to write my own code based on what I had learned about what needs to happen. I had to assign two pins values. In the The whole point it that the capacitive sensing plate will slowly gain and lose voltage between o and the maximum. The whole point is to get readings somewhere in the middle of those ranges. So, assign one pin a high, the other pin a low at specific intervals and get readings in the middle of those cycles. This is the code I was working with:


I had to involve the teaching staff in this journey after I failed at programming the code. Anthony fiddled around with the arduino capsense library and it was to y great relief that he too, realized that the library isn’t compatible with the tinys. 3 days spent, but finally, there was a headway. He helped me tweak the code to work for our purposes. Ok, the next step in the capacitive sensing journey was to use a new code -


Finally, this worked! What’s happening here is that when i place my hand on top of the capacitive sensing plate, the val2 decreases considerably. Over time, one can average out this value and then trigger the motor based on this value. But more on that later! For now, enjoy the cap sens video.

However, i didn’t get it right in the first 20-30 tries. Every time I would plug in the board to try and run the code, my board would fry and i would smell solder and see smoke. Trying to understand the issues, I had to debug everything, starting from the Attiny.