Week Nine: Input Devices
dance dance revolutionizing
Task
Measure something: add a sensor to a microcontroller board and read it.
Result
This week I wanted to make ballroom dance partner peace mediating system. When dancing, you need to know what foot your weight is on and disagreements on this often cause arguments between partners. Pressure sensors in each shoe would determine how the dancer was standing and LEDs on the dancer's shoulder and wrists would make that information visible to both people.
I took a twisted path towards this system, with a few side-results along the way, including a light sensor, a stretch sensor, a pressure sensor, and the final(ish) system:
Files
Here are the board and code files for the various sensors:
Approach
Design
I created my board using Eagle and building from the light sensor design. I wanted to add multiple sensors and output pins, so I switched from the ATtiny45 to the ATtiny44. I also made the original ATtiny45 light sensor board and vinyl cut traces for a few sets of LEDs in parallel.
I milled and stuffed the board with the Roland Modela as usual. I vinyl cut the traces for the LEDs...this was a learning experience, possibly one I would not repeat.
I had to do some system prep before running the code. First I installed tkinker though "sudo apt-get install python-tk" and added execution privileges to the python scripts. A few sticking points here--the files were in my Windows partition and running "chmod +x hello.light.44.py" had no effect and gave no error! Relocating them to the Ubuntu partition solved this.
To compile, upload, and run the codes I used:
make
sudo make program-usbtiny
python python filename /dev/ttyUSB0
I used the CBA code for the light sensor board without any trouble. I altered this code in steps for my pressure/stretch sensing board with python-serial/LED output off the ATtiny44. This took some (much) debugging--thanks to Dan Novy and Valentine for help and advice! See Trials and Tribulations for details. A few highlights of re-coding process:
Once the python script was mostly working, I experimented with various combinations of conductive and non-(less)-conductive materials as sensors with the code I was using. Ultimately I was sensing change in resistance of the materials as they were acted upon by the outside world. I tried a number of (1) conductive-ish materials (2) conductive materials separated by less-conductive fabric with the following results:
I suspect most of these materials would work as sensors if "calibrated" right in the hardware and code, but since I found a few things that worked I let that go for now. The adhesive copper separated by green lace worked great for my purposes--it showed no connection with light contact and full connection with substantial pressure, without too much fuzz in-between. Off/on seemed like a good place to start, though modulating LED intensity based on amount of pressure would be a nice step later on.
I tried a number of things in the code, including implementing bipolar difference of two pressure sensors and an initial pressure calibration phase. These sort of worked, but are still in progress.
Having selected my sensor and testing its step sensing suitability, I started assembling the ballroom dance partner peace mediating system in real life. My tabletop version used alligator clips to connect the various parts. I was advised to solder everything when I was ready for a long term connection...this did not turn out well in the tabletop to person transfer. I used hot glue and tape liberally, but while attaching the shoe pressure sensors and the board to the belt worked okay the LEDs connections ripped quickly and resisted attempts to reattach them.
Trials and Tribulations
I misassigned my ADC pins on my first attempt at modifying the light board for the ATtiny44. Despite a post-it note from myself warning against this, I didn't pay attention to whether the ATtiny44 pins I was selecting for the sensor I was selecting were ADC and of course they were the few that weren't. Lesson: don't trust late night Eagle files. At Valentin's advice, I Frankenstein-ed the board by cutting traces and adding wires to reassign the pins. This was a soldering challenge and I got worried that I overheated the chip in the process so I ended up re-doing the board.
Vinyl cutting the LED board extensions was an adventure--thanks to Sam for sharing the suffering. It's definitely worth cutting many boards while tweaking the blade height, force, and speed instead of trying to weed a board that's not nicely cut. As you can see from the picture, my tweezer skills improved with practice. I found cutting through the Linux work-flow was more straightforward that Windows.
The connections between the board and the LED and pressure sensor extensions did not hold up in real life deployment. I connected the parts by soldering wires and enforcing the attachments with hot glue and tape. Soldering on the wires was a (literal) huge pain--I frequently burned myself trying to hold everything in place. I need a new technique for this. Additionally, even small movements of the wires and board caused the traces to quickly peel up. Perhaps altering soldering and hot gluing would have prevented this, but I'd probably go with formal connectors the next time around, as well as boards instead of vinyl cut circuits.
A few other notes on problems: