View Single Post
  #2   Spotlight this post!  
Unread 13-02-2012, 12:03
baronep's Avatar
baronep baronep is offline
Student President
FRC #2848 (Jesuit All-Sparks)
Team Role: Leadership
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Dallas TX
Posts: 167
baronep is on a distinguished road
Re: using the pid module

Because I could not tell from your post, I am assuming that you have no prior knowledge of PID.

First of all, I would suggest using the accelerometer and not the gyro to balance your robot. Search Chief Delphi or the NI FRC examples to determine how that works, there is plenty of material available.

As far as PID goes, there are several inputs to that you must provide in order to get an output. Fist is the process variable, this is the sensor reading (filterer, scaled or unfiltered. You just have to experiment to figure out which gives you the cleanest results). Then you have the setpoint which is the value that you want your process variable to go to. Make sure that any scaling that you do to the PV (process variable), you also do to to setpoint. Then you have something along the lines out output range which is generally [-1,1] or [0,1], depending if you want your motor to run backwards to slow itself down. (You would probably want [0,1].

Then the most interesting part, the PID gains. You need to create a cluster control or constant which then has 3 inputs. The P, I and D coefficients. Changing these coefficents is known as tuning the PID loop. Search Chief Delphi on how to do this, there is a lot of good advice out there.

Finally, you can use the output of the PID function to control your motor speed.

Honestly the hardest parts of this is A) getting a clean enough input and B) getting the PID gains set correctly. If you find that the gains are at the very bottom of the accepted input values (ex. P=.001 is still unstable), try dividing both the PV and setpoint by 10 or 100. Then you can change P to .01 or .1 respectively. Then go from there.

Hope this helps
Reply With Quote