Difference between revisions of "RGB LED HAT"
(8 intermediate revisions by 2 users not shown) | |||
Line 34: | Line 34: | ||
Its data transfer protocol uses single NZR communication mode. After the pixel is power-on and reset, the DIN port receives the data from the controller. The first 24 bit data is collected by the first pixel, and then sent to the internal data latch. The other data are reshaped by the internal signal reshaping amplification circuit and sent to the next cascade pixel through the DO port. After the transmission for all pixels, the signal may reduce to 24bit. The pixel adopts auto reshaping transmit technology, which allows the pixel cascade number is up to the speed of the signal transmission but not bound by the signal transmission restriction. For more information about auto reshaping transmit technology, please refer to the section data transfer protocol. | Its data transfer protocol uses single NZR communication mode. After the pixel is power-on and reset, the DIN port receives the data from the controller. The first 24 bit data is collected by the first pixel, and then sent to the internal data latch. The other data are reshaped by the internal signal reshaping amplification circuit and sent to the next cascade pixel through the DO port. After the transmission for all pixels, the signal may reduce to 24bit. The pixel adopts auto reshaping transmit technology, which allows the pixel cascade number is up to the speed of the signal transmission but not bound by the signal transmission restriction. For more information about auto reshaping transmit technology, please refer to the section data transfer protocol. | ||
=== Sequence chart === | === Sequence chart === | ||
− | : [[File:rgb-led-hat-user-manual-1.png| | + | : [[File:rgb-led-hat-user-manual-1.png|200px|thumb|Sequence chart]] |
* Data transfer time( TH+TL=1.25µs±600ns) | * Data transfer time( TH+TL=1.25µs±600ns) | ||
{|class="wikitable" | {|class="wikitable" | ||
Line 48: | Line 48: | ||
| RES || The unit of frame, low voltage time || Above 50µs || | | RES || The unit of frame, low voltage time || Above 50µs || | ||
|} | |} | ||
+ | |||
=== Data transmission method === | === Data transmission method === | ||
+ | : [[File:rgb-led-hat-user-manual-2.png|400px|thumb|Data transmission method]] | ||
On the base of the data sequence, we can easily complete data transfer with the communication protocol. | On the base of the data sequence, we can easily complete data transfer with the communication protocol. | ||
− | + | ||
Note: The data of D1 is send by MCU, and D2, D3, D4 are transmitted through pixel internal reshaping amplification. | Note: The data of D1 is send by MCU, and D2, D3, D4 are transmitted through pixel internal reshaping amplification. | ||
*Composition of 24bit data: | *Composition of 24bit data: | ||
Line 58: | Line 60: | ||
|} | |} | ||
: Note: The data is sent in the order of GRB and the high bit is sent at first. | : Note: The data is sent in the order of GRB and the high bit is sent at first. | ||
+ | |||
== How to use == | == How to use == | ||
Perhaps the descriptions above is too verbose to understand but you can skip it and just use the corresponding libraries in your Raspberry Pi. In this case, you should copy the example program packages to your Pi and unzip them. | Perhaps the descriptions above is too verbose to understand but you can skip it and just use the corresponding libraries in your Raspberry Pi. In this case, you should copy the example program packages to your Pi and unzip them. | ||
Line 73: | Line 76: | ||
Run the line below to perform testing. You can see the RGB LED flickering. | Run the line below to perform testing. You can see the RGB LED flickering. | ||
sudo ./test | sudo ./test | ||
− | Run the following line | + | Run the following line to install the python library. |
cd python | cd python | ||
sudo python setup.py install | sudo python setup.py install | ||
− | Run the | + | Run the demo code for testing. |
cd examples | cd examples | ||
sudo python lowlevel.py | sudo python lowlevel.py | ||
Line 94: | Line 97: | ||
# <code>from neopixel import *</code> import the library rpi-ws281x | # <code>from neopixel import *</code> import the library rpi-ws281x | ||
# <code>Adafruit_NeoPixel</code> creates an object strip, sets the number of the LEDs to 32, the pin to 18, and the frequency to 800000. The parameter <code>LED_BRIGHTNESS</code> is the brightness of the LED. | # <code>Adafruit_NeoPixel</code> creates an object strip, sets the number of the LEDs to 32, the pin to 18, and the frequency to 800000. The parameter <code>LED_BRIGHTNESS</code> is the brightness of the LED. | ||
− | # <code>begin()</code> | + | # <code>begin()</code> RGB LED initialization function. |
# <code>setPixelColor(pos, color)</code> This sets the pixel, of which pos is the LED position, and color is the RGB color | # <code>setPixelColor(pos, color)</code> This sets the pixel, of which pos is the LED position, and color is the RGB color | ||
− | # <code>color(r,g,b)</code> This converts the RGB value to a 24 bit color. | + | # <code>color(r, g, b)</code> This converts the RGB value to a 24 bit color. |
# <code>show()</code> This transfers data, showing the set LED color. | # <code>show()</code> This transfers data, showing the set LED color. | ||
# For more information about the functions, please see rpi_ws281x-master/python/neopixel.py | # For more information about the functions, please see rpi_ws281x-master/python/neopixel.py | ||
+ | |||
=== Web control with Bottle === | === Web control with Bottle === | ||
− | : [[File:rgb-led-hat-user-manual-5.jpg|thumb| | + | : [[File:rgb-led-hat-user-manual-5.jpg|thumb|200px|controlled by browser]] |
Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. By Bottle, you can fast and easily implement Web control. | Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. By Bottle, you can fast and easily implement Web control. | ||
Line 111: | Line 115: | ||
Then, enter the IP address of your Pi and the port number 8000 into the address bar of the browser. Clicking different position of the palette, the LEDs will display different colors. There are 3 display modes selectable, static, breath and flash. | Then, enter the IP address of your Pi and the port number 8000 into the address bar of the browser. Clicking different position of the palette, the LEDs will display different colors. There are 3 display modes selectable, static, breath and flash. | ||
* '''Note: This web-RGB program only supports the mobile phone browser. It is unavailable for PC browser. ''' | * '''Note: This web-RGB program only supports the mobile phone browser. It is unavailable for PC browser. ''' | ||
+ | |||
== Resources == | == Resources == | ||
=== Documentation === | === Documentation === | ||
Line 117: | Line 122: | ||
=== Software === | === Software === | ||
* [[:File:RGB_LED_HAT.tar.gz|Demo Code]] | * [[:File:RGB_LED_HAT.tar.gz|Demo Code]] | ||
− | * [[ | + | |
+ | === Others === | ||
+ | * [[Raspberry Pi Tutorial Series]] | ||
== Support == | == Support == | ||
{{Service00}} | {{Service00}} | ||
+ | |||
+ | [[Category:Expansions|Expansions]], [[Category:Raspberry Pi|Raspberry Pi]] |
Revision as of 13:10, 4 July 2019
| ||
Introduction
True color RGB LED HAT for Raspberry Pi, colorful display
More |
Interfaces
- For Raspberry Pi, you only need to insert the product to the corresponding interface on the Pi;
- For other devices, you'd better to solder the pin headers to the pads of 5V, GND, DIN and DOUT for wiring.
Symbols | Pin descriptions |
---|---|
5V | 5V power supply |
GND | Ground |
DIN | Control signal input |
DOUT | Control signal output |
Description
WS2812B is an intelligent LED controller of which the control circuit and the RGB chip are integrated in a package of 5050 components. It internally includes an intelligent digital port, a data latch and a signal reshaping amplification drive circuit. To ensure the color brightness consistent of the pixel light, it also contains a precision internal oscillator and a 12V voltage programmable constant current control part.
Its data transfer protocol uses single NZR communication mode. After the pixel is power-on and reset, the DIN port receives the data from the controller. The first 24 bit data is collected by the first pixel, and then sent to the internal data latch. The other data are reshaped by the internal signal reshaping amplification circuit and sent to the next cascade pixel through the DO port. After the transmission for all pixels, the signal may reduce to 24bit. The pixel adopts auto reshaping transmit technology, which allows the pixel cascade number is up to the speed of the signal transmission but not bound by the signal transmission restriction. For more information about auto reshaping transmit technology, please refer to the section data transfer protocol.
Sequence chart
- Data transfer time( TH+TL=1.25µs±600ns)
T0H | 0 code, high voltage time | 0.4µs | ±150ns |
T1H | 1 code, high voltage time | 0.8µs | ±150ns |
T0L | 0 code, low voltage time | 0.85µs | ±150ns |
T1L | 1 code, low voltage time | 0.45 µs | ±150ns |
RES | The unit of frame, low voltage time | Above 50µs |
Data transmission method
On the base of the data sequence, we can easily complete data transfer with the communication protocol.
Note: The data of D1 is send by MCU, and D2, D3, D4 are transmitted through pixel internal reshaping amplification.
- Composition of 24bit data:
G7 | G6 | G5 | G4 | G3 | G2 | G1 | G0 | R7 | R6 | R5 | R4 | R3 | R2 | R1 | R0 | B7 | B6 | B5 | B4 | B3 | B2 | B1 | B0 |
- Note: The data is sent in the order of GRB and the high bit is sent at first.
How to use
Perhaps the descriptions above is too verbose to understand but you can skip it and just use the corresponding libraries in your Raspberry Pi. In this case, you should copy the example program packages to your Pi and unzip them.
Libraries installation
Copy the file rpi_ws281x-master.zip to your Pi, and run the following line to unzip it.
unzip rpi_ws281x-master.zip
For the latest libraries, you can visit the website: https://github.com/jgarff/rpi_ws281x
Install the depended-upon software
sudo apt-get install build-essential python-dev scons swig
Compile the program
cd rpi_ws281x-master sudo scons
Run the line below to perform testing. You can see the RGB LED flickering.
sudo ./test
Run the following line to install the python library.
cd python sudo python setup.py install
Run the demo code for testing.
cd examples sudo python lowlevel.py
- If the library is installed successfully, you can see the RGB LED flickering.
- If the LED displays the wrong color, please add the lines below into the file /boot/config.txt, and restart the Pi to take them effect.
- RGB LED adopts DMA control, which may occupy the video output DMA channel on the Raspberry Pi. Therefore, adding these lines may cause the earphone connector unusable.
hdmi_force_hotplug=1 hdmi_force_edid_audio=1
Demo descriptions
Running the demo ws2812.py, you can see the RGB LED display the gradient color.
cd RGB_LED_HAT sudo python ws2812.py
from neopixel import *
import the library rpi-ws281xAdafruit_NeoPixel
creates an object strip, sets the number of the LEDs to 32, the pin to 18, and the frequency to 800000. The parameterLED_BRIGHTNESS
is the brightness of the LED.begin()
RGB LED initialization function.setPixelColor(pos, color)
This sets the pixel, of which pos is the LED position, and color is the RGB colorcolor(r, g, b)
This converts the RGB value to a 24 bit color.show()
This transfers data, showing the set LED color.- For more information about the functions, please see rpi_ws281x-master/python/neopixel.py
Web control with Bottle
Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. By Bottle, you can fast and easily implement Web control.
Install the library
sudoapt-get install python-bottle
Perform web control RGB LED via Bottle
cd ~/RGB LED HAT/web-RGB sudo python main
Then, enter the IP address of your Pi and the port number 8000 into the address bar of the browser. Clicking different position of the palette, the LEDs will display different colors. There are 3 display modes selectable, static, breath and flash.
- Note: This web-RGB program only supports the mobile phone browser. It is unavailable for PC browser.
Resources
Documentation
Software
Others
Support
Support
If you require technical support, please go to the Support page and open a ticket.,