Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Introduction

The PCA9685 driver for various types fo DC motors is used to drive the control pins of an H-Bridge to control 8 motors simultaneously. The enable pins of the H-Bridge are tied high, so we can supply the direction and speed data directly to the two dc input pins of any H-Bridge.


Driver Parameters

The PCA9685 driver for motor control has three parameters that need 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

Note

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

DC 1 Pin

This is one channel of the PCA9685 connected to an input pin on the H-Bridge. The pin transmits information regarding speed and direction. Please select a number between 0-15 to connect the channels seen on the pinout.

DC 2 Pin

This is the other channel of the PCA9685 connected to the other input pin on the H-Bridge. The pin transmits information regarding speed and direction as well. Please select a number between 0-15 to connect the channels seen on the pinout.


Wiring

Attached are the pinout of the PCA9685 IC and of a generic H-Bridge.

The PCA9685 can be found in either a DIP socket adapter or in popular development boards as shown below

Development Board

Chip Pinout

L293D

Some important facts about the H-Bridge:

  • all 0V (GND) pins should be connected, since they also dissipate the heat from the chip

  • pin 16 (+V) should be at 5V to provide proper functionality while pin 8 (+Vmotor) can be anything between 3.5V and 12V

Example

The PCA9685 is connected to 5V and GND from the circuit and to the Builder Base via I2C with the SDA pins connected to each other and the SCL pins connected to each other. Two output channels of the PCA9685 are connected to an H-Bridge to control the speed and direction of the motor connected to the H-Bridge. We see that there is a switch, that can either switch our motor voltage to the 5V output of the Builder Base or to anything we want to supply with the barrel jack (3.5V - 12V).

 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 “Motor” 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 “Motor” object onto the grid.

 

Next, under the interface tab, locate the switch, slider percent, and slider analog interface objects. Next, drag two of the switch objects, a slider percent object, and slider analog object onto the grid.

 

 

 

 

 

Finally, connect a switch object to each the clockwise and counter clockwise ports on the motor object, connect the slider percent object to the speed port, and the Slider Analog to the Joystick Axle. For the sake of organization, label each of the interface objects, and save your application.

 


How to create a firmware

Navigate to the Firmware Builder and create a new firmware file.

Click the “+ Add Hardware” button and listed under the “Actuators” tab find the “Motor” hardware option.

Give your device a name, and click “Add Device”

 

 

 

Next, select the “PCA-9685” under the driver dropdown menu.

 

 

For this example we select:

  • I2C Address: 0x40

  • DC 1 Pin: 1

  • DC 2 Pin: 2

 

 

You may now save your firmware file and upload it to one of your clients.

 

 

 


Supported Hardware

  • PCA-9685

  • Motors

  • Servos

  • Other Actuators


Downloads

Apps

View file
nameMotor App .json

Firmware

View file
nameMotor Firmware.json

Assets