View Single Post
  #2   Spotlight this post!  
Unread 04-02-2013, 18:44
IDKnow IDKnow is offline
Registered User
FRC #1671
 
Join Date: Feb 2013
Location: California
Posts: 8
IDKnow is an unknown quantity at this point
Re: PID Controller Class WPI

The following is an approximation of how PID works.

Situation:
Say you have a motor you need running at 2000 rpm. You use an encoder to check the speed of the motor and if it's too high you lower the voltage; if it is too low you raise the voltage. Say I do so by 1 V every time. This will most likely result in fluctuating above and below the target speed.
Proportion:
To avoid the above issue, proportion takes the 'error,' or difference from the target speed and 'proportionally' approaches it. For example, a 'P' value of .5 with an error of 1000rpm at 0V will ramp up in the next cycle to half the required power to make up the difference, and the cycle after, and so on.
Integral:
The proportion will only make you approach the target speed. It's like Zeno's Paradox. Integral will solve this by adjusting the proportion up.
Derivative:
This is a response value. If the speed drops, or rises suddenly then this will rapidly make up the drop or lower V to counter a rise. This will not, however, assist in the initial approach to the target speed.

Not all of the control options are required in a PID loop.

Obviously you could code one yourself but it'd be slow.

To find good PID values I suggest you use the BDC Com provided by first. The class you need can be found in the WPI library. If after significant trial with this you need help, inform me and I'll drop some hints. Finally, the CANJaguar class allows you to do PID without using the CIRO to do it. This is the primary benefit of jaguars. CANJags are hooked up differently than Jags are otherwise. Also, they are coded different and need to be imaged. The class is available in the WPI Library and you can ask someone else about imaging it.

Rather you use your own PID code, the PID Class, or PID with CANJags, best of luck. Again, the CANjags are probably the best option.
Reply With Quote