Adafruit 16-channel PWM/Servo Shield Created by lady ada Last updated on 2018-01-16 12:20:38 AM UTC
Guide Contents Guide Contents Overview Assembly Shield Connections Pins Used Connecting other I2C devices Powering Servos / PWM 2 3 5 13 13 13 13 Adding a Capacitor to the thru-hole capacitor slot Connecting a Servo Adding More Servos 14 14 15 Stacking Shields 17 Addressing the Shields 18 Using the Adafruit Library Install Adafruit PCA9685 library Test with the Example Code: 20 20 20 If using a Breakout: If using a Shield: If using a FeatherWing: 21 21 21 Connect a Servo 21 Calibrating your Se
Overview Driving servo motors with the Arduino Servo library is pretty easy, but each one consumes a precious pin - not to mention some Arduino processing power. The Adafruit 16-Channel 12-bit PWM/Servo Driver Shield will drive up to 16 servos over I2C with only 2 pins. The on-board PWM controller will drive all 16 channels simultaneously with no additional Arduino processing overhead.
© Adafruit Industries https://learn.adafruit.
Assembly This section assumes you do not want to stack the shield with stacking headers. If you want to stack another shield on top, skip to the Stacking Shields section! Check you have everything you need: assembled shield PCB, 0.1" male header, 4 of 3x4 male header, and a 2 pin terminal block Break apart the 0.1" header into 6, 8 and/or 10-pin long pieces and slip the long ends into the headers of your Arduino © Adafruit Industries https://learn.adafruit.
Place the shield on top of the header pins, they should fit into each of the holes along the edge Solder each of the pins to secure the shield to the headers © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Place the 2 pin terminal block so it faces out. Also place the 3x4 headers so the short pins are plugged into the shield and the long pins are sticking up To keep them in place, a few pieces of tape will hold them for when you flip the board over. © Adafruit Industries https://learn.adafruit.
Flip the board over and solder the terminal block Then solder one pin of each 3x4 header to tack them in place. © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Finally...solder every pin of the 3x4 headers © Adafruit Industries https://learn.adafruit.
You're done! Go onto the next sections to learn how to use your servo/pwm shield © Adafruit Industries https://learn.adafruit.
Shield Connections Pins Used The shield plugs in directly into any shield-compatible Arduino such as Duemilanove, Diecimila, UNO, Leonardo, Mega R3+, ADK R3+. The only pins required to run are the Ground, 5V and SDA + SCL I2C control pins. For backwards compatibility with old Ardunos, SCL is connected to A5 and SDA is connected to A4. UNOs already have this connection on board.
5v 10A switching power supply (up to perhaps 16 servos) 4xAA Battery Holder - 6v with Alkaline cells. 4.8v with NiMH rechargeable cells, portable! 4.8 or 6v Rechargeable RC battery packs from a hobby store. SERVOS CAN USE A LOT OF POWER! It is not a good idea to use the Arduino 5v pin to power your servos. Electrical noise and 'brownouts' from excess current draw can cause your Arduino to act erratically, reset and/or overheat.
Adding More Servos Up to 16 servos can be attached to one board. If you need to control more than 16 servos, additional boards can be stacked as described on the next page. © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Stacking Shields If you want to plug shields on top of this one, make sure you pick up a set of shield-stacking headers http://www.adafruit.com/product/85 and solder them instead of the male header Since this shield only uses the I2C pins and the I2C bus is sharable, you can stack multiple shields on top of each other. You will need to have installed stacking headers & right angle 3x4 connections for it to physically connect. Multiple shields (up to 62!) can be stacked to control still more servos.
Addressing the Shields Each board in the chain must be assigned a unique address. This is done with the address jumpers on the upper right edge of the board. The I2C base address for each board is 0x40. The binary address that you program with the address jumpers is added to the base I2C address. To program the address offset, use a drop of solder to bridge the corresponding address jumper for each binary '1' in the address. © Adafruit Industries https://learn.adafruit.
Board 0: Address = 0x40 Offset = binary 00000 (no jumpers required) Board 1: Address = 0x41 Offset = binary 00001 (bridge A0 as in the photo above) Board 2: Address = 0x42 Offset = binary 00010 (bridge A1) Board 3: Address = 0x43 Offset = binary 00011 (bridge A0 & A1) Board 4: Address = 0x44 Offset = binary 00100 (bridge A2) etc. © Adafruit Industries https://learn.adafruit.
Using the Adafruit Library Since the PWM Servo Driver is controlled over I2C, its super easy to use with any microcontroller or microcomputer. In this demo we'll show using it with the Arduino IDE but the C++ code can be ported easily Install Adafruit PCA9685 library To begin reading sensor data, you will need to install the Adafruit_PWMServo library (code on our github repository). It is available from the Arduino library manager so we recommend using that. From the IDE open up the library manager...
If using a Breakout: Connect the driver board and servo as shown on the previous page. Don't forget to provide power to both Vin (3-5V logic level) and V+ (5V servo power). Check the green LED is lit! If using a Shield: Plug the shield into your Arduino. Don't forget you will also have to provide 5V to the V+ terminal block. Both red and green LEDs must be lit. If using a FeatherWing: Plug the FeatherWing into your Feather. Don't forget you will also have to provide 5V to the V+ terminal block.
Again using the example code, edit SERVOMAX until the high-point of the sweep reaches the maximum range of travel. Again, is best to approach this gradually and stop before the physical limit of travel is reached. Use caution when adjusting SERVOMIN and SERVOMAX. Hitting the physical limits of travel can strip the gears and permanently damage your servo.
Library Reference setPWMFreq(freq) Description This function can be used to adjust the PWM frequency, which determines how many full 'pulses' per second are generated by the IC. Stated differently, the frequency determines how 'long' each pulse is in duration from start to finish, taking into account both the high and low segments of the pulse.
pwm.setPWM(pin, 4096, 0); You can set the pin to be fully off with pwm.setPWM(pin, 0, 4096); © Adafruit Industries https://learn.adafruit.
FAQ Can this board be used for LEDs or just servos? It can be used for LEDs as well as any other PWM-able device! I am having strange problems when combining this shield with the Adafruit LED Matrix/7Seg Backpacks The PCA9865 chip has an "All Call" address of 0x70. This is in addition to the configured address. Set the backpacks to address 0x71 or anything other than the default 0x70 to make the issue go away.
Downloads & Links Files PCA9685 datasheet Adafruit PWM/Servo Driver Library in GitHub Adafruit Fritzing Library EagleCAD PCB files on GitHub Schematic Fabrication Print © Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2018-01-16 12:20:37 AM UTC Page 27 of 27