Jump to content

Component: LED (Generic, RGB) (LED)

From Flowcode Help
Revision as of 10:44, 17 November 2021 by Wiki bot (talk | contribs)
Author Matrix Ltd
Version 1.3
Category LED


LED (Generic, RGB) component

An LED with red, green and blue elements that can be mixed together to produce almost any colour at any brightness.

Detailed description

No detailed description exists yet for this component

Examples

Tricolour LEDs generally have four pins and come in both common anode and common cathode configurations and must be wired to suit. The RGBLED component has a property allowing you to configure which LED type your using.


An active high LED will light when the microcontroller pin is outputting a logic 1 and be off when the microcontroller pin is outputting a logic 0 or in input mode.


An active low LED will light when the microcontroller pin is outputting a logic 0 and be off when the microcontroller pin is outputting a logic 1 or in input mode.


Six pin tricolour LEDs can simply be treated as three individual standards LEDs.


The series resistor acts to protect each individual LED from damage due to excess current. The value of resistor used can be changed based on the brightness of the LED and power consumption. Usually the three colour LEDs have different characteristics from each other so a different protection resistor should be provided for each LED to balance the LEDs output.


This LED Calculator tool is a good resource for calculating the correct LED series protection resistor.

LED Resistor Calculator Tool



This example for the RGB LED uses three analogue sliders to set the output colour of the LED.

RGB LED Example


The LED Colour is output to the LED using the Timer interrupt which calls the RGB LED Tick function.


The RGB LED properties include a setting for "Colour Bit Size" which sets the period for the LED colour PWM. The "Rollover Value" property shows the number of interrupts required for each PWM period so the timer interrupt should be running fast enough to allow the LED to output several periods per second. Persistence of vision can normally no longer detect any flickering light above approx 24Hz.


For a constant none flickering LED you can work out the minimum interrupt frequency like this.

30Hz * Rollover Value = Minimum interrupt frequency

30Hz * 256 = 7680Hz

60Hz * 64 = 3840Hz


Each LED colour channel can be set from 0 (minimum) to the rollover value - 1 (maximum). Therefore with a colour channel bit size of 8 there are theoretically 16777216 colours available 2^(8*3). With a colour bit size of 4 the available number of colours that can be generated drops to 4096, 2^(4*3).

Downloadable macro reference

Disable
Disables the RGB LED. It will no longer respond to color changes. 
- VOID Return


Enable
Enables the RGB LED. This must be done before the LED can be lit or the color changed. 
- VOID Return


Tick
Call this macro at regular intervals to illuminate the LED with the chosen color. Turns each pin on and off to generate a simple PWM signal for each color - when done rapidly, this gives the illusion of the chosen color. 
- VOID Return


SetColor
Set the target color for the LED. Each of the Red, Blue and Green channels can be set to any value from 0 (off) to 255 (full brightness). 
- BYTE red
Red component of RGB LED local to this macro 
- BYTE green
Green component of RGB LED local to this macro 
- BYTE blue
Blue component of RGB LED local to this macro 
- VOID Return


WriteMicroseconds
Sets the PWM output of one of the PCA9685 pins based on the input microseconds, output is not precise 
- BYTE Output
One of the PWM output pins - Range: 0 to 15 
- UINT Microseconds
The number of Microseconds to turn the PWM output ON 
- VOID Return


SetPWM
Sets the PWM output of one of the PCA9685 pins 
- BYTE Output
One of the PWM output pins - Range: 0 to 15 
- UINT On
At what point in the 4096-part cycle to turn the PWM output ON 
- UINT Off
At what point in the 4096-part cycle to turn the PWM output OFF 
- VOID Return


Initialise
Sets up the I2C ready for communications to begin 
- VOID Return


WakeUp
Wakes the module from Sleep mode 
- VOID Return


SetPin
Sets pin without having to deal with on/off tick placement and properly handles a zero value as completely off and 4095 as completely on. 
- BYTE Output
One of the PWM output pins - Range: 0 to 15 
- UINT Duty
The number of ticks out of 4096 to be active 
[[File:]] - Invert
0=Normal, 1=Inverted 
- VOID Return


DrawRectangle2D
Draws a basic 2D rectangle onto the LEDs 
- BYTE X1
 
- BYTE Y1
 
- BYTE X2
 
- BYTE Y2
 
- BYTE DrawStyle
Sets the draw style - 0=Soild, 1=Edge, 2=Corners 
- BYTE R
 
- BYTE G
 
- BYTE B
 
- VOID Return


ShiftLEDs2D
Shifts the contents of the display by the number of vertices specified ***Please Note that Wrap mode is currently unavailable*** 
[[File:]] - X
Number of pixels to shift the display -1 to 1 / 0 = No Shift 
[[File:]] - Y
Number of pixels to shift the display -1 to 1 / 0 = No Shift 
- BYTE DataMode
0=ResetToZero, 1=WrapAroundDisplay, 2=Smear 
- VOID Return


GetLEDIndex3D
Gets the index of a single LED in RAM as a 3D array. 
- UINT X
LED Column to change the colour / Range: 0 to (LED Column - 1) 
- UINT Y
LED Row to change the colour / Range: 0 to (LED Row - 1) 
- UINT Z
LED Layer to change the colour / Range: 0 to (LED Layer - 1) 
- UINT Return


DrawCuboid3D
Draws a basic 3D cuboid onto the LEDs 
- BYTE X1
Start X pixel coordinate 
- BYTE Y1
Start Y pixel coordinate 
- BYTE Z1
Start Z pixel coordinate 
- BYTE X2
End X pixel coordinate 
- BYTE Y2
End Y pixel coordinate 
- BYTE Z2
End Z pixel coordinate 
- BYTE DrawStyle
Sets the draw style - 0=Soild, 1=Edge, 2=Corners 
- BYTE R
Red Colour Channel 
- BYTE G
Green Colour Channel 
- BYTE B
White Colour Channel 
- VOID Return


Initialise
Inisialises the RGB colour RAM to 0,0,0 = LED Off and clocks out the data to initialise all the LED ICs in the chain. 
- VOID Return


ShiftLEDs3D
Shifts the contents of the display by the number of vertices specified ***Please Note that Wrap mode is currently unavailable*** 
[[File:]] - X
Number of pixels to shift the display -1 to 1 / 0 = No Shift 
[[File:]] - Y
Number of pixels to shift the display -1 to 1 / 0 = No Shift 
[[File:]] - Z
Number of pixels to shift the display -1 to 1 / 0 = No Shift 
- BYTE DataMode
0=ResetToZero, 1=WrapAroundDisplay, 2=Smear 
- VOID Return


Initialise
Sets up the data memory and draws the simulated LED cube on the panel. 
- VOID Return


Initialise
Starts up the formula flowcode PWM for motor control and performs the wait for button press 
- VOID Return


Initialise
The Init macro must be called once to initialise the Graphical LCD display before any other Graphical LCD component macros are called. 
- VOID Return


Initialise
The Init macro must be called once to initialise the Graphical LCD display before any other Graphical LCD component macros are called. 
- VOID Return


Initialise
The Init macro must be called once to initialise the Graphical LCD display before any other Graphical LCD component macros are called. 
- VOID Return


Initialise
The Init macro must be called once to initialise the Graphical LCD display before any other Graphical LCD component macros are called. 
- VOID Return


Initialise
Resets and initialises the Internet E-Block. It sets up the gateway address, subnet mask, device IP address and device MAC address as defined in the properties of the Flowcode component. This macro must be called before any other TCP_IP component macros  
- VOID Return


Initialise
Resets and initialises the Internet E-Block. It sets up the gateway address, subnet mask, device IP address and device MAC address as defined in the properties of the Flowcode component. This macro must be called before any other TCP_IP component macros  
- VOID Return


Initialise
Resets and initialises the Internet E-Block. It sets up the gateway address, subnet mask, device IP address and device MAC address as defined in the properties of the Flowcode component. This macro must be called before any other TCP_IP component macros  
- VOID Return


MODPMSHAPE
Sets PM waveform shape to; 0 = SINE, 1 = SQUARE, 2 = RAMPUP, 3 = RAMPDN, 4 = TRIANG, 5 = NOISE, 6 = DC, 7 = SINC, 8 = EXPRISE, 9 = LOGRISE, 10 = ARB1, 11 = ARB2, 12 = ARB3, 13= ARB4. 
- BYTE Shape
Sets PM waveform shape (1 = SINE, 2 = SQUARE, 3 = RAMPUP, 4 = RAMPDN, 5 = TRIANG, 6 = NOISE, 7 = DC, 8 = SINC, 9 = EXPRISE, 10 = LOGRISE, 11 = ARB1, 12 = ARB2, 13 = ARB3, 14= ARB4). 
- VOID Return


ARB4
Loads the binary-data to an existing arbitrary waveform memory location ARB4. 
- BYTE Waveform
 
- VOID Return


CLKSRRet
Returns the clock source <INT> or <EXT>. 
[[File:]] - Return


MODPMDEV
Sets PM waveform deviation to <nrf> degrees. (Lower limit: -360° - Upper limit: 360°). 
[[File:]] - Degrees
Sets PM waveform deviation in degrees (-360 - 360). 
- VOID Return


MSTLOCK
Sends signal to SLAVE generator to get synchronised 
- VOID Return


HILVL
Sets the amplitude-high-level to <nrf> Volts. (Lower limit: -0.490 V - Upper limit: 5.000 V). 
[[File:]] - HighLevel
Sets the amplitude-high-level in Volts(V) (-0.490 V - 5.000 V). 
- VOID Return


ARB3
Loads the binary-data to an existing arbitrary waveform memory location ARB3. 
- UINT Waveform
 
- VOID Return


WAVE
Sets the waveform type. 0 = SINE, 1 = SQUARE, 2 = RAMP, 3 = TRIANG, 4 = PULSE, 5 = NOISE, 6 = ARB 
- BYTE WaveType
0 = SINE, 1 = SQUARE, 2 = RAMP, 3 = TRIANG, 4 = PULSE, 5 = NOISE, 6 = ARB. 
- VOID Return


CALADJ
Adjust the selected calibration value by <nrf> (Lower limit: -100 - Upper limit: 100). 
[[File:]] - Calibrate
Adjust the selected calibration value (-100 - 100). 
- VOID Return


STBRet
Returns the value of the Status Byte Register in <nr1> numeric format. 
- BYTE Return


ARB2
Loads the binary-data to an existing arbitrary waveform memory location ARB2. 
- UINT Waveform
 
- VOID Return


EERRet
Query and clear execution error number register. 
- STRING Return


MODFMSRC
Sets FM waveform source to; 0 INT, 1 = EXT. 
[[File:]] - Source
Sets FM waveform source (0 = INT, 1 = EXT). 
- VOID Return


MODAMFREQ
Sets AM waveform frequency to <nrf> Hz. (Lower limit: 1uHz - Upper limit: 20kHz). 
[[File:]] - Frequency
Sets AM waveform frequency in Hertz(Hz) (1uHz - 20kHz). 
- VOID Return


ESE
Sets the Standard Event Status Enable Register to the value of <nrf>. 
- BYTE Value
Value of register 0-255 
- VOID Return


ARB1
Loads the binary-data to an existing arbitrary waveform memory location ARB1. 
- UINT Waveform
16 Bit binary number for arbitrary waveform. 
- VOID Return


ARB4DEFRet
Returns user specified waveform name, waveform pint interpolation state and waveform length of ARB4. 
- STRING Return


CLS
Clears status byte register of the interface. 
- VOID Return


MSTRELOCK
Resynchronises the two generators in MASTER-SLAVE mode. 
- VOID Return


NOISLVL
Sets the output noise level to <nr1> %. (Lower limit: 0% - Upper limit: 50%) 
- BYTE Percent
Sets the output noise level in percent. (0 - 50) 
- VOID Return


LOCKMODE
Sets the synchronising mode to; 0 = MASTER, 1 = SLAVE, 2 = INDEP. 
- BYTE Mode
Sets the synchronising mode (0 = MASTER, 1 = SLAVE, 2 = INDEP). 
- VOID Return


ADDRESSRet
Returns the instruments address 
[[File:]] - Return


MODPMSRC
Sets PM waveform source to; 0 INT, 1 = EXT. 
[[File:]] - Source
Sets PM waveform source (0 = INT, 1 = EXT). 
- VOID Return


MODPWMSRC
Sets PWM waveform source to; 0 = INT, 1 = EXT. 
[[File:]] - Source
Sets PWM waveform source (0 = INT, 1 = EXT). 
- VOID Return


MOD
Sets modulation to; 0 = OFF, 1 = AM, 2 = FM, 3 = PM, 4 = FSK, 5 = PWM. 
- BYTE Modulation
Sets modulation (0 = OFF, 1 = AM, 2 = FM, 3 = PM, 4 = FSK, 5 = PWM). 
- VOID Return


ISTRet
Returns IST local message as defined by IEEE Std. 488.2. The syntax of the response is 0<rmt>, if the local message is false, or 1<rmt>, if the local message is true. 
[[File:]] - Return


LRNRet
Returns the complete setup of the instrument as a binary data block 
[[File:]] - Return


OPCRet
Query Operation Complete status. The response is always 1<rmt> and will be available immediately the command is executed because all commands are sequential. 
[[File:]] - Return


SWPTYPE
Sets the sweep type to; 0 = LINUP, 1 = LINDN, 2 = LINUPDN, 3 = LINDNUP, 4 = LOGUP, 5 = LOGDN, 6 = LOGUPDN, 7 = LOGDNUP. 
- BYTE Type
Set the sweep type (0 = LINUP, 1 = LINDN, 2 = LINUPDN, 3 = LINDNUP, 4 = LOGUP, 5 = LOGDN, 6 = LOGUPDN, 7 = LOGDNUP). 
- VOID Return


PULSRANGE
Sets PWM waveform source to <1>, <2> or <3>; 1 = 1, 2 = 2, 3 = 3. 
- BYTE Range
Sets the pulse rise and fall range. (1, 2 or 3) 
- VOID Return


TSTRet
The generator has no self test capability and the response is always 0 <rmt>. 
[[File:]] - Return


BSTTRGPOL
Sets the burst trigger slope to; 0 = POS, 1 = NEG. 
[[File:]] - Slope
Set the burst trigger slope (0 = POS, 1 = NEG). 
- VOID Return


ARB3Ret
Returns the binary-data from an existing abbitrary wavefrom memory location. 
- UINT Return


BSTPHASE
Sets the burst phase to <nrf> degrees. (Lower limit: -360 - Upper limit: 360) 
[[File:]] - Degrees
Sets the burst phase in degrees (-360 - 360) 
- VOID Return


IDNRet
Returns the instrument identification. The IDN is saved to the variable passed from the function 'ReturnIDN'. The return parameter is TRUE when the IDN is successfully returned. 
- STRING ReturnIDN
 
- STRING Return


SWPTRGPER
Sets the sweep trigger period to <nrf> seconds 
[[File:]] - Seconds
Set the sweep trigger period in seconds. 
- VOID Return


PULSDLY
Sets the waveform delay to <nrf> sec 
[[File:]] - Sec
 
- VOID Return


Initialise
Opens the COM port ready for communications. 
- VOID Return



Property reference

Properties
Red
Pin that the red LED is connected to. 
Green
Pin that the green LED is connected to. 
Blue
Pin tha the Blue pin is connected to. 
Polarity
Active High: Use for common cathode LEDs - Pin true = LED On. Active Low: Use for common anode LEDs - Pin false = LED On. 
Color bit size
Color bit depth. Sets the resolution of the virtual PWM signals driving the LEDs. Lower values mean that the 'Tick' macro can be called less often, but reduced the number of colours that can be created. 
Rollover value
The number of unique colours each R/G/B channel can output. Range: 0 to (Rollover Value - 1). 
Connections
Simulations
Target
Create custom LED shapes by pointing this property at any object on your panel. This also works with groups of objects - all children of the group will change color. 
Shape
Choose a simple shape for the LED when there is no 'Target' selected. 
Width
Width of the LED shape. 
Height
Height of the LED shape. 
Depth
Depth of the LED shape.