0

New High-Speed SPI Library for LPD8806 LED Strips
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: New High-Speed SPI Library for LPD8806 LED Strips

by cjbaar on Mon Oct 28, 2013 4:23 am

Funny you should mention that. I just finally started migrating my holiday strip setup to a Due last week. I'm moving up to 9 full strips this year (1440 pixels), so I really needed the extra room… but some of the conversion process has been particularly tricky.

From your message, it sounds like you might be using the wrong SPI pins. Unlike the earlier Arduino boards, the Due has a separate SPI bus that is not shared with the ICSP headers or any other pins. The SPI pins that the library will use are located further down on the board, near the little "erase" button. I found the diagram on this site to be very useful.
http://forum.arduino.cc/index.php?topic=132130.0

I'm also learning that port manipulation is quite different on the Due, and very few of the pin-to-port functions work at all, so you are correct that the existing digitalWriteFast() probably won't work.

I'm actually surprised you got the LPD8806 library to compile to all. From what I've experienced, even the SPI initialization parameters are different on Due, and my library wouldn't compile because it's missing constants like SPI_CLOCK_DIV8.

As far as speed, the Due runs at 84MHz. The SPI.setClockDivider function is based directly on that, so to match the SPI speed of the previous versions (2MHz), you would use SPI.setClockDivider(42). Over short distances, I have been able to successfully drive a single 5m strip using SPI.setClockDivider(7)… or about 12MHz. Results vary wildly based on things like distance and connectors/cables used.

cjbaar
 
Posts: 73
Joined: Fri Aug 26, 2011 5:58 pm

Re: New High-Speed SPI Library for LPD8806 LED Strips

by ergodic on Mon Oct 28, 2013 5:03 am

Thanks. That was helpful.

No problem at all getting the (updated) LPD8806 library to compile under IDE 1.5.4. I didn't have to change anything, but I do have to include the SPI.h library in my main sketch.

My version of the LPD8806 library has this in the headers:

Code: Select all | TOGGLE FULL SIZE
#ifndef SPI_CLOCK_DIV8
  #define SPI_CLOCK_DIV8 4
#endif


..so possibly you have the older library?

(Do you know the proper conditional compilation constant for detecting the Due? The only thing I can see in the compile log is a "__SAM3X8E__" .)

I'll try scoping that actual "SPI" header -- I couldn't get anything on that either, but your point about the clock div may have been the issue and something that hadn't occurred to me. With what's in the library it would be driving at > 20MHz. I'll try putting scoping that header and see what it's up to. But am I generally correct in assuming that if I simply connect SPI MOSI to strip data line, and SPI SCK to strip clock that should do the job?

I'm using cat6 for clock/data and only need about 10' so hopefully OK.
ergodic
 
Posts: 8
Joined: Mon Mar 25, 2013 12:33 am

Re: New High-Speed SPI Library for LPD8806 LED Strips

by cjbaar on Mon Oct 28, 2013 12:47 pm

Yes, yes, and yes.

I don't have that definition check for SPI_CLOCK_DIV8. And you're right, with a value of 4, the speed would exceed the rated spec of those strips.

You are also correct in that the SAMX8E is the processor on the Due, though I haven't tried using that value for any conditional checks.

And, finally, your wiring description is also accurate. MOSI and SCK are all you need. (As always, make sure you are using a separate 5V power supply.) Even though the Due only sends 3.3v signals, I have found that the strip interprets these well enough.

Contrary to everything I read online about distance, I have been running SPI from Arduinos over about 50-60 feet of length without issues. I am currently using CAT5e (have purchased some super-shielded CAT6a for testing, but haven't opened it yet). On my setup, with 3.3v Due, Cat5e cable, and a single 5m strip, I think was able to get up to a clock divider under 21 (4MHz). On a shorter cable, I was up to a divider of 7.

I've done a lot of testing to get the best speed. When you get too high or have too much crosstalk, you will know because the strips will start doing totally unexpected things. One of the things that i have learned is that I always run the lines in pairs with a ground. In other words, something like blue=data, green=clock, then both blue/white and green/white tied to ground. Otherwise I get way too much crosstalk.

I'm still messing with mine to maximize speed, so please let me know what your results are as well.

cjbaar
 
Posts: 73
Joined: Fri Aug 26, 2011 5:58 pm

Re: New High-Speed SPI Library for LPD8806 LED Strips

by ergodic on Tue Oct 29, 2013 1:53 am

THANK YOU! You got me pointed in the right direction and it's now working perfectly with SPI output.

I'm using the Due with the Bliptronics spectrum analyzer shield and the LPD8806 LED strip to do a holiday "color organ" display to music. It's awesome. But also it obviously needs to be near-real-time. With a 10 meter strip and non-SPI, processing was about 70ms on each display cycle - enough to have a noticeable effect. With SPI at 4MHz the delay is a negligible 4.5ms .

I finally set the divider at 21, but it seemed to work fine at 7. I just don't need anything faster for this.

In case it helps, I've posted my code library at github:

https://github.com/ergodic00/LightOrgan .

It's written as a C++ class so it's very easy to use: Just define your display segments on the strip and how they act. The "LEDSegs" class object does the rest. The preamble comments explain the details.
ergodic
 
Posts: 8
Joined: Mon Mar 25, 2013 12:33 am

Re: New High-Speed SPI Library for LPD8806 LED Strips

by cjbaar on Tue Nov 05, 2013 3:15 pm

Thanks for the code link. You're commenting and descriptions are beyond anything I've ever seen in a library. I am using the SF audio shield, which looks to be using the same chip, based on what I'm seeing in your code.

I finished constructing my strips for this year. I am running eight 5m strips over about 60 feet of cat6a cable, and using divider of 10 (about 8MHz). It's actually pretty amazing to me how fast the strips can be driven.

cjbaar
 
Posts: 73
Joined: Fri Aug 26, 2011 5:58 pm

Re: New High-Speed SPI Library for LPD8806 LED Strips

by ergodic on Tue Nov 05, 2013 5:07 pm

How are you getting power to the 8 strips?
ergodic
 
Posts: 8
Joined: Mon Mar 25, 2013 12:33 am

Re: New High-Speed SPI Library for LPD8806 LED Strips

by cjbaar on Tue Nov 05, 2013 5:26 pm

Currently, I have a separate power supply (5V 10A) for each strip. I am not chaining the strips end-to-end -- they all start from a central point and radiate outwards -- so it easier to connect the power supply to each strip. If I were chaining them, I think I would create custom JST cables and jump in each power supply inline.

This raises a good question, though, about how much power is needed. Based on the specs given, each LED can draw up to 20mA. Multiply this by three per pixel and by 160 pixels, and you get 9.6A maximum draw. This is why ada recommends a single 5V 10A supply for each strip. However, I did some measurements on one of the strips that was set to all white, and I was only reading around 2A draw (about 4mA per LED). So either the data sheet is off, or my meter is. But it seems possible to me now that I don't need all of these power bricks.

cjbaar
 
Posts: 73
Joined: Fri Aug 26, 2011 5:58 pm

Re: New High-Speed SPI Library for LPD8806 LED Strips

by ergodic on Tue Nov 05, 2013 5:51 pm

Wondering that too. Though I do get some "browndown" with 2 serial strips and one 10A supply. If it isn't a true RMS meter it may be getting confused by the square wave chop. I'll measure it and see what I get.

I'm partly interested in how to ground multiple serialized strips. You need to feed power close to each strip or two to avoid too much drop (and too much current through the beginning strips). But then how to tie the grounds?

I tried feeding power locally at the base of two chained strips and then tying a common ground back to the Arduino through the Cat5. I reasoned there wouldn't be much current.

What I got for my trouble was a blown first LED. Not sure why but I'm not real eager to try that again.
ergodic
 
Posts: 8
Joined: Mon Mar 25, 2013 12:33 am

Re: New High-Speed SPI Library for LPD8806 LED Strips

by cjbaar on Tue Nov 05, 2013 6:29 pm

Ouch. Not sure why that would happen… but yes, the ground is returning a lot of current. The ground carries whatever the power supply is supplying plus some small amount of current for the clock/data lines, I would believe.

I also had issues when trying to supply multiple chained strips from a single source. Perhaps it's an issue of the strip being able to carry that much power all the way through itself. However, at the moment I having no problems running four strips off of one power supply in parallel. While it never hurts to err on the side of caution, it does seem that the data sheet is fairly overrated.

Attached is a pic of my output board. The comm lines come in over the cat6, then are distributed to each strip output, which was built to have its own power supply.
Attachments
IMG_7374.jpg
Output board
IMG_7374.jpg (321.58 KiB) Viewed 743 times

cjbaar
 
Posts: 73
Joined: Fri Aug 26, 2011 5:58 pm

Re: New High-Speed SPI Library for LPD8806 LED Strips

by ergodic on Tue Nov 05, 2013 9:36 pm

OK. Got it.

Ada has a 5V 3a / (5a peak) inline dc-dc switching inverter. That seems about the perfect rating for a single 5m strip.

So I'm thinking to get one of those for each strip in the series and then feed each inverter's input from a common 12v supply. Then, any ground loop and loop loss concerns pretty much go away.

Whatever happens (good or bad) I'll post back the results. Now that I have the processing delay problem solved, the possibility of 100' of lineal LED is just irresistible.

I may need to crank up that clockdiv8 after all!
ergodic
 
Posts: 8
Joined: Mon Mar 25, 2013 12:33 am

Re: New High-Speed SPI Library for LPD8806 LED Strips

by cjbaar on Tue Nov 05, 2013 10:23 pm

Heh. They are addictive. Let me know how the power works out for you. Anything I can do to cut down on the number of giant bricks is helpful.

cjbaar
 
Posts: 73
Joined: Fri Aug 26, 2011 5:58 pm

Please be positive and constructive with your questions and comments.