SM2 1/7 (R3_Feb_2012)
NGEE ANN POLYTECHNIC
Diploma in Aerospace Technology
System Dynamics and Control
EXPERIMENT SM2: SIMULATION OF PID CONTROL ACTIONS USING
MATLAB
OBJECTIVES:
1 . To solve tutorial problems using MATLAB as an analytical tool.
2. To familiar with PID controller.
3. To study the effect of changing controller parameters.
INTRODUCTION TO PID CONTROLLER
In a closedloop system the controller carries out the 'decision' process. In general, the
controller consists of an error detector and a control mode unit. The error detector computes
the error signal (E) which is the desired value (R) minus measured value (Y).
E = R Y
The control mode unit uses the error signal to produce the control action or controller output
(C). The controller output is then applied to the final control element. The controller acts as a
filter. The filtering can be divided into several parts. The first part is the proportional term,
which produces a term, C
p
, that is proportional to E.
C
p
= K
p
E .
The second filtering operation is to produce an output signal, C
d
, which is proportional to the
derivative of E. This part is represented by the transformed equation
C
d
= sK
d
E
The third part of the filtering is the integrator output C
i
, given by
C
i
= E
s
K
i

.

\

The output signal, C, is the sum of the three components
C = C
p
+C
d
+C
i
,
The transfer function F(s), relating the filter output, C, to the system error, E, is
F(s) = C/E + K
p
+ sK
d
+K
i
/ s
This type of filter is known as a PID filter. It is most commonlyused in feedback control
system.
SDC
SM2 2/7 (R3_Feb_2012)
ASSIGNMENT 1
Task a: Openloop time response
A process with an input c(t) and output y(t) is described by :
d y t
dt
2
2
( )
+
dy(t)
dt
+ 5y(t) = c(t)
Laplace Transform ¬
Y(s)
=
1
s + s + 5
2
C s ( )
Obtain the open loop time responseto a unit step input and determine the steady state
gain.
Procedure:
1. Launch MATLAB by double click the 'MATLAB' button.
2. You will see three windows in 'Matlab' environment, i.e. "Workspace', 'Command
History', and 'Command Window' windows.
3. Open a new ‘Mfile’ editor by clicking the icon at the top left hand corner.
4. Copy the following programming and paste it to the editor
num=1;
den=[1 1 5];
G=tf(num,den);
step(G)
wait for 2 seconds, you will see the response curve for the above Transfer Function.
You may copy the figure to your report.
5. Copy response figure (use 'edit' copy figure) to your document. Submit your
report through Mel.
You need to key in 'figure' in the 'command window' in order to get a new figure.
Otherwise the new figure will not appeared.
SDC
SM2 3/7 (R3_Feb_2012)
6. Observations and results
(a) Determine the damping ratio of the plant transfer function,
Y(s)
=
1
s + s + 5
2
C s ( )
and
steady state gain. State the type of response obtained. (Do your calculations to find
,
and K
ss
on the space provided below:)
Express 2 2
2
ss
2
+ s 2 + s
K
5 + s + s
1
=
n
n
e ,e
e
From the above calculation:
Damping ratio(
,
) : ________________________
Steady state gain of response (K
ss
) : ________________________
Type of response : ________________________
underdamped/criticallydamped/overdamped
From the response curve:
Paste the response figure here.
Steadystate gain of response (K
ss
) : _________________________________
Type of response : _________________________________
underdamped/criticallydamped/overdamped
Tasks b: Effects of control actions on system performance
A PID controller is used to control the above process, the error signal, E(s) and the
controller output, C(s) given in the block diagram in figure 2 :
Figure 1: Block diagram of a closed loop control system
Find the steady value of the closed loop system to a unit step when the controller
parameters are :
i) K
p
= 4, K
i
= 0, K
d
= 1.25
+

R(s)
C(s) E(s)
Y(s)
5
1
2
+ + s s
(
¸
(
¸
+ +
s
K s s K
K
i d
p
2
Process
Y(s)
Controller
SDC
SM2 4/7 (R3_Feb_2012)
ii) K
p
= 4, K
i
= 1, K
d
= 1.25
Before investigating the effects of control actions on system performance, we need to
correlate the controller and system parameters in MATLAB block diagram.
Figure 2: System structure of computer model correlated with the system parameters
1. Controller with Kp= 4, K
i
= 0, K
d
= 1.25 and Kp= 4, K
i
= 1, K
d
= 1.25 can be entered.
This will enable you to see the response graph with different parameters.
Ki=0;Kp=4;
PID=tf([1.25 1 Ki],[1 0]);
plant=tf(1,[1 1 5]);
sysol=Kp*PID*plant;
syscl=feedback(sysol,1);
step(syscl,0:0.01:10);
hold on; grid on;
Ki=1;Kp=4;
PID=tf([1.25 1 Ki],[1 0]);
plant=tf(1,[1 1 5]);
sysol=Kp*PID*plant;
syscli=feedback(sysol,1);
step(syscli,0:0.01:10);
2. To obtain the steady state gain. One click on the graph obtained, a black square
appears on the curve. Click and drag the black square to the right to obtain the steady
state gain. Paste the response figure here.
Steady state gain for the closedloop response
for set of controller parameters (i) : ___________________
3. Repeat step 6 to obtain the steady state gain for controller parameters (ii), ie. K
p
= 4,
K
i
=1 and K
d
= 1.25.
Steady state gain for the closedloop response
for set of controller parameters (ii) : ___________________
Input
R(s)
s
K s s K
d
+ +
2
5
1
2
+ + s s
E(s)
Gain Compensator
Control
Effort C(s)
Plant
Ouput
Y(s)
Kp G
c
(s) Gp(s)
SDC
SM2 5/7 (R3_Feb_2012)
ASSIGNMENT 2
A DC motor velocity control system shown in Figure 4. G
c
(s) is the transfer function of the
controller. The motor has a transfer function given by:
where K
t
= 0.1/15 v/rpm (tachogenerator sensitivity)
n = 1
T
m
= 0.0625 sec
K
m
= 10 rpm/v
L
a
= 0
Figure 4: DC motor velocity control system
Investigate the system performance of the system with (1) a proportional controller, (2) a
proportionalintegral controller.
The system block diagram is shown in Figure 5. Obtain G
p
(s) by substituting the given
numerical values for the parameters.
Figure 5: System block diagram
G
c
(s)
G
p
(s)
Actual
Velocity
Reference
Velocity
1 06255 . 0
0667 . 0
1 06255 . 0
10
15
1 . 0
1
) (
+
=
+
=
s
x x
s G
p
1
) (
+
=
m
m t
p
sT
K nK
s G
SDC
SM2 6/7 (R3_Feb_2012)
Task 1: Proportional controller
Simulate the system response under a unit step input with G
c
(s) = 25, 50, 100; obtain the
transient and steadystate responses.
Gc=25;
Gp=tf([0.0677],[0.06255 1]);
sysol=Gc*Gp;
sys25=feedback(sysol,1);
step(sys25,0:0.01:0.15);
hold on; grid on;
Gc=50;
Gp=tf([0.0677],[0.06255 1]);
sysol=Gc*Gp;
sys50=feedback(sysol,1);
step(sys50,0:0.01:0.15);
hold on; grid on;
Gc=100;
Gp=tf([0.0677],[0.06255 1]);
sysol=Gc*Gp;
sys100=feedback(sysol,1);
step(sys100,0:0.01:0.15);
Discussion
Paste the response figure here.
Write down the steadystate error for each case. Are they equal to zero? Why?
TASK 2: PROPORTI ONALI NTEGRAL CONTROLLER
Simulate the system response under a unit step input with G
c
(s) = K
p
+ K
i
/s
(i.e.
s
K s K
i p
+
), for the following values of K
p
and K
i
:
a) K
p
= 2, K
i
= 50 [Gc=tf([2 50],[1 0])]
b) K
p
= 2, K
i
= 100 [Gc=tf([2 100],[1 0])]
c) K
p
= 2, K
i
= 200 [Gc=tf([2 200],[1 0])]
and note the transient and steadystate responses.
Programming for case (a) : Gc=tf([2 50],[1 0]);
Gp=tf([0.0677],[0.06255 1]);
sysol=Gc*Gp;
syscl50=feedback(sysol,1);
step(syscl50,0:0.01:2);
SDC
SM2 7/7 (R3_Feb_2012)
hold on; grid on;
Modify the above programming to incorporate case (b) and (c). [Similar to Task 1]
Discussion
(1) Measure the steadystate error for each case. Are they equal to zero? Why?
(2) Which of the above controlled system response approaches critical response (ie.
fastest approach to steadystate without overshooting)?