Hello all,
I am trying to use a PCA9685 driver to drive mutliple SG-90 servo motors. I am at a complete loss. When I run my code (attached below) the servos run smoothly when they are moving one at a time. But when I have two or more of them running at the same time they stop all together. All I want is simple 180 degree rotation in my servos, sometimes alone, most times together in unison. Here is my code, borrowed in tutorial by robojax on youtube.
/***************************************************
This is an example for our Adafruit 16-channel PWM & Servo driver
Servo test - this will drive 8 servos, one after the other on the
first 8 pins of the PCA9685
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/815
These drivers use I2C to communicate, 2 pins are required to
interface.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// you can also call it with a different address and I2C interface
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);
// Depending on your servo make, the pulse width min and max may vary, you
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN 120 // This is the 'minimum' pulse length count (out of 4096)(use135)
#define SERVOMAX 630 // This is the 'maximum' pulse length count (out of 4096)(use615)
// our servo # counter
uint8_t servonum = 0;
void setup() {
Serial.begin(9600);
Serial.println("16 channel Servo test!");
pwm.begin();
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
}
void loop() {
pwm.setPWM(0, 0, 135);
delay(500);
pwm.setPWM(1, 0, 135);
delay(500);
pwm.setPWM(2, 0, 135);
delay(500);
pwm.setPWM(3, 0, 135);
delay(500);
pwm.setPWM(0, 0, 615);
delay(500);
pwm.setPWM(1, 0, 615);
delay(500);
pwm.setPWM(2, 0, 615);
delay(500);
pwm.setPWM(3, 0, 615);
delay(500);
pwm.setPWM(0, 0, 135);
pwm.setPWM(1, 0, 135);
pwm.setPWM(2, 0, 135);
pwm.setPWM(3, 0, 135);
delay(1500);
pwm.setPWM(0, 0, 615);
pwm.setPWM(1, 0, 615);
pwm.setPWM(2, 0, 615);
pwm.setPWM(3, 0, 615);
delay(1500);
}
A diagram of my connections is attached. I didn't make it I borrowed it from brainybits on youtube but its the same thing.
The motors are 5 volt and approx. 270 millamp motors.
I am using a 5 volt, 4 amp power supply. Though my voltmeter reads 4.5 volts from the power supply, and for some reason the power the motors are pulling are around 3 volts and when the problem happens and they all stop the motors are pulling about .5 volts.
Does this issue sound familiar to anyone?