Difference between revisions of "Component: PWM 16CH 12Bit (PCA9685) (General Output)"

From Flowcode Help
Jump to navigationJump to search
 
(15 intermediate revisions by the same user not shown)
Line 14: Line 14:
 
==PWM 16CH 12Bit (PCA9685) component==
 
==PWM 16CH 12Bit (PCA9685) component==
 
The PCA9685 is an I²C-bus controlled 16-channel LED controller optimized for Red/Green/Blue/Amber (RGBA) color backlighting or Servo motor applications.  Each output has its own 12-bit resolution (4096 steps) fixed frequency individual PWM controller that operates at a programmable frequency from a typical of 24 Hz to 1526 Hz. All outputs are set to the same PWM frequency. Up to 64 devices can be chained together on a single I²C-bus to provide up to 1024 individual PWM outputs.
 
The PCA9685 is an I²C-bus controlled 16-channel LED controller optimized for Red/Green/Blue/Amber (RGBA) color backlighting or Servo motor applications.  Each output has its own 12-bit resolution (4096 steps) fixed frequency individual PWM controller that operates at a programmable frequency from a typical of 24 Hz to 1526 Hz. All outputs are set to the same PWM frequency. Up to 64 devices can be chained together on a single I²C-bus to provide up to 1024 individual PWM outputs.
 +
 +
==Component Source Code==
 +
 +
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_PCA9685_16_Channel_PWM.fcfx FC_Comp_Source_PCA9685_16_Channel_PWM.fcfx]
 +
 +
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_PCA9685_16_Channel_PWM.fcfx FC_Comp_Source_PCA9685_16_Channel_PWM.fcfx]
  
 
==Detailed description==
 
==Detailed description==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
 
''No detailed description exists yet for this component''
 
''No detailed description exists yet for this component''
  
 
==Examples==
 
==Examples==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
Line 25: Line 79:
  
  
==Downloadable macro reference==
 
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Reset'''
 
|-
 
| colspan="2" | Sends a reset command to the PCA9685 chip over I2C 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetPWMFrequency'''
 
|-
 
| colspan="2" | Sets the PWM frequency for the entire chip, up to approx 1.6 KHz 
 
|-
 
|-
 
| width="10%" align="center" | [[File:]] -
 
| width="90%" | Frequency
 
|-
 
| colspan="2" | Floating point frequency that we will attempt to match 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
  
  
 +
 +
 +
 +
 +
 +
==Macro reference==
 +
 +
===GetClockFrequency===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetOutputMode'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetClockFrequency'''
 
|-
 
|-
| colspan="2" | Sets the output mode of the PCA9685 to either open drain or push pull. Warning: LEDs with integrated zener diodes should only be driven in open drain mode. 
+
| colspan="2" | Returns the current clock frequency 
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:]] -
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | Mode
 
|-
 
| colspan="2" | 0=OpenDrain, 1=Push/Pull 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===Initialise===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Sleep'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
 
|-
| colspan="2" | Puts the module into Sleep mode 
+
| colspan="2" | Sets up the I2C ready for communications to begin 
 
|-
 
|-
 
|-
 
|-
Line 89: Line 119:
  
  
 +
===Reset===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetExternalClock'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Reset'''
 
|-
 
|-
| colspan="2" | Sets EXTCLK pin to use the external clock 
+
| colspan="2" | Sends a reset command to the PCA9685 chip over I2C 
 
|-
 
|-
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Prescale
 
|-
 
| colspan="2" | External Clock Prescaler - Range: 3-255 
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 107: Line 133:
  
  
 +
===SetAddress===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 125: Line 152:
  
  
 +
===SetClockFrequency===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 143: Line 171:
  
  
 +
===SetExternalClock===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetClockFrequency'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetExternalClock'''
 +
|-
 +
| colspan="2" | Sets EXTCLK pin to use the external clock 
 +
|-
 
|-
 
|-
| colspan="2" | Returns the current clock frequency 
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Prescale
 
|-
 
|-
 +
| colspan="2" | External Clock Prescaler - Range: 3-255 
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===SetOutputMode===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteMicroseconds'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetOutputMode'''
 
|-
 
|-
| colspan="2" | Sets the PWM output of one of the PCA9685 pins based on the input microseconds, output is not precise 
+
| colspan="2" | Sets the output mode of the PCA9685 to either open drain or push pull. Warning: LEDs with integrated zener diodes should only be driven in open drain mode. 
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" | Output
+
| width="90%" | Mode
 
|-
 
|-
| colspan="2" | One of the PWM output pins - Range: 0 to 15 
+
| colspan="2" | 0=OpenDrain, 1=Push/Pull 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Microseconds
 
|-
 
| colspan="2" | The number of Microseconds to turn the PWM output ON 
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 179: Line 209:
  
  
 +
===SetPWM===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 207: Line 238:
  
  
 +
===SetPWMFrequency===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetPWMFrequency'''
 
|-
 
|-
| colspan="2" | Sets up the I2C ready for communications to begin 
+
| colspan="2" | Sets the PWM frequency for the entire chip, up to approx 1.6 KHz 
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
+
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
+
| width="90%" | Frequency
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WakeUp'''
 
|-
 
| colspan="2" | Wakes the module from Sleep mode 
 
 
|-
 
|-
 +
| colspan="2" | Floating point frequency that we will attempt to match 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 233: Line 257:
  
  
 +
===SetPin===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 251: Line 276:
 
| colspan="2" | The number of ticks out of 4096 to be active 
 
| colspan="2" | The number of ticks out of 4096 to be active 
 
|-
 
|-
| width="10%" align="center" | [[File:]] -  
+
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" | Invert
 
| width="90%" | Invert
 
|-
 
|-
Line 261: Line 286:
  
  
 +
===Sleep===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DrawRectangle2D'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Sleep'''
 
|-
 
|-
| colspan="2" | Draws a basic 2D rectangle onto the LEDs 
+
| colspan="2" | Puts the module into Sleep mode 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | X1
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Y1
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | X2
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Y2
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | DrawStyle
 
|-
 
| colspan="2" | Sets the draw style - 0=Soild, 1=Edge, 2=Corners 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | R
 
|-
 
| colspan="2" |  
 
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | G
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | B
 
|-
 
| colspan="2" |  
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 314: Line 300:
  
  
 +
===WakeUp===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ShiftLEDs2D'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WakeUp'''
 
|-
 
|-
| colspan="2" | Shifts the contents of the display by the number of vertices specified ***Please Note that Wrap mode is currently unavailable*** 
+
| colspan="2" | Wakes the module from Sleep mode 
 
|-
 
|-
|-
 
| width="10%" align="center" | [[File:]] -
 
| width="90%" | X
 
|-
 
| colspan="2" | Number of pixels to shift the display -1 to 1 / 0 = No Shift 
 
|-
 
| width="10%" align="center" | [[File:]] -
 
| width="90%" | Y
 
|-
 
| colspan="2" | Number of pixels to shift the display -1 to 1 / 0 = No Shift 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | DataMode
 
|-
 
| colspan="2" | 0=ResetToZero, 1=WrapAroundDisplay, 2=Smear 
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 342: Line 314:
  
  
 +
===WriteMicroseconds===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLEDIndex3D'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteMicroseconds'''
 
|-
 
|-
| colspan="2" | Gets the index of a single LED in RAM as a 3D array. 
+
| colspan="2" | Sets the PWM output of one of the PCA9685 pins based on the input microseconds, output is not precise 
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | X
+
| width="90%" | Output
 
|-
 
|-
| colspan="2" | LED Column to change the colour / Range: 0 to (LED Column - 1) 
+
| colspan="2" | One of the PWM output pins - Range: 0 to 15 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Y
+
| width="90%" | Microseconds
|-
 
| colspan="2" | LED Row to change the colour / Range: 0 to (LED Row - 1) 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Z
 
|-
 
| colspan="2" | LED Layer to change the colour / Range: 0 to (LED Layer - 1) 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DrawCuboid3D'''
 
|-
 
| colspan="2" | Draws a basic 3D cuboid onto the LEDs 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | X1
 
|-
 
| colspan="2" | Start X pixel coordinate 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Y1
 
|-
 
| colspan="2" | Start Y pixel coordinate 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Z1
 
|-
 
| colspan="2" | Start Z pixel coordinate 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | X2
 
|-
 
| colspan="2" | End X pixel coordinate 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Y2
 
|-
 
| colspan="2" | End Y pixel coordinate 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Z2
 
|-
 
| colspan="2" | End Z pixel coordinate 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | DrawStyle
 
|-
 
| colspan="2" | Sets the draw style - 0=Soild, 1=Edge, 2=Corners 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | R
 
|-
 
| colspan="2" | Red Colour Channel 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | G
 
|-
 
| colspan="2" | Green Colour Channel 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | B
 
|-
 
| colspan="2" | White Colour Channel 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
 
| colspan="2" | 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. 
 
 
|-
 
|-
 +
| colspan="2" | The number of Microseconds to turn the PWM output ON 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ShiftLEDs3D'''
 
|-
 
| colspan="2" | Shifts the contents of the display by the number of vertices specified ***Please Note that Wrap mode is currently unavailable*** 
 
|-
 
|-
 
| width="10%" align="center" | [[File:]] -
 
| width="90%" | X
 
|-
 
| colspan="2" | Number of pixels to shift the display -1 to 1 / 0 = No Shift 
 
|-
 
| width="10%" align="center" | [[File:]] -
 
| width="90%" | Y
 
|-
 
| colspan="2" | Number of pixels to shift the display -1 to 1 / 0 = No Shift 
 
|-
 
| width="10%" align="center" | [[File:]] -
 
| width="90%" | Z
 
|-
 
| colspan="2" | Number of pixels to shift the display -1 to 1 / 0 = No Shift 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | DataMode
 
|-
 
| colspan="2" | 0=ResetToZero, 1=WrapAroundDisplay, 2=Smear 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
 
| colspan="2" | Sets up the data memory and draws the simulated LED cube on the panel. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
  
  
Line 541: Line 385:
 
|-
 
|-
 
| colspan="2" | Number of microseconds the PWM output can resolve to 
 
| colspan="2" | Number of microseconds the PWM output can resolve to 
 +
|-
 +
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | I2C Communications
 +
|-
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Line 572: Line 420:
 
| colspan="2" | On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not  a 10ms delay between an I2C stop event and the next I2C start event.  Most modern microcontrollers will not have a problem so this property can be disabled to speed up the  I2C communications.  
 
| colspan="2" | On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not  a 10ms delay between an I2C stop event and the next I2C start event.  Most modern microcontrollers will not have a problem so this property can be disabled to speed up the  I2C communications.  
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" | Scope Traces
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
|-
 
| colspan="2" | Selects if the component pin connections are automatically generated on the data recorder window or not. Yes: Automatically add the component pins to a group on the data recorder which will reflect the sim data during simultion. No: Do not show the pin signals on the data recorder window. 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Console Data
 
|-
 
| colspan="2" | Selects if the console data is automatically generated or not 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | API
 
|-
 
| colspan="2" | Specifies the API component on the panel to interact with to provide comms simulation. 
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''
 
 
|-
 
|-
 
|-
 
|-

Latest revision as of 13:12, 7 February 2023

Author Matrix TSL
Version 1.0
Category General Output


PWM 16CH 12Bit (PCA9685) component

The PCA9685 is an I²C-bus controlled 16-channel LED controller optimized for Red/Green/Blue/Amber (RGBA) color backlighting or Servo motor applications. Each output has its own 12-bit resolution (4096 steps) fixed frequency individual PWM controller that operates at a programmable frequency from a typical of 24 Hz to 1526 Hz. All outputs are set to the same PWM frequency. Up to 64 devices can be chained together on a single I²C-bus to provide up to 1024 individual PWM outputs.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_PCA9685_16_Channel_PWM.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_PCA9685_16_Channel_PWM.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples







Macro reference

GetClockFrequency

Fc9-comp-macro.png GetClockFrequency
Returns the current clock frequency 
Fc9-u32-icon.png - ULONG Return


Initialise

Fc9-comp-macro.png Initialise
Sets up the I2C ready for communications to begin 
Fc9-void-icon.png - VOID Return


Reset

Fc9-comp-macro.png Reset
Sends a reset command to the PCA9685 chip over I2C 
Fc9-void-icon.png - VOID Return


SetAddress

Fc9-comp-macro.png SetAddress
Allows a different I2C address to be specified allowing one component to control multiple PCA9685 modules. 
Fc9-u8-icon.png - BYTE Address
Range: 0x40 - 0x7F 
Fc9-void-icon.png - VOID Return


SetClockFrequency

Fc9-comp-macro.png SetClockFrequency
Sets the current clock frequency, used for things like calculating the PWM frequency and Microsecond duty. 
Fc9-u32-icon.png - ULONG Clock
 
Fc9-void-icon.png - VOID Return


SetExternalClock

Fc9-comp-macro.png SetExternalClock
Sets EXTCLK pin to use the external clock 
Fc9-u8-icon.png - BYTE Prescale
External Clock Prescaler - Range: 3-255 
Fc9-void-icon.png - VOID Return


SetOutputMode

Fc9-comp-macro.png SetOutputMode
Sets the output mode of the PCA9685 to either open drain or push pull. Warning: LEDs with integrated zener diodes should only be driven in open drain mode. 
Fc9-bool-icon.png - BOOL Mode
0=OpenDrain, 1=Push/Pull 
Fc9-void-icon.png - VOID Return


SetPWM

Fc9-comp-macro.png SetPWM
Sets the PWM output of one of the PCA9685 pins 
Fc9-u8-icon.png - BYTE Output
One of the PWM output pins - Range: 0 to 15 
Fc9-u16-icon.png - UINT On
At what point in the 4096-part cycle to turn the PWM output ON 
Fc9-u16-icon.png - UINT Off
At what point in the 4096-part cycle to turn the PWM output OFF 
Fc9-void-icon.png - VOID Return


SetPWMFrequency

Fc9-comp-macro.png SetPWMFrequency
Sets the PWM frequency for the entire chip, up to approx 1.6 KHz 
Fc9-f32-icon.png - FLOAT Frequency
Floating point frequency that we will attempt to match 
Fc9-void-icon.png - VOID Return


SetPin

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Output
One of the PWM output pins - Range: 0 to 15 
Fc9-u16-icon.png - UINT Duty
The number of ticks out of 4096 to be active 
Fc9-bool-icon.png - BOOL Invert
0=Normal, 1=Inverted 
Fc9-void-icon.png - VOID Return


Sleep

Fc9-comp-macro.png Sleep
Puts the module into Sleep mode 
Fc9-void-icon.png - VOID Return


WakeUp

Fc9-comp-macro.png WakeUp
Wakes the module from Sleep mode 
Fc9-void-icon.png - VOID Return


WriteMicroseconds

Fc9-comp-macro.png WriteMicroseconds
Sets the PWM output of one of the PCA9685 pins based on the input microseconds, output is not precise 
Fc9-u8-icon.png - BYTE Output
One of the PWM output pins - Range: 0 to 15 
Fc9-u16-icon.png - UINT Microseconds
The number of Microseconds to turn the PWM output ON 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Address
Module I2C Address. This setting can be overridden using the SetAddress component macro. 
Fc9-type-16-icon.png Output Mode
Sets the output mode of the PCA9685 to either open drain or push pull. Warning: LEDs with integrated zener diodes should only be driven in open drain mode. Can be overridden using the SetOutputMode component macro. 
Fc9-type-16-icon.png Clock Type
Configures the input clock source to the module. 
Fc9-type-21-icon.png Clock Frequency
Frequency of the module. Internal oscillator defaults to 250000000 or 25MHz but can actually be anywhere from 23 to 27MHz. External clock frequency can be specified here up to a max value of 50000000 or 50MHz. This setting can be overridden using the SetClockFrequency component macro. 
Fc9-type-21-icon.png Prescaler
External Clock Prescaler Range: 3 to 255 
Fc9-type-15-icon.png Target PWM Frequency
The ideal PWM frequency we would like to generate on the output pins. Servo motors require an output frequency around 50Hz. LEDs require a mugh higher output frequency to avoid visible flicker. 
Fc9-type-15-icon.png Actual PWM Frequency
The calculated actual PWM frequency available using the Clock Frequency and Prescaler 
Fc9-type-15-icon.png PWM Resolution
Number of microseconds the PWM output can resolve to 
Fc9-conn-icon.png I2C Communications
Fc9-type-16-icon.png Channel
Channel selection 
Fc9-type-16-icon.png Baud Select
Baud rate option selector 
Fc9-type-14-icon.png Baud Rate
Baud rate to be used 
Fc9-type-5-icon.png SDA
Pin used for SDA (data signal) 
Fc9-type-5-icon.png SCL
Pin used for SCL (clock signal) 
Fc9-type-7-icon.png Stop Delay
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not a 10ms delay between an I2C stop event and the next I2C start event. Most modern microcontrollers will not have a problem so this property can be disabled to speed up the I2C communications.  
Fc9-conn-icon.png Simulation
Fc9-type-7-icon.png Simulate Comms