Hello,
I’m building a quadrapod using 8 servos (the GWS S03T STD) and an Orangutan SVP-324. Right now, I’m working on the program that will control the forward walking motion, but there is a problem.
The following program I’m using is for switching between the different servos, and then determining their ranges and which directions I need the servos to rotate, by using the middle and bottom buttons to increase/decrease the servo rotation. The top button changes servos.
int main()
{
const int NUM_SERVOS = 8;
const unsigned char DEMUX_PINS[] = {IO_B3, IO_B4, IO_C0}; // 8 servos
const int MIN_SERVO_POSITION = 750;
const int NEUTRAL_SERVO_POSITION = 1500;
const int MAX_SERVO_POSITION = 2250;
int servo = 0; // current servo
int servoPositions[NUM_SERVOS]; // current positions of all servos
int i;
// wait for top button before doing anything
clear();
print("Press TOP btn");
lcd_goto_xy(0, 1);
print_long(read_battery_millivolts_svp());
print("mV");
wait_for_button_press(TOP_BUTTON);
wait_for_button_release(TOP_BUTTON);
// initialize the demux for 8 servos
servos_start(DEMUX_PINS, sizeof(DEMUX_PINS));
// put the servos into a neutral position
for(i = 0; i < NUM_SERVOS; i ++)
{
set_servo_speed(i, 150);
set_servo_target(i, NEUTRAL_SERVO_POSITION);
servoPositions[i] = NEUTRAL_SERVO_POSITION;
}
// main loop
while(1)
{
// print information about the current servo
lcd_goto_xy(0, 0);
print("Servo ");
print_long(servo);
print(": ");
print_long(servoPositions[servo]);
print(" "); // put in a blank so we don't have to clear the screen
lcd_goto_xy(0, 1);
print("Top: next servo ");
// top button changes servo
if(button_is_pressed(TOP_BUTTON))
{
servo ++;
if(servo >= NUM_SERVOS)
{
servo = 0;
}
wait_for_button_release(TOP_BUTTON);
}
// middle button increases servo position
if(button_is_pressed(MIDDLE_BUTTON))
{
servoPositions[servo] ++;
if(servoPositions[servo] > MAX_SERVO_POSITION)
{
servoPositions[servo] = MAX_SERVO_POSITION;
}
set_servo_target(servo, servoPositions[servo]);
}
// bottom button decreases servo position
if(button_is_pressed(BOTTOM_BUTTON))
{
servoPositions[servo] --;
if(servoPositions[servo] < MIN_SERVO_POSITION)
{
servoPositions[servo] = MIN_SERVO_POSITION;
}
set_servo_target(servo, servoPositions[servo]);
}
}
}
I’ve connected the IO lines B3, B4, and C0 to SA, SB, and SC, respectively. The servos are powered from VADJ, adjusted to 6v.
The program works as expected, with one exception - the servos, being at any position other than neutral, begin jittering quite severely, as if servo target positions are occasionally being sent to the wrong servo. The eight-servo demo program works perfectly fine and does not jitter.
I’ve looked into this as best I can, but unfortunately, cannot find a cause for this problem. Would someone be able to shed some light on this? Thanks.
Geoff