Log in

View Full Version : Robot turning Erratically in auton...


Moloch
21-02-2005, 13:19
During auton mode, when given a turn command in the commands.h, all it does is spin around in circles...please help! We ship out tonight!

Jon236
21-02-2005, 17:04
During auton mode, when given a turn command in the commands.h, all it does is spin around in circles...please help! We ship out tonight!


Did you get it running with the original scripting code? I haven't been able to do that....

Jon

neilsonster
21-02-2005, 22:13
Your motors are either turning in the wrong direction or your gyro isn't calculating the bias properly. For us we had to give the gyro a second to get bias or else it would spit out an angle like 20 000 milliradians to turn (it spins in circles). Try adding in some extra wait time before calculating bias. If it works then decrease it as much as you can. Hope that helps

Kingofl337
22-02-2005, 11:33
the PWM's are mixed up. swap them and it will solve your problems.

Moloch
23-02-2005, 13:49
Incorrect.

Ryan M.
23-02-2005, 14:20
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:
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:
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: :D

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...

Joe Ross
23-02-2005, 16:07
I would assume that your encoders are working, since you didn't mention any problems with going straight. Is your gyro working is the first question.

Even with a working gyro, we had trouble with the turning code, I think it was because our encoders didn't give enough resolution to give good velocity control. With a few modifications we were able to get the code to turn with encoders working well enough. We're still working on turning with the gyro.