Alright, while working on a demo for my project I found something strange, all of the servos are hooked up the same way, number 4 and 5 always rotate the same direction and they are modified, numbers 1 through 3 all rotate clockwise then reset, but number 0 goes the opposite direction, the other 3 servos are hitec, while the first one is from parallax, is this what the problem is?
int i;
for(i=0;i<150;i++)
{
PORT_ON(PORTD,7);
delay_cycles(25);
PORT_OFF(PORTD,7);
delay_cycles(200);
}
while(1)
{
for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(20);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);
PORT_ON(PORTD, 1);
delay_cycles(20);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);
PORT_ON(PORTD, 2);
delay_cycles(20);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);
PORT_ON(PORTD, 3);
delay_cycles(20);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);
PORT_ON(PORTD, 4);
delay_cycles(20);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);
PORT_ON(PORTD, 5);
delay_cycles(20);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);
for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(25);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);
PORT_ON(PORTD, 1);
delay_cycles(25);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);
PORT_ON(PORTD, 2);
delay_cycles(25);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);
PORT_ON(PORTD, 3);
delay_cycles(25);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);
PORT_ON(PORTD, 4);
delay_cycles(25);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);
PORT_ON(PORTD, 5);
delay_cycles(25);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);
for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(30);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);
PORT_ON(PORTD, 1);
delay_cycles(30);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);
PORT_ON(PORTD, 2);
delay_cycles(30);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);
PORT_ON(PORTD, 3);
delay_cycles(30);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);
PORT_ON(PORTD, 4);
delay_cycles(30);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);
PORT_ON(PORTD, 5);
delay_cycles(30);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);
for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(35);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);
PORT_ON(PORTD, 1);
delay_cycles(35);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);
PORT_ON(PORTD, 2);
delay_cycles(35);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);
PORT_ON(PORTD, 3);
delay_cycles(35);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);
PORT_ON(PORTD, 4);
delay_cycles(35);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);
PORT_ON(PORTD, 5);
delay_cycles(35);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);
for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(40);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);
PORT_ON(PORTD, 1);
delay_cycles(40);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);
PORT_ON(PORTD, 2);
delay_cycles(40);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);
PORT_ON(PORTD, 3);
delay_cycles(40);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);
PORT_ON(PORTD, 4);
delay_cycles(40);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);
PORT_ON(PORTD, 5);
delay_cycles(40);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);
/* Servo Test Code
i=250;
while(i>0)
{
servo_left(40);
i--;
}
i=250;
while(i>0)
{
servo_left(24);
i--;
}
*/
//rprintf("Initialization Complete\r\n");
//output message to serial (use hyperterminal)
//print("Hello, World! Read My Analog: %u\r\n", sensor_0);
//delay_cycles(500);//a small delay to prevent crazy oscillations
}
/*********ADD YOUR CODE ABOVE THIS LINE **********/
return 0;
}