Jump to content

  • Log In with Google      Sign In   
  • Create Account

Photo

WS2811 LED controller driver


  • Please log in to reply
22 replies to this topic

#1 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 811 posts
  • LocationMichigan, USA


Posted 13 November 2012 - 08:42 PM

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.

Attached File  WS2811 timing.PNG   17.42KB   7 downloads

Attached Files


  • bluehash, GeekDoc, jsolarski and 2 others like this

#2 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 811 posts
  • LocationMichigan, USA


Posted 15 November 2012 - 06:50 PM

High speed mode has now been tested.

Rickta59 discovered that they will run at high speed!
  • spirilis likes this
Sent from a bunker in an undisclosed location deep beneath a mountain.

#3 RobG

RobG

    Level 5

  • Members
  • 2,692 posts
  • LocationCary, NC, US


Posted 15 November 2012 - 07:41 PM

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.

#4 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 811 posts
  • LocationMichigan, USA


Posted 15 November 2012 - 08:08 PM

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).
Sent from a bunker in an undisclosed location deep beneath a mountain.

#5 Rickta59

Rickta59

    Level 3

  • Global Moderators
  • 672 posts
  • LocationEastern NC


Posted 15 November 2012 - 08:17 PM

Here is a port of the asm routines so you can use this code with msp430-gcc.


Attached File  ws2811_hs.zip   1.45KB   94 downloads

-rick
  • oPossum and spirilis like this

#6 RobG

RobG

    Level 5

  • Members
  • 2,692 posts
  • LocationCary, NC, US


Posted 15 November 2012 - 08:18 PM

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

#7 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 811 posts
  • LocationMichigan, USA


Posted 16 November 2012 - 01:09 AM

I used timing from WS2811 spec sheet.

Timing table added to first post.
Sent from a bunker in an undisclosed location deep beneath a mountain.

#8 spirilis

spirilis

    Level 5

  • Members
  • 1,688 posts


Posted 16 December 2012 - 03:18 AM

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) - Attached File  ws2811_hs_one.zip   1.5KB   82 downloads

 

Pic: Attached File  dsc_4902.sm.jpg   68.55KB   79 downloads


I made some 43oh Store gadgets

Also see my Tindie store


#9 GeekDoc

GeekDoc

    Level 4

  • Administrators
  • 1,379 posts
  • LocationO'Fallon, Illinois (St. Louis Metro area)
  • Sparkfun Wishlist


Posted 03 January 2013 - 01:06 AM

Have you guys seen this?

 

http://www.instructa...h-an-AVR-thing/


Public Service Announcement: I am a microcontroller / electronics noob! I should usually be quietly ignored or patiently instructed.
http://blog.DocsTech.net

#10 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 811 posts
  • LocationMichigan, USA


Posted 03 January 2013 - 01:14 AM

Saw it.

 

Probably shouldn't comment.  ;-)


Sent from a bunker in an undisclosed location deep beneath a mountain.

#11 GeekDoc

GeekDoc

    Level 4

  • Administrators
  • 1,379 posts
  • LocationO'Fallon, Illinois (St. Louis Metro area)
  • Sparkfun Wishlist


Posted 03 January 2013 - 02:21 AM

Saw it.

 

Probably shouldn't comment.  ;-)

 

'nuff said. :grin:


Public Service Announcement: I am a microcontroller / electronics noob! I should usually be quietly ignored or patiently instructed.
http://blog.DocsTech.net

#12 vinietje

vinietje

    Noob Class

  • Members
  • 3 posts

Posted 09 April 2013 - 08:39 PM

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

Attached Files


Edited by vinietje, 09 April 2013 - 08:40 PM.


#13 piglet

piglet

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationSouth of England

Posted 19 July 2013 - 10:26 AM

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



#14 RobG

RobG

    Level 5

  • Members
  • 2,692 posts
  • LocationCary, NC, US


Posted 19 July 2013 - 12:20 PM

They are probably wired for high speed, try this code.


  • piglet likes this

#15 piglet

piglet

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationSouth of England

Posted 19 July 2013 - 09:13 PM

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.



#16 RobG

RobG

    Level 5

  • Members
  • 2,692 posts
  • LocationCary, NC, US


Posted 19 July 2013 - 09:21 PM

WS2811 has 2 speeds of operation, 400kHz and 800kHz. However, 5050/WS2811 or WS2812, is set to work at high speed only.

Also, WS2811 does not use SPI protocol. SPI hardware is used to output 1 wire protocol required by WS2811.



#17 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 811 posts
  • LocationMichigan, USA


Posted 20 July 2013 - 04:22 AM

To use the high speed protocol just change write_ws2811() to write_ws2811_hs(). That will give you the most precise timing possible and allow use of any pin on port 1. SPI/IIC remains free for other uses.

 

Here is some code for RTC: http://forum.43oh.co...tc-two-methods/

 

The 32 kHz crystal is used just for the RTC - the MSP430 can still run at 16 MHz.


  • GeekDoc likes this
Sent from a bunker in an undisclosed location deep beneath a mountain.

#18 Adi

Adi

    Noob Class

  • Members
  • 3 posts
  • LocationUSA

Posted 04 March 2014 - 02:02 AM

This library is awesome. 

 

I'm trying to integrate it into my existing firmware. My MSP430G2553 is running at DCO 1MHz.. 

 

How can I adjust the timings, or any other trick to make this code calculated for 16MHz cycle run on my existing firmware (@1MHz) ?

 



#19 RobG

RobG

    Level 5

  • Members
  • 2,692 posts
  • LocationCary, NC, US


Posted 04 March 2014 - 11:30 PM

You cannot, 1MHz is too slow for WS2811.


  • Adi likes this

#20 Adi

Adi

    Noob Class

  • Members
  • 3 posts
  • LocationUSA

Posted 09 March 2014 - 11:45 PM

Thank you for responding RobG. 

 

I'm still trying to avoid bit banging assembly and use timer interrupts to generate PWM with 20% & 50% duty cycle for 0 & 1 respectively. If you have tried already, can you suggest if it's possible with WS2811 ? I read your very first question in this forum and OPossum thinks it's duty cycle that chip looks for. I wonder if you did any further discovery into it ?

 

Yes, I changed my MCLK to run at 8MHz now (& may further update it to 16 MHz). With that, I can have width of 0 bit pulse to like 25 uS. Roughly running at 20 kHz frequency. Datasheet mentioned only about 400 & 800kHz, but can it run at 10 ~ 20 kHz as well ? Eagerly looking forward for your answer.

 

Thanks,






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users