PCA9685 driver for Analog Outputs
Introduction
The PCA9685 driver for Analog Outputs is used to modulate the pulse width of a channel on a PWM extender connected to the Builder Base. This driver cannot alter the frequency, it is pure PWM.
Driver Parameters
The PCA9685 driver for Analog Outputs has two parameters that have to be configured:
I2C Address
This is the address the device is being referenced by on the I2C bus. The base I2C address is
Binary: 1000000
Hex: 0x40
The last 6 bits are altered by the address A0-A5 pins:
A5 A4 A3 A2 A1 A0
1 0 0 0 0 0 0
So as an example if we set all pins to 1 we have
Binary: 1111111
Hex: 0x7f
The device has a “can all“ address, which is 0x70, so the I2C scan is going to report two addresses usually: the one selected with the A pins and 0x70.
More information about addressing can be found in the datasheet
Also for translation help see the Binary to Hex converter here
Channel
This is the channel on the PCA9685 modulating the pulse width; enter a number between 0-15 to select the channel you want to modulate. The Quantum System supports 8-bit (0-255) PWM.
Wiring
The chip can be found in either a DIP socket adapter or in popular development boards as shown below
Development Board
Chip Pinout
Example
Channel 0 is connected to an LED directly. The chip is connected to address 0x40 of the I2C bus because none of the connectable addresses is set to HIGH.
Breadboard
Schematic
Used Pins
Used Pins | Description |
---|---|
5V | The voltage level for the assembly |
GND | The ground potential for the assembly |
SDA | The I2C data line |
SCL | The I2C clock line |
How to write an App
Navigate to the App Builder and create a new application. You can find the “Analog Out” code object under the “Hardware” Tab in the object drop down menu on the left, or you can also use the search bar.
Drag the “Analog Out” Object onto the canvas.
Next, locate the “Slider Analog” object under the “Interface” tab and drag it onto the canvas.
Finally, connect the value port on the Analog Slider to the value port on the Analog Out object.
How to create a firmware
Navigate to the Firmware Builder and create a new Firmware file.
Click the “+Add Hardware” button which will open a modal window. Scroll down in the list to find the “Generic” section and select the “Analog Out” hardware option.
Give your device a name and click “Add Device”
Next, select the “PCA9685” driver under the driver dropdown menu.
Next, set the I2C Address and the channel
For this example we will select:
I2C Address: 0x40
Channel: 0
You may now save your firmware file and upload it to one of your Builder Bases
Supported Hardware
PWM
Buzzer
Downloads
Apps
Firmware
Assets