This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
-> I am beginner in embedded system design.
-> i want to control color and brightness of ws2812b rgb led using msp430 g2553 launchpad.
-> I search on internet and develop code which control rgb color of ws2812b using spi of launchpad.
-> But i can't find any thing to control brightness of led ws2812b.
thanks in advance...
If you managed to communicate with led controller then to change brightness of each color or change them all - you have to change corresponding R, G or B 8-bit values you send to controller. That' s it. Did you read datasheet of the controller?
Maheshkumar,
I did not work with the WS2812B myself, but after a short look into the datasheet it does not look like these LEDs are controlled via SPI. You could have noticed yourself that there isn't a data and clock input. It is just a single data input (and output for cascading). It is NRZ coded
In the datasheet:
It tells you that a logic one is represented by 0.8µs high followed by 0.45µs low and a logic zero is 0.4µs high followed by 0.85µs low. 24 bits of data is one complete information block for a LED. 256 brightness levels for red, green and blue respectively.
I would have a look at the timer of the MSP430G2553 - start with the code examples:
These code examples give you an overview of how to use the timer module:
And in addition you should read the user's guide:
Chapter 12 on page 355 describes the timer module. Don't be scared by that big document - you only have to read the chapter of the function you wnat to use at that moment.
To be honest: For an absolute beginner I would say that this is not the right project to start from. SPI would be easier. But you can accomplish it anyway, of course.
I would start with writing a program that generates a timer interrupt at freely chosen time intervalls.
Dennis
According to the datasheet the MOSI of the USCI is not suitable for that since it does not output a variable high/low time NRZ signal. Using SPI is not how the LED is controlled. Read my first answer. It is all about timing of high and low time of your data bit. And changing the brightness of the whole LED is done by changing the brightness of R, G and B at the same time.
Dennis
Dennis Eichmann said:Using SPI is not how the LED is controlled.
I disagree here. Obviously you shall not expect SPI to translate your data into NRZ format during transmission, instead you shall format data into NRZ before you put it into SPI transmit register.
Specification says:
Dennis Eichmann said:logic one is represented by 0.8µs high followed by 0.45µs low and a logic zero is 0.4µs high followed by 0.85µs low
You missed to mention that tolerance for pulses is +/- 150ns which is +/-0.150µs. So we are free to _not_ stretch low signals by 0.05µs compared to high signals. So we run SPI clock at 2.5MHz to get bit time 0.4µs, send two bits to have long pulse and one bit to have short pulse.
Example: data "0110" translates to 100110110100 which we shall send out of SPI peripheral. So to send 24bits of LED data you have to shift out 72 bits of NRZ-encoded bits which conveniently is 9 bytes of SPI transmission.
I would do 7bit UART, active high (so reversed from standard TTL UART)
Put 3 LED bits in every 9bit data as 33% and 66% high for respective 0 or 1 should be within tolerance.
uart-start-bit is always used for the first bit, stop bit is the 0 bit in the last LED bit
example 3bits are all zeros :
1_0010010_0
└─┘=One LED bit
example 3bits are all 1:
1_1011011_0
└─┘=One LED bit
**Attention** This is a public forum