Tuning a PID Controller¶
These steps apply to position PID controllers. Velocity PID controllers typically don’t need .
Set , , and to zero.
Increase as much as possible without introducting jittering in the system response.
Plot the position setpoint, velocity setpoint, measured position, and measured velocity. The velocity setpoint can be obtained via numerical differentiation of the position setpoint (i.e., ). Increase until the position tracks well, then increase until the velocity tracks well.
If the controller settles at an output above or below the setpoint, one can increase such that the controller reaches the setpoint in a reasonable amount of time. However, a steady-state feedforward is strongly preferred over integral control (especially for PID control).
Adding an integral gain to the controller is an incorrect way to eliminate steady-state error. A better approach would be to tune it with an integrator added to the plant, but this requires a model. Since we are doing output-based rather than model-based control, our only option is to add an integrator to the controller.
Beware that if is too large, integral windup can occur. Following a large change in setpoint, the integral term can accumulate an error larger than the maximal control input. As a result, the system overshoots and continues to increase until this accumulated error is unwound.
The frc-characterization toolsuite can be used to model your system and give accurate Proportional and Derivative values. This is preferred over tuning the controller yourself.
A controller calculates its output based on the error between the reference and the current state. Plant in the real world don’t have unlimited control authority available for the controller to apply. When the actuator limits are reached, the controller acts as if the gain has been termporarily reduced.
We’ll try to explain this through a bit of math. Let’s say we have a controller where is the control effort, is the gain, is the reference, and is the current state. Let be the limit of the actuator’s output which is less than the uncapped value of and be the associated maximum gain. We will now compare the capped and uncapped controllers for the same reference and current state.
For the inequality to hold, must be less than the original value for . This reduced gain is evident in a system response when there is a linear change in state instead of an exponetial one as it approaches the reference. This is due to the control effort no longer following a decaying exponential plot. Onnce the system is closer to the reference, the controller will stop saturating and produce realistic controller values again.