Updated WS2801 Arduino Library

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Updated WS2801 Arduino Library

Post by pburgess »

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

WS2801 strip = WS2801(25, dataPin, clockPin);
becomes:

Code: Select all

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.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Updated WS2801 Arduino Library

Post by adafruit »

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
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: Updated WS2801 Arduino Library

Post by pburgess »

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)

Taifuuni
 
Posts: 15
Joined: Fri Oct 28, 2011 12:05 pm

Re: Updated WS2801 Arduino Library

Post by Taifuuni »

Does the ledstream.pde in Adalight use this library?

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: Updated WS2801 Arduino Library

Post by pburgess »

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).

Taifuuni
 
Posts: 15
Joined: Fri Oct 28, 2011 12:05 pm

Re: Updated WS2801 Arduino Library

Post by Taifuuni »

Thanks for the clarification.

User avatar
jfenwick
 
Posts: 19
Joined: Thu Nov 17, 2011 6:16 pm

Re: Updated WS2801 Arduino Library

Post by jfenwick »

I made a posting here:
http://forums.adafruit.com/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?

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: Updated WS2801 Arduino Library

Post by pburgess »

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.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Updated WS2801 Arduino Library

Post by adafruit »

jfenwick wrote:I made a posting here:
http://forums.adafruit.com/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
anstone
 
Posts: 34
Joined: Tue Mar 06, 2012 11:23 am

Re: Updated WS2801 Arduino Library

Post by anstone »

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

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Updated WS2801 Arduino Library

Post by adafruit »

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”