iacoposk8:
How many answers, thanks guys!
Sorry for the delay in the answer.
In the end the problem was just mechanical, I have this hub:

and I can screw it in 4 different positions, I thought they were all the same, but no.
Now I have this problem (see link): same servomotor, same configuration in attach, but one has a greater excursion than the other, why?
#include <Servo.h>
const int n_servo = 3;
Servo servo[n_servo];
void moveTo(int n_sync, int idx[], int degree[]){
int count_success = 0;
while(count_success < n_sync){
count_success = 0;
for(int i = 0; i < n_sync; i += 1){
int pos = servo[idx[i]].read();
if(pos < degree[i]){
pos += 1;
}
if(pos > degree[i]){
pos -= 1;
}
if(pos == degree[i]){
count_success += 1;
} else {
servo[idx[i]].write(pos);
}
}
delay(10);
}
}
int idx[] = {0};
int deg[] = {0};
void setup()
{
servo[1].attach(4,570,2300);
servo[2].attach(5,570,2300);
deg[0] = 0;
deg[1] = 0;
deg[2] = 180;
moveTo(3, idx, deg);
delay(1000);
deg[0] = 180;
deg[1] = 180;
deg[2] = 0;
moveTo(3, idx, deg);
delay(1000);
deg[0] = 90;
deg[1] = 90;
deg[2] = 90;
moveTo(3, idx, deg);
delay(1000);
}
Wow! You just discovered a fundamental law of mechanical engineering! Without FEEDBACK, you can never synchronize two or more motions.
Your only feedback is you eyeballs noticing the moving arms don't keep up the same movement. No feedback to the servos.
If you actually expect this to work in synchronization, you must have one servo electronics control both motors, or design a system so the second servo is aware of the position of the first servo and adjust it's movement to correspond to the first servo.
Paul