Sunday, October 2, 2011

LDP8806 and the netlogicdc sign

So far...
(updated post)


Progress with the Addressable Digital LED Strip from Adafruit is going very well. But changes to the original design and placement of the netlogicdc sign have changed the final outcome of this project for now. Whether we decide to add this to the sign or not, I'm coming up with some cool uses for the LED strip.

This post has a comparison of the old, Adafruit code using the digital Arduino pins, and the new code that uses the SPI interface. I go over the hardware I'm using, show some video comparisons, and I post links to the github code.

I initially started work with the code provided by Adafruit, and customized that to test and experiment with the strip. So far, I've got the hardware working and coded a few of my own Arduino sketches for the strip. I've begun to familiarize myself with how the strip reacts and what it's capable of. My initial prototypes used the original code provided by Adafruit - Original Adafruit code here.

Current hardware
More about the power supply
Read the disclaimer
Calculating the power requirements is beyond the scope of this post. But to help you get started, I'm using a 450W ATX power supply I salvaged from an old computer. It says it can handle 45A on the +5V terminals. This is 225W. This seems to be more than enough to power a 160LED strip at full white intensity, w/o blowing anything. 160LEDs should draw no more than 20A, so the math is right. I'll post something to show how to wire the ATX power so that it powers on without a computer. For now, see this article: http://reprap.org/wiki/PCPowerSupply

Connections
The Adafruit tutoral has some great information to get started. This works with the old code and old setup. Be sure to connect the following:

  • 5V power supply connects to the +5 on the LED strip
  • GND on the power supply connects to the GND of the Arduino board and the GND of the LDP8806 LED strip. This is very important that the Arduino, the LED strip, and the Power Supply are all grounded to the same potential. 
To keep with the the Adafruit conventions:
  • Connect a green lead from the Data pin on the LED strip, D1 to digital pin 2 on the Arduino.
  • Connect the clock pin, C1, on the LED strip, to the digital pin 3 on the Arduino. 
  • Remember these two pins on the LDP8806, clock and data. It will help later if you use cjbaar's  faster code.

So now that it's working...
Here's a video of Adafruit's original code, using the digital pins on the Arduino board. Once I had the connections and wiring correct and the LED strip is up and running, my first challenge was to make the code more efficient. The code updates each pixel, then sends a refresh to the strip to change the correct pixels. Each update iteration the strip is far too slow for production. It was taking almost 1 second per pixel (LED) to update. On a 35 pixel strip, this is over 30 seconds. On a 160 pixel strip... you get the picture. This video shows the original code's update speed.

Original Arduino Sketch Code
Get the code for this sketch on my LPD8806 repository on Github. Be sure to read the README.txt file if you want to use this old library.

Note that I randomized the update speed, so the refresh rates change. But this should still show a good idea of the possible fastest update speed with the original code.

Optimized LDP8806 code using SPI 
I did a lot of research to find ways to optimize the code. Even at 16MHz the Arduino should be capable of running this a bit faster. I found a discussion on the Adafruit Forums, RGB LED Strip Arduino Speed which links to another post by cjbaar. CJBaar shared some code in the cjbaar LDP8806 Github Repo.

The new code is significantly faster. I'm very impressed, I had no idea that the little 16Mhz Atmel chip could perform this well, after seeing how slow the original code was. I think it's actually too fast for this project. But it is far easier to make the code slower by adding delays. At least not until magic.strip(speed up my code)is implemented.

Again, note that I have randomized the update code, so that the direction and speed of refreshes vary. this is intentional.

SPI Arduino LDP8806 Code
The new Arduino sketch for the LDP8806 using SPI on Github
Next steps
The next post on this project will be the addition of and interactive aspect. I still have some experimentation to do, but basically I'll have the interactive component skew the direction or the randomization of the speed one direction or the other. It will depend on the feel of the interaction, and how well the various sensors handle it.


Credits, attribution
If you haven't been following these posts, thanks again to Adafruit for providing the LPD8806 Addressable Digital LED Strips and publishing code for these LED strips. They're way cool! And thanks to cjbaar for sharing code to use the SPI interface.
  • The original code and wiring for the Digital LED Strip was written by Adafruit, and I'll confirm, but released under an MIT or Open source license of course.
  • The optimization was coded by cjbaar.



Note
I also updated the progress on the netlogicdc sign entry, so it now points to my github code for the interactive serial interface for the LED strip.


singularityNode()


.

No comments:

Post a Comment