PICAXE WS2811 RGB LED Controller

agroom

New Member
So I broke down and bought a 5M roll of the individually addressable RGB LED strips based on the WS2811 current driver. I've been playing around with it on my Arduino using the Fast_SPI library (SPI_TM1809 chipset) and is relatively easy to write programs for. However, I can't really dedicate my arduino to driving this, so I'd like to build a controller for it using one of the PICAXE chips I have (20M2, 20X2, 14M2 and 08M2), or buy another if need be. Since it only requires a 1-Wire 800kHz signal, all of them 'should' work; however, I'd like to attach it to a joystick switch (x/y axis w/ push button...and prob a few other buttons for added features), so the 08M2 is out since it wouldn't have enough pins. Unfortunately I don't know where to begin!

Background / WS2811 Info:
I've been doing a lot of research on the WS2811's protocol and have a pretty solid understanding of how the timing/data is formatted. It works on a 1-wire protocol providing both data and timing. Essentially each WS2811 byte is 10uS long, divided into 8-1.25uS bits. Each bit is then sub-divided into 5-250nS segments. Each bit must start with a logic 1 and end with a logic 0. The middle 3 segments determine the value of the bit. After each byte, a minimum of 50uS is required for a reset condition.

Timing:
To sent a 0 - 250ns high / 1000ns low.
To sent a 1 - 1000us High / 250ns low.

The timing on this doesn't have to be exact since the read is at the midpoint of 625nS (+/- 150nS), so there's a lot of room for noise. Essentially then, each WS2811 incoming byte requires 5 bytes sent from the controller.
Code:
|8th  7th   6th  5th   4th   3rd  2nd   1st  |   [WS2811 bits]
|1XXX01XX|X01XXX01|XXX01XXX|01XXX01X|XX01XXX0|   [data]
|  First | Second | Third  | Forth  | Fifth  |   [Controller bytes]
The 0s and 1s are required, and the Xs make up the bits that change. Most of the data I found comes from these three sources: One, Two, Three, and the datasheet.

Like I said, I've been able to drive my 5M strip very well using my arduino and the Fast_SPI library, though the TM1809 uses a slightly different timing. Each bit is only divided into 3 segments, but is the same length. It requires a little less bandwidth, but not as much noise immunity. But it seems to be working fine. The project I have in mind only uses about 3M too.

The datasheet also says there's a low-speed timing mode too using a 400kHz data rate. But that requires PIN 7 of the chip to be set to Vdd. I sampled the arduino's output pin though and it's using 1250uS timing, so it seems it's setup in fast mode.

Where I need help
There's essentially two areas I need help with:
  1. How to produce the required timing
  2. The actual data format to control them
1. Though I've been using PICAXE for about 6 months now, I'm still quite the novice. Other than some MCU basics, I've used the ADC module and I2C in master mode. Initially I thought using the pulseout command would work, but even running at 64MHz the best it can produce is 625nS pulse. So my next bet would be using spiout/shiftout/hspiout. Although this uses both a data and clock pin, I can just leave the clock pin disconnected. This would even be more ideal since, given the proper timing, I can shift a full byte at a time, requiring only 5 commands.

It looks like the hspiout would be what I want, but I'm honestly completely confused when it comes to all this timing! Fastspi mode can achieve 1MHz, which seems to over satisfy the 800kHz data rate, but beyond that the whole timing thing starts going way over my head :)

2. So even if I'm able to produce the proper output data timing, I'm still not sure how to actually format the data. The datasheet does show a 24-bit data format, but I'm not exactly sure how to interpret it, nor does it say anything about address data.

From datasheet: 24bit composition R7 R6 R5 R4 R3 R2 R1 R0 G7 G6 G5 G4 G3 G2 G1 G0 B7 B6 B5 B4 B3 B2 B1 B0

I'm assuming since the TM1809 chipset uses the same data composition that this is a relatively common format, so I'm just hoping someone here might have some added insight on this.

Thanks for any help or info anyone can provide, and please don't be afraid to say I'm in way over my head :) Though likely it won't do much to detour me! hehe
 
Last edited:

Jamster

Senior Member
Here may be a good start, and I'd reccommend that you use an X2 as well, much faster and has hardware SPI as needed.

Jamster :)
 

REB100

New Member
Thanks for any help or info anyone can provide, and please don't be afraid to say I'm in way over my head :) Though likely it won't do much to detour me! hehe

Take a look at the thread about the WS2803 posted in the last couple days. I managed (with a lot of help from the fourm members) to get a PICAXE 08M2 to drive the WS2803 which has 18 channels. There is a link to work done on the WS2801 which is very similar to your 2811
 
Last edited by a moderator:

westaust55

Moderator
While the data format (as in 1 byte per channel) is the same for the WS2811, WS2803 and WS2801 the WS2811 uses an asynchronous (no clock signal) protocol whereas the other two are synchronous (use a clock signal). As a consequence the SPIOUT and HSPIOUT are not applicable unless we can try just ignoring the clock signal.

I suspect that Bit bang methods. Will be too slow.
Take at M2 part operating at 32 MHz where on average each BASIC command will take around 30 usec.
The WS2811 needs output pin state changes in time intervals of 0.5 uSec.

With an X2 part whether the HSPIOUT can be pressed into service using just the data signal would need some investigation (sorry I do not have time today).

A "raw" PIC chip running machine code would do the task but PICAXE with interpreted BASIC is a lot slower due to overhead of the interpreter.
 

agroom

New Member
Sorry I haven't responded sooner, but we went out of town Saturday and I'm just getting back into thing. I haven't had a chance to review the all material posted yet, but I just wanted to give some preliminary feedback that I've read all the replies so far :)

Here may be a good start, and I'd reccommend that you use an X2 as well, much faster and has hardware SPI as needed.
I just skimmed the first post there, but this looks exactly like what I'm looking for! I tried searching for the driver I was using with no luck, but I suppose since it's newer I should have checked some of the others...like the WS2801.

Take a look at the thread about the WS2803 posted in the last couple days. I managed (with a lot of help from the fourm members) to get a PICAXE 08M2 to drive the WS2803 which has 18 channels. There is a link to work done on the WS2801 which is very similar to your 2811
I think you might be referring to the post linked by Jamster :)

While the data format (as in 1 byte per channel) is the same for the WS2811, WS2803 and WS2801 the WS2811 uses an asynchronous (no clock signal) protocol whereas the other two are synchronous (use a clock signal). As a consequence the SPIOUT and HSPIOUT are not applicable unless we can try just ignoring the clock signal.
Yeah, that's what I planned on doing if I used those, just ignoring the clock pin. I read in another forum it's what they did and it worked fine. Though I'm pretty sure they didn't have a PICAXE, but prob still a PIC MCU.

I suspect that Bit bang methods. Will be too slow.
Take at M2 part operating at 32 MHz where on average each BASIC command will take around 30 usec.
The WS2811 needs output pin state changes in time intervals of 0.5 uSec.

With an X2 part whether the HSPIOUT can be pressed into service using just the data signal would need some investigation (sorry I do not have time today).

A "raw" PIC chip running machine code would do the task but PICAXE with interpreted BASIC is a lot slower due to overhead of the interpreter.
Well, I think I have to change the timing intervals at 0.250uS since the WS2811 is running in fast mode @800kHz. It could be run in slow mode @400kHz, but there's a pin on the WS2811 that needs to be enabled/disabled (forget offhand), but it looks like that's pre-set in the manufacturing of the LED strip, since I don't think there's a way I can tell them via the data line which mode to run in.

But I agree, I think I'll ultimately end up using something in the PIC12 family since they're 20Mhz chips. I'll need to send data at 4MHz, and the PIC chips operate at 20MHz/4, so that should give me a little leeway and ability to slip some extra code in for however I decide to interface with it to change modes, etc.

Thanks for all your help, I think with this I should be able to move forward. And based on the WS2801 post, I might even be able to achieve this with my PICAXE...
 
Top