Hello, I´m trying to use two herkulex 0101 servos with the library of this site: Dongbu Herkulex Arduino Library « Robottini using an Arduino Mega. I can communicate with the servos and get feedback normally, these things are okay, but the problem is that when I put in the continous rotation mode one servo is slightly faster than the other (5% I think) and I would be very happy if someone figured out the reason why(The margin shouldn´t be under the 1% because of the PID and other algorithms of speed control of the motor?). I also put the code.
PS: I don´t know why the Herkulex.torqueON and torqueOFF stands for, i cant see any differences in the motor.
#include <Herkulex.h>
void setup()
{
delay(2000); //a delay to have time for serial monitor opening
Serial.begin(115200); // Open serial communications
Serial.println("Begin");
Herkulex.beginSerial2(115200); //open serial port 1
//Herkulex.set_ID(253, 252);
Herkulex.torqueOFF(252);
Herkulex.torqueOFF(253);
Herkulex.reboot(252); //reboot first motor
Herkulex.reboot(253); //reboot second motor
delay(500);
Herkulex.initialize(); //initialize motors
// read status
Serial.println("");
Serial.print("Status1:");
Serial.println(Herkulex.stat(252));
Serial.print("Status2:");
Serial.println(Herkulex.stat(253));
// move servos in continous rotation at unison
Serial.println("");
Serial.println("MoveSpeedALL ");
Herkulex.moveSpeedAll(253,300,1);
Herkulex.moveSpeedAll(252,300,1);
Herkulex.actionAll(672);
delay(2500);
// move all to position
Serial.println("");
Serial.println("Move All to position");
Serial.println("Move Position1: 200");
Serial.println("Move Position2: 420");
Herkulex.moveAll(253, 200, 2); //move to position 200
Herkulex.moveAll(252, 420, 2); //move to position 820
Herkulex.actionAll(1000); //start movement in 1500 milliseconds
delay(1100);
Serial.print("Get Position servo 1:");
Serial.println(Herkulex.getPosition(253)); //get position
Serial.print("Get Position servo 2:");
Serial.println(Herkulex.getPosition(252));//get position
delay(10);
// move all to angle
Serial.println("");
Serial.println("Move All to Angle");
Serial.println("Move Angle1: 120.5 degrees");
Serial.println("Move Position2: -120.5 degrees");
Herkulex.moveAllAngle(252, 120.5, 2);;
Herkulex.moveAllAngle(253, -120.5, 2);
Herkulex.actionAll(2000);
delay(2100);
Serial.print("Get Angle1:");
Serial.println(Herkulex.getAngle(252));
Serial.print("Get Angle2:");
Serial.println(Herkulex.getAngle(253));
Herkulex.setLed(252,LED_PINK); //set the led
Herkulex.setLed(253,LED_GREEN2); //set the led
delay(1000);
for(int contador = 0; contador < 15; contador++){
Herkulex.moveSpeedOne(252, 1000, 0, 2);
Herkulex.moveSpeedOne(253, 1000, 0, 2);
delay(700);
Herkulex.moveSpeedOne(252, -1000, 0, 2);
Herkulex.moveSpeedOne(253, -1000, 0, 2);
delay(700);
}
Herkulex.moveSpeedOne(252, 0, 0, 2);
Herkulex.moveSpeedOne(253, 0, 0, 2);
delay(5000);
while(1){
Herkulex.moveSpeedOne(252, 1000, 0, 2);
Herkulex.moveSpeedOne(253, 1000, 0, 2);
}
Herkulex.end();
}
void loop(){
}