banner left Boxtec Banner
Platzhalter BoxtecProdukteForumShopKontaktPlaygroundn/aJobs
 

# 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

:—: :—:
![WS2801](ws2801_1.png) ![WS2801](ws2801_2.png)

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

:—: :—:
![APA102](apa102_1.png) ![APA102](apa102_2.png)

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

:—: :—:
![WS2812b](ws2812b_1.png) ![WS2812b](ws2812b_2.png)

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

:—: :—:
![APA104](apa104_1.png) ![APA104](apa104_2.png)

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

:—:
![APA106](apa106_1.png) The APA106 is the through-hole LED version of the APA104.

### SK6812

:—:
![SK6812](sk6812_1.png) ![SK6812](sk6812_2.png)

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.

—:
<br>As said before, each circuit takes the first set of clocks and data he receives for himself, not transmitting that information further. The next clocks and data are amplified and transmitted. The delay introduced between each LED may be noticed over very long strips. The APA102C implement an additional trick to make the transmission reliable. It results in a strange formula, incorrect and not explained for the terminating frame. Not easy to well understant if you have not been educated with integrated circuit logic. Let us try! ![Serial uc control](serial_ctl1.png)
—:
<br>For the correct operation of a shift register, the flipflops must have the data stable when the clock edge occurs. set-up and hold time is 5 to 20 ns depending on the technology.The output D' changes after e.g. 20ns, and this must match the set-up time of the next flip-flop. One needs to add output buffers that introduce their own delay, plus the delay of the line. Depending on the difference between the clock and data propagation time, the transfer may not work correctly. <br>One solution is to increase the delay on the data line. This was probably done on the WS2801. It is more reliable to add a flip-flop on the data output, that add a delay of half a clock. This was implemented in the 1970' CD4094 8-bit shift register and is used on the APA102 and SK98. <br>The main advantage is the very high transfer speed it permits. ![Serial uc control](serial_ctl2.png)

![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.

 
playground/playground1.txt · Last modified: 2017/01/19 15:40 by boxtec
 
 

zum Seitenanfang

Letzte Aktualisierung: © boxtec internet appliances · the better security products