Tuning a PID Controller (or why linear systems theory is incredible)
Setup
Consider a double integrator:
where the object has a mass , and we apply the control input .
Suppose a PD controller is used to control this system:
Assuming , the closed-loop system has a transfer function
This makes it a second order linear system, of the form
using the map:
Analysis
We can now analyze a few things about this system:
- the closed loop response (i.e. solution to such that ) is
where and .
- the rise time (defined as the first time that ):
- the overshoot (defined as the maximum value reached minus one):
There are other properties you can analyse, see Ref 1.
Design
Notice that there are two design parameters in the controller: .
Therefore, if the overshoot and the rise time are specified, the controller gains can be determined, as follows:
1) Using the overshoot formula, determine :
2) Using the rise time, choose :
3) Using , determine :
4) Using , determine :
Examples
Matlab Code:
%% inputs
m = 1.0; % mass of system
M = 0.10; % overshoot
tr = 0.4; % rise time
%% outputs
xi = -(log(M)/sqrt(pi^2 + (log(M))^2))
omega_n = (2* atan(sqrt((1 + xi)/(1 - xi))))/(sqrt(1 - xi^2) * tr )
kx = m * omega_n^2
kv = 4 * xi^2 * sqrt(m * kx)
For kg:
:
100 ms | 200 ms | 500 ms | 1 s | 2 s | |
---|---|---|---|---|---|
1% | 2.04E+03 | 5.09E+02 | 8.14E+01 | 2.04E+01 | 5.09E+00 |
5% | 1.04E+03 | 2.60E+02 | 4.15E+01 | 1.04E+01 | 2.60E+00 |
10% | 7.46E+02 | 1.87E+02 | 2.98E+01 | 7.46E+00 | 1.87E+00 |
20% | 5.28E+02 | 1.32E+02 | 2.11E+01 | 5.28E+00 | 1.32E+00 |
50% | 3.35E+02 | 8.38E+01 | 1.34E+01 | 3.35E+00 | 8.38E-01 |
:
100 ms | 200 ms | 500 ms | 1 s | 2 s | |
---|---|---|---|---|---|
1% | 1.23E+02 | 6.16E+01 | 2.46E+01 | 1.23E+01 | 6.16E+00 |
5% | 6.14E+01 | 3.07E+01 | 1.23E+01 | 6.14E+00 | 3.07E+00 |
10% | 3.82E+01 | 1.91E+01 | 7.64E+00 | 3.82E+00 | 1.91E+00 |
20% | 1.91E+01 | 9.55E+00 | 3.82E+00 | 1.91E+00 | 9.55E-01 |
50% | 3.40E+00 | 1.70E+00 | 6.80E-01 | 3.40E-01 | 1.70E-01 |
Here are a few starting points for PID tuning:
0.25 | 0.5 | 18.8 | 2.83 |
0.25 | 1.0 | 4.714 | 1.42 |
0.125 | 0.5 | 26.7 | 6.29 |
0.125 | 1.0 | 6.68 | 3.14 |
As a rough gauge of the control input required, the peak control input is likely to be at the very start, where the control input is . So by looking at the term, we can get a sense of the order of magnitude of the control input for a step input.
References:
- https://courses.engr.illinois.edu/ece486/fa2019/handbook/lec06.html