Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Robot turning Erratically in auton... (http://www.chiefdelphi.com/forums/showthread.php?t=35129)

Moloch 21-02-2005 13:19

Robot turning Erratically in auton...
 
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

Re: Robot turning Erratically in auton...
 
Quote:

Originally Posted by Moloch
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

Re: Robot turning Erratically in auton...
 
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

Re: Robot turning Erratically in auton...
 
the PWM's are mixed up. swap them and it will solve your problems.

Moloch 23-02-2005 13:49

Re: Robot turning Erratically in auton...
 
Incorrect.

Ryan M. 23-02-2005 14:20

Re: Robot turning Erratically in auton...
 
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: :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

Re: Robot turning Erratically in auton...
 
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.


All times are GMT -5. The time now is 04:43.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi