please help with WS2811 led IC

The fastspi library has code for the TM1809 LED driver which uses a clockless data line as well. Two clock cycles is well within the precision possible on an arduino or PIC if you disable interrupts for the duration of the write. The fastspi library simply defines two specific counts of nop instructions to insert into each loop to make the data sending work out right.

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:

are using this library?

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?

Sorry to dig up this oldish thread, but I too have a bunch of ws8211's, and I am determined to get them to work (preferably with the Pro Mini/Nano's as I have many of those too).

This thread is very puzzling as people are mostly saying that the SPI side is not possible, however, it works great with the FastSPI library. As long as my code is in the chip I can do anything I want with the lights, fairly fast if you ask me (a 5fps adalight would work fine for me). The problem is handling the serial port. I'm obviously having overruns there, and get very different results at different baud rates and all. I slowed it down to 2400baud, but it still doesn't work right. My super-simple well-commented code is below... the Startup Test works perfect, but Boblight (or even uploading a custom-made binary file through a terminal) is random and broken even at 2400baud upload, and all the delay(x)'s I could think of to try.

#include <FastSPI_LED.h>

//------------------------------------------------------
// Config
//------------------------------------------------------

//LED communication-pin
#define PIN 4

//Number of LEDs
#define NUM 50

//Key byte to syncronize begining of frame with BobLight (prefix)
#define KEY 0x69

//Change order of RGB below for some LED pixel brands.
struct CRGB { unsigned char r; unsigned char g; unsigned char b; };
struct CRGB *leds;


//------------------------------------------------------
// Setup - Main Code
//------------------------------------------------------
void setup()
 {
  //Baud Rate
  Serial.begin(2400);

  //FastSPI Setup (choose correct Chipset)
  FastSPI_LED.setLeds(NUM);
  FastSPI_LED.setChipset(CFastSPI_LED::SPI_TM1809);
  FastSPI_LED.setPin(PIN);
  FastSPI_LED.init();
  FastSPI_LED.start();
  leds = (struct CRGB*)FastSPI_LED.getRGBData(); 
  memset(leds, 0, NUM * 3);
  FastSPI_LED.show();

  //Startup Test
  for(int i=0; i<128; i++)
   {for(int j=0; j<NUM; j++)
     {leds[j].r = i;
      leds[j].g = i;
      leds[j].b = i;}
    FastSPI_LED.show();
    delay(20);}
  memset(leds, 0, NUM * 3);
  FastSPI_LED.show();
  delay(500);

  //Send "Ada" for auto port-detection by BobLight
  Serial.print("Ada\n");

  //Show colors while waiting for first serial frame
  for(int k=0; k<NUM; k++)
   {leds[k].r = 250-(5*k);
    leds[k].g = 0;
    leds[k].b = 5*k;}
  FastSPI_LED.show();


  //MainLoop
  for(;;)
   {if(Serial.available())
     {if(Serial.read()==KEY)
       {
        //Skip 2 after KEY
        if (!Serial.available()) {}
        Serial.read();
        delay(10);
        if (!Serial.available()) {}
        Serial.read();
        delay(10);

        //Now Load All Bytes
        for (int pixel=0; pixel<NUM; pixel++)
         {
          if (!Serial.available()) {}
          leds[pixel].r = Serial.read();
          delay(10);
          if (!Serial.available()) {}
          leds[pixel].b = Serial.read();
          delay(10);
          if (!Serial.available()) {}
          leds[pixel].g = Serial.read();
          delay(2);
         } 
        FastSPI_LED.show();
 } } } }

//------------------------------------------------------
// End
//------------------------------------------------------

void loop()
 {
  // loop() is avoided as even that small bit of function overhead
  // has a measurable impact on this code's overall throughput.
 }

Can someone point me to some code for getting a SP interrupt working so it can fill a circular buffer that way an I can just pass the values to FastSPI? I tried searching everywhere and tried to reverse engineer LEDstream, but I feel a bit lost.

...or is this really not possible without a faster micro? I'd think since the LEDs work fine, it would have to be possible to pass serial bytes to them, even if I have to send, wait, send, wait one 153-byte frame at a time, at even 0.5FPS... it has to be possible!

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

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: