Shop OBEX P1 Docs P2 Docs Learn Events
WS2801 Driver — Parallax Forums

WS2801 Driver

JonnyMacJonnyMac Posts: 8,929
edited 2014-09-12 12:23 in Propeller 1
For a project I'm working on I needed control of several RGB LEDs. Through Minion's Web (www.minionsweb.com) I found a strip that includes a WS2801 driver for each LED. Most of the work I found used Spin (I did too, at first, just to test) or uses the SPI object. For my projectsI decided to create a clean WS2801 object that can deal with as many channels as I need (currently set to 64, but this can be changed).

The driver is written in PASM so it's pretty zippy; it takes about 10us per RGB LED to update. Review and comments before I move to ObEx are appreciated.
«1

Comments

  • TubularTubular Posts: 4,622
    edited 2012-07-26 13:37
    Nice Jon, I'll try this out later.

    I bought sample of a UBLeds strip which I saw at a recent trade show. These are very clean as the driver ic is actually integrated into the led iteself, and the flex strip is black rather than white. LED pitch is 20mm (shorter than average) or 40mm. If you'd like photos or pricing details or contact details for the mfr just ask.
  • JonnyMacJonnyMac Posts: 8,929
    edited 2012-07-26 14:16
    It would be nice to know another source.

    For the project I'm working on (with Steve Wang ["Predator"] and his crew) we will actually cut the strip into short segments and then attach them to a sphere (which will be inside another with some diffusion). After I've mapped the sphere my code will animate the LEDs to create specific effects. Will get photos and video when done.
  • TubularTubular Posts: 4,622
    edited 2012-07-26 16:57
    Jon,

    Here's a photo of the 20mm UBled product. It shows a join.

    I'll email you contact details and indicative pricing. US pricing should be cheaper.

    cheers
    Lachlan
    1024 x 681 - 36K
  • JonnyMacJonnyMac Posts: 8,929
    edited 2012-07-26 19:16
    Looks good. Have you written a driver for it?
  • TubularTubular Posts: 4,622
    edited 2012-07-26 19:58
    JonnyMac wrote: »
    Looks good. Have you written a driver for it?

    Not yet.

    I put very basic Spin drivers for HL1606 and WS2801 based strips in the obex. I'll look at your pasm driver, may be able to adapt it to the UBleds because they're very similar (shift register based), but UBleds are 5 bits per color (1RrrrrGggggBbbbb) .
  • StephenMooreStephenMoore Posts: 188
    edited 2012-07-26 20:30
    Hi Jon,

    It would be useful to be able to load a comma delimited file containing RGB data and delay times into eeprom. This would allow a relatively large color program to be easily developed in a spread sheet program for playback. Another feature I have been toying with is using led string segments to form large letters (10 or 12 RGB leds per letter). A method to define 'sub-programs' per letter would be really great, e.g 1st letter rainbows from color 1 to color 2, 2nd letter rainbows from color 3 to color 4, etc. All leds would of course be on the same serial string.

    I love your pasm, I will gratefully employ it on my next sign effort.

    Regards,

    sm
    1024 x 683 - 39K
  • pjvpjv Posts: 1,903
    edited 2012-07-26 21:13
    Hi Jonny;

    About a year ago I had a commercial application to drive thousands of individual independent LEDs for custom graphic sign boards. To keep currents reasonable, I integrated switch mode PWM current conversion regulators into the circuit so the LEDs could run off 24VDC directly without current limiting resistors, and hence heat dissipation. All the switching and regulation was done by TI 430 micros (35 cents ea), with a transistor, and wired 4 LEDs per module. This would all be serially controlled from banks of Props. Unfortunately the project has stalled before I completed it, but if your application could benefit from such a concept, then I'd be happy to share my design with you. Let me know if it might be applicable for your LED count.

    P.S. I cannot release the design for general use as it still has considerable commercial value.

    Cheers,

    Peter (pjv)
  • JonnyMacJonnyMac Posts: 8,929
    edited 2012-07-26 21:53
    I see file access and LED driver as two independent processes. The display I'm presently working on will use a combination of direct programming and file access.

    For the latter I'm using Vixen to create sequences. When Steve is happy, I will export the sequence to a file (binary, small and easy to read) and read it from an SD card. ASCII files are tempting, easy to read and parse, but in the end the overhead murders through-put. I just went through this on another project which is why I asked K.C. Oaks to add the export feature to Vixen. It works really well. For this project I may be creating four channels per LED (the export provided one byte per channel); by using four bytes it will align with a long that I can move right into the driver array.

    Hi Jon,

    It would be useful to be able to load a comma delimited file containing RGB data and delay times into eeprom. This would allow a relatively large color program to be easily developed in a spread sheet program for playback. Another feature I have been toying with is using led string segments to form large letters (10 or 12 RGB leds per letter). A method to define 'sub-programs' per letter would be really great, e.g 1st letter rainbows from color 1 to color 2, 2nd letter rainbows from color 3 to color 4, etc. All leds would of course be on the same serial string.

    I love your pasm, I will gratefully employ it on my next sign effort.

    Regards,

    sm
  • jstjohnzjstjohnz Posts: 91
    edited 2012-07-26 23:06
    I have a prop-based board that I have been selling as a commercial product for about a year and a half that will drive up to 16 separate strings of RGB pixels. About 10 different pixel protocols are supported. Data comes in on ethernet in the E1.31 protocol, which is basically multiple DMX universes over ethernet. The E1.31 siource is typically software such as Vixen, Light Show Pro, LightORama, Madrix, Light Factory, etc. The current project is a board that will be able to capture E1.31 data and save it to a file on an SD card, then be able to play it back to drive the pixel controller. That will allow for a stand-alone display, no PC needed, but still allow the use of high-end software like Madrix to create the effects.

    For applications that need pixels + audio, I am using Jon's wav player board to handle the audio.
  • JonnyMacJonnyMac Posts: 8,929
    edited 2012-08-04 08:39
    Update on my project. This is for a character (Ryze) from the game "League of Legends." This character (and another called Tryndamere) will be on display at PAX Prime in Seattle in a couple weeks.

    The shop built a sphere which holds an EFX-TEK HC-8+ controller inside. Two of the TTL outputs are driving the LED chain (94 channels in the end). After the sphere was built super-bright LEDs (controlled by the remaining six outputs) were mounted inside; these will connect to translucent rods and in the end, simulate lightning emanating from the center sphere (the lightning sim runs in its own cog). After the sphere was closed they cut up the LED strip and then re-applied it in a spiral pattern from top to bottom. Then they gave it to me to solder the LEDs back together and program.

    Now... I realize this doesn't look very pretty (it's a one-off, and the first time through). This ball is encased in a diffusion sphere that spreads the LED light; we get blobs instead of dots. I wrote a starter program and Steve let it run as he was working on the diffusion sphere. Yesterday he shook my hand saying that I made "magic." This is the promise he makes to his customers; when they employ Steve and his team at Biomorphs they expect -- and always get -- magic. I'm happy that they call on me when electronics is in the mix. The Propeller-powered HC-8+ made this pretty straightforward (and there are two more in other parts of the display).

    When the figures go public I'll post pictures and if possible, links to video.
    640 x 480 - 420K
  • JonnyMacJonnyMac Posts: 8,929
    edited 2012-08-31 13:43
    And the figure has gone public so I can share. This is Ryze from the game, "League of Legends."

    528015_446387775406423_1243360907_n.jpg

    Once again, Steve Wang and his team at Biomorphs did an unbelievable job. In fact, the client (Riot Games) was so happy on the preview day that they brought their entire 60-person art department back the next day so that everyone could see it before it shipped to Seattle.

    What you can't see in the still image is that the energy sphere is running a swirling pattern that transitions from green to blue. On top of that is a "smoke ring" animation that transitions from blue to green while bouncing between the north and south poles of the sphere. Finally, there are six channels of "lightning" output to super-bright white LEDs; these LEDs are in the base of the rods that support the outer sphere. Steve loved the lightning effect but wanted more of it so I just launched it in another cog. Perfect. There is a second HC-8+ animating the eyes and the base lighting.

    A happy moment for me was when Steve Wang -- a legend in the effects business -- turned to me and said, "McPhalen, you made magic."

    If you're in Seattle, pop over to PAX and check it out. There is a second character from the game that also uses the Propeller-powered EFX-TEK HC-8+ for animation (Tryndamere).
  • max72max72 Posts: 1,155
    edited 2012-09-28 02:28
    Jon,
    I tested your great object with a LED strip I got here:
    http://www.ebay.it/itm/50pcs-DC5V-12mm-Diffused-Digital-RGB-LED-Pixels-black-cable-WS2801-/110951257375?pt=LH_DefaultDomain_0&hash=item19d535d51f#ht_2357wt_1164

    It looks like R and B colors are switched, at least in my case.

    Please find attached the modified object.

    Thanks again for the great object.
    Massimo
  • JonnyMacJonnyMac Posts: 8,929
    edited 2012-09-28 10:17
    I have actually updated my driver to do the swap in assembly (faster); what I'll do before finalizing is add a parameter to the start methods that allow the red/blue swap only if desired. The other reason for the change (swap in PASM section) is that it keeps the values in the hub using the format $RR_GG_BB. I will post my updated code for you to try.

    [Edit] I've attached my latest version. Again, this does the color swap in PASM so the hub values are always in $RR_GG_BB format. The color swap is conditional, based on the final parameter of the start method (true swap, false not to).
  • max72max72 Posts: 1,155
    edited 2012-09-29 14:07
    Thanks.
    I'll play with it and let you know.
    Massimo
  • max72max72 Posts: 1,155
    edited 2012-10-01 09:14
    It works perfectly here.
    Thanks again,
    Massimo
  • Mag748Mag748 Posts: 263
    edited 2012-10-18 13:13
    Hello,

    I am interested in using this driver for my application. I have a slightly different set up though. I will be driving multiple strings of LEDs. As in, there will be multiple pairs of SPI Clock/Data lines. Is there a way to modify this object to automatically alternate to each SPI pair in between frames?

    Even better: could all the clocks be tied together? Then just the data lines would need to be updated based on their respective color buffers. Would having a different number of LEDs on each string cause a problem though?

    Lastly, I will need to add support for the LPD8806 LED driver, which also uses SPI, just a slightly different data format and a "latching" byte at the end instead of a delay.

    Thanks for the input,
    Marcus
  • JonnyMacJonnyMac Posts: 8,929
    edited 2012-10-18 21:32
    Sure, you could do all that -- have at it. The code is available under MIT license for those that want to put it to use or modify it for different use models.

    For my animations I want the refresh rate to be as quick as possible. If I ever needed to do more than one string I'd just start a second copy of the object.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-11-03 14:22
    Jon,

    Once again your work looks great.

    Thanks for sharing your code.

    I'm adding some LEDs to my hexacopter, here are the LEDs running through some test code as I try to figure out what kind of patterns I want.

    [video=youtube_share;24kuTdHBmek]

    It should be fun to see at night in the sky (if I'm brave enough to take it for a night flight).
  • JonnyMacJonnyMac Posts: 8,929
    edited 2012-11-04 14:02
    Very cool. Looking forward to the reports of UFO sightings in your area when you start flying that dude at night! Really nice work, Duane.
  • OldFartRadiomanOldFartRadioman Posts: 30
    edited 2012-11-05 13:01

    First attempt at inserting a video. Thanks JonnyMac for making my recumbent trike riding safer. Am I bad? No buffering on the data and clock lines and everything working fine.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-11-05 13:45
    JonnyMac wrote: »
    Very cool. Looking forward to the reports of UFO sightings in your area when you start flying that dude at night! Really nice work, Duane.

    Thanks for the kind words. They mean a lot to me.
    No buffering on the data and clock lines and everything working fine.

    I don't think anyone is going to miss seeing your trike with those LEDs flashing. I hope they're not so distracting as to cause a crash.

    I didn't use any level shifters either. I haven't found many 5V devices that wont read 3.3V logic. Of course if you're making a board for someone else (and charging money), the buffers are probably a good idea.

    I received five meters of these LEDs on Saturday. I had to repair the solder on one chip, but I soon had them all lit up.

    When Ken started a thread about controlling 50 LEDs I shot this video in case he wanted to consider using a WS2801 based solution. Since JonnyMac already mentioned the option of using WS2801 chips, I decided to post this video here.

    The first 20 seconds shows off the 160 LEDs.

    These should be fun.
  • Mark_TMark_T Posts: 1,981
    edited 2012-11-05 14:00

    First attempt at inserting a video. Thanks JonnyMac for making my recumbent trike riding safer. Am I bad? No buffering on the data and clock lines and everything working fine.

    Definitely hi-vis - you might get people reporting lightning strikes on a cyclist!!
  • ctilley79ctilley79 Posts: 10
    edited 2013-01-17 12:02
    On mine the led's make it fairly easy to tell orientation at night. Blue up front red in the rear. Kinda cool.
  • JonnyMacJonnyMac Posts: 8,929
    edited 2013-01-17 13:02
    First attempt at inserting a video. Thanks JonnyMac for making my recumbent trike riding safer. Am I bad? No buffering on the data and clock lines and everything working fine.

    That's really cool. Now... you might want to check with a local police officer before riding it in public. In CA, one can have animated brake lights but they can only be red. I know this from an SX project I did some time back. I pulled into a convenience store next to a police officer and asked him to help him check my brake lights. He smiled and told me that I was okay because, 1) all the LEDs are red, and 2) they are pointing backward. He told me that if I used blue and yellow on the board or pointed it forward I would be ticketed.

    Still, I may have to replace that board with a Propeller and some RGB LEDs....

    -- http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol8/col/nv150.pdf
  • D_D_S_BD_D_S_B Posts: 8
    edited 2013-10-17 22:06
    Hey guys I am on the quest of choosing a micro for my next project. Eying the Due but then stumbled over this, I like that P8x32A is only 44 pins and not 144. So my question is how may frames per second can you get out of the ws2812's using the P8x32A?

    Thank you

  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-10-18 01:54
    D_D_S_B wrote: »
    . . . how many frames per second can you get out of the ws2812's using the P8x32A?

    What do you consider a frame? The communication speed with the WS2812 is microcontroller independent. Each bit needs to be 1.25us long (30us per LED). As JonnyMac stated in one of the WS2812 threads (this thread is about his WS2801 driver), the Propeller can continuously send the color information to the LEDs while other microcontrollers have stop whatever else they're doing to send the information. Only another device with multiple processors would be able to "refresh" WS2812 LEDs as frequently as the Propeller.

    I have a link to Rich's forum search page at the top of post #1 of my index (see my signature). You can use it to find the WS2811 / WS2812 threads. My NeoPixel ring project is here.
  • JonnyMacJonnyMac Posts: 8,929
    edited 2013-10-18 10:06
    Hey guys I am on the quest of choosing a micro for my next project. Eying the Due but then stumbled over this, I like that P8x32A is only 44 pins and not 144. So my question is how may frames per second can you get out of the ws2812's using the P8x32A?

    That, of course, depends on how many LEDs you have connected. My WS2801 driver (easier if you're going the Arduino route) uses a fixed frame rate. I just programmed a costume for Limp Bizkit guitarist, Wes, Borland, that had nearly 300 LEDs (in two groups, 180, 110); I uses a 5ms auto-refresh rate with WS2801 LEDs.

    My WS2811/12 driver free runs; when the last LED is updated it goes back and fetches the data for the first. I got an email (from a person that had never used my code or these LEDs) speculating that my free-running code would create visible artifacts. It doesn't. I've used this code in a few projects with my friend, Steve Wang (one of the biggest names in Hollywood special effects); if there was a visual problem, we would have seen it and corrected it.

    The WS2811/12 runs at 800kHz. With 24 bits per pixel it takes about 30us per pixel -- plus you'll have a little overhead. Handling the strict timing requirements of the WS2811/12 is a breeze for the Propeller; not so much with the Arduino. And with multiple cores, you can run more than one copy of the driver. You'll find a thread started by me having to do Wes's costume. We used WS2801 strings for the costume and had two drivers running at the same time; one for his helmet, one for his arm. The main code loop ties everything together.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-10-18 11:45
    It seems like the WS2812 LEDs have been a relatively common topic on the forums lately.

    Here are some of the threads I recall about them.

    JonnyMac's post about manipulating bits in PASM so the colors can be arranged in hub RAM in the conventional red, green, blue order.
    More discussion of the driver when David Betz asked if a driver existed.
    Another thread with some beginner questions about how to change colors and turn off the LEDs.
    My NeoPixel ring thread.

    I just noticed the video I posted didn't have a level shifter on the data line. There are lots of glitches in color. I'll make a better demo video with a level shifter soon.

    Here's the thread about the costume with WS2801 strips.

    Wes Borland's costume.
    One of my WS2801 projects.

    There are of course other ways to drive RGB LEDs.

    This time of year CostCo sells individually addressable RGB Christmas lights. These can be controlled with a Propeller.

    The cheapest way I know to purchase a bunch of RGB LEDs is to buy the 8x8 arrays off ebay. I'm still hoping to make a coffee table sized LED array sometime.

    I can see I need to expand the LED section of my index.
  • D_D_S_BD_D_S_B Posts: 8
    edited 2013-10-18 18:19
    Duane Degn wrote: »
    \the Propeller can continuously send the color information to the LEDs while other microcontrollers have stop whatever else they're doing to send the information
    That is an extremely good point right there.
  • D_D_S_BD_D_S_B Posts: 8
    edited 2013-10-18 18:36
Sign In or Register to comment.