Adafruit Motor Shield v2.0 Servo Control via I2C Interface
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- vierkant
- Posts: 2
- Joined: Fri Aug 29, 2014 12:57 pm
Adafruit Motor Shield v2.0 Servo Control via I2C Interface
I just purchased the Adafruit Motor Shield v2.0 kit for servo control. While the board provides direct servo PWM connection to the Arduino via pins 9/10, I purchased the board to take advantage of the I2C interface and thereby offload PMW control to the board- instead of PWM management in the Arduino Mega 2560. I purchased the board based on the Adafruit website discussion of Servo control where it states "... The nice thing about using the onboard PWM is that its very precise and goes about its business in the background. You can use the built in servo library.". However, the onboard PWM chips receive commands via the PCA chip that processes I2C commands and the built in servo library does not use the I2C but manages Arduino pins directly. Is there a library for I2C servo control using the Adafruit board?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motor Shield v2.0 Servo Control via I2C Interfa
The PCA9685 has 16 channels, and not all of them are used by the motor shield. The spare pins are brought out near the prototyping area on the board (see the arealabeled "PWMs"on the upper right of the photo below), so you could wire up some servos there. The Adafruit_PWMServoDriver.h library you are currently using in conjunction with the Adafruit_MotorShield.h library will allow you to drive those spare channels.
There is also a dedicated PWM/Servo shield based on the same chip: https://www.adafruit.com/product/1411
It uses the same library.
There is also a dedicated PWM/Servo shield based on the same chip: https://www.adafruit.com/product/1411
It uses the same library.
- vierkant
- Posts: 2
- Joined: Fri Aug 29, 2014 12:57 pm
Re: Adafruit Motor Shield v2.0 Servo Control via I2C Interfa
Thank you for the response. That is the path I was planning on going down- using one of the spare PWM outputs. I had looked at the dedicated 1411 product, as well. Unfortunately, MicroCenter did not have that one in stock and I do need a small amount of prototyping space and a stackable shield.
I note the library has the capability to control speed of both DC and stepper motors- nice to have. But, I don't see a corresponding speed command for servos. Is there a servo speed function?
My current sketch uses the VarSpeedServo library which works pretty well. But, as noted in the original post, I'm trying to offload as much servo management to the Adafruit PWM control as I can and it would be nice to have speed control as well.
I note the library has the capability to control speed of both DC and stepper motors- nice to have. But, I don't see a corresponding speed command for servos. Is there a servo speed function?
My current sketch uses the VarSpeedServo library which works pretty well. But, as noted in the original post, I'm trying to offload as much servo management to the Adafruit PWM control as I can and it would be nice to have speed control as well.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motor Shield v2.0 Servo Control via I2C Interfa
To use the motor shield, you include 3 libraries, one of which is the PWM Servo library:
Usage of the library for servo control is described here:
https://learn.adafruit.com/adafruit-16- ... it-library
Code: Select all
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
https://learn.adafruit.com/adafruit-16- ... it-library
Please be positive and constructive with your questions and comments.