SM2 1/7 (R3_Feb_2012)
NGEEANNPOLYTECHNIC
Diploma in Aerospace Technology
System Dynamics and Control
EXPERIMENT SM2: SIMULATIONOFPIDCONTROLACTIONS USING
MATLAB
OBJECTIVES:
1 . To solve tutorial problems using MATLABas an analytical tool.
2. To familiar with PIDcontroller.
3. To study the effect of changing controller parameters.
INTRODUCTIONTOPIDCONTROLLER
In a closedloop systemthe 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.
Cp=KpE .
The second filtering operation is to produce an output signal, Cd, 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 sumof the three components
C= C
p
+C
d
+C
i
,
The transfer function F(s), relating the filter output, C, to the systemerror, E, is
F(s) = C/E + K
p
+ sK
d
+K
i
/ s
This type of filter is known as a PIDfilter. 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 response to 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 Kss on the space provided below:)
Express 2 2
2
ss
2
+ s 2 + s
K
5 + s + s
1
=
n
n
ω ζω
ω
From the above calculation:
Damping ratio(
ζ
) : ________________________
Steady state gain of response (Kss) : ________________________
Type of response : ________________________
underdamped/criticallydamped/overdamped
From the response curve:
Paste the response figure here.
Steadystate gain of response (Kss) : _________________________________
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 Gc(s) Gp(s)
SDC
SM2 5/7 (R3_Feb_2012)
ASSIGNMENT 2
A DC motor velocity control system shown in Figure 4. Gc(s) is the transfer function of the
controller. The motor has a transfer function given by:
where Kt = 0.1/15 v/rpm (tachogenerator sensitivity)
n = 1
Tm = 0.0625 sec
Km = 10 rpm/v
La = 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 Gp(s) by substituting the given
numerical values for the parameters.
Figure 5: System block diagram
Gc(s)
Gp(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 Gc(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: PROPORTIONALINTEGRAL CONTROLLER
Simulate the system response under a unit step input with Gc(s) = Kp + Ki /s
(i.e.
s
K s K
i p
+
), for the following values of Kp and Ki:
a) Kp = 2, Ki = 50 [Gc=tf([2 50],[1 0])]
b) Kp = 2, Ki = 100 [Gc=tf([2 100],[1 0])]
c) Kp = 2, Ki = 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)?