Output Feedback Control and PID Control
Table of Contents
Reference
Consider the constant gain plant $G$
So far, we have learnt about dynamics of plant $G$
If $G = \frac{1}{s}$
The open loop system cannot change the poles of system (Stability)
Predicting models incorrectly has a critical impact on speed (Uncertainty, Low Robustness)
Disturbance directly affects the system (Disturbance rejection)
The closed loop system can change the poles of system (Stability)
Model uncertainty has a reduced impact on speed (Uncertainty, Robustness)
Disturbance little affects the system (Disturbance rejection)
For the car model
In a block diagram
In a Laplace transform
We want to achieve
The proportional term produces an output value that is proportional to the current error value. The proportional response can be adjusted by multiplying the error by a constant $k_P$, called the proportional gain constant.
Small error yields small control signals
Nice and smooth
So-called proportional regulation (P regulator)
A high proportional gain results in a large change in the output for a given change in the error. If the proportional gain is too high, the system can become unstable. In contrast, a small gain results in a small output response to a large input error, and a less responsive or less sensitive controller. Industrial practice indicate that the proportional term should contribute the bulk of the output change.
c = 1;
m = 1;
G = tf(c/m,[1 0]);
k = 5;
C = k;
Gcl = feedback(C*G,1,-1);
x0 = 0;
t = linspace(0,5,100);
r = 70*ones(size(t)); % reference
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,70*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,75])
What if the true system is:
Caveat: the "real" model is augmented to include a wind resistance term:
At steday-state
gamma = 1;
Gtr = tf(c/m,[1 gamma]);
C = k;
Gcl = feedback(C*Gtr,1,-1);
x0 = 0;
t = linspace(0,5,100);
r = 70*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,70*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,75])
The contribution from the integral term is proportional to both the magnitude of the error and the duration of the error. The integral controller is the sum of the instantaneous error over time and gives the accumulated offset that should have been corrected previously. The accumulated error is then multiplied by the integral gain ($k_I$) and added to the controller output.
The integral term accelerates the movement of the process towards setpoint and eliminates the residual steady-state error that occurs with a pure proportional controller. However, since the integral term responds to accumulated errors from the past, it can cause the present value to overshoot the setpoint value.
Gtr = tf(c/m,[1 gamma]);
kP = 5;
kI = 5;
C = tf([kP kI],[1 0]);
Gcl = feedback(C*Gtr,1,-1);
x0 = 0;
t = linspace(0,5,100);
r = 70*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,70*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,75])
The derivative of the process error is calculated by determining the slope of the error over time and multiplying this rate of change by the derivative gain $k_D$.
Derivative action predicts system behavior and thus improves settling time and stability of the system. The implementations of D controllers include an additional low-pass filtering for the derivative term to limit the high-frequency gain and noise. Derivative action is seldom used in practice though because of its variable impact on system stability in real-world applications.
PID: by far the most used low-level controller
P: contributes to stability, medium-rate responsiveness
I: tracking and disturbance rejection, slow-rate responsive, may cause oscillations
D: fast-rate responsiveness, sensitive to noise
Feedback has a remarkable ability to fight uncertainty in model parameters !
The goal of this problem is to show how each of the term, $k_P, k_I$ and $k_D$ contributes to obtaining the common goals of:
Fast rise time
Minimal overshot
Zero steady-state error
$k_P = 1,k_I = 0, k_D = 0$
Gtr = tf(c/m,[1 gamma]);
kP = 1;
kI = 0;
kD = 0;
C = tf([kD kP kI],[1 0]);
Gcl = feedback(C*Gtr,1,-1);
x0 = 0;
t = linspace(0,5,100);
r = 70*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,70*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,75])
$k_P = 1, k_I = 1, k_D = 0$
Gtr = tf(c/m,[1 gamma]);
kP = 1;
kI = 1;
kD = 0;
C = tf([kD kP kI],[1 0]);
Gcl = feedback(C*Gtr,1,-1);
x0 = 0;
t = linspace(0,5,100);
r = 70*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,70*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,75])
$k_P = 1, k_I = 10, k_D = 0$
Gtr = tf(c/m,[1 gamma]);
kP = 1;
kI = 10;
kD = 0;
C = tf([kD kP kI],[1 0]);
Gcl = feedback(C*Gtr,1,-1);
x0 = 0;
t = linspace(0,5,100);
r = 70*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,70*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,75])
$k_P = 1, k_I = 2, k_D = 0.1$
Gtr = tf(c/m,[1 gamma]);
kP = 1;
kI = 2;
kD = 0.1;
C = tf([kD kP kI],[1 0]);
Gcl = feedback(C*Gtr,1,-1);
x0 = 0;
t = linspace(0,5,100);
r = 70*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,70*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,75])
Another Example
$$G(s) = \frac{1}{s^2 + 10s + 20}$$s = tf('s');
G = 1/(s^2 + 10*s + 20);
x0 = 0;
t = linspace(0,2,100);
r = 1*ones(size(t));
[y,tout] = lsim(G,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,1*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,2])
kP = 300;
C = pid(kP,0,0);
Gcl = feedback(C*G,1,-1);
x0 = 0;
t = linspace(0,2,100);
r = 1*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,1*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,2])
kP = 300;
kD = 10;
C = pid(kP,0,kD);
Gcl = feedback(C*G,1,-1);
x0 = 0;
t = linspace(0,2,100);
r = 1*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,1*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,2])
kP = 30;
kI = 70;
C = pid(kP,kI);
Gcl = feedback(C*G,1);
x0 = 0;
t = linspace(0,2,100);
r = 1*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,1*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,2])
kP = 350;
kI = 300;
kD = 50;
C = pid(kP,kI,kD);
Gcl = feedback(C*G,1,-1);
x0 = 0;
t = linspace(0,2,100);
r = 1*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y, 'linewidth', 2), hold on
plot(tout,1*ones(size(tout)),'--k'), hold off
xlabel('t'), ylim([0,2])
When you are designing a PID controller for a given system, follow the steps shown below to obtain a desired response.
Obtain an open-loop response and determine what needs to be improved
Add a proportional control to improve the rise time
Add a derivative control to reduce the overshoot
Add an integral control to reduce the steady-state error
Adjust each of the gains $k_P$, $k_I$, and $k_D$ until you obtain a desired overall response.
Lastly, please keep in mind that you do not need to implement all three controllers (proportional, derivative, and integral) into a single system, if not necessary. For example, if a PI controller meets the given requirements (like the above example), then you don't need to implement a derivative controller on the system. Keep the controller as simple as possible.
%%html
<center><iframe src="https://www.youtube.com/embed/-fNoz5K5FHA?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/DJuo9kLdr4M?list=PLp8ijpvp8iCvFDYdcXqqYU5Ibl_aOqwjr?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/cQhqx65kLfM?list=PLp8ijpvp8iCvFDYdcXqqYU5Ibl_aOqwjr?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/Mk1ygHj4zxw?list=PLp8ijpvp8iCvFDYdcXqqYU5Ibl_aOqwjr?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/UR0hOmjaHp0?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/XfAt6hNV8XM?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')