Pie Control Tutorial
Pie Control Tutorial
SYSTEM
MODELING
Introduction: PID Controller
ANALYSIS
Design
Related
Tutorial Links
Circuit
Control
Activity
Temp
Control
Activity
Motor
Control
Activity
Related
External
Links
MATLAB
PID Video
PID Intro
Video
Contents
PID Overview
Example Problem
Proportional Control
Proportional-Derivative Control
Proportional-Integral Control
Proportional-Integral-Derivative Control
PID Overview
The output of a PID controller, which is equal to the control input to the
plant, is calculated in the time domain from the feedback error as follows:
(1)
First, let's take a look at how the PID controller works in a closed-loop
system using the schematic shown above. The variable ( ) represents the
tracking error, the difference between the desired output ( ) and the actual
output ( ). This error signal ( ) is fed to the PID controller, and the controller
computes both the derivative and the integral of this error signal with
proportional gain ( ) times the magnitude of the error plus the integral
gain ( ) times the integral of the error plus the derivative gain ( ) times
This control signal ( ) is fed to the plant and the new output ( ) is obtained.
The new output ( ) is then fed back and compared to the reference to find
the new error signal ( ). The controller takes this new error signal and
computes an update of the control input. This process continues while the
controller is in effect.
(2)
Kp = 1;
Ki = 1;
Kd = 1;
s = tf('s');
C = Kp + Ki/s + Kd*s
C =
s^2 + s + 1
-----------
C = pid(Kp,Ki,Kd)
C =
Kp + Ki * --- + Kd * s
with Kp = 1, Ki = 1, Kd = 1
Let's convert the pid object to a transfer function to verify that it yields the
tf(C)
ans =
s^2 + s + 1
-----------
increasing the control signal for the same level of error. The fact that the
controller will "push" harder for a given level of error tends to cause the
fixed, the only way that the control will increase is if the error increases.
With derivative control, the control signal can become large if the error
begins sloping upward, even while the magnitude of the error is still
and builds, thereby increasing the control signal and driving the error down.
A drawback of the integral term, however, is that it can make the system
more sluggish (and oscillatory) since when the error signal changes sign, it
may take a while for the integrator to "unwind."
loop system are summarized in the table below. Note, these guidelines hold
in many cases, but not all. If you truly want to know the effect of tuning the
individual gains, you will have to do more analysis, or will have to perform
Small
Kp Decrease Increase Decrease
Change
Small No
Kd Decrease Decrease
Change Change
Example Problem
(3)
(4)
The transfer function between the input force and the output
Let
m = 1 kg
b = 10 N s/m
k = 20 N/m
F = 1 N
(6)
The goal of this problem is to show how each of the terms, , , and ,
Minimal overshoot
Let's first view the open-loop step response. Create a new m-file and run the
following code:
s = tf('s');
step(P)
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value
0.95, which is quite large. Furthermore, the rise time is about one second,
and the settling time is about 1.5 seconds. Let's design a controller that will
reduce the rise time, reduce the settling time, and eliminate the steady-state
error.
Proportional Control
From the table shown above, we see that the proportional controller ( )
reduces the rise time, increases the overshoot, and reduces the steady-state
error.
(7)
Let the proportional gain ( ) equal 300 and change the m-file to the
following:
Kp = 300;
C = pid(Kp)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
C =
Kp = 300
P-only controller.
T =
300
----------------
s^2 + 10 s + 320
Continuous-time transfer function.
The above plot shows that the proportional controller reduced both the rise
time and the steady-state error, increased the overshoot, and decreased the
Proportional-Derivative Control
Now, let's take a look at PD control. From the table shown above, we see
overshoot and the settling time. The closed-loop transfer function of the
(8)
Let equal 300 as before and let equal 10. Enter the following
Kp = 300;
Kd = 10;
C = pid(Kp,0,Kd)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
C =
Kp + Kd * s
with Kp = 300, Kd = 10
T =
10 s + 300
----------------
s^2 + 20 s + 320
This plot shows that the addition of the derivative term reduced both the
overshoot and the settling time, and had a negligible effect on the rise time
Proportional-Integral Control
Before proceeding to PID control, let's investigate PI control. From the table,
we see that the addition of integral control ( ) tends to decrease the rise
time, increase both the overshoot and the settling time, and reduces the
steady-state error. For the given system, the closed-loop transfer function
(9)
Let's reduce to 30, and let equal 70. Create a new m-file and enter
Kp = 30;
Ki = 70;
C = pid(Kp,Ki)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
C =
Kp + Ki * ---
with Kp = 30, Ki = 70
T =
30 s + 70
------------------------
s^3 + 10 s^2 + 50 s + 70
the above plot. We have reduced the proportional gain ( ) because the
integral controller also reduces the rise time and increases the overshoot as
the proportional controller does (double effect). The above response shows
that the integral controller eliminated the steady-state error in this case.
Proportional-Integral-Derivative Control
Now, let's examine PID control. The closed-loop transfer function of the
(10)
to an m-file and run it in the command window. You should obtain the
Kp = 350;
Ki = 300;
Kd = 50;
C = pid(Kp,Ki,Kd)
T = feedback(C*P,1);
t = 0:0.01:2;
step(T,t)
C =
1
Kp + Ki * --- + Kd * s
When you are designing a PID controller for a given system, follow the steps
improved
overall response. You can always refer to the table shown in this "PID
characteristics.
Lastly, please keep in mind that you do not need to implement all three
the above example), then you don't need to implement a derivative controller
found at the following link. This example also begins to illustrate some
MATLAB provides tools for automatically choosing optimal PID gains which
makes the trial and error process described above unnecessary. You can
access the tuning algorithm directly using pidtune or through a nice
model, and 'p' specifies that the tuner employ a proportional controller.
pidTuner(P,'p')
The pidTuner GUI window, like that shown below, should appear.
Notice that the step response shown is slower than the proportional
on the top right. As expected, the proportional gain, , is smaller than the
see the resulting response in the GUI window. Try dragging the Response
Time slider to the right to 0.14 s, as shown in the figure below. This causes
the response to indeed speed up, and we can see is now closer to the
manually chosen value. We can also see other performance and robustness
parameters for the system. Note that before we adjusted the slider, the
target phase margin was 60 degrees. This is the default for the pidTuner
performance.
Now let's try designing a PID controller for our system. By specifying the
pidTuner will design another PID controller (instead of P or PI) and will
compare the response of the system with the automated controller with that
of the baseline.
pidTuner(P,C)
We see in the output window that the automated controller responds slower
and exhibits more overshoot than the baseline. Now choose the Domain:
Frequency option from the toolstrip, which reveals frequency domain tuning
parameters.
Now type in 32 rad/s for Bandwidth and 90 deg for Phase Margin, to
that a higher closed-loop bandwidth results in a faster rise time, and a larger
phase margin reduces the overshoot and improves the system stability.
Finally, we note that we can generate the same controller using the
command line tool pidtune instead of the pidTuner GUI employing the
following syntax.
opts = pidtuneOptions('CrossoverFrequency',32,'PhaseMargin',9
C =
Kp + Ki * --- + Kd * s
info =
Stable: 1
CrossoverFrequency: 32
PhaseMargin: 90