Pages: 1 2 [3] 4   Go Down
Author Topic: please help with WS2811 led IC  (Read 24248 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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

http://www.instructables.com/id/My-response-to-the-WS2811-with-an-AVR-thing/

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

Breaking Worse
Offline Offline
Edison Member
*
Karma: 19
Posts: 1109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I have only come here seeking knowledge. Things they would not teach me of in college.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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" smiley
Logged

US
Offline Offline
Newbie
*
Karma: 2
Posts: 35
Hi! I wrote and maintain the FastSPI_LED library. Working on trying to keep it up to date.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

--

FastLED (formerly FastSPI_LED) -- new home http://fastled.io

Breaking Worse
Offline Offline
Edison Member
*
Karma: 19
Posts: 1109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

US
Offline Offline
Newbie
*
Karma: 2
Posts: 35
Hi! I wrote and maintain the FastSPI_LED library. Working on trying to keep it up to date.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

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 smiley
Logged

--

FastLED (formerly FastSPI_LED) -- new home http://fastled.io

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5757
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Breaking Worse
Offline Offline
Edison Member
*
Karma: 19
Posts: 1109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley-mr-green

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

I have only come here seeking knowledge. Things they would not teach me of in college.

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5757
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5757
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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?
Logged

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5757
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Short pulse is a zero.
Long pulse is a one.

The values for T0L, T0H, etc. are on the previous page (nb. your LEDs are most likely "high speed")

PS: The diagram makes it look like the rising edge of a pulse must be exactly 2.5uS after the previous one but in practice it doesn't matter if it's a bit longer than that.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, I think I got it figured out: You just supply a train of 24 bit bundles where each chip latches and chops off one group, passing along the rest of the train to the next chip in line.  Each bit is encoded as per the spec sheet by holding the line high for some period, then low.

I think I also figured out the (T1, T2, T3) triplet in FastSPI_LED2 by reading fastSetBit: https://code.google.com/p/fastspi/source/browse/branches/FastSPI_LED2/clockless.h#60.  Looks like T1 = amount of time you hold the line hi whether or not you're encoding a 0 or 1, T2 = amount of time you'd hold the line low for 0 but continue to hold the line hi for 1 (e.g. how long the 0/1 encodings differ), and T3 = amount of time you'd hold the line low whether or not you're encoding a 1 or 0.  So for the ws2811 in fast mode, that'd give us (250ns, 350ns, 650ns), but since all the timings have +/-150ns tolerances according to the specsheet, the default (350ns, 350ns, 550ns) in fastspi should still also work.

Hopefully someone else looking into this finds the above helpful smiley  Anyway, back to my problems...

===

Unfortunately, my ideal timing triple (250ns, 350ns, 650ns) doesn't work either and I'm still getting a ton of noise on the leds.  It seems to work better for shorter stretches of leds (e.g. <10) but still hiccups and shows random colors every couple seconds.  It feels like those hiccups are likely when timing errors accumulate enough to go out of the tolerance range... or it could just be I got a bad set of LED strips smiley-sad Has anyone else dealt with or experienced this of have any advice?

I feel like my next step would be to try to get my hands on an oscilloscope to see what the data line actually looks like.  Now to find an oscilloscope smiley-razz
Logged

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5757
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately, my ideal timing triple (250ns, 350ns, 650ns) doesn't work either and I'm still getting a ton of noise on the leds.  It seems to work better for shorter stretches of leds (e.g. <10) but still hiccups and shows random colors every couple seconds.  It feels like those hiccups are likely when timing errors accumulate enough to go out of the tolerance range... or it could just be I got a bad set of LED strips smiley-sad Has anyone else dealt with or experienced this of have any advice?

Did you disable interrupts while you do it?
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Pages: 1 2 [3] 4   Go Up
Jump to: