please help with WS2811 led IC

Grumpy_Mike:
I don't think you can do it. If you look at the timing you have to be accurate to 100nS and there simply isn't enough time in a 16MHz processor to do that, it turns out to be about two clock cycles. Even in machine code the overhead of reading data and producing those two diffrent waveforms times is too tight.
I think you will have to have a diffrent processor, one that runs faster. Or a very fancy piece of hardware.

Why not have the Arduino write it into a RAM and then use a discrete circuit with a trigger and a precision timer to read the RAM when triggered and bitbang it out all purely using hardware? The biggest, bestest serial to parallel shift register evah. Sure, this is nasty overkill but at least it will prove you can make a nice little bespoke circuit. :grin:

Just as a note, the MSP430G2553 (available as part of the $4.30 Launchpad bundle) can run at least 60 of these things, despite being a 16MHz part.
There's even a library for Energia (Arduino IDE ported to MSP430), here: http://forum.43oh.com/topic/2882-energia-library-ws2811driver-led-controller-class/#entry24208

rpmccormick:
Well I guess I proved all the nay-sayers wrong. My 50-channels of WS2811 bulbs are now working with an Arduino Nano at 30fps under Win7 Aero by using the FastSPI library.

See pics at the bottom of the first page of this thread: http://arduino.cc/forum/index.php/topic,122810.0.html

Hi,
I am trying to get the ws2811 strips working but getting few flickers/errors.
Can you please help me with timing to send 1's and 0's ?
Following timing I'm using...


Also I'm using 50uSec delay in between two frames!
Currently sending data for 1 pixel (24 bit: 1byte R, 1byte G, 1byte B).


Is there anything else to be considered to remove the flickering?

P.S. I'm not using SPI or Fast SPI
Timing for "0" = 250nS HIGH and 1uS LOW
Timing for "1" = 1uS HIGH and 250nS LOW

The MSP link requires a log on.

Bob

Docedison:
The MSP link requires a log on.

Bob

Timing for "0" = 250nS HIGH and 1uS LOW
Timing for "1" = 1uS HIGH and 250nS LOW
Img Link;

Docedison:
The MSP link requires a log on.

Bob

Odd, it's in the Libraries section, didn't think that would take a logon.

Well I guess I proved all the nay-sayers wrong.

No you didn't, you proved that the chip responds to signal timing outside the quoted values, that's all.

It is possible to get the exact 250nsec/1000nsec timings that are required by the WS2811 out of a 16MHz AVR, with no timing jitter anywhere. It's just not particularly easy, you need to do it in assembler. I've written it up, along with code, at http://bleaklow.com/2012/12/02/driving_the_ws2811_at_800khz_with_a_16mhz_avr.html. Note this code is for pixels wired up in (G,R,B) order rather than (R,G,B).

And another note: there seems to be an assumption in earlier posts on this thread that if you use the FastSPI library to drive the WS2811 you are using SPI and therefore the WS2811 is a SPI device. That's wrong - when driving the WS2811 FastSPI uses bit-banging. Oh, and the timings aren't correct, which may be the issue if it doesn't work for you - see the blog post linked to above for details.

Grumpy_Mike:

Two clock cycles is well within the precision possible on an arduino or PIC

No it is not. Write the code and see.

Yes you can output something in 1 clock cycle, then you have to fetch the next byte, check if you have outputted all the data and loop back if not all in the next clock cycle?

Yes Mike is Grumpy and he should ease up a bit.

2 clock long pulses are easy doable on an AVR. As long as you have time outside the pulse to make you decisions.

In this case you have 20 clock cycles before your next decision.

Check out

for a bit banging routine on an AVR that leaves about 1/5 of your overall clocks free for doing what ever else you want too.

What is it with the youth today thinking the solution to every problem is a 32bit CPU running at 80Mhz. Back in my day we had 8bits, 4Mhz and we where happy.

cunningfellow:
What is it with the youth today thinking the solution to every problem is a 32bit CPU running at 80Mhz. Back in my day we had 8bits, 4Mhz and we where happy.

I had that too and I remember the painful waiting for the next greatest thing, which was only marginally better. And the software these days is STILL only marginally better though the hardware is pretty freaking amazing.

I blame library dependence.

If there isn't already a library for doing it it can't be done.

I was given a challenge to see if I could read data from an SD card and stream it out a string of LEDs in ASM.

Thats certainly a stretch goal over "two clock cycles isn't enough" :slight_smile:

I'm currently testing a full rewrite of the FastSPI_LED library that uses exactly 20 clocks per bit for the ws2811 library (as well as opening the code up to better porting to other platforms and hopefully speeding up the development/addition of new chipset support to the library and making the library far far smaller, nearly an order of magnitude smaller, than the currently published library - in theory, I should be able to support new clockless chips by just specifying the spacing of timings).

dgarcia42:
I'm currently testing a full rewrite of the FastSPI_LED library that uses exactly 20 clocks per bit for the ws2811 library (as well as opening the code up to better porting to other platforms and hopefully speeding up the development/addition of new chipset support to the library and making the library far far smaller, nearly an order of magnitude smaller, than the currently published library - in theory, I should be able to support new clockless chips by just specifying the spacing of timings).

What are new clockless chips? An asynchronous processor? How does that work? Who provides that product?

JoeN:

dgarcia42:
I'm currently testing a full rewrite of the FastSPI_LED library that uses exactly 20 clocks per bit for the ws2811 library (as well as opening the code up to better porting to other platforms and hopefully speeding up the development/addition of new chipset support to the library and making the library far far smaller, nearly an order of magnitude smaller, than the currently published library - in theory, I should be able to support new clockless chips by just specifying the spacing of timings).

What are new clockless chips? An asynchronous processor? How does that work? Who provides that product?

I don't know - they haven't been released yet :slight_smile:

I'm referring to chips in the family of the TM1809, the UCS1903, and the WS2811. These chips only have a data line, no clock line. Instead the signal is something like the line held high for 340ns, then low 680 for a 1 and high for 680ns then low for 340ns for a 0, etc... Each of the chipsets out there has slightly different timings. For the new version of the library, I will be able to support new variations on these chips by simply specifying the hi/lo timings for 0 and 1 and it will figure out everything it needs timing wise from that :slight_smile:

Headroom:
As stated several times a higher MHz processor may do the trick. Running at 80MHz a Uono32 could work and is likely less expensive than tossing the LED strips:

I've driven 120-LED WS2811 strings using a Tiny85 running on the internal 8MHz clock. No problem.

JoeN:

Grumpy_Mike:
I don't think you can do it. If you look at the timing you have to be accurate to 100nS and there simply isn't enough time in a 16MHz processor to do that, it turns out to be about two clock cycles. Even in machine code the overhead of reading data and producing those two diffrent waveforms times is too tight.
I think you will have to have a diffrent processor, one that runs faster. Or a very fancy piece of hardware.

Why not have the Arduino write it into a RAM and then use a discrete circuit with a trigger and a precision timer to read the RAM when triggered and bitbang it out all purely using hardware? The biggest, bestest serial to parallel shift register evah. Sure, this is nasty overkill but at least it will prove you can make a nice little bespoke circuit. :grin:

I am going to quote myself above. No one commented on this idea. Is it a stupid idea? I do stupid stuff like this all the time just to see if I can get it right. You can throw the discrete idea away and use something like a Xilinx XC9572XL in a PLCC with 5-volt compliant IO pins which is super hobbiest friendly and learn something. And with the right crystal and maybe a scaler in the CPLD I bet you can get it 1% complant with whatever timing the WS2811 requires.

JoeN:
I am going to quote myself above. No one commented on this idea. Is it a stupid idea?

Yes, but don't let that stop you... :slight_smile:

Arduinos are perfectly capable of driving a WS2811 without this. The timing for each bit is tight, yes, but between each bit you get 50us of breathing space - enough time to do just about anything you want.

Just relating my experience:

  • Arduino Uno
  • Aliexpress WS2811 5050 SMD LED strip
  • FastSPI_LED2 library (preview build from March 2013)

I have a 130 LED strip being driven by the Arduino Uno. I had to adjust the timing in FastSPI_LED2.h for WS2811Controller800Mhz for the Aliexpress (Chinly brand) LEDs to 350, 800, 600.

I'm just writing code to drive a WS2811 string and playback sampled sounds on an ATtiny85 @ 8Mhz.

[Sorry to bump, but I think there's some good context in this thread]

So, my setup (UNO, 5050ws2811 from aliexpress, FastSPI_LED2 Aug13) is also struggling with ws2811 timing: a simple sketch to move a white light down the strip (i.e. FirstLight) causes the strip flash randomly, especially within the first 6 leds. I have almost the same set up as mc1457 in the post above, though his timings didn't work for me. Futzing with the timings for WS2811Controller800Mhz makes the sketch run better or worse -- sometimes I can actually see a white led traveling down the strip with only a mild amount of tomfoolery on the parts of the other leds. The best triple I've found is (300, 400, 550) but it's still pretty awful.

I'm actually a bit confused as to how the timing defined in fastspi was derived. chipsets.h defines the triple (350ns, 350ns, 550ns), while the ws2811 spec sheet (http://www.adafruit.com/datasheets/WS2811.pdf) says a 0 is 250ns hi, 1000ns low; a 1 is 600ns hi, 650ns low. Not sure how we get the first three numbers from the latter four, or if they should just be updated. The comment in the code about the triple was hard for me to decipher relative to the spec sheet.

These controllers have 3 control points in their cycle for each bit.  The first point is where the
line is raised hi.  The second pointsnt is where the line is dropped low for a zero.  The third
point is where the line is dropped low for a one.  (T1, T2, T3) correspond to the timings for
those three in clock cycles.

In trying to figure out the timing myself, I've become pretty stumped by the cascade diagram on page 4 of the spec (http://www.adafruit.com/datasheets/WS2811.pdf). Can someone explain what it means, or in general how we're able to individually control all these leds with a single data line?