Adafruit 16-Channel Servo Driver with Arduino

Similar documents
Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Adafruit SHT31-D Temperature & Humidity Sensor Breakout

DS1307 Real Time Clock Breakout Board Kit

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

2.2" TFT Display. Created by Ladyada. Last updated on :15:09 PM EDT

Tiny Arduino Music Visualizer

Pololu DRV8835 Dual Motor Driver Shield for Arduino

TEECES DOME LIGHTING SYSTEMS

Arduino Lesson 14. Servo Motors

Adafruit Proto Shield for Arduino

PolyBot Board. User's Guide V1.11 9/20/08

1.8" TFT Display Breakout and Shield

INTRODUCTION TO SERIAL ARM

1.5" & 2.1" Monochrome 128x64 OLED Display Module

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

2.3" Monochrome 128x32 OLED Display Module

TSL2561 Luminosity Sensor

Arduino Lesson 0. Getting Started

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

Arduino Lesson 13. DC Motors. Created by Simon Monk

Servo Info and Centering

The $25 Son of a cheap timer This is not suitable for a beginner. You must have soldering skills in order to build this kit.

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL ADC WITH I2C LTC2485 DESCRIPTION

DIY Pocket LED Gamer - Tiny Tetris!

AXE114S BINARY CLOCK. revolution Revolution Education Ltd. Web: Version /09/08 AXE114.PMD.

ARDUINO SEVERINO SERIAL SINGLE SIDED VERSION 3 S3v3 (REVISION 2) USER MANUAL

BUILDING INSTRUCTIONS

MANUAL FOR RX700 LR and NR

UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation

Matrix and 7-Segment LED Backpack with the Raspberry Pi

UniPi technical documentation REV 1.1

Flight Controller. Mini Fun Fly

Adafruit LSM9DS0 Accelerometer + Gyro + Magnetometer 9-DOF Breakouts

PN532 NFC RFID Module User Guide

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

The self-starting solar-powered Stirling engine

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

Adafruit ATWINC1500 WiFi Breakout

Adafruit Si4713 FM Radio Transmitter with RDS/RDBS Support

Advanced LED Controller (LED Chaser)

System theremino MasterDIL-V3

Board also Supports MicroBridge

Arduino ADK Back. For information on using the board with the Android OS, see Google's ADK documentation.

2013 G Miller. 3 Axis Brushless Gimbal Controller Manual

SERVO CONNECTIONS FOR OLDER BOARDS

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

Arduino Due Back. Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum. Overview

Real Time Clock USB Evaluation Board V3.0

Arduino Lesson 16. Stepper Motors

RC Camera Control. User Guide v /20/2012

Work with Arduino Hardware

Arduino Motor Shield (L298) Manual

Designing VM2 Application Boards

DIY Y6. Build Manual V.A 2014

Ocean Controls RC Servo Motor Controller

CAN-Bus Shield Hookup Guide

User manual DinaSys DTC/DTS and DTC/DTZ

INDEX. Trademarks All name and product s trademarks mentioned below are the property of their respective companies.

IR Communication a learn.sparkfun.com tutorial

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Arduino Lesson 1. Blink

Adafruit LED Backpacks

Controlling a Dot Matrix LED Display with a Microcontroller

RGB LED Strips. Created by lady ada. Last updated on :00:18 PM EST

DEPARTMENT OF ELECTRONICS ENGINEERING

Pulse Width Modulation Applications

AR1100 Resistive Touch Screen Controller Guide

SYSTEM 4C. C R H Electronics Design

XBee USB Adapter Board (#32400)

Thermistor. Created by Ladyada. Last updated on :30:46 PM EDT

ET-BASE AVR ATmega64/128

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Microprocessor Project Laboratory

MCP4725 Digital to Analog Converter Hookup Guide

0832 Dot Matrix Green Display Information Board User s Guide

DIY QUAD. Build Manual V.A 2014

DATASHEET. ADAM Arduino Display Adaptor Module. Arduino Compatible Shield P/N: 4Display-Shield-FT843 For the 4D Systems 4DLCD-FT843 Display

Objectives: Part 1: Build a simple power supply. CS99S Laboratory 1

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

Arduino Lesson 4. Eight LEDs and a Shift Register

A REST API for Arduino & the CC3000 WiFi Chip

Six-servo Robot Arm. DAGU Hi-Tech Electronic Co., LTD Six-servo Robot Arm

Theory and Practice of Tangible User Interfaces. Thursday Week 2: Digital Input and Output. week. Digital Input and Output. RGB LEDs fade with PWM

SD21-21 Channel Servo Driver Module Power Servo's

SainSmart UNO R3 Starter Kit

revolution Contents: Introduction Power 28-pin Project Board with input/output cables

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

Mini Breakout-Board. CNC Interface for LPT Port. Installation Manual Version 4

SYSTEM 45. C R H Electronics Design

How to connect to a Class II router using a mobile-phone data cable specifically for Solwise & Safecom routers

Transmitter Interface Program

Tutorial. replace them with cell-phone operated module. The advantages of a cell-phone operated bot are:-

Designing a Schematic and Layout in PCB Artist

Arduino Lesson 9. Sensing Light

ISP Engineering Kit Model 300

Electrical Engineering Department College of Engineering California State University, Long Beach Long Beach, California, 90840

OPERATING MANUAL. Table of contents. 2 Phase Stepping Motor Driver 2M542. Rev. A. Introduction page 2. Specifications page 2 Timing chart page 3

ECEN 1400, Introduction to Analog and Digital Electronics

Robot Board Sub-System Testing. Abstract. Introduction and Theory. Equipment. Procedures. EE 101 Spring 2006 Date: Lab Section # Lab #6

MAX6683 Evaluation System/Evaluation Kit

BUILD YOUR OWN RC SWITCH (Issue 3)

Transcription:

Adafruit 16-Channel Servo Driver with Arduino Created by Bill Earl Last updated on 2016-10-07 04:59:20 PM UTC

Guide Contents Guide Contents Overview Assembly Install the Servo Headers Solder all pins Add Headers for Control Install Power Terminals Hooking it Up Connecting to the Arduino Power for the Servos Adding a Capacitor to the thru-hole capacitor slot Connecting a Servo Adding More Servos Chaining Drivers Addressing the Boards Using the Adafruit Library Download the library from Github Test with the Example Code: If using a Breakout: If using a Shield: If using a FeatherWing: Connect a Servo Calibrating your Servos Converting from Degrees to Pulse Length Library Reference setpwmfreq(freq) Description Arguments Example setpwm(channel, on, off) Description Arguments Example FAQ Downloads 2 4 6 6 6 6 7 8 8 9 10 10 11 13 13 16 16 16 17 17 17 17 17 18 19 19 19 19 19 19 19 20 20 21 22 Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 2 of 23

Files Schematic & Fabrication Print 22 22 Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 3 of 23

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 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. What's more, you can chain up to 62 of them to control up to 992 servos - all with the same 2 pins! The Adafruit PWM/Servo Driver is the perfect solution for any project that requires a lot of servos. Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 4 of 23

Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 5 of 23

Assembly Install the Servo Headers Install 4 3x4 pin male headers into the marked positions along the edge of the board. Solder all pins There are a lot of them! Add Headers for Control A strip of male header is included. Where you want to install headers and on what side depends a little on use: For breadboard (http://adafru.it/239) use, install headers on the Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 6 of 23

bottom of the board. For use with jumper wires (http://adafru.it/758), install the headers on top of the board. For use with our 6-pin cable (http://adafru.it/206), install the headers on top of the board. If you are chaining multiple driver boards, you will want headers on both ends. Install Power Terminals If you are chaining multiple driver boards, you only need a power terminal on the first one. Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 7 of 23

Hooking it Up Connecting to the Arduino The PWM/Servo Driver uses I2C so it take only 4 wires to connect to your Arduino: "Classic" Arduino wiring: +5v -> VCC (this is power for the BREAKOUT only, NOT the servo power!) GND -> GND Analog 4 -> SDA Analog 5 -> SCL Older Mega wiring: +5v -> VCC (this is power for the BREAKOUT only, NOT the servo power!) GND -> GND Digital 20 -> SDA Digital 21 -> SCL R3 and later Arduino wiring (Uno, Mega & Leonardo): (These boards have dedicated SDA & SCL pins on the header nearest the USB connector) +5v -> VCC (this is power for the BREAKOUT only, NOT the servo power!) GND -> GND SDA -> SDA SCL -> SCL Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 8 of 23

The VCC pin is just power for the chip itself. If you want to connect servos or LEDs that use the V+ pins, you MUST connect the V+ pin as well. The V+ pin can be as high as 6V even if VCC is 3.3V (the chip is 5V safe). We suggest connecting power through the blue terminal block since it is polarity protected. Power for the Servos Most servos are designed to run on about 5 or 6v. Keep in mind that a lot of servos moving at the same time (particularly large powerful ones) will need a lot of current. Even micro servos will draw several hundred ma when moving. Some High-torque servos will draw more than 1A each under load. Good power choices are: 5v 2A switching power supply (http://adafru.it/276) 5v 10A switching power supply (http://adafru.it/658) 4xAA Battery Holder (http://adafru.it/830) - 6v with Alkaline cells. 4.8v with NiMH rechargeable cells. 4.8 or 6v Rechargeable RC battery packs from a hobby store. 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. Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 9 of 23

Adding a Capacitor to the thru-hole capacitor slot We have a spot on the PCB for soldering in an electrolytic capacitor. Based on your usage, you may or may not need a capacitor. If you are driving a lot of servos from a power supply that dips a lot when the servos move, n * 100uF where n is the number of servos is a good place to start - eg 470uF or more for 5 servos. Since its so dependent on servo current draw, the torque on each motor, and what power supply, there is no "one magic capacitor value" we can suggest which is why we don't include a capacitor in the kit. Connecting a Servo Most servos come with a standard 3-pin female connector that will plug directly into the headers on the Servo Driver. Be sure to align the plug with the ground wire (usually black or brown) with the bottom row and the signal wire (usually yellow or white) on the top. Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 10 of 23

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 chained as described on the next page. Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 11 of 23

Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 12 of 23

Chaining Drivers Multiple Drivers (up to 62) can be chained to control still more servos. With headers at both ends of the board, the wiring is as simple as connecting a 6-pin parallel cable (http://adafru.it/206) from one board to the next. Addressing the Boards 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.com/16-channel-pwm-servo-driver Page 13 of 23

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. In your sketch, you'll need to declare a separate pobject for each board. Call begin on each object, and control each servo through the object it's attached to. For example: #include <Wire.h> #include <Adafruit_PWMServoDriver.h> Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40); Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41); void setup() { Serial.begin(9600); Serial.println("16 channel PWM test!"); pwm1.begin(); pwm1.setpwmfreq(1600); // This is the maximum PWM frequency pwm2.begin(); pwm2.setpwmfreq(1600); // This is the maximum PWM frequency Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 14 of 23

} Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 15 of 23

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 Download the library from Github Start by downloading the library from the GitHub repository (http://adafru.it/aql) You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip Download Adafruit PWM/Servo Library http://adafru.it/cdw Rename the uncompressed folder Adafruit_PWMServoDriver and check that the Adafruit_PWMServoDriver folder contains Adafruit_PWMServoDriver.cpp and Adafruit_PWMServoDriver.h Place the Adafruit_PWMServoDriver library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. We also have a great tutorial on Arduino library installation at: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use (http://adafru.it/aym) Test with the Example Code: First make sure all copies of the Arduino IDE are closed. Next open the Arduino IDE and select File->Examples->Adafruit_PWMServoDriver->Servo. This will open the example file in an IDE window. Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 16 of 23

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. Check the green LED is lit! Connect a Servo A single servo should be plugged into the PWM #0 port, the first port. You should see the servo sweep back and forth over approximately 180 degrees. Calibrating your Servos Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 17 of 23

Servo pulse timing varies between different brands and models. Since it is an analog control circuit, there is often some variation between samples of the same brand and model. For precise position control, you will want to calibrate the minumum and maximum pulse-widths in your code to match known positions of the servo. Find the MInimum: Using the example code, edit SERVOMIN until the low-point of the sweep reaches the minimum range of travel. It is best to approach this gradually and stop before the physical limit of travel is reached. Find the Maximum: 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. Converting from Degrees to Pulse Length The Arduino "map()" function (http://adafru.it/aqm) is an easy way to convert between degrees of rotation and your calibrated SERVOMIN and SERVOMAX pulse lengths. Assuming a typical servo with 180 degrees of rotation; once you have calibrated SERVOMIN to the 0-degree position and SERVOMAX to the 180 degree position, you can convert any angle between 0 and 180 degrees to the corresponding pulse length with the following line of code: pulselength = map(degrees, 0, 180, SERVOMIN, SERVOMAX); Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 18 of 23

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. Frequency is important in PWM, since setting the frequency too high with a very small duty cycle can cause problems, since the 'rise time' of the signal (the time it takes to go from 0V to VCC) may be longer than the time the signal is active, and the PWM output will appear smoothed out and may not even reach VCC, potentially causing a number of problems. Arguments freq: A number representing the frequency in Hz, between 40 and 1000 Example The following code will set the PWM frequency to the maximum value of 1000Hz: pwm.setpwmfreq(1000) setpwm(channel, on, off) Description This function sets the start (on) and end (off) of the high segment of the PWM pulse on a specific channel. You specify the 'tick' value between 0..4095 when the signal will turn on, and when it will turn of. Channel indicates which of the 16 PWM outputs should be updated with the new values. Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 19 of 23

Arguments channel: The channel that should be updated with the new values (0..15) on: The tick (between 0..4095) when the signal should transition from low to high off:the tick (between 0..4095) when the signal should transition from high to low Example The following example will cause channel 15 to start low, go high around 25% into the pulse (tick 1024 out of 4096), transition back to low 75% into the pulse (tick 3072), and remain low for the last 25% of the pulse: pwm.setpwm(15, 1024, 3072) Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 20 of 23

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 We are not sure why this occurs but there is an address collision even though the address are different! Set the backpacks to address 0x71 or anything other than the default 0x70 to make the issue go away. With LEDs, how come I cant get the LEDs to turn completely off? If you want to turn the LEDs totally off use setpwm(pin, 4096, 0); not setpwm(pin, 4095, 0); I can't get this to work with my 7-segment LED display. The PCA9865 chip has an "All Call" address of 0x70. This is in addition to the configured address. This will cause an address collision if used with any other chip addressed to 0x70. Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 21 of 23

Downloads Files PCA9685 datasheet (http://adafru.it/okb) Arduino driver library (http://adafru.it/aql) EagleCAD PCB files on GitHub (http://adafru.it/rme) Fritzing object in the Adafruit Fritzing library (http://adafru.it/ap3) Schematic & Fabrication Print Adafruit Industries https://learn.adafruit.com/16-channel-pwm-servo-driver Page 22 of 23

Adafruit Industries Last Updated: 2016-10-07 04:59:19 PM UTC Page 23 of 23