Updated WS2801 Arduino Library
Moderators: adafruit_support_bill, adafruit

Updated WS2801 Arduino Library

by pburgess on Thu Nov 17, 2011 8:47 pm

Hi folks,

The WS2801 Arduino library has been updated -- memory usage has been reduced, and hardware SPI support is now an option. For "soft" SPI, performance improvements from the LPD8806 library have been carried over.

Download from github: https://github.com/adafruit/Adafruit-WS2801-Library

To use hardware SPI, simply omit the data and clock pin parameters when invoking WS2801. In other words, this:
Code: Select all | TOGGLE FULL SIZE
WS2801 strip = WS2801(25, dataPin, clockPin);

becomes:
Code: Select all | TOGGLE FULL SIZE
WS2801 strip = WS2801(25);

Unlike software SPI which is configurable, hardware SPI works only on very specific pins. On the Arduino Uno, Duemilanove, etc., clock = pin 13 and data = pin 11. For the Arduino Mega, clock = pin 52, data = pin 51. For the ATmega32u4 Breakout Board and Teensy, clock = pin B1, data = B2. Alternately, on most boards you can use the 6-pin programming header for SPI output as well, in which case clock = pin 3 and data = pin 4.

There are no other syntax changes; this should be a drop-in replacement. I've tested this (both hardware and software SPI) on a couple different Arduino boards and using both the 0022 and 1.0rc2 versions of the IDE...but sometimes surprises pop up in the wild, so please let me know if you encounter any difficulties with an installation that worked with the prior code.
User avatar
pburgess
 
Posts: 2735
Joined: Sun Oct 26, 2008 2:29 am

Re: Updated WS2801 Arduino Library

by adafruit on Thu Nov 17, 2011 8:53 pm

Thanks Mr Dragon! Can you tell these fine folks how long it takes to update say 150 x WS2801 pixels with this fabulous new library?
User avatar
adafruit
 
Posts: 11740
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Updated WS2801 Arduino Library

by pburgess on Fri Nov 18, 2011 1:15 am

Surely!

These figures are strictly I/O time and don't include any overhead for calculating the pixel image. Thus your actual speed will be somewhat less, depending on the complexity of the rendering code involved.

Original library using digitalWrite:
1000 + 470 microseconds per LED
(For 150 LEDs, about 14 frames/second)

Revised library with direct PORT writes:
1000 + 130 uS/LED
(~ 50 FPS)

Revised library using hardware SPI:
1000 + 17 uS/LED
(~280 FPS)
User avatar
pburgess
 
Posts: 2735
Joined: Sun Oct 26, 2008 2:29 am

Re: Updated WS2801 Arduino Library

by Taifuuni on Sat Nov 19, 2011 9:53 am

Does the ledstream.pde in Adalight use this library?
Taifuuni
 
Posts: 15
Joined: Fri Oct 28, 2011 12:05 pm

Re: Updated WS2801 Arduino Library

by pburgess on Sat Nov 19, 2011 11:33 am

Does the ledstream.pde in Adalight use this library?


Nope. The library is for "standalone" Arduino apps.

LEDstream is a special case because it's designed for larger PC-controlled installations, where the Arduino itself may not have enough memory to hold that many LEDs. That code has always used hardware SPI (with no "soft" option).
User avatar
pburgess
 
Posts: 2735
Joined: Sun Oct 26, 2008 2:29 am

Re: Updated WS2801 Arduino Library

by Taifuuni on Sat Nov 19, 2011 11:42 am

Thanks for the clarification.
Taifuuni
 
Posts: 15
Joined: Fri Oct 28, 2011 12:05 pm

Re: Updated WS2801 Arduino Library

by jfenwick on Sat Nov 19, 2011 12:18 pm

I made a posting here:
viewtopic.php?f=47&t=24280

I was using the FastSPI library but I found the new version of the strandtest this morning with hardware SPI and decided to try that.

However I'm still having the same issue where pixels that are toward the end of strands (other than the first strand) flicker a lot.

What could be causing this?
jfenwick
 
Posts: 12
Joined: Thu Nov 17, 2011 6:16 pm

Re: Updated WS2801 Arduino Library

by pburgess on Sat Nov 19, 2011 2:34 pm

They look like pretty long strands. Are you at least powering them from both ends?

Do you have a supply of capacitors handy? Can't say for certain if it'll help in this situation, but when I encountered something similar with Shiftbrite LEDs, adding 100 uF capacitors periodically to the strand cleared it up. Try one at each end of the strand, at the very least.
User avatar
pburgess
 
Posts: 2735
Joined: Sun Oct 26, 2008 2:29 am

Re: Updated WS2801 Arduino Library

by adafruit on Sat Nov 19, 2011 8:01 pm

jfenwick wrote:I made a posting here:
viewtopic.php?f=47&t=24280

I was using the FastSPI library but I found the new version of the strandtest this morning with hardware SPI and decided to try that.

However I'm still having the same issue where pixels that are toward the end of strands (other than the first strand) flicker a lot.

What could be causing this?



Hi there, welcome to the Adafruit customer support forums. It seems like based on your videos you are having technical problems with WS2801 LED strips. we dont sell WS2801 LED strips - please contact the place you purchased them for tech support and help with running the strips, thanks! :)
User avatar
adafruit
 
Posts: 11740
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Updated WS2801 Arduino Library

by anstone on Fri Mar 23, 2012 5:58 pm

Has this library been removed from github? Link doesn't seem to be working any more...
anstone
 
Posts: 34
Joined: Tue Mar 06, 2012 11:23 am

Re: Updated WS2801 Arduino Library

by adafruit on Fri Mar 23, 2012 6:17 pm

anstone wrote:Has this library been removed from github? Link doesn't seem to be working any more...


https://github.com/adafruit/Adafruit-WS2801-Library

cheers!
adafruit support
User avatar
adafruit
 
Posts: 11740
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc