Component: PWM 16CH 12Bit (PCA9685) (General Output)

From Flowcode Help
Jump to navigationJump to search
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