Jump to content

m0nk37

Members
  • Content Count

    22
  • Joined

  • Last visited


Reputation Activity

  1. Like
    m0nk37 reacted to LiviuM in MSP430G2553 and 3-wire SPI RGB LED timing help   
    Hi,
    have you seen the @@Fmilburn's topic about controlling WS2812B LEDs using MSP430G2553 LP and SPI?
  2. Like
    m0nk37 reacted to chicken in MSP430G2553 and 3-wire SPI RGB LED timing help   
    Just the other day, there was an article on hackaday that may give you some workarounds
    http://hackaday.com/2017/01/20/cheating-at-5v-ws2812-control-to-use-a-3-3v-data-line/
     
    Alternatively, a level shifter like SN74HCT125 could be used.
  3. Like
    m0nk37 reacted to LiviuM in MSP430G2553 and 3-wire SPI RGB LED timing help   
    I've used some (4) WS2812B powered at 3.3 V and they worked OK. Never used TM1809, though.
  4. Like
    m0nk37 reacted to chicken in MSP430G2553 and 3-wire SPI RGB LED timing help   
    Looking at the data sheet:
    - Hi/lo speed is determined by the voltage on the SET pin. See page 2
    - The timing waveform on page 4 is describing 1 bit. Repeat it 72 times to transmit 72 bits of data (8/8/8 bit RGB for 3 LEDs), times the number of chained ICs.
     
    From what I understand, the SPI trick uses multiple bits of SPI data to match a single LED bit's timing. E.g. you'd use 100 to transmit a 0 and 110 to transmit a 1. You just have to make sure that SPI runs at roughly 600ns / bit, i.e. 1.666 MHz, with 1.6 probably being close enough. The trickier question is how to get the color data into that format and feeding it to the SPI peripheral. That's where the library comes in.
     
    @@Fmilburn to the rescue :-)
  5. Like
    m0nk37 reacted to Fmilburn in MSP430G2553 and 3-wire SPI RGB LED timing help   
    I have learned not to comment on devices I haven't worked with before but here goes anyway
     
    How did you set the clock and are you sure you got that correct?  If it is 625 ns then it would appear to be OK with LONG and SHORT as you have described it.  Did you post your code?  I didn't see it.
     
    What code are you using that gives 90-95% correct?  The schematic in the datasheet shows a capacitor between Vcc and GND - did you place that in your circuit?  Could possibly be something flaky because of that.
     
    It is really useful to have a logic analyzer for this type work, unfortunately mine isn't working at the moment.
  6. Like
    m0nk37 reacted to Fmilburn in MSP430G2553 and 3-wire SPI RGB LED timing help   
    I had a quick look at your code and I suspect there are multiple problems.  For example, in main_working_95.c
    // DCO Speed Divider UCB0BR0 = 3.2; You can't put a floating point number into a register and I don't think this is doing what you want it to.  If you are new to registers on microcontrollers I suggest The TI workshop at http://processors.wiki.ti.com/index.php/Category:CCSv6_Training#Workshops_and_Modules
     
    I think you can modify the CCS code I posted in the link @@LiviuM referred to and make it work.  Here is my quick edit of the code:
    // Runs on G2553 at 8 MHz // Output is on pin P1_2 (MOSI) #include <msp430.h> #define SPIDIV 0x02 // 8 MHz/2 gives ~250 ns for each on bit in byte <===== #define SPILONG 0b11111000 // 1250 ns on, 750 ns off <===== #define SPISHORT 0b11100000 // 750 ns on, 1250 ns off <===== void initClock(); void initSPI(); void initWS2812(); void sendByte (unsigned char ; void sendPixel (unsigned char r, unsigned char g, unsigned char ; void show(); int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer initClock(); initSPI(); initWS2812(); while(1){ sendPixel(0xFF, 0xFF, 0xFF); // show all ones <====== // sendPixel(0x00, 0x00, 0x00); // show all zero <====== show(); } } void initClock(){ BCSCTL1 = CALBC1_8MHZ; // load calibrated data for 8 MHz <====== DCOCTL = CALDCO_8MHZ; // <====== } void initSPI(){ P1SEL = BIT1 + BIT2 + BIT4; P1SEL2 = BIT1 + BIT2 + BIT4; UCA0CTL0 |= UCCKPL + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 |= SPIDIV; // clock divider UCA0BR1 = 0; // UCA0MCTL = 0; // No modulation UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0RXIE; // Enable USCI0 RX interrupt } // Sends one byte to the LED strip by SPI. void sendByte (unsigned char { unsigned char bit; for (bit = 0; bit < 8; bit++){ if (b & 0x80) // is high-order bit set? UCA0TXBUF = SPILONG; // long on bit defined for each clock speed else UCA0TXBUF = SPISHORT; // short on bit defined for each clock speed b <<= 1; // shift next bit into high-order position } } // Send a single pixel worth of information. Turn interrupts off while using. void sendPixel (unsigned char r, unsigned char g, unsigned char { sendByte (g); // NeoPixel wants colors in green-then-red-then-blue order sendByte (r); sendByte (; } // latch the colors void show(){ __delay_cycles(72); // 18 micro seconds } void initWS2812(){ show (); // in case MOSI went high, latch in whatever we sent sendPixel (0, 0, 0); // now change back to black show (); // and latch that } The main changes I made are:
    In the function initClock() the clock speed is set to 8 MHz using the factory stored defaults.  The workshop linked above has a good overview of how to do this for the MSP430 family. At the very top SPIDIV is set to 2 which means it is ticking at 4 MHz - a period of 250 ns. Accordingly, the bytes defined in the next two lines will have the on/off periods that are shown - these happen to fall within the specifications given by the datasheet. You can test this with your oscilloscope.  In main() there is a line that sends all ones and another (commented out) that sends all zeros. This is what I see on my oscilloscope when the output is set to all ones:

    The time divisions are set to 250 ns and  you can see that the wiggles are high for 1250 ns and then low for 750 ns.  Right on the money.  There is a lot of overshoot - that is why a 0.1 uF capacitor between the signal and ground is probably a good idea.  You can check your scope to see if it is doing what it should.
  7. Like
    m0nk37 reacted to Fmilburn in MSP430G2553 and 3-wire SPI RGB LED timing help   
    From the family user guide, slau144j, pg 436:
  8. Like
    m0nk37 reacted to Fmilburn in MSP430 how to make WS2811Driver reduce from 800 kHz to 400 kHz link inside   
    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/
  9. Like
    m0nk37 reacted to Rickta59 in MSP430 how to make WS2811Driver reduce from 800 kHz to 400 kHz link inside   
    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
  10. Like
    m0nk37 reacted to Fmilburn in MSP430 how to make WS2811Driver reduce from 800 kHz to 400 kHz link inside   
    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:


    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
  11. Like
    m0nk37 reacted to Fmilburn in MSP430 how to make WS2811Driver reduce from 800 kHz to 400 kHz link inside   
    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
  12. Like
    m0nk37 reacted to Fmilburn in MSP430 how to make WS2811Driver reduce from 800 kHz to 400 kHz link inside   
    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.
  13. Like
    m0nk37 reacted to Fmilburn in MSP430 how to make WS2811Driver reduce from 800 kHz to 400 kHz link inside   
    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.
  14. Like
    m0nk37 reacted to Fmilburn in MSP430 how to make WS2811Driver reduce from 800 kHz to 400 kHz link inside   
    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...
  15. Like
    m0nk37 reacted to Fmilburn in MSP432 with WS2811 LED strip, where to start?   
    I would only be guessing.  But if the LEDs get something they don't understand they do strange things.  I saw something similar when I was experimenting and adjusting timing to get inside the tolerances.  Hopefully you didn't apply 5V to the microcontroller - don't think the MSP432 is 5V tolerant.  On my projects I have run the microcontroller and the WS2811s on battery power at 3V without a problem.
     
    Most of the WiFi experimentation I have done was with a MSP430F5529 and CC3100 BoosterPack with Energia.  The F5529 is used with WS2811s in the link I gave above, so I would probably start there.  I would get the LEDs working the way I wanted with the F5529 and then add the CC3100.
     
    As a fallback, most of the projects I've done with the WS2811/12 were on the MSP430G2553 and there is a good library for it here on 43oh.  The LEDs could be controlled with a G2553 that was receiving commands from a F5529/CC3100.  Or could use a CC3200, Raspberry Pi or other WiFi capable device to control something like a G2553.
     
  16. Like
    m0nk37 reacted to Fmilburn in MSP432 with WS2811 LED strip, where to start?   
    Hi @@m0nk37,
     
    I am not aware of a WS2811/12 library for the MSP432.  I presume you have already done a search on 43oh and have seen the working code and discussion for the MSP430 and Tiva.  The two approaches commonly used to achieve the timing requirements are asm and SPI.  SPI was used in the Tiva example and would seem to be the easiest approach for the MSP432.  You can find my writeup on using SPI with the MSP430 here:  http://forum.43oh.com/topic/10011-using-spi-and-energia-with-ws2812-leds/
     
    I had a quick look at using SPI with the MSP432 at the time I made that post.  Energia for the MSP432 uses TI-RTOS and I seemed to be getting interrupts that interfered with the timing.  There may be ways around this but I didn't pursue it.  I would think this would be straight forward outside of Energia/RTOS but haven't tried that either.
×
×
  • Create New...