# Smart RGB LED strips Original document by [Didel](http://www.didel.com). ![RGB LED strip](rgb-led-strip.png) There is now a big choice of strips of colored leds. They are supported by libraries for Arduino, Raspberry and ESP8266. We are interested here about the functionality of chips from different makers and how to write the required low level control routines. ## SPI 2-control lines 0 – 20 MHz ### WS2801
This 14-pin circuit includes three 8-bit PWM . Easy to program, as shown later. Can be used with any leds and any resistor value. Ck/Data serial transfer. ![WS2801 protocol](ws2801_proto.png) The LPD8806/LPD6806 is similar but desappeared from the market. Transfer was three 5-bit PWM (16-bit words). ### APA102C and SK9822
The APA102C and Sk9822 have SPI-like transfer, no timing constraint. New there is also a miniature APA102C-2020. The APA102C is an additional control register v that sets the brightness of every pixel, independently of its color. APA102 has 20 kHz PWM, SK9822 1.2 kHz: ![APA102 protocol](apa102_proto.png) ## 1-wire control 800 or 580 kHz (timings see here) ### WS2812b
The WS2812 (not shown) was the first RGB 5050 package with the microcontroller inside. 6-pin package replaced by WS2812b The WS2812b is controlled by one wire with a critical timing that needs bit-banging routines on 16MHz AVR. ![WS2812 protocol](ws2812b_proto.png) ### APA104
The APA104 has a slightly different timing than the WS2812B, but can be compatible. A 50us delay terminates the shift-in. ![APA104 protocol](apa104_proto.png) ### APA106
### SK6812
The SK6812 receives 24 bit words. Transfer speed is 800 kHz. ![SK6812 protocol](sk6812_proto.png) ## A word about serial transfers ![The 74HC595](74hc595_serial.png) Shift registers are used to convert a stream of bits synchronized by a clock into parallel data. A parallel register keeps the previous data during the shift and is updated at the end of the transfer. This is the principle of the SPI transfer. Registers can be cascaded. ![Serial LED comms](serial_led1.png) A popular application for this is to control LEDs. Several manufacturers propose shift registers with constant current sources at the outputs. A single resistor sets the current, same for all LEDs. PWM can be done on every LED. See [http://www.didel.com/diduino/CommandeLeds.pdf ](http://www.didel.com/diduino/CommandeLeds.pdf) for an elegant solution updating PWM while shifting. ## WS2801 as example of the inside logic The WS2801 includes a 24 bit shift register with three 8-bit PWM controllers. Three LEDs are controlled by the circuit, usually a RGB SMD LED in a 5050 package. Intensity of LEDs is controlled by a resistor, constant current circuitry makes the intensity independant of the voltage (with 3-5V range). ![WS2801 Logic](ws2801_logic.png) The block diagram show something new. Data is not shifted through the complete serially connected circuits. The first 24 bits stay in the first circuit. When 24 clocks are counted, a switch transfers the clock to the output. Since there is no load line to transfer the shifted data to the PWM circuit, a one-shot circuit is activated when there is no clock for more than 1 ms. The signals are regenerated, allowing long strips, but adding a delay.
![Serial uc control](serial_ctl3.png) Due to the mechanism that allows to access the pixels in the order they have been sent, and not as if it was a simple shift register, data is delayed by half a clock for each consecutive pixel. The last bit sent for the last pixel must be pushed half a clock at a time till its destination. |
|||||||||||||||||||||||||||||||||
Letzte Aktualisierung: © boxtec internet appliances · the better security products |