Week Fifteen: Final Project

return of the dance R-evolution strikes back...


Design and make a final project that integrates the range of units covered. Also design and make a machine with a group.



I continue my work from past weeks to create the Ballroom Dance buddy. It:

Late night video proof: (higher quality to come)

I also worked with Sam, Dan, and Catherine on the creepy crawly cutter.




I tested a number of pressure sensor types and configurations. I wanted to develop something soft that was more comfortable to have in your shoe than the copper tape I'd used in the past. I had a pressure sensor knit with conductive thread, but found that it didn't give me much of a signal when stepped on. I ended up using conductive fabric patches on the balls of the foot separated by two layers of non-conductive fabric with holes in it. The parts are anchored to an insole that can be easily fit into a shoe. I made two sets--one by sewing the layers together and another by ironing them together using fusing material (and chopped up hot glue stick).

I also tried a few ways to attach the wires to the conductive material. First I stripped the cable and sewed a stretch to the fabric using conductive thread and a bit of hot glue to hold things in place. This wasn't very successful--it didn't appear to be a robust electrical or mechanical connection. Since this didn't work, I tried to "lightly" solder the connection. This was the preferred approach, though I had to use quite a bit of solder and be careful not the burn through the fabric. I also hot glued everything in place to close things off and was careful when ironing in this area later in the assembly process.

LED bracelets

I laser cut the LED bracelets from clear acrylic, using Corel Draw and the Epilogue laser cutter for a cut layer and a raster layer. I then bent the acrylic into a bracelet-like shape by heating it with the acrylic bender and shaping it around a foam mold. This took some practice, but worked out reasonably well in the end. I put copper tape in the rastered groves, soldered the wires, LEDs and resistors, and hot glued everything in place for good measure.


I programmed in C (board, LEDs), python (organizing data and displaying the dance type outcome), and R (data analysis). I also used Rscript and rpy2 to connect everything, and tkinker for some early testing.

Hardware PWM, two ADC inputs, and math in C were my breakthroughs of the week.

Math required sorting out variable types--my nemesis! I used a few weighted calculations to improve the sensor data and determine an "overall score" that would dictate the brightness of my LEDs. Casting and naming with "official" variable types were useful approaches here.

Thanks to Brian Mayton for help setting up hardware PWM and the two ADC inputs. Tables 11.9 and 11.9.4 in the datasheet provide most of the necessary information for hardware PWM (fast PWM in non-inverting mode).

I used python to pull together the sensor data to be processed in R, with rPy2 and Rscript to connect the two. My R code does some data cleaning (e.g. discarding initial and end values) and then uses autocorrelation function analysis to match the dance to know patterns. It can identify chacha and rumba. I established the known patterns by collecting a data at different speeds from two dancers (thanks Jorge). The majority of the data analysis occurs by using python and Rscript to run R. The script only runs after a chunk of data has been collected and updates periodically as data is added.

The R script outputs an image file with the dance name--python changes the user's desktop background to this file.

Trials and Tribulations

The fabric fusing material would have been great had it been double sided! Make sure to check this before buying.

Though the pressure sensor has improved over the weeks, it still isn't ideal. It doesn't turn off as fast as I'd like, it's more of a switch than a range of values, and it also changes its behavior somewhat over time. It works quite well for normal walking, but it doesn't have the accuracy necessary for the speed and odd pattern of dancing. I liked Sam's multiplexed capacitive foot sensor so I might head in that direction in the future. The piezo-electric material is another promising direction.

Many of my troubles in C came down to variable type issues. This was particularly frustrating as mistakes were hard to identify--there were no errors and the system would seem to be "working" just not quite correctly. Brian taught me not to trust the "float", "char", "double" etc variable types as compilers may interpret them differently. Instead use "uint8_t," "uint16_t" and so forth. Remember uint16_t variables are too big to send over FTDI in one go. Casting is a useful way to control variable types during mathematical operations--note that it occurs at every step of the operation so should be controlled through judicious use of parentheses. For example (uint8_t)((9/20)*100) = 0 while (uint8_t)((9*100)/20) = 45. Division can be quite slow, unless you're dividing by a power of 2.

Hardware PWM for fading the LEDs is a really great tool. Thanks to Brian Mayton for helping me sort out this and other coding issues.

I'd like to clean up my statistics a bit still. My approach distinguishes chacha and rumba basic steps quite reliably--it has a perfect record so far with a few different people, instances, and speeds of dance. But I'd like it to match from a larger set of dances. And my approach is a bit too hacked together--there has to be a better way to do this and I want to figure out why the Fourier transform route was giving odd results.

Wireless! Soon! Wires are a major barrier to elegance and grace (read: not tripping yourself).