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

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
+
{| style="width:50%"
{| width="50%"
 
 
|-
 
|-
| width="20%" style="color: gray;" | Author
+
| width="20%" style="color:gray;" | Author
 
| Matrix TSL
 
| Matrix TSL
 
|-
 
|-
| width="20%" style="color: gray;" | Version
+
| width="20%" style="color:gray;" | Version
| 1.0 (Release)
+
| 1.0
 
|-
 
|-
| width="20%" style="color: gray;" | Category
+
| width="20%" style="color:gray;" | Category
 
| General Output
 
| 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.
  
==[[File:Component Icon 5bd41be2_1b9c_4f30_ba78_84cb29d61ced.png|Image]] PWM 16CH 12Bit (PCA9685) component==
+
==Component Source Code==
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.
 
  
==Examples==
+
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]
''<span style="color:red;">No additional examples</span>''
 
  
 +
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]
  
==Downloadable macro reference==
+
==Detailed description==
  
===<span style="font-weight: normal;"><u><tt>Reset</tt></u></span>===
 
Sends a reset command to the PCA9685 chip over I2C
 
  
'''Parameters'''
 
  
:''This macro has no parameters''
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>SetPWMFrequency</tt></u></span>===
 
Sets the PWM frequency for the entire chip, up to approx 1.6 KHz
 
  
'''Parameters'''
 
  
:[[Variable Types|FLOAT]] ''Frequency''
 
::Floating point frequency that we will attempt to match
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>SetOutputMode</tt></u></span>===
 
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.
 
  
'''Parameters'''
 
  
:[[Variable Types|BOOL]] ''Mode''
 
::0=OpenDrain, 1=Push/Pull
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>Sleep</tt></u></span>===
 
Puts the module into Sleep mode
 
  
'''Parameters'''
 
  
:''This macro has no parameters''
+
''No detailed description exists yet for this component''
  
 +
==Examples==
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>SetExternalClock</tt></u></span>===
 
Sets EXTCLK pin to use the external clock
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Prescale''
 
::External Clock Prescaler - Range: 3-255
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>SetAddress</tt></u></span>===
 
Allows a different I2C address to be specified allowing one component to control
 
  
multiple PCA9685 modules.
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Address''
 
::Range: 0x40 - 0x7F
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>SetClockFrequency</tt></u></span>===
 
Sets the current clock frequency, used for things like calculating the PWM frequency and Microsecond duty.
 
  
'''Parameters'''
 
  
:[[Variable Types|ULONG]] ''Clock''
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>GetClockFrequency</tt></u></span>===
+
''<span style="color:red;">No additional examples</span>''
Returns the current clock frequency
 
  
'''Parameters'''
 
  
:''This macro has no parameters''
 
  
  
'''Return value'''
 
  
:[[Variable Types|ULONG]]
 
  
  
===<span style="font-weight: normal;"><u><tt>WriteMicroseconds</tt></u></span>===
 
Sets the PWM output of one of the PCA9685 pins based on the input microseconds, output is not precise
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Output''
 
::One of the PWM output pins - Range: 0 to 15
 
  
:[[Variable Types|UINT]] ''Microseconds''
 
::The number of Microseconds to turn the PWM output ON
 
  
  
'''Return value'''
+
==Macro reference==
  
:''This call does not return a value''
+
===GetClockFrequency===
 +
{| 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;" | '''GetClockFrequency'''
 +
|-
 +
| colspan="2" | Returns the current clock frequency&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
===<span style="font-weight: normal;"><u><tt>SetPWM</tt></u></span>===
+
===Initialise===
Sets the PWM output of one of the PCA9685 pins
+
{| 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 I2C ready for communications to begin&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Output''
+
===Reset===
::One of the PWM output pins - Range: 0 to 15
+
{| 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&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|UINT]] ''On''
 
::At what point in the 4096-part cycle to turn the PWM output ON
 
  
:[[Variable Types|UINT]] ''Off''
+
===SetAddress===
::At what point in the 4096-part cycle to turn the PWM output OFF
+
{| 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;" | '''SetAddress'''
 +
|-
 +
| colspan="2" | Allows a different I2C address to be specified allowing one component to control multiple PCA9685 modules.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Address
 +
|-
 +
| colspan="2" | Range: 0x40 - 0x7F&nbsp;
 +
|-
 +
| 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''
 +
|}
  
  
'''Return value'''
+
===SetClockFrequency===
 +
{| 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;" | '''SetClockFrequency'''
 +
|-
 +
| colspan="2" | Sets the current clock frequency, used for things like calculating the PWM frequency and Microsecond duty.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 +
| width="90%" | Clock
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| 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''
 +
|}
  
:''This call does not return a value''
 
  
 +
===SetExternalClock===
 +
{| 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;" | '''SetExternalClock'''
 +
|-
 +
| colspan="2" | Sets EXTCLK pin to use the external clock&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Prescale
 +
|-
 +
| colspan="2" | External Clock Prescaler - Range: 3-255&nbsp;
 +
|-
 +
| 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''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
 
Sets up the I2C ready for communications to begin
 
  
'''Parameters'''
+
===SetOutputMode===
 +
{| 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;" | '''SetOutputMode'''
 +
|-
 +
| 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.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 +
| width="90%" | Mode
 +
|-
 +
| colspan="2" | 0=OpenDrain, 1=Push/Pull&nbsp;
 +
|-
 +
| 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''
 +
|}
  
:''This macro has no parameters''
 
  
 +
===SetPWM===
 +
{| 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;" | '''SetPWM'''
 +
|-
 +
| colspan="2" | Sets the PWM output of one of the PCA9685 pins&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Output
 +
|-
 +
| colspan="2" | One of the PWM output pins - Range: 0 to 15&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | On
 +
|-
 +
| colspan="2" | At what point in the 4096-part cycle to turn the PWM output ON&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Off
 +
|-
 +
| colspan="2" | At what point in the 4096-part cycle to turn the PWM output OFF&nbsp;
 +
|-
 +
| 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''
 +
|}
  
'''Return value'''
 
  
:''This call does not return a value''
+
===SetPWMFrequency===
 +
{| 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&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 +
| width="90%" | Frequency
 +
|-
 +
| colspan="2" | Floating point frequency that we will attempt to match&nbsp;
 +
|-
 +
| 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''
 +
|}
  
  
===<span style="font-weight: normal;"><u><tt>SetPin</tt></u></span>===
+
===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.
+
{| 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;" | '''SetPin'''
 +
|-
 +
| colspan="2" | 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.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Output
 +
|-
 +
| colspan="2" | One of the PWM output pins - Range: 0 to 15&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Duty
 +
|-
 +
| colspan="2" | The number of ticks out of 4096 to be active&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 +
| width="90%" | Invert
 +
|-
 +
| colspan="2" | 0=Normal, 1=Inverted&nbsp;
 +
|-
 +
| 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''
 +
|}
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Output''
+
===Sleep===
::One of the PWM output pins - Range: 0 to 15
+
{| 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;" | '''Sleep'''
 +
|-
 +
| colspan="2" | Puts the module into Sleep mode&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|UINT]] ''Duty''
 
::The number of ticks out of 4096 to be active
 
  
:[[Variable Types|BOOL]] ''Invert''
+
===WakeUp===
::0=Normal, 1=Inverted
+
{| 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&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
  
'''Return value'''
+
===WriteMicroseconds===
 
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
:''This call does not return a value''
+
|-
 
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteMicroseconds'''
===<span style="font-weight: normal;"><u><tt>WakeUp</tt></u></span>===
+
|-
Wakes the module from Sleep mode
+
| colspan="2" | Sets the PWM output of one of the PCA9685 pins based on the input microseconds, output is not precise&nbsp;
 
+
|-
'''Parameters'''
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
:''This macro has no parameters''
+
| width="90%" | Output
 
+
|-
 
+
| colspan="2" | One of the PWM output pins - Range: 0 to 15&nbsp;
'''Return value'''
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
:''This call does not return a value''
+
| width="90%" | Microseconds
 
+
|-
 
+
| colspan="2" | The number of Microseconds to turn the PWM output ON&nbsp;
 
+
|-
==Simulation macro reference==
+
| 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''
''This component does not contain any simulation macros''
+
|}
  
  
 
==Property reference==
 
==Property reference==
<span style="font-weight: normal;"><u>Address</u></span>
 
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Address''.
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
Module I2C Address.
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
This setting can be overridden using the SetAddress component macro.
+
|-
 
+
|-
<span style="font-weight: normal;"><u>Output Mode</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Address
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''OutputMode''.
+
|-
 
+
| colspan="2" | Module I2C Address. This setting can be overridden using the SetAddress component macro.&nbsp;
Sets the output mode of the PCA9685 to either open drain or push pull.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Warning: LEDs with integrated zener diodes should only be driven in open drain mode.
+
| width="90%" | Output Mode
 
+
|-
Can be overridden using the SetOutputMode component macro.
+
| 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. Can be overridden using the SetOutputMode component macro.&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Clock Type</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Clock Type
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''ClockType''.
+
|-
 
+
| colspan="2" | Configures the input clock source to the module.&nbsp;
Configures the input clock source to the module.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
<span style="font-weight: normal;"><u>Clock Frequency</u></span>
+
| width="90%" | Clock Frequency
 
+
|-
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''ClockFrequency''.
+
| colspan="2" | 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.&nbsp;
 
+
|-
Frequency of the module.
+
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
 
+
| width="90%" | Prescaler
Internal oscillator defaults to 250000000 or 25MHz but can actually be anywhere from 23 to 27MHz.
+
|-
 
+
| colspan="2" | External Clock Prescaler Range: 3 to 255&nbsp;
External clock frequency can be specified here up to a max value of 50000000 or 50MHz.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
This setting can be overridden using the SetClockFrequency component macro.
+
| width="90%" | Target PWM Frequency
 
+
|-
<span style="font-weight: normal;"><u>Prescaler</u></span>
+
| colspan="2" | 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.&nbsp;
 
+
|-
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''Prescaler''.
+
| width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
 
+
| width="90%" | Actual PWM Frequency
External Clock Prescaler
+
|-
 
+
| colspan="2" | The calculated actual PWM frequency available using the Clock Frequency and Prescaler&nbsp;
Range: 3 to 255
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
<span style="font-weight: normal;"><u>Target PWM Frequency</u></span>
+
| width="90%" | PWM Resolution
 
+
|-
This property is of type ''Floating point'' and can be referenced with the variable name ''TargetPWMFreq''.
+
| colspan="2" | Number of microseconds the PWM output can resolve to&nbsp;
 
+
|-
The ideal PWM frequency we would like to generate on the output pins.
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | I2C Communications
Servo motors require an output frequency around 50Hz.
+
|-
 
+
|-
LEDs require a mugh higher output frequency to avoid visible flicker.
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Channel
<span style="font-weight: normal;"><u>Actual PWM Frequency</u></span>
+
|-
 
+
| colspan="2" | Channel selection&nbsp;
This property is of type ''Floating point'' and can be referenced with the variable name ''PWMFrequency''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
The calculated actual PWM frequency available using the Clock Frequency and Prescaler
+
| width="90%" | Baud Select
 
+
|-
<span style="font-weight: normal;"><u>PWM Resolution</u></span>
+
| colspan="2" | Baud rate option selector&nbsp;
 
+
|-
This property is of type ''Floating point'' and can be referenced with the variable name ''PWMResolution''.
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | Baud Rate
Number of microseconds the PWM output can resolve to
+
|-
 
+
| colspan="2" | Baud rate to be used&nbsp;
<span style="font-weight: normal;"><u>Channel</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c1::CHANNEL''.
+
| width="90%" | SDA
 
+
|-
Channel selection
+
| colspan="2" | Pin used for SDA (data signal)&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Baud Select</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | SCL
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c1::BAUD_LIST''.
+
|-
 
+
| colspan="2" | Pin used for SCL (clock signal)&nbsp;
Baud rate option selector
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
<span style="font-weight: normal;"><u>Baud Rate</u></span>
+
| width="90%" | Stop Delay
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_i2c1::BAUD''.
+
| 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. &nbsp;
 
+
|-
Baud rate to be used
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
<span style="font-weight: normal;"><u>SDA</u></span>
+
|-
 
+
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c1::SDA''.
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Simulate Comms
Pin used for SDA (data signal)
+
|-
 
+
| colspan="2" | &nbsp;
<span style="font-weight: normal;"><u>SCL</u></span>
+
|}
 
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c1::SCL''.
 
 
 
Pin used for SCL (clock signal)
 
 
 
<span style="font-weight: normal;"><u>Stop Delay</u></span>
 
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c1::StopDel''.
 
 
 
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.
 
 
 
<span style="font-weight: normal;"><u>Simulate Comms</u></span>
 
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''SimComms''.
 
 
 
''<span style="color:red;">No additional information</span>''
 
 
 
 
 
 
 
<span style="font-weight: normal;"><u>Scope Traces</u></span>
 
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c1::ScopeTraces''.
 
 
 
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.
 
 
 
<span style="font-weight: normal;"><u>Console Data</u></span>
 
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c1::ConsoleData''.
 
 
 
Selects if the console data is automatically generated or not
 
 
 
<span style="font-weight: normal;"><u>API</u></span>
 
 
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c1::Injector''.
 
 
 
Specifies the API component on the panel to interact with to provide comms simulation.
 

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