A lot of jitter while working with 6 heavy servos

Hi!

For a project I am working on a robot with 6 heavy torque servos. They work independently but together, even with just the startin position programmed, they jitter like hell. None of the motor does keep standing on the right spot and moving them is even harder. The one that has to move doesn't and the other jitter like hell. Does anyone know how to fix this? Is it code or hardware?

The servo's are joined and have a seperate powe supply of 5V3A. The arduino is just used for the PWM pins and the signals. The grounds and positives are connected in the external power supply.

Please help!

Is it code or hardware?

What code, what hardware ?

UKHeliBob:
What code, what hardware ?

I described the equipment in the text above, like how the servo's are connected. Or maybe you think that I am missing something like Capacitors. The code is here:

#include <Servo.h>

Servo head1; //hoofd omhoog en omlaag
Servo head2; //hoofd opzij
Servo elbow1;// rechter elleboog omhoog/omlaag
Servo elbow2;//linker elleboog omhoog/omlaag
Servo hand1;//rechterhand omhoog/omlaag
Servo hand2;//linkerhand omhoog/omlaag

int pos = 90;    // variable to store the servo position 

//afstandsmeter
const int influence = 150;
const int echoPin = 7;
const int trigPin = 8;
int maximumRange = 500;
int minimumRange = 0;
long duration, distance;

int obstacle = afstand();

void setup(){
head1.attach(11,1000, 2000);
head2.attach(10,1000, 2000);
elbow1.attach(9,1000, 2000);
elbow2.attach(6,1000, 2000);
hand1.attach(5,1000, 2000);
hand2.attach(3,1000, 2000);

//set everything to neutral position
  head1.writeMicroseconds(2000);
  head2.writeMicroseconds(1500);
  elbow1.writeMicroseconds(2000);
 elbow2.writeMicroseconds(2000);
  hand1.writeMicroseconds(2000);
  hand2.writeMicroseconds(2000);

//afstandssensor
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
}

void loop(){
  //delay(100);
  //afstand();  
  //Serial.println(distance);
  
  
 //head1.write(1000);
 //head1.write(2000);
  
 //delay(5000);
}



//afstandssensor
long afstand(){
  /* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */ 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 
 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;
 
 distance = constrain(distance, 0, 500);
 
 return duration / 58.2;
 
}

void neutralmovements(){
  
  // om zich heen kijken of er mensen zijn
  head1.writeMicroseconds(1300);
 // head2.writeMicroseconds(1000);
  delay(500);
  
 // head2.writeMicroseconds(2000);
  delay(500);
  
  //head2.writeMicroseconds(1500);
  delay(500);
  
  
  //krabben aan been/kruis met linkerhand
  //elbow2.writeMicroseconds(1100);
  delay(100);
  //elbow2.writeMicroseconds(1000);
  delay(100);
  //elbow2.writeMicroseconds(1100);
  delay(100);
  //elbow2.writeMicroseconds(1000);
  delay(100);
  
  delay(1000);
  
  //krabben aan linkerarm met rechterhand
  //hand1.writeMicroseconds(1900);
  delay(300);
  //hand1.writeMicroseconds(1700);
  delay(100);
  //hand1.writeMicroseconds(1900);
  delay(100);
  //hand1.writeMicroseconds(1000);
  
  delay(500);
  
  //nek kraken
  //head1.writeMicroseconds(1700);
  delay(200);
  //head1.writeMicroseconds(1100);
  delay(200);
  //head2.writeMicroseconds(1000);
  delay(200);
  //head2.writeMicroseconds(2000);
  delay(200);
  //head2.writeMicroseconds(1500);
  delay(200);
  head1.writeMicroseconds(1300);
  delay(200);
  
}

void influencedmovements(){
  //om zich heen kijken of er mensen zijn
  head1.writeMicroseconds(1300);
  //head2.writeMicroseconds(1000);
  delay(500);
  
  //head2.writeMicroseconds(2000);
  delay(500);
  
  //head2.writeMicroseconds(1500);
  delay(500);
  
  delay(500);
  
  // arm ophouden tegen lichtverandering
  //elbow2.writeMicroseconds(1800);
  delay(200);
  //hand2.writeMicroseconds(1900);
  delay(200);
  //head2.writeMicroseconds(1750);
  delay(200);
  //head2.writeMicroseconds(1650);
  delay(200);
  //head2.writeMicroseconds(1750);
  delay(200);
  
  //hand2.writeMicroseconds(1500);
  delay(200);
  //elbow2.writeMicroseconds(1300);
  delay(200);
  //hand2.writeMicroseconds(1000);
  delay(200);
  //elbow2.writeMicroseconds(1000);
  delay(200);
  
  //Arm op schouder
  //elbow2.writeMicroseconds(1250);
  delay(200);
  //hand2.writeMicroseconds(1850);
  delay(200);
  //head2.writeMicroseconds(1250);
  delay(200);
  
  //Weer kijken of iemand kijkt
 // head2.writeMicroseconds(2000);
  delay(200);
  //head2.writeMicroseconds(1500);
  delay(200);
  //head2.writeMicroseconds(2000);
  
  //linkerarm laten zakken
 // hand2.writeMicroseconds(1000);
  delay(300);
 // elbow2.writeMicroseconds(1000);
  delay(300);
  
  delay(500);
  
  // Arm vasthouden
 // hand1.write(1750);
  delay(200);
 
  //elbow1.write(1500);
  delay(200);
  
  delay(500);
  
}

3A supply isn't 1A per servo.... For heavy duty servos you may actually need 2 or 3A each.

So I suggest measuing the worst case current consumption of one servo, multiply that by 6, add 50%,
and use that to spec. your power supply.

It's not 100% clear (to me, anyhow) from the description if the Arduino ground is connected to the servo/servo power ground.

Nothing beats a schematic.....

I am using six Bluebird BMS 630 MG Servo's, but I can't find how much current they use. They work perfectly fine when tried seperately. The Arduino GND is connected with the servo GND. Together they are connected to the GND of the powersupply.

From the Blue Bird specification sheet

Idle 5ma
Moving 680ma
Stall 1800ma

source: http://joanna.iwr.uni-heidelberg.de/projects/SCHAUKEL2010/downloads/servo_daten.pdf

So 6 servos moving = 4.08 amp, and this number is likely unloaded, for loaded I would would say 1A per servo would probably be a fair estimate.

BH72:
From the Blue Bird specification sheet

Idle 5ma
Moving 680ma
Stall 1800ma

source: http://joanna.iwr.uni-heidelberg.de/projects/SCHAUKEL2010/downloads/servo_daten.pdf

So 6 servos moving = 4.08 amp, and this number is likely unloaded, for loaded I would would say 1A per servo would probably be a fair estimate.

That sounds fair, but I only use two at the maximum per time. Does that matter?

I only use two at the maximum per time.

  head1.writeMicroseconds(2000);
  head2.writeMicroseconds(1500);
  elbow1.writeMicroseconds(2000);
 elbow2.writeMicroseconds(2000);
  hand1.writeMicroseconds(2000);
  hand2.writeMicroseconds(2000);

Looks like 6 servos to me. You are not actually moving them in the code you posted but do not assume that they use zero current when not moving. Are the servos loaded at all, perhaps being pushed/pulled/rotated and having to maintain their position ?

BH72:
From the Blue Bird specification sheet

Idle 5ma
Moving 680ma
Stall 1800ma

source: http://joanna.iwr.uni-heidelberg.de/projects/SCHAUKEL2010/downloads/servo_daten.pdf

So 6 servos moving = 4.08 amp, and this number is likely unloaded, for loaded I would would say 1A per servo would probably be a fair estimate.

6 servos = 6 x stall current, so ~12A supply recommended if you want all of them operating
together trouble free. And check what voltage that stall current is for too (and then go measure
it because the specs are likely wrong for a hobby servo).

People usually run servos from batteries because the load is so spikey - an SLA 6V battery will
handle the peaks with ease and can be charged at a much more reasonable current level.

I read something about capacitors on the internet. We've measured the current of the servo's and it was enough fot the supply. And I've measured the moments when the motors ask for the most current - while in action.

I've decided to apply some capacitors (1000uF) between the + and - of the servo's, and tried it with a sweep funtion for six motors. Luckily, it worked perfectly and no jitter at all!

So question solved!

So question solved!

Problem solved maybe, but what exactly was the problem and have you just papered over the cracks instead of solving it ? As adding the caps makes the servos stop jittering I suspect that the real problem was voltage sag due to the amount of current being drawn.