0

PCA9685 and 15 servos
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PCA9685 and 15 servos

by RM_1 on Sat Sep 25, 2021 12:27 pm

Hi,

I've hooked up 15 servos (Towerpro MG996R) to your PCA9685 and an Arduino Uno.
I'm powering the servos 6.4 v with a 10A power source through the V+ pin.
The Servo example in your library works fine, moving one servo at a time.
But when I try to sweep all the servos together I run into problems.
I'm using the following code:
Code: Select all | TOGGLE FULL SIZE

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();


#define Min  150
#define Max  500

int pulselen;
int myservo;

void setup() {

  Serial.begin(9600);
  pwm.begin();

  pwm.setOscillatorFrequency(27000000);
  pwm.setPWMFreq(50);  // Analog servos run at ~50 Hz updates

  delay(10);

}

void loop() {

  for ( pulselen = Min; pulselen < Max; pulselen += 2) {

      for (myservo = 0; myservo < 15; myservo++) {

      pwm.setPWM(myservo, 0, pulselen);

     delay(5);
      }
      }

      for (pulselen = Max; pulselen > Min; pulselen -=2 ) {

      for (myservo = 0; myservo < 15; myservo++){
      pwm.setPWM(myservo, 0, pulselen);

      delay(5);
      }
      }
 
}


Without the "delay" , some move, others won't. No clean sweep.
Incrementing the "pulselen" by 2, servos sweep real slowly and any higher value gives strange results. i.e. some servos move, some don't and some jump.
I need to be able to sweep all the servos together, much faster and with different speeds.
Appreciate your help.

RM_1
 
Posts: 5
Joined: Sat Sep 25, 2021 11:57 am

Re: PCA9685 and 15 servos

by adafruit_support_bill on Sun Sep 26, 2021 6:44 am

Without the "delay" , some move, others won't. No clean sweep.

A high-torque servo like the MG996 can pull several amps at the start of a move. If you are trying to move 15 of them concurrently with a 10A supply, you are probably seeing some voltage sag from the supply.

I need to be able to sweep all the servos together, much faster and with different speeds.

There is a tutorial on that here:
https://learn.adafruit.com/multi-taskin ... ino-part-1
https://learn.adafruit.com/multi-taskin ... ino-part-2

adafruit_support_bill
 
Posts: 82093
Joined: Sat Feb 07, 2009 10:11 am

Re: PCA9685 and 15 servos

by RM_1 on Sun Sep 26, 2021 9:48 am

The MG996 data sheet says:

RM_1
 
Posts: 5
Joined: Sat Sep 25, 2021 11:57 am

Re: PCA9685 and 15 servos

by RM_1 on Sun Sep 26, 2021 9:56 am

Thank you,
So it's power source problem ?
The MG996 data sheet says: current draw idle = 10 mA, no load operating current draw is 170 mA and stall current draw = 1,400 mA.
I'm testing with no load and I thought a 10A power source should do the job.
What would I need to solve my problem ? Any suggestion please ?

RM_1
 
Posts: 5
Joined: Sat Sep 25, 2021 11:57 am

Re: PCA9685 and 15 servos

by adafruit_support_bill on Sun Sep 26, 2021 7:46 pm

Tower specs tend to be optimistic. Nevertheless, startup current is the same as stall current until the servo starts moving. So 15 x 1.4A = 21A. If you command all servos to start at the same time, you will still overload your power supply.

A simple test is to run the same program, but only connect 4 or 5 servos. If that runs OK, add some more. Keep adding servos until you see problems. That will be the limit of your power supply's ability to cope.

adafruit_support_bill
 
Posts: 82093
Joined: Sat Feb 07, 2009 10:11 am

Re: PCA9685 and 15 servos

by RM_1 on Mon Sep 27, 2021 3:08 am

Actually I had done as your suggestion, adding a motor one at a time. I got to 15 and they all swept.
I ran into problem when I tried sweeping them faster, my first post.
So I suppose faster moves, more current draw ?!?

I'm thinking of dividing the servos, daisy chaining 3 PCA9685 and using 3 power supplies.
Would that be a good solution ?

Thanks.

RM_1
 
Posts: 5
Joined: Sat Sep 25, 2021 11:57 am

Re: PCA9685 and 15 servos

by adafruit_support_bill on Mon Sep 27, 2021 6:51 am

So I suppose faster moves, more current draw ?!?

Yes. The output filter caps on your power supply can fill in for brief current spikes. But they need some time to recover. If the spikes are coming fast and furious, the output voltage will start to sag.

I'm thinking of dividing the servos, daisy chaining 3 PCA9685 and using 3 power supplies.
Would that be a good solution ?

Probably. I'd start by reducing the number of servos on your current setup to find out how many servos each supply can drive at the speeds you need.

adafruit_support_bill
 
Posts: 82093
Joined: Sat Feb 07, 2009 10:11 am

Re: PCA9685 and 15 servos

by RM_1 on Tue Sep 28, 2021 6:40 am

Thanks Bill, I'll do some testing and will post results.

RM_1
 
Posts: 5
Joined: Sat Sep 25, 2021 11:57 am

Please be positive and constructive with your questions and comments.