oPossum 1,083 Posted November 13, 2012 Share Posted November 13, 2012 Assembly code for driving WS2811 LED controllers at low or high speed on any pin of PORT1 (could be modified for other ports). Requires 16 MHz MCU clock and interrupts must be disabled. Timing is from WS2811 spec sheet and is as precise as possible. ws2811.zip GeekDoc, spirilis, jsolarski and 2 others 5 Quote Link to post Share on other sites
oPossum 1,083 Posted November 15, 2012 Author Share Posted November 15, 2012 High speed mode has now been tested. Rickta59 discovered that they will run at high speed! spirilis 1 Quote Link to post Share on other sites
RobG 1,892 Posted November 15, 2012 Share Posted November 15, 2012 How is that possible? WS2811 doesn't have any speed auto-detect feature, does it? Is it possible that the low speed timing you are using is on the max side of allowed timing and the high speed on the min side? I couldn't find any information about WS2811's internals, but I think there must be 2 one shot monostable multivibrators inside, one re-triggerable for reset and one for data. At slow speed, it is probably set at ~1us and is triggered by the DI, after 1us, it clocks the shift register and shifts in the state of DI. Because SET pin must be left floating for high speed, I assume it is connected to a simple RC timing circuit. For example, if the internal timer is set at 0.95us, 0.9us/2us and 0.5us/1us would work and they would appear to be two different speeds. Quote Link to post Share on other sites
oPossum 1,083 Posted November 15, 2012 Author Share Posted November 15, 2012 Nothing in the docs I have seen. I suspect it compares total bit time (rising edge to rising edge) to on time using a RC integrator and a comparator. So it looks at pulse width as a percentage of bit time. All I know for sure is that it works if the timing is good. (20% / 48% pulse width). Quote Link to post Share on other sites
Rickta59 589 Posted November 15, 2012 Share Posted November 15, 2012 Here is a port of the asm routines so you can use this code with msp430-gcc. ws2811_hs.zip -rick oPossum and spirilis 2 Quote Link to post Share on other sites
RobG 1,892 Posted November 15, 2012 Share Posted November 15, 2012 Looks like Ray included more information and it appears that those are wired for high speed TH + TL = 1.26us +/-600ns T0H 0.35us +/-150ns T1H 0.7us T0L 0.8us T1L 0.6us There is also a reference to WS2821, but this could be a typo... The timing I am using: TH + TL = 2us +~0-1us T0H 0.5us T1H 1.0us T0L 1.5us +~0-1us T1L 0.5us +~0-1us Quote Link to post Share on other sites
oPossum 1,083 Posted November 16, 2012 Author Share Posted November 16, 2012 I used timing from WS2811 spec sheet. Timing table added to first post. Quote Link to post Share on other sites
spirilis 1,265 Posted December 16, 2012 Share Posted December 16, 2012 Minor variation of Rickta's version of oPossum's code, it ditches the reset procedure (reset_hs just pop R11 and ret) so you can continually bang this code in a C loop. Works great, got a prototype "poinsettia mood lighting" strip I'm working on... did a toner-transfer PCB with dip socketed G2553 (see underneath the LP, I used a hobby paint marker to apply a faux red soldermask), just waiting on an SMD USB connector for it: Code (ASM routine) - ws2811_hs_one.zip Pic: Quote Link to post Share on other sites
GeekDoc 226 Posted January 3, 2013 Share Posted January 3, 2013 Have you guys seen this? http://www.instructables.com/id/My-response-to-the-WS2811-with-an-AVR-thing/ Quote Link to post Share on other sites
oPossum 1,083 Posted January 3, 2013 Author Share Posted January 3, 2013 Saw it. Probably shouldn't comment. ;-) Quote Link to post Share on other sites
GeekDoc 226 Posted January 3, 2013 Share Posted January 3, 2013 Saw it. Probably shouldn't comment. ;-) 'nuff said. :grin: Quote Link to post Share on other sites
vinietje 4 Posted April 9, 2013 Share Posted April 9, 2013 (edited) Hi guys, Ik tried all the above assembly code, but I cannot to get my led to give some form of output. I've looked at the scope at the output pin, and there is a nice square wave coming out of it. I'm kinda lost on how to get these leds shining. Presently i've connected the bare led with 5v on the VCC, VDD and 3.3V straight out of the launchpad to the DI (data in). But it won't work, There is NO capacitor on the VCC. Any thoughts would be very welcome! cheers ps. For good measure, ive included my stuff, (a make file, Main.c and the assembly by you guys. NOTE THAT THIS DOES NOT WORK ON MY SETUP), altough output seems oke.. ws2811-broken.zip Edited April 9, 2013 by vinietje Quote Link to post Share on other sites
piglet 14 Posted July 19, 2013 Share Posted July 19, 2013 I tried the code in the first post in this thread last night on some of these, and the correct number of LEDs became active. The first LED in the chain cycled through the colours perfectly, but the rest of the lit LEDs flickered and didn't cycle the colours as expected. The chain works Ok with the "mini 3keys smart pixel controller" which I got with it, so it looks like a timing issue from the MSP430. It's a shame the seller doesn't provide a link to the data sheet.... Do you have any pointers for how best to tweak the timing for these WS2811's, or is there some later code I should try? Thanks in advance Quote Link to post Share on other sites
RobG 1,892 Posted July 19, 2013 Share Posted July 19, 2013 They are probably wired for high speed, try this code. piglet 1 Quote Link to post Share on other sites
piglet 14 Posted July 19, 2013 Share Posted July 19, 2013 Thank you. Yes - that works very nicely - but only after a change: from UCB0BR0 |= 0x04; // 1:4 - 16MHz/4 = 0.25us to UCB0BR0 |= 0x03; // 1:3 - 16MHz/3 = 0.1875us I guess this is because these WS2811 LEDs need it a little faster. Hmmm. I've never used SPI before. I'm still very new to this and have only done bit-banging in C using the timers. I've got some reading to do. My next challenge is to be able to put these LEDs into a particular state depending on time of day, while keeping accurate time using an external 32768Hz crystal. If this code needs 16MHz clock, and the clock part needs the 32768Hz crystal as clock am I stuck? I just don't know enough. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.