Tuesday 23 July 2013

WS2812 RGB Led Matrix Booster Pack

The WS2812 is a highly interesting RGB led, since it already has a controller build in and supports daisy chaining.

Now how does it work ?
You can send 3 bytes of information to the led. Every byte corresponds to either the intensity of the colour red green or blue. 255 translates to highest intensity while 0 turns the corresponding colour of.
So f.e. you have 10 leds in a row and send 30 bytes to them. The first led grabs the first 3 bytes and passes the left 27 bytes down to the other leds. But the led not only passes the bytes down, it also reshapes the signal and amplifies it.. You don't need to worry of signal integrity.

The controller also only needs one data line, so there is no clock signal needed.

There is only one problem, the signal has to be short to get reasonable update rates.
So a 1 is translated to a 1.2us long high impulse followed by a 1.3us long low impulse.
While a 0 is translated to a 0.5us long high impulse followed by a 2. us long low impulse.

So the pulses need to be so fast you cannot bit bang them any more you need a built in hardware module.
Some genius developer on the internet suggested to use the built in Spi bus protocol since it supports fast data rates.But there are still some problems waiting to be solved. In hardware Spi a bit always has the same time frame and either a high or a low pulse.

So you have to map your bit to a matching spi sequence.
So first program the bus speed to 2 mhz. Every bit is now 0,5 us long.
A bit with value 1 now translates roughly into 11000
A bit with value 0 translates exactly into 10000

The bit with the value 1 is not exactly mapped but the processor has a tolerance of +-150 nS so we should be fine.

I tested the code with a WS2812 led light strip I built and it worked.

This is a great example of a developers ingenuity, there is a big problem but thinking out of the box and using an hardware bus protocol which has completely different specs but is fast enough saved the day.

I plan to use the led matrix  as a moodlight, but most importantly I wanted to learn how to use this leds.
I want to use them to display sensor data like temperature and humidity. Blue would translate to below comfortable, green ok and red above comfortable level.

RobG Led Matrix Msp430 Booster Pack


Backside JP1 powers module from launchpad

Booster pack in action
 Links:
Buy pcb
Designers forum thread

1 comment:

  1. this is an easy diy combinable ws2812b matrix: http://www.greeled.net/diy-ws2812b-led-matrix-unit.html

    ReplyDelete