Vous êtes sur la page 1sur 6

LAB 12

To Show Root Locus and PID Controller Elaboration


Using MATLAB

Elaboration of Root Locus

Matlab Code

close all
clear all
% system transfer
function num1=[1 8];
den1=poly([0 -2 -10]); % try others values as well
sys1=tf(num1,den1)
t1=[0:.02:10];
% ploting step response of
system ys1=step(sys1,t1);
subplot(2,2,1)
plot(t1,ys1)
title('step response of signal')
% evaluating steady state
error disp('steady state
error') os1=max(ys1)-1
subplot(2,2,2)
% showing root locus of sys1 in 2nd window of
subplot rlocus(sys1)
[k,r]=rlocfind(sys1);
% display gain of system and roots at selected point on root
locus disp('k=')
disp(k)
disp('r=')
disp(r)
% introducing feedback gain in system evaluated at specific point above
% transfer function of modified system
[num2,den2]=feedback(k*num1,den1,1,1,-
1); sys2=tf(num2,den2)
t2=[0:.02:10];
% ploting step response of system
ys2=step(sys2,t2);
subplot(2,2,3)
plot(t2,ys2)
title('step response of signal')
% evaluating steady state
error disp('steady state
error') os2=max(ys2)-1

Figure

Output Command Window

Prepared By: Kashif Javed (Lab Engineer FAST-NUCES Peshawar) Page 2


Transfer function:
s+8
-------------------
s^3 + 12 s^2 + 20 s

steady state error

os1 =

2.8100

Select a point in the graphics window

selected_point =

-1.7614 + 7.8049i

k=
70.9610

r= -
8.9319
-1.5340 + 7.8233i
-1.5340 - 7.8233i

Transfer function:
70.96 s + 567.7
------------------------------
s^3 + 12 s^2 + 90.96 s + 567.7

steady state error

os2 =

0.5768

Prepared By: Kashif Javed (Lab Engineer FAST-NUCES Peshawar) Page 3


Elaboration of PID Controller

Matlab Code

close all
clear all
% without PID
Controller n=[1];
d=[1 10 21];
disp('transfer function of system without PID
Controller') q=tf(n,d)
subplot(3,2,1)
step(q)
subplot(3,2,2)
rlocus(q)
% with P Controller
kp=500;
n=[kp];
d=[1 10 20+kp];
disp('transfer function of system with P
Controller') q=tf(n,d) subplot(3,2,3)

step(q)
subplot(3,2,4)
rlocus(q)
% with PI
Controller kp=30;
ki=70;
n=[kp ki];
d=[1 10 20+kp ki];
disp('transfer function of system with PI
Controller') q=tf(n,d)
subplot(3,2,5)
step(q)
subplot(3,2,6)
rlocus(q)

Prepared By: Kashif Javed (Lab Engineer FAST-NUCES Peshawar) Page 4


Figure

Output Command Window

transfer function of system without PID Controller

Transfer
function: 1
---------------
s^2 + 10 s + 21

transfer function of system with P Controller

Transfer
function: 500
----------------
s^2 + 10 s + 520

Prepared By: Kashif Javed (Lab Engineer FAST-NUCES Peshawar) Page 5


transfer function of system with PI Controller

Transfer function:
30 s + 70
------------------------
s^3 + 10 s^2 + 50 s + 70

Lab Tasks

Elaboration of Root Locus

Q. What is the effect on SSE if gain K is increased?

Q. Where will you click on the window to make sure that gain K should be less?

Q. Does the modified system after introduction of gain K have changed in order as compared to
previous one?

Elaboration of PID Controller


nd
Q. What is the nature of 2 order system specified in tf ([1], [1 10 21])?

Q. Explain the effect of response of the system by introduction of P parameter of PID.

Q. Have the order of system changed by the introduction of P parameter?

Q. How many extra poles/zeros have been added to the original system transfer function by
introduction of I parameter of PID?

Q. Is there any change in roots locus of the original system and the system with P and I?

Modify and change the parameter values in above Matlab codes and provide the figures and
command window output in lab report.

Prepared By: Kashif Javed (Lab Engineer FAST-NUCES Peshawar) Page 6

Vous aimerez peut-être aussi