View Single Post
  #7   Spotlight this post!  
Unread 31-01-2008, 14:10
David Fort David Fort is offline
Registered User
FRC #1001
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2003
Location: Cleveland, OH
Posts: 26
David Fort is on a distinguished road
Re: Motor control for steering

Quote:
Originally Posted by DarKCroNo View Post
Okay I understand that part, but how do I implement PID onto easyC?, Sorry but it's our rookie year and I've been reading on PID control and all I've been getting are the theory but I don't understand how to code it with easyC
Our team is struggling also (but using MPLab), so take my advice with a grain of salt, but the equations for PID are really pretty simple. A lot of teams use the C code from Kevin Watson
http://frc.kevin.org/frc/2005/naviga...2005_01_08.zip

there are files pid.c and pid.h in that zip file. There is a newer flavor of the same on his web page too, but the zip format was corrupt when i downloaded it.

I suggest you just take the pid function and implement the same formula using expressions and variables in Easy C. I've only used Easy C for about an hour, so I won't pretend to know exactly how to do that, but I'm pretty sure it is straightforward.

The Hard part is getting the "tuning" right. The tuning tells your control system how Much to correct for a given error. If you correct too much, you overshoot, and then get an error the other way, which overshoots back to the original side, etc. If you correct too little, then the steering will lag the joystick significantly.

To further complicate life, there are 3 factors of interest, the P, I, and D factors, and each of them contributes a different problem.

If I figure out a good tuning strategy, i'll let you know. :-)
Generally, I think people start with I and D zero, then get P so that it doesn't oscillate out of control, then increase I until the control loop reaches the desired steady state value in a reasonable time. There are lots of texts on it and lots of variations on the control scheme, but the challenge I find is that you get such a short burst of test before the steering is locked all the way to one side. It would be easier if you could test the response to various steps without hitting the stop. I guess I've blurred the distinction between steering position control and steering velocity control (i.e. a pid controlling the speed that the steering wheel turns). As I recall Kevin Watson has a version for position as well as for velocity. Sometimes (e.g. in the industrial robot I worked on in the '80s) there are several layers - an "outer" layer, controlling Position, which results in a Desired Velocity to turn the motor to correct the Position, which then produces a Desired Acceleration, which then produces a desired Torque, which then produces a Desired Current. I think it reasonable to attempt the Position and Velocity layers in a FIRST robot, and you might think of the other parts as the job of the Victor speed controller.

Also fwiw, we are using the Globe motor as recommended earlier, and I find it to be way faster than necessary even though it has a gear reduction box. That might contribute to the difficulty we are having tuning, and I sometimes wish we were using one of the worm drive motors instead.

EDIT: I see on the vex forum, someone has posted something about PID in EasyC. I didn't read it, but perhaps it is worth a look: http://www.vexforum.com/showthread.php?t=1510

Last edited by David Fort : 31-01-2008 at 14:15. Reason: Add link to similar topic on Vex forum