Well the title of the thread actually isnt exactly my problem. Autonomous works however one of my functions doesn't work. We are trying to get our robot to rotate (a 0 degree turn). I'm using WPILib so we have to write totally new code.
Well anways here is the function Rotate():
Code:
void Rotate(char direction, int degrees, char speed)
{
int time = (1000 * (degrees/ 300));
char RightMotor = NEUTRAL + (speed * direction * (SPEED_TO_PWM));
char LeftMotor = NEUTRAL + (speed * direction * (SPEED_TO_PWM));
//the SPEED_TO_PWM = 127/10 which converts the speed to PWM value
printf("Rotate()\r");
SetPWM(LEFT_WHEEL, LeftMotor);
SetPWM(LEFT_FRONT_WHEEL, LeftMotor);
SetPWM(RIGHT_WHEEL, RightMotor);
SetPWM(RIGHT_FRONT_WHEEL, RightMotor);
printf("time: %d\r", time);
Wait(time);
SetPWM(LEFT_WHEEL, NEUTRAL);
SetPWM(LEFT_FRONT_WHEEL, NEUTRAL);
SetPWM(RIGHT_WHEEL, NEUTRAL);
SetPWM(RIGHT_FRONT_WHEEL, NEUTRAL);
//NEUTRAL = 127
}
now the main problem is the time. When I pass for example:
the time displays as 0. I find it really odd. However I ran time as a constant:
and the function worked perfectly. So the real problem here is one of the variables involved in the time equation and I dont know which one or what is wrong.
Any help would be appreciated