TI Launchpad Up and Running w/ 16 Strings

For the past few weeks, in my ever more sporadic free time, I've been moving all my previously working code from Arduino Pro Minis to TI TM4C123 Launchpads. The Launchpads are vastly more powerful, have a lot more features, and are still a lot cheaper than the 32U4 Arduinos. Just about the only thing they don't have is anywhere near as much community support, but that's okay; I have datasheets and I can write code.

So before I decided to switch to the TI ARM MCUs, I had Arduinos running several 16-string demos very reliably. The first cluster has been running for several months now with no problems, except for a loose wire and sporadic flicker at the end of each string. However, just running the basic rain demo, the Arduinos are working near their limits. On top of that, they're flat out overpriced. So at this point I've reproduced almost all the previous functionality on the Launchpad. The best part is that instead of using 75% of the Arduino's resources, it's using ~5% of the Launchpad's, so I have plenty of time left over to do more complex visualizations.

After a bit of testing, I've put together a nice, extremely simple interrupt-based WS2812 signal generator package with extremely low overhead. I can write to 16 strings, each with 16 lights, at 60fps, using 2.9% of the CPU time. This is accomplished by activating all of the Launchpad's Port A and Port B as GPIO, then writing to each port at once, basically treating 16 GPIO pins like two parallel ports. That means I can write to 8 pins with a single line of C code, all eight pins flip at the same time, then we flip the next eight. Checking this on a scope, we can see that all the Port A pins go high at the same time. A few cycles later, all the Port B pins go high. Then Port A zero pins go low, then Port B zero pins, then Port A one pins, then Port B one pins, all in parallel. Beautiful.




All I have to do to write useful data to 16 strings of lights is write 16*16 color values to LED[]. That array is then transformed every 1/60 of a second from 256 24-bit words (one for each LED) to 384 16-bit parallel commands (one for each bit of the parallel signal). The only problems so far are that the time difference between Port A and Port B movements is inconsistent, meaning that A and B times are slightly different, and the fact that our 800kHz interrupt is taking longer than 1.25e-6 seconds to complete, meaning we're not actually running at 800kHz. So far, running single LEDs, that's not a problem. It might become a problem when running longer strings.


For a first demo, I'm showing rainbows again. I ported Adafruit's rainbow cycle function from Arduino to Launchpad. In the video shown here, keep in mind that this is two separate strings, each with one light, not one string with two lights. The next step will be to add on some MOSFETs and stiffening caps to minimize startup current, then design an add-on board to hold it all. Then we fabricate and assemble a bunch of those, spend like two weeks soldering strings of lights, and we'll have the first working chandelier. Woo.

Comments