Professional Documents
Culture Documents
OBJECTIVE(S)
OUTCOME(S)
An ability to use the techniques, skills, and modern PLO5: Modern Tool Usage
engineering tools necessary for engineering practice.
An ability to communicate effectively (written/oral) PLO10: Communication
LAB RUBRICS:
11.1 Objective: To illustrate the performance of PID and digital PID controller using
MATLAB/Simulink
11.4 Introduction
2|Page
Effect of each controller KP, KI and KD on the closed-loop system are summarized below:
11.4.4 MATLAB Code to design Digital PID Controller for plant given by
Result
csys_closed =
1
s^2 + s + 1
Continuous-time transfer function.
dsys_closed =
0.3679 z + 0.2642
z^2 - z + 0.6321
Sample time: 1 seconds
3|Page
Discrete-time transfer function.
ans =
RiseTime: 1
SettlingTime: 16
SettlingMin: 0.8015
SettlingMax: 1.3996
Overshoot: 39.9576
Undershoot: 0
Peak: 1.3996
PeakTime: 3
dpid =
1.4 z^2 - 1.4 z + 0.2
z^2 - z
Sample time: 1 seconds
Discrete-time transfer function.
dsys_closed_pid =
0.515 z^3 - 0.1451 z^2 - 0.2964 z + 0.05285
z^4 - 1.853 z^3 + 1.591 z^2 - 0.6642 z + 0.05285
Sample time: 1 seconds
Discrete-time transfer function.
ans =
RiseTime: 1
SettlingTime: 18
SettlingMin: 0.7669
SettlingMax: 1.7079
Overshoot: 70.7898
Undershoot: 0
Peak: 1.7079
PeakTime: 3
4|Page
There are two ways to design a digital controller or a discrete-time control system. In first way
design a continuous-time controller and then discretize it using ZOH or bilinear transformation
or any discretization technique to obtain an equivalent digital controller as shown in Figure-11.2.
Alternatively, one could discretize the plant first to obtain a sampled-data system or discrete-time
system and then apply digital control system design techniques to design a digital controller as
shown in Figure-11.3.
The three term Proportional-Integral-Derivative (PID) control is still widely used in industries
because of its simplicity. No need for a plant model and no design to be performed. The user just
installs a controller and adjusts three gains to get the best achievable performance. PID
regulation is the most mature and the most widely used technology of continuous system. The
substance of its regulation is based on the deviation of the input value, a function of the
proportional, integral and differential operator and the result of calculation for the output to
control. In practical applications, depending on the circumstances, the structure of the PID
control can be flexibly changed. Most PID controllers nowadays are digital.
For the continuous-time PID, start with the so-called parallel form
(1)
Where 𝐾𝑝 : proportional gain, 𝐾i : integral gain, 𝐾𝐷 : derivative gain, 𝑇i : integral time constant
and 𝑇𝑑 : derivative time constant.
6|Page
11.5.1 Example: 2
Consider a unity feedback system with forward path transfer function:
1
𝐺 𝑠 =
𝑠2 + 10𝑠 + 20
Convert this system in z-domain with 𝑇 = 0t1 sec. Show the effect of addition of a PD
controller on the system performance.Eliminate overshoots in the controller
num=1;
den=[1 10 20];
g1=tf (num,den)
t1=feedback(g1,1)
d1=c2d(t1,.1,'zoh')
step(d1,'g')
hold on
num1=10;
den1=[1 10 20];
g2=tf (num1,den1)
t2=feedback(g2,1)
d2=c2d(t2,.1, 'zoh')
step(d2,'m')
hold on
Kp=500;
Kd=10;
numc=[Kd Kp];
numo=conv(numc,num) Figure-11.5 output results
deno=den
g3=tf(numo,deno)
t3=feedback(g3,1)
d3= c2d(t3,.1,'zoh')
step(d3,'b')
hold on Kp=500; Kd=5;
numc=[Kd Kp];
numo=conv(numc,num)
deno=den
g3=tf(numo,deno)
t3=feedback(g3,1)
d3= c2d(t3,.1,'zoh')
step(d3,'y') hold on Kp=500; Kd=.01;
numc=[Kd Kp];
numo=conv(numc,num)
deno=den
g3=tf(numo,deno) t3=feedback(g3,1)
d3= c2d(t3,.1,'zoh')
step(d3,'r') hold o
7|Page
8|Page
11.6 Review Exercise
b) Write a MATLAB code to design Digital PID Controller for plant G(s) = 1/(s+1) &
H(s) =1. Choosing an appropriate sampling time, tune Kp, Ki & Kd to get an optimized
step response.
%19-18ES67
close all
s=tf('s');
csys=1/(s+1);
csys_closed=feedback(csys,1)
step(csys_closed) %Cont: time step response
hold on
dsys=c2d(csys,1.8,'zoh');
dsys_closed=feedback(dsys,1)
step(dsys_closed,'y') %Discrete time step response without pid
stepinfo(dsys_closed) %Discrete time transient response ch without pid
hold on
z=tf('z',1);
kp=5;
ki=3;
kd=5;
dpid=((kp+ki+kd)*z^2-(kp+2*kd)*z+kd)/(z^2-z) %pulse tf ofdigital pid
dsys_closed_pid=feedback(dpid*dsys,1)
step(dsys_closed_pid,'g') %discrete time step response with pid
stepinfo(dsys_closed_pid) %Discrete time transient response ch with pid
9|Page
c) Attach the code and results of example1 and example2.
Example 1:
Example 2:
10 | P a g
e
11 | P a g
e
12 | P a g
e
13 | P a g
e