In the small pockets of free time I have now and then I’ve been able to play around with my LED strip. It’s a really neat device, and I really wish I had more time to play around with it. Each one of the LEDs on this strip is uniquely addressable and can be assigned a 24-bit RGB color value. The black magic involved to make this work is what I find most interesting. It all boils down to this wonderful little IC/LED known as the WS2812B. I’m not even sure how to categorize the device because it’s essentially an RGB LED with an LED driver chip embedded in the actual LED.
They’ve implemented a proprietary 1-wire self clocked serial protocol to push out data to the lights. It works akin to a daisy chain of buffered shift registers. You send data out filling up buffers from the furthest LED to the nearest LED and then send “latch” pulse on the bus to update the color data on the LEDs. This places a rather slow upper bound on the refresh rate because of the chips are not truly addressable and the protocol is just slow to begin with, but unless you’re designing a fixture that makes use of persistence of vision it’s not too big of a deal. The real hassle that comes from this serial protocol is implementation. Since it’s self clocked the timing of the signals is absolutely critical. From the data sheet though we’re only talking about precision on the order of microseconds but it’s just more trouble than it’s worth to go ahead and write out the bit banging function for your favorite microcontroller. I originally wanted to do my work on TI’s Tiva C ARM processors, but I decided to take a page from the CS majors and simply download someone else’s code to get it working. This of course meant that I had to use a crappy 8-bit Arduino (yuck). I briefly looked through Adafruit’s NeoPixel library code and it’s actually pretty neat how they bit banged the protocol using assembly. This was only necessary because of how slow these Atmel chips run and how they could only use GPIO pins to maintain pin independence.
As the picture illustrates, I did get this thing working after I discovered that I burnt out the first pixel in the strip. Note to self, don’t trust the output of cheap chinese power supplies. Those transient voltage spikes are killer to microelectronic circuits. I had to place a 2200uF filter capacitor to make the voltage a little more palatable for the strip. After that though, I had no problems getting it all working. Current output seems to be adequate for my purposes and I don’t think this strip will surpass the rated 2A this supply can deliver.
My goal with this project is to connect this strip to my network and build applications on top of that. I first need to come up with a general API for assigning colors to the LEDs. Since I’m stuck with the Arduino, this is going to be implemented through UART. On the other side of the UART will be a Raspberry Pi purely for the wireless network connectivity aspect. This will run a little server application with some port/socket based API. From there I can then start thinking about things like Android applications and web apps that can manipulate my strip remotely. It’s a pretty simple design overall, but I’m just worried that the timing would be too slow because of all the interfaces that have to be dealt with. Then again, you always have to remember that electronics work on a scale much faster than you can ever comprehend.