Quote:
|
Originally Posted by Moloch
Incorrect.
|
I'm not sure who you're saying was incorrect, but turning one of the cables around would definetly solve your problem, but it's most likely not the solution you want. (Because you, I assume, have it working correctly under normal driver control.)
What I would do is go into pid.c and and find the function called pid(). Down at the bottom of that function, find these lines:
Code:
switch (motor)
{
case LEFT:
{
wheel_l = (unsigned char)(PWM_ZERO + LEFT_DIR * motor_info[left].pwm);
break;
}
case RIGHT:
{
wheel_r = (unsigned char)(PWM_ZERO + RIGHT_DIR * motor_info[right].pwm);
break;
}
default:
{
printf("Unknown motor");
break;
}
}
For which ever motor is running the wrong way, take the value they are currently assigning to it and subtract it from 255. IE, if you're left motor is the one running backward:
Code:
switch (motor)
{
case LEFT:
{
wheel_l = 255 - (unsigned char)(PWM_ZERO + LEFT_DIR * motor_info[left].pwm);
break;
}
case RIGHT:
{
wheel_r = (unsigned char)(PWM_ZERO + RIGHT_DIR * motor_info[right].pwm);
break;
}
default:
{
printf("Unknown motor");
break;
}
}
Yep... and I just read your post and discovered that it spins in circles when you tell it to turn. So I'll leave that because it may help someone else, but now for my new answer:
You're probably going so fast that your encoders are missing clicks. If you're not using interrupts, you have a fairly limited ability to see state changes...