![]() |
PID loops using rate
Hey,
We're trying to get our PID loops to control the motors' rate, as opposed to their distance. Here is our code: Code:
//Initializes the motors. |
Re: PID loops using rate
Quote:
I would need to study the WPIJ PID class to see what its actually doing... to see if it clips the values, helps with integral windup and other control stuff to give you a complete answer... but off the bat, how did you get your gains? Your setPoint is 1000 so your first iteration is 1000*0.1 = 100, because PWM only accepts +1 to -1 as inputs to the motor controllers.that instantly drives your motor to full power. I am not sure what the units of your 1000 but if your motor can spin faster than that, then your gains will cause your motor to oscillate... try reducing your gains. |
Re: PID loops using rate
Quote:
|
Re: PID loops using rate
My understanding is that the standard PID controller is set up to apply motor speeds to reach a certain distance. In this scenario, the end value goes to 0 when the target is reached.
For a rate controlled system, the end value is not 0 (you don't want your motor power to go to 0 when you achieve the desired rate). So, what we have been doing is trapping the pidWrite() method (if you extend PIDSource) or usePIDOutput() method (if you extend PIDSubSystem). We then use the value passed in by the PID control loop as a "adjustment" to the current motor power. For example: Code:
/** |
Re: PID loops using rate
2013 FRC WPILib (at least for Java) has added a feedforward term to the PIDController to help support using the library PID for speed control. So this gives you other options. Instead of integrating the PID output, you can set your feedforward gain so that the feedforward motor command corresponds roughly to what you'd expect is required for the speed you are commanding. Then tune the PID with I only (set P and D to zero) to get the steady-state accuracy. |
| All times are GMT -5. The time now is 10:06. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi