Experiments in wearable electronic art.


SD cards, streaming animation, and bit-banging

It was an eventful weekend. I built a new prototype rig from an Arduino Mega2560 (the very same Mega that was in my Anthrolume 1.0 suit), because I was going to run out of I/O pins on the Arduino Uno after adding the hand controller, mode LEDs, and XBee radio. Additionally, the Mega has 8KB of RAM, enough that I can keep a record of the colors of all the LEDs in memory, which facilitates some features I want such as drawing moving text across my body.

One of the technical hurdles for Anthrolume 2.0 was figuring out how to use an SD card reader and CoolNeon lights at the same time. The problem lies in the fact that they both want to use the SPI (Small Peripheral Interface) bus on the Arduino, but the CoolNeon lights sort of want that whole bus for themselves.

I designed some digital logic using tri-state buffers that would allow me to switch the SPI bus between the SD card reader and the light strand under the control of one digital pin on the Arduino. But I didn’t really want to add that logic wart if I could find another way.

The “other way” is to hook the light strand to a couple other digital pins and “fake” the SPI protocol. “Faking it” in this case is a technique called “bit-banging.” The idea is that you simulate a protocol (in this case a simple clock-line/data-line setup) by manually setting the logic state of a couple Arduino pins very quickly.

On Sunday I got this approach to work. It allows me to read from the SD card using SPI and write to the LED strand manually via bit-banging. At first I found bit-banging to be quite a bit slower than the hardware-accelerated SPI provided by the Arduino, but by using the badass digitalWriteFast library I was able to achieve frame rates of 95 fps with 50 LEDs. That will give me up to 40fps for my production strand of 250 LEDs – easily enough.

I wrote a very simple C# program to emit two pre-canned animations to files. The files consist of RGB tuples x 50 LEDs x some number of frames. Later I’ll beef up the .ani files to include metadata, musical synchronization information, etc. I used that program to write two 37K animation files to an SD card and loaded that SD card into the Arduino’s external SD card adapter.

The video below demonstrates me reading animation frames from the SD card and streaming them to the strand in real time. This is a big technical milestone for Anthrolume 2.0!

Leave a comment

Testing with Batteries

This weekend I verified I can run my new 250-light strand sufficiently from batteries. I used 8 D-cells in a series-parallel configuration for 6V at high current. My conclusion: if I run the strand at a maximum of 1/4 of total brightness, I can run off 8 D-cells with no problem. Brighter than that just draws too much current. Even at 1/4 brightness as seen in the video below, if I turn on all 250 LEDs to #404040 white, it draws 2.8A at 6V, or nearly 17W.

I also wrote a few 10-line functions to do fun things with the lights. I’m pretty convinced I won’t have trouble clocking animation frames into the strand based on these tests.