Jump to content
43oh

WS2811 timing


Recommended Posts

So I've been pretty much obsessed with these ws2811 led chips since I got some in a group buy a while back.  They are great for testing out the capabilities of a new mcu chip and its peripherals.  However, one thing I've been bothered by is all the different timing numbers that are published on the net. Some people use 250ns / 600ns, or 250ns./ 1000ns and finally 350ns / 800ns.  Most people are using a total cycle length of 1250 ns ( or as close as they can ). 

  

I was perplexed by some attiny asm code I found on github. It was using different timing settings I hadn't seen and also had an inconsistent total pulse length.  I've wondered how the ws2811 works internally and mentioned it to oPossom in IRC.  He speculated that the ws2811 chip probably doesn't care about anything other than the pulse duration. It probably didn't care about the entire cycle length of the signal as long as it was close.  We talked about various things they might be doing and in passing he mentioned the ws2811 probably re-clocks the pulse and sets them to the proper duration.  I'd never thought much about that but I slapped a scope on the input side and output side (DIN, DO) pins of the ws2811.  Much to my surprise the pulse duration numbers coming out the DO side were different than the published timing numbers.

 

My latest chip experiment was using one of those LPC810 8 pin 32 bit cortex-m0+ chips running at 24MHz to bit bang the ws2811 protocol.  Using the 250ns / 600ns timing I was able to get them going.  In my code, when I pushed in a 250 ns pulse on DIN, the chip was sending out a 340 ns pulse on DO. When I pushed in a 600 ns pulse it put out a 675 ns one.  I measured each chip down the strip and those numbers stayed consistent. 340 ns and 675 ns.

 

I've since changed my routines to use  333 ns and 666 ns.  Those values are pretty easy to achieve with a 24MHz clock.  Now my timings going in are closer to the timings coming out.  Not sure if it really matters but at least I feel like I'm using the right timing now.

 

Of course if you have code that works you can ignore all this. It was just something I thought I would pass on and see if anyone else had seen the same thing. 

 

-rick

Link to post
Share on other sites

If you have a DMA and a Timer that can output via DMA, then you might-as-well implement the timing exactly to spec.  Set up the timer for toggle mode, and turn each byte of data into 16 timer periods (this is pursuant to how the WS281x works, so check out that datasheet).  Doing three bytes will thus require a 96 byte buffer, but that's not so bad.  If you have the RAM to spare, it will reduce your interrupts dramatically and improve your program runtime.  Granted, that's only of great importance if you are running a bunch of other tasks, too, or if you have some kind of energy limitations.

Link to post
Share on other sites

I am using DMA in my 8 channel WS2811 driver, however, I have to use few tricks because MSP430 doesn't have enough triggers.

Can't you cascade the WS2811 units?  That's what I was thinking, that they were all cascaded and a stream was sent to them.  The only DMA interrupt you really need is the transfer-complete, which will occur immediately after the last time-period is sent.  As this last time-period is the ~50us wait slot needed between the cascaded datagrams, this is a perfect place to have the interrupt because there is plenty of time to wake-up, change context, and load the next RGB triple into the DMA buffer.

 

For the record, once I implemented an old RFID modulation using this basic pattern.  So, I'm not just inventing this on the spot :)

Link to post
Share on other sites

... (this is pursuant to how the WS281x works, so check out that datasheet).

The point of this posting is to reject the idea that the datasheet timings are correct.  The datasheets I've found conflict with the timings I've observed.

 

This document http://auschristmaslighting.com/wiki_source/images/b/ba/WS2811.pdf is often sited in internet postings. However, the chip described isn't even the SMD5050 version of the chip.  It has 8 pins instead of 6 and no on-board led.  It provides timings of 250 for off, 600 for on, and a cycle time of 1250 nanoseconds.

 

I've also found a rar file on this page but it fails to unrar using debian:

 

http://www.world-semi.com/en/Driver/Lighting_LED_driver_chip/WS2811/

 

I found someone to unpack it for me and it looked the same as the other link.

 

-rick

Link to post
Share on other sites

Yes you can, however, manufacturer recommends strings of up to 6m and updating 100s of units requires long time, so forget about smooth animations. My board controls 8 strings at the same time.

Judging by the spec, which is apparently not ideal, it should be possible to achieve 60 Hz refresh with a string of about 300.  Have you found this to be inaccurate?

Link to post
Share on other sites

It takes ~36us to update 1 unit, so you might be OK when you have 300 of them. But when you have let's say 8x150 or 64x64 array, you need multiple channels.

Sure-sure.  36us is less than the spec sheet says (~50us).  So, that's a good thing.

 

It seems to me that the bigger problem with doing nice animations is the memory interface and ability to hold a frame buffer.  From that perspective, a decent CM0 or CM3 part is a lot better-suited than any MSP430 is.  MSP430 DMA is intended to reduce interrupts more-so than to improve the system performance during memory-intense operations.  For memcpy() it still is superior to using an unrolled loop, but it blocks.

 

In any case, I was drawn to this thread because this weekend I have been looking at the WS281x parts.  I'm going to have a new board made for early 2014, to celebrate OpenTag 1.0.  It will be a funny surprise for anyone in that community, but most importantly I'm going to put-on a bunch of 2812 chips.  I would guess 15 or so.  That is a long-way from 64x64, but still enough to do fun things, like wireless controlled lighting.  In your experience, how many WS2812's is enough to generate a reasonable amount of illumination (compare to 60W incandescent)?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...