Jump to content
Sign in to follow this  
m0nk37

MSP430 how to make WS2811Driver reduce from 800 kHz to 400 kHz link inside

Recommended Posts

Hello,

 

I am trying to make the WS2811Driver found here (https://github.com/ILAMtitan/WS2811Driver) work with my UCS193 / TM1903 RGB-LED Light strip. I am failing to modify the assembly file inside to adjust the delay from 800 kHz to 400 kHz, half that of the WS2811, Atleast i think that is what i need to do.

 

Can anyone provide insight into whether i am on the right track or if they can let me know of a resource i can look into which will allow my MSP430 to control the mentioned RGB-LED Strip?

 

So far it works but after about 3-4 cycles of on/off red/green (what i intended) it will do random light fluttering which i assume is from the lights being sent too many instructions with overwrite happening. 

 

I know thats a bit of a stretch if anyone knows what to do in order to help me but any help would be appreciated. Ill of course post the code if i can get this working.

 

Thanks for your time

Share this post


Link to post
Share on other sites

Hi @@m0nk37

 

The Energia library you linked to was was written by @@ILAMtitan and  in the  attribution is listed @Ricta59.  What modifications did you make to the assembly?  How many LEDs are you trying to control, what microcontroller are you using at what speed, etc.  Do you have a logic analyzer or some other way of looking at the output and adjusting to get inside the specs?

 

An alternate way that might work would be to use SPI as described here:  http://forum.43oh.com/topic/10011-using-spi-and-energia-with-ws2812-leds/

Share this post


Link to post
Share on other sites

Hello @@Fmilburn, thanks for your response!

 

The microcontroller i am using is an MSP430G2 at 16 Mhz.

 

The only modifications i have made to the assembly was to create a new copy of the 16 Mhz version there and add it as a "ls" (low speed) variant. I was trying to mess with it and see what i could come up with but my assembly is terrible at the moment.

 

I dont have any sort of analyzer equipment either so im just going off of datasheets and what not.

 

The library i linked seems to work fine for solid colors, its only when i want to animate it does it get sporadic. Animations seem to work for a few cycles and then it "catches up" and goes random for a couple cycles. I know that the speed for the LED lights im using is half that of the WS2811 and almost identical setup.

 

The library you posted i tried as well, it too seems to work for solid colors but once we get into animations it doesnt play nice.

 

Im trying to adjust the speed i guess of the WS2811 to half of what it is and im not sure how to proceed with that.

 

EDIT: oh and for the code you posted, what i did to get it semi-working was change these definitions as follows:

#if defined(__MSP430G2553)
  #define SPIDIV     SPI_CLOCK_DIV4
  #define SPILONG    0b11110000 
  #define SPISHORT   0b11000000  

Share this post


Link to post
Share on other sites

do you mean ucs1903?

 

https://www.google.com/url?sa=t&source=web&rct=j&url=http://www.bestlightingbuy.com/pdf/UCS1903%2520datasheet.pdf&ved=0ahUKEwjdwbLRhv_QAhWB4CYKHW1cAgYQFggaMAA&usg=AFQjCNHoYBl1ZT-VnoPdVKydzOUcP4lB8w

 

If so, the timing on that is completely different 0.5us short pulse, 2.0us long pulse, 2.5us total cycle

 

-rick

Share this post


Link to post
Share on other sites

Yes that is what i am referring to, I am trying to make the ucs1903 RGB-LED strip i have work with the MSP430G2. The timing is different yes, but it is similar.

 

Edit: I have read that it is similar, do you have any advice to move forward with using this LED strip with the MSP430G2? I was hoping i could modify an existing library to get started with playing around with it. Would it be better to approach this differently?

Share this post


Link to post
Share on other sites

I explained the math for the SPI approach in my post and there are references behind that as well. Do the calculations with the timing that Rick has posted above. That will tell you if the SPI approach will work and if so, what byte to send for short and long. Have you tried that?

EDIT: This table gives the information needed, including tolerances:
post-45284-0-26178900-1482117549_thumb.jpg

Calculate a clock divider for SPI that will give a reasonable "tick" - eg. DIV4 on the G2553 gives 250 ns
Now look at the table and determine what bits to send via SPI to get the correct wave form -
for 0: 0b11000000 would give (2*250=500H, 6*250=1500L)
and 1: 0b11111100 would give (1500 H, 250 500 L)      EDIT
and R: 0b00000000 would give (1750 2000 L).      EDIT
pretty iffy - outside spec

for F5529,
SPI divider = 2 gives 312 ns per tick
for 0: 0b11000000 is (2*312=624 H, 6*312=1,872 L)
for 1: 0b11111100 is (1872 H, 624 L)
looks to be within spec

Share this post


Link to post
Share on other sites

No i have not tried that yet, I dont have very much experience with hardware so i was hoping it might be a little more simple than that as i felt it might be out of my experience level?

 

Anyways that sounds like a plan now, ill try and make sense of it and put the data sheet to use.

 

Thanks @@Rickta59 and @@Fmilburn. Hopfully i can get it working! Ill post my results once i get any here

Share this post


Link to post
Share on other sites

See my edit above - try it with the G2553 and SPI - it might work

 

EDIT:  also I guess you can try "high-speed mode"  pin 7 probably isn't accessible

 

Just a follow up question trying to make sure i understand everything, what is the formula you are using to obtain the 250 ns calculation?

 

"DIV4 on the G2553 gives 250 ns" and "16 MHz/4 gives 250 ns for each on bit in byte" for example?

 

So obviously the divider of 16 MHz as 4 is 4 MHz. Then how to get the 250 ns for each on bit in byte?

 

Thanks for all the help so far! :)

Share this post


Link to post
Share on other sites

I am trying to select a frequency that results in a period that meets the requirements. See wikipedia article on frequency.

 

f = 1 / T

 

The period of something at 1 MHz is 1 uSec, or 1000 nSec. The period of something at 4 MHz is 250 nSec.

Share this post


Link to post
Share on other sites

Thank you the calculations make sense now.

 

Looking at the datasheet for UCS1903:

 

Name Description                   Typ. value Allowable error
T0H    code 0, high level time 0.5

Share this post


Link to post
Share on other sites

It is saying that to send a "0" requires pulse high for 0.5 us, and follow with a low pulse for 2 us.  To send a "1" pulse high for 2 us, and pulse low for 0.5 us.  Each pulse should vary by no more than +/- 0.15 us.  So, for example, an acceptable pulse for0.5 us could be between 0.35 and 0.65.  Those values should work reliably since they come from the datasheet.  The total pulse length should be about 2.5 us.  Unfortunately I don't see a value which fits well with a 16 MHz clock.  However, often times things work for values outside the datasheet which is why I suggested what I did.  Clearly you would not want to do this for a critical application.

 

You can try lengthening / shortening things from what I suggested and see if something will work - I really can't say since it is outside the specification.  Not sure I can be of much more help....

 

The values for the SPI clock divider are fixed for the micro-controller peripheral being used.  You can only use the values that are given in the micro-controller datasheet (or in this case whatever Energia provides).  If you weren't using Energia/Arduino then you could change clock speed and account for it that way but you aren't - that kind of flexibility is something you give up with Energia/Arduino.

Share this post


Link to post
Share on other sites

Thank you.

 

So if i used CCS for example, would i gain the ability to change the clock speed and achieve what i need? Granted i know that the methods and total process will need to be revised, but do you think it would be possible?

 

I also have an MSP432 laying around at 28 MHz so if it is, then perhaps i can do something with that with modified timing of the clock or even something with the MSP430 ive been trying. 

Share this post


Link to post
Share on other sites

Just about any microcontroller could do this - if you are serious about learning how then there are lots of resources.  For example:

 

http://processors.wiki.ti.com/index.php/MSP_Design_Workshop     

Several free courses at edX

this one at udemy I thought was good:  Microcontrollers and the C Programming Language by Mark Budnik

Lots of stuff on 43oh and other internet locations to explore

       

Energia/Arduino has a place but you are basically stuck with whatever microcontroller and ICs that other people have written Energia/Arduino libraries for.  Good luck...

Share this post


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.

Sign in to follow this  

×
×
  • Create New...