Component: LED WS2811 WS2812 (Outputs: LEDs)
Author | Matrix TSL |
Version | 1.0 (Release) |
Category | Outputs: LEDs |
Contents
LED WS2811 WS2812 component
A simple chained RGB LED controller IC allowing multiple LEDs to be controlled using a serial data stream. Compatible with the WS2811, WS2812 and WS2812B Type Controller ICs. Allows RGB LEDs to be driven with full 24-bit colour depth. Allows single chains, 2D arrays and 3D cube formations to be simulated. Requires a high speed microcontroller to generate the critical timings to drive the device.
Detailed description
1D Configuration
In the 1D configuration each LED simply follows on from the last in a chain.
2D Configuration
In the 2D configuration each LED follows on from the last in a chain which travels back and forth through the columns a row at a time.
3D Configuration
In the 3D configuration each layer follows the 2D configuration with each layer then following on by mirroring the layer below. First layer connections are shown in Red and second layer connections are shown in Blue.
3V3 Microcontrollers
Note you may have to voltage shift the micro controller control pins to meet the 0.7 * VDD minimum requirement. E.g. if VDD is 5V then the input voltage needs to be at least 3.5V.
A simple buffer IC could be used to do the voltage shifting.
Examples
RGB Mood Light
A simple example using three potentiometers to set the individual Red, Green and Blue channels of the LED colour.
Animated Light
A simple example which picks a random colour assigns it to the first LED, then shifts and repeats.
Downloadable macro reference
GetLEDColour
Sets the colour of a single LED in RAM as a 1D array.
Parameters
- UINT LED
- LED to change the colour / Range: 0 to (LED Count - 1)
- BYTE ColIdx
- 0 = R, 1 = G, 2 = B
Return value
DrawLine2D
Draws a line on a 2D array of LEDs
Parameters
- UINT X1
- UINT Y1
- UINT X2
- UINT Y2
- BYTE R
- BYTE G
- BYTE B
Return value
- This call does not return a value
SetAllLEDColour
Sets the colour of all the LEDs in RAM
Parameters
- BYTE R
- BYTE G
- BYTE B
Return value
- This call does not return a value
SetLEDColour
Sets the colour of a single LED in RAM as a 1D array.
Parameters
- UINT LED
- LED to change the colour / Range: 0 to (LED Count - 1)
- BYTE R
- BYTE G
- BYTE B
Return value
- This call does not return a value
Refresh
Clocks out the current colour data to the LEDs from the values stored in RAM
Parameters
- This macro has no parameters
Return value
- This call does not return a value
ShiftLEDs1D
Shifts the LED colours in 1D and wraps
Parameters
- BYTE Direction
- 0 = Forwards, 1 = Backwards
Return value
- This call does not return a value
DrawLine3D
Draws a line on a 3D array of LEDs
Parameters
- UINT X1
- UINT Y1
- UINT Z1
- UINT X2
- UINT Y2
- UINT Z2
- BYTE R
- BYTE G
- BYTE B
Return value
- This call does not return a value
GetLEDIndex2D
Sets the index of a single LED in RAM as a 2D array.
Parameters
- UINT LED_Column
- LED Column to change the colour / Range: 0 to (LED Column - 1)
- UINT LED_Row
- LED Row to change the colour / Range: 0 to (LED Row - 1)
Return value
GetLEDIndex3D
Gets the index of a single LED in RAM as a 3D array.
Parameters
- UINT LED_Column
- LED Column to change the colour / Range: 0 to (LED Column - 1)
- UINT LED_Row
- LED Row to change the colour / Range: 0 to (LED Row - 1)
- UINT LED_Layer
- LED Layer to change the colour / Range: 0 to (LED Layer - 1)
Return value
Initialise
Inisialises the RGB colour RAM to 0,0,0 = LED Off and clocks out the data to
initialise all the WS2801 ICs in the chain.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
This component does not contain any simulation macros
Property reference
LED Controller
This property is of type Fixed list of ints and can be referenced with the variable name LED_Controller.
Allows the user to select which LED controller IC they are using.
The different controller ICs all work the same way but have different timing characteristics.
Reset Time (uS)
This property is of type Floating point and can be referenced with the variable name Reset_Time.
Blanking reset period to reset the LED shift chain and start from the beginning
T0H (uS)
This property is of type Floating point and can be referenced with the variable name T0H.
Logic 0 high time in microseconds
T0L (uS)
This property is of type Floating point and can be referenced with the variable name T0L.
Logic 0 low time in microseconds
T1H (uS)
This property is of type Floating point and can be referenced with the variable name T1H.
Logic 1 high time in microseconds
T1L (uS)
This property is of type Floating point and can be referenced with the variable name T1L.
Logic 1 low time in microseconds
LED Arrangement
This property is of type Fixed list of ints and can be referenced with the variable name LED_Arrangement.
Controls the arrangement of the LEDs on the panel.
1D - Creates a straight line of LEDs
2D - Creates an X by Y Array of LEDs
3D - Creates an X by Y by Z Array of LEDs
LED Count
This property is of type Unsigned integer and can be referenced with the variable name LED_Count.
Total number of LEDs in the design
LED Columns
This property is of type Unsigned integer and can be referenced with the variable name LED_Cols.
Number of horizontal LEDs - X axis
Column Spacing
This property is of type Floating point and can be referenced with the variable name x_spacing.
X Spacing Between LEDs on the Panel
LED Rows
This property is of type Unsigned integer and can be referenced with the variable name LED_Rows.
Number of vertical LEDs - Y axis
Row Spacing
This property is of type Floating point and can be referenced with the variable name y_spacing.
Y Spacing Between LEDs on the Panel
LED Layers
This property is of type Unsigned integer and can be referenced with the variable name LED_Layers.
Number of LED layers - Z axis
Layer Spacing
This property is of type Floating point and can be referenced with the variable name z_spacing.
Z Spacing Between LEDs on the Panel
Data Pin
This property is of type Single digital pin and can be referenced with the variable name MOSI.
LED Data Pin - Connected to the Data In pin of the first WS821x IC.