Servos were trembling, especially when reaching 100% PWM duty cycle

Hi All,

I have a problem with controlling multiple servos. I use one Arduino Mega to control 20 servos(futaba s3305) with external power supply. But the servos started to tremble/shake, especially when they reached higher % of PWM duty cycle.
When the number of servos it supported reduced to 10, the servos became much stable.

More Details:

  • The servos are connected through digital signal pins.
  • <Servo.h> is used to control them.
  • I use 10 analog output pins for analog output and also, the shaking became more obvious when they reached higher % of PWM duty cycle.

Any idea about how to make servos not tremble will be well appreciated!!!

Thank you!!

I use 10 analog output pins for analog output

I don't know what you mean. Post your code.

arcticpenguin:
I have a problem with controlling multiple servos. I use one Arduino Mega to control 20 servos(futaba s3305) with external power supply. But the servos started to tremble/shake, especially when they reached higher % of PWM duty cycle.
When the number of servos it supported reduced to 10, the servos became much stable.

I found a note that says:

Futaba S3305 High Torque, Metal Gear Servo.
per Futaba this servo is approved for use with NiCd batteries ONLY!

This servo can produce high-current draw from your batteries.
If using NiMH or LiPo batteries, make sure they are capable
of delivering sufficient amps.

The NiCd is meant for vehicle use obviously, but it still emphasises that power draw may be excessive.

Are you sure the PS is up to the task? Have you measured the A loads directly?

If you want help, post your code..

jbarchuk:
The NiCd is meant for vehicle use obviously, but it still emphasises that power draw may be excessive.

Are you sure the PS is up to the task? Have you measured the A loads directly?

Thank you for your reply jbarchuk!
I haven't measured the current directly, but the PC power supply's specification says it can provide up to 40A for 5v, which I think is enough to support. And since I have little knowledge and experience about electronic control...Do you think there will be some unexpected problems caused by using PC power supply with correct volts and enough current instead of NiCD batteries mentioned on the page?
In addition, servos started to tremble when I set 20 output pins for servos signal(but 10 were connected), while remained stable when I set 10 output pins. So I think there're some problems with the number of Arduino signal output..

raschemmel:

I use 10 analog output pins for analog output

I don't know what you mean. Post your code.

Thank you for the reply and sorry for the delay raschemmel..!!

Here's the useful part of my code and hope it can explain my problem more clearly.
int fanGroup[ NUM ] = { 13, 10, 9, 8, 7};//, 6, 5, 4, 3, 2 };
int servoGroup1[ NUM ] = { 34, 35, 36, 37, 38};//, 39, 40, 41, 42, 43 };
int servoGroup2[ NUM ] = { 22, 23, 24, 25, 26};//, 27, 28, 29, 30, 31 };

In the loop() function, I update the output one by one when necessary:
for( int index = 0; index < NUM; index++ ) {
servoGroup1[ index ].write( value1 );
servoGroup2[ index ].write( value2);
analogWrite( fanGroup[ index ], value );
}

Analog output means that I am using analogWrite to control PWM fans. When I uncomment the additional pins above, i.e. 20 servo output and 10 fan output in total, the servos will start trembling(looks like that the output signal is not stable), but when I only use 10 servo output and 5 fan output, the system remains stable.

You don't 'talk' to servos with analogWrite() commands. You include the servo library and use servo write commands as in the
following example.

#include <Servo.h> 

Servo myservo;

void setup() 
{ 
  myservo.attach(9);
  myservo.write(90);  // set servo to mid-point
} 

void loop() {}

More info can be found here: http://arduino.cc/en/Reference/Servo

T

retrolefty:
You don't 'talk' to servos with analogWrite() commands. You include the servo library and use servo write commands as in the
following example.

#include <Servo.h> 

Servo myservo;

void setup()
{
  myservo.attach(9);
  myservo.write(90);  // set servo to mid-point
}

void loop() {}




More info can be found here: http://arduino.cc/en/Reference/Servo

Thank you retrolefty!
Yes I used <servo.h> to control servos. And analogWrite() is used for PWM fans control.
Do you think they could somehow influence each other?

Could be a conflict on internal timers used depending on what pins you are using for the servos and pwm fans. Again from the reference:

The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12.

retrolefty:
Could be a conflict on internal timers used depending on what pins you are using for the servos and pwm fans. Again from the reference:

Thank you retrolefty!
But in my setup, Arduino Mega is used and pin 11 and 12 are avoided.

Here's the distribution with trouble (while only 5 fans and 10 servos are connected):
10 pins for analogWrite()PWM: 2-10, 13
20 pins for servos: 22-31, 34-43

And the stable distribution is (Also, 5 fans and 10 servos are connected):
5 pins for analogWrite()PWM: 7-10, 13
10 pins for servos: 22-26, 34-38

The previous one, theoretically, should supported by Arduino Mega, according to the reference...but the servos were still shaking.

Servo PWM should never be anything close to 100% duty cycle.

Servo pulse length between 0.5 and 1.5 milliseconds and pulse spacing about 20 milliseconds.

retrolefty,
This sounds like a hardware issue.
@OP,
How about drawing a schematic by hand with pen and paper and take a photo with your cell phone. Get a multimeter and measure the voltage on your external power with one servo and then add the rest of the servos one at a time measuring the external supply voltage after each addition. Make sure you have a common GND. Post the schematic photo and the measurements. A photo of your circuit might be requested in the future if the situation doesn't improve.

Do you think there will be some unexpected problems caused by using PC power supply with correct volts and enough current instead of NiCD batteries mentioned on the page?

Very well could be. Start with a single servo or motor and see if it performs as expected. If so add more until the issue appears.