Hello,
I am using maestro 24 servo controller, since today i have used it to drive 12 analog servo motors (Hitec HS-645MG), and it was ok, but i have upgraded my hexapod robot by adding addition DoF per leg . new servos are more powerful digital Hitec HS-5645MG. After connecting all 18 servos they started to behave odd. To contact with servos i am using UART at 115200 baudrate and i am using pololu protocol to write to all servos at once. When running code, servos more-or less follow the commands but they are sometimes making uncontrollable, weird motions. When i run 4 legs (12 servos, 8 analog, 4 digital) and set rest of servos to fixed neutral position, code is executed correctly. after attaching any more servos , all of the servos are acting badly.
Function used to send commands to maestro
int maestroSet18Targets(int fd, unsigned short target0, unsigned short target1,
unsigned short target2, unsigned short target3,
unsigned short target4, unsigned short target5,
unsigned short target6, unsigned short target7,
unsigned short target8, unsigned short target9,
unsigned short target10, unsigned short target11,
unsigned short target12, unsigned short target13,
unsigned short target14, unsigned short target15,
unsigned short target16, unsigned short target17)
{
target0 = SetAngle(target0); target1 = SetAngle(target1); target2 = SetAngle(target2);
target3 = SetAngle(target3); target4 = SetAngle(target4); target5 = SetAngle(target5);
target6 = SetAngle(target6); target7 = SetAngle(target7); target8 = SetAngle(target8);
target9 = SetAngle(target9); target10 = SetAngle(target10); target11 = SetAngle(target11);
target12 = SetAngle(target12); target13 = SetAngle(target13); target14 = SetAngle(target14);
target15 = SetAngle(target15); target16 = SetAngle(target16); target17 = SetAngle(target17);
unsigned char command[] = { 0xAA, 0xC, 0x1F, 0x12, 0, target0 & 0x7F, target0 >> 7 & 0x7F ,
target1 & 0x7F, target1 >> 7 & 0x7F ,
target2 & 0x7F, target2 >> 7 & 0x7F ,
target3 & 0x7F, target3 >> 7 & 0x7F ,
target4 & 0x7F, target4 >> 7 & 0x7F ,
target5 & 0x7F, target5 >> 7 & 0x7F ,
target6 & 0x7F, target6 >> 7 & 0x7F,
target7 & 0x7F, target7 >> 7 & 0x7F,
target8 & 0x7F, target8 >> 7 & 0x7F,
target9 & 0x7F, target9 >> 7 & 0x7F ,
target10 & 0x7F, target10 >> 7 & 0x7F,
target11 & 0x7F, target11 >> 7 & 0x7F,
target12 & 0x7F, target12 >> 7 & 0x7F,
target13 & 0x7F, target13 >> 7 & 0x7F,
target14 & 0x7F, target14 >> 7 & 0x7F,
target15 & 0x7F, target15 >> 7 & 0x7F,
target16 & 0x7F, target16 >> 7 & 0x7F,
target17 & 0x7F, target17 >> 7 & 0x7F
};
if (write(fd, command, sizeof(command)) == -1)
{
mvprintw(10, 10, "Maestro err wriring");
refresh();
return -1;
}
return 0;
}
int SetAngle(double angle)
{
if (angle > 180 || angle < 0)
return 6000;
else
{
angle = angle / 180.0;
angle = angle * 1800.0 + 600.0;
angle = angle * 4;
return (int)angle;
}
}