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 ceido on Fri Sep 30, 2011 5:03 pm

This looks awesome! What exactly has been edited here? :oops: I have an Uno and a set of WS2801 12mm RGB LED Pixels. I'd like to get them running a bit faster. Could I use what's been applied here to get them to work in the same way? Thanks for any help in advance!
ceido
 
Posts: 18
Joined: Fri Sep 30, 2011 4:57 pm

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

by cjbaar on Fri Sep 30, 2011 5:46 pm

ceido--
I'm not sure how the data gets written to the WS2801 strips, compared to these... but someone has already written a library for those strips that use the SPI bus. This is actually what I based my work on for these strips. Check out: http://forums.adafruit.com/viewtopic.php?f=47&t=22858

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

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

by ceido on Fri Sep 30, 2011 8:31 pm

Thanks for your quick reply! I've got it up and running now! So much faster! :D
ceido
 
Posts: 18
Joined: Fri Sep 30, 2011 4:57 pm

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

by Phoenix on Tue Oct 04, 2011 12:58 pm

Hey guys,

I've installed the Arduino 0022 software... and I have LPD8806 strips connected as per adafruit guide to my UNO.
I can verify and upload the standard LPD8806 script without problems plus it runs fine albit slow as expected.
Moving forward I replaced the standard LPD8806 script with cjbaar's SPI script. Verify and upload worked fine.. however nothing starts on the LED strips.
I don't know what to do next? I'm sure my Arduino software installed fine. :( any ideas??
Phoenix
 
Posts: 3
Joined: Tue Jul 19, 2011 11:18 am

SPI pins

by DoctorDidj on Tue Oct 04, 2011 1:13 pm

Are you sure you've got the strip connected to the SPI pins (digital pin 11 data, digital pin 13 clock)? The SPI library will work only using those pins.
Food Processor with Ears
DoctorDidj
 
Posts: 28
Joined: Fri Apr 27, 2007 9:30 am
Location: Boston

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

by cjbaar on Tue Oct 04, 2011 1:17 pm

Phoenix--
The first thing that comes to my mind if you are switching from one library to the other is that they use different pins by default. If you used the defaults from the original library, you probably have your strip plugged into pins 2 and 3. The SPI library uses pins 11 and 13, so you would need to move the connection wires. (Because the library takes advantage of the SPI bus built in to the ATmega hardware, you do not get to choose the pins it uses.)

If you are already using pin 11 for data and pin 13 for clock, then please post some additional info about your environment.

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

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

by Phoenix on Tue Oct 04, 2011 1:48 pm

hehe Awesome! Thanks! :D
Phoenix
 
Posts: 3
Joined: Tue Jul 19, 2011 11:18 am

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

by IceDog on Fri Oct 14, 2011 4:31 pm

I have a question about using this awesome high-speed SPI library with multiple strips.

I've seen that it's best to use multiple strips by demuxing the output; however, is it possible to demultiplex the SPI output. To do that, I would need another output (digital) to select the channel, but that digital out is too slow for SPI, correct?
IceDog
 
Posts: 3
Joined: Fri Oct 14, 2011 4:27 pm

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

by mkomkom on Tue Oct 18, 2011 11:48 pm

Hey, great work!

Can anyone tell me if the original library needs to be installed first? Thanks,

-Tyler-
mkomkom
 
Posts: 10
Joined: Mon Oct 17, 2011 4:42 pm

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

by cjbaar on Wed Oct 19, 2011 12:07 am

IceDog--
I am not sure if I completely understand how you're setting that up, since I haven't personally played with multiplexing. To have multiple strips on the SPI bus, you need something that keeps the data line (at the very least) low for the strips you don't want to be talking to at the moment. So, yes, you would use one or more digital outputs for that... which would be slower than the SPI bus. Someone else here mentioned that they used AND gates -- in conjunction with a dedicated select pin for each strip -- to accomplish this.

The loss of speed would depend on how long the strips are, but I wouldn't it expect to be huge. The shorter the strips are, the more often you have to make the slower strip select call. If you have 32 LEDs on each strip, then you are making probably 2 digitalWrite() calls for every 832 SPI clock cycles (32x24 bits + 64 bits of "flushing")... which is relatively insignificant. You could, of course, replace the digitalWrite() calls with direct port manipulation to make them even faster (but the code becomes less portable).

Hope that makes sense. :)

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

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

by cjbaar on Wed Oct 19, 2011 12:09 am

mkomkom--
No; this is a replacement for the original library, so the original doesn't need to be installed first. In fact, since this was done as a fork from the original repository, it has exactly the same name... so you would overwrite the files anyway.

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

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

by IceDog on Wed Oct 19, 2011 2:38 am

cjbaar wrote:IceDog--
I am not sure if I completely understand how you're setting that up, since I haven't personally played with multiplexing. To have multiple strips on the SPI bus, you need something that keeps the data line (at the very least) low for the strips you don't want to be talking to at the moment. So, yes, you would use one or more digital outputs for that... which would be slower than the SPI bus. Someone else here mentioned that they used AND gates -- in conjunction with a dedicated select pin for each strip -- to accomplish this.

The loss of speed would depend on how long the strips are, but I wouldn't it expect to be huge. The shorter the strips are, the more often you have to make the slower strip select call. If you have 32 LEDs on each strip, then you are making probably 2 digitalWrite() calls for every 832 SPI clock cycles (32x24 bits + 64 bits of "flushing")... which is relatively insignificant. You could, of course, replace the digitalWrite() calls with direct port manipulation to make them even faster (but the code becomes less portable).

Hope that makes sense. :)


cjbaar,

Thanks for your helpful reply. Indeed, I'll use the direct port manipulation advantage.
IceDog
 
Posts: 3
Joined: Fri Oct 14, 2011 4:27 pm

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

by cjbaar on Wed Oct 19, 2011 6:12 pm

Actually, after re-evaluating the math, I think the impact is even less. Since every SPI bit is replacing three digitalWrite() calls (set data, clock on, clock off), you're technically only adding two calls for every 2,496 SPI actions. Even without direct port manipulation on the select lines, I can't imagine this would be particularly noticeable.

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

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

by physwm2501 on Thu Oct 20, 2011 1:09 am

which pins do I need to be using for this?
physwm2501
 
Posts: 1
Joined: Thu Oct 20, 2011 1:07 am

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

by cjbaar on Thu Oct 20, 2011 8:49 pm

The readme file contains more info, but generally it uses the MOSI line for data, and the SCLK line for the clock. On an Arduino Uno, this would be pins 11 and 13. The +5V and ground stay the same as in the original tutorial.

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

Please be positive and constructive with your questions and comments.