Lab Reports (Control System)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

Control System lab

Experiment no 01:

FREQUENCY-DOMAIN MODELING IN MATLAB (SIMULINK)

Objective:
Analyzing the output of a transfer function through different signals in MATLAB (Simulink)

Theory:

Transfer function: The ratio of the Laplace transform of the output of a system to the Laplace
transform of the input.
OR
Transfer function is the mathematical representation of a system in frequency domain.
Linearly Time-Invariant System (LTI): LTI system relates the output of the system to its input with
zero initial conditions. The system is fed by the input signals (e.g., unit step or impulse) and the
output is analyzed. The derivative of unit step input produces unit impulse input

Procedure:

• Open the MATLAB software and start to write the code.


• First define the nominator and denominator coefficients of the given transfer function.
• Now plot the step and impulse response by using the plot command.

For Unit Step Input:

• Open the Simulink in MATLAB and then select the step input and transfer function.
• Now set the values of transfer function and then make the connection between input and
transfer function.
• To see the output scope was used.

For Unit Impulse Input:

• In case of unit impulse input add the derivate block between the input and transfer function.

BILAL UZ ZAMAN KHAN 16JZELE0105


MATLAB Code:
num=[10];
den=[1 2 20];
h=tf(num, den);
step(h);
hold on
plot(diff(step(h)));
legend('Impulse Response')

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


For Unit Step Input :

Simulink Model:

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


For Unit Impulse Input:

Simulink Model:

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 02:

TIME DOMAIN MODELING IN MATLAB

Objective:
The objective of this lab is to model the system in time domain

Theory:

State Space representation is the time-domain technique for modeling, analyzing and designing a
wide range of systems and applications. State space is represented by state equations and output
equations. The state variables are chosen and once determined are used to specify other system
variables. The state variables are chosen either by phase-variable choice, controller canonical form,
observer canonical form.

Procedure:

• Open the MATLAB software and start to write the code.


• First define the nominator and denominator coefficients of the given transfer function.
• To convert into phase variable form define the identity matrix.
• Now to find the value take the inverse of identity matrix and perform the multiplication
process.

Transfer function to state space representation:

MATLAB Code:
num=[1 7 2];
den=[1 9 26 24];
[A,B,C,D]=tf2ss (num, den);
P=[0 0 1;0 1 0;1 0 0];
A=inv(P)*A*P
B=inv(P)*B
C=C*P

BILAL UZ ZAMAN KHAN 16JZELE0105


Result:

State Space Representation to the transfer function:

MATLAB Code:
A=[-4 -1.5;4 0];
B=[2;0];
C=[1.5 0.625];
D=0;
T=ss(A,B,C,D);
T=tf(T)

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 03:

DETERMINING THE SYSTEM STABILITY IN MATLAB (SIMULINK)

Objective:
Analyzing the stability of a system through different positions of its roots on real axis in MATLAB
(Simulink)

Theory:
The stability of the system is determined by the position of its roots in the s-plane at real axis. If the
roots are in left half plane, system is stable; if at least one root is on right half plane, system is
unstable and if they are at imaginary axis, system is marginally stable. The roots may also be
complex conjugate meaning that they have real as well as imaginary part but still the stability will
depend on placement in left or right half plane.

Procedure:
MATLAB:

• Open the MATLAB software and start to write the code.


• First define the nominator and denominator coefficients of the given transfer function.
• To find the roots of denominator root command was used.

Simulink:

• Open the Simulink in matlab and then select the step input and transfer function.
• Now set the values of transfer function and then make the connection between input and
transfer function.
• To see the output scope was used.

For G1(s) = 1/(s2+2s+1):

MATLAB Code:

num1=[1];
den1=[1 2 1];
r1=roots(den1)

BILAL UZ ZAMAN KHAN 16JZELE0105


Result:

Simulink Model:

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


For G1(s)=1/(s2-2s+1):

MATLAB code:
num1=[1];
den1=[1 -2 1];
r1=roots(den1)

Result:

Simulink Model:

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 04:

SYSTEM INTERCONNECTIONS IN SIMULINK

Objective:
The aim of the lab is to connect the subsystems in different configurations for analysis.

Procedure:

• Open the Simulink in MATLAB and then select the step input and transfer function.
• Now set the values of transfer function and then make the connection between input and
transfer function.
• To see the output scope was used.

Cascade system interconnection:

• In case of Cascade system interconnection different transfer function blocks were used.

Equivalent system:

• In case of Equivalent system all transfer functions combined together and only single block
was used.

Parallel system interconnection:

• In this case first step input applied to each transfer function and then added together.

Negative feedback system interconnection:

• The step function is the input to the transfer function G(s) and the output of the G(s) is
provided as an input to the H(s)and the output of H(s) is feedback to the G(s).

BILAL UZ ZAMAN KHAN 16JZELE0105


Cascade system interconnection:

Simulink model:

Result:

Equivalent system:
Simulink Model:

BILAL UZ ZAMAN KHAN 16JZELE0105


Result:

Parallel system interconnection:


Simulink model:

BILAL UZ ZAMAN KHAN 16JZELE0105


Result:

Equivalent system:
Simulink Model:

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Negative feedback system interconnection:

Simulink model:

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Equivalent system:
Simulink Model:

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 05:

STEADY-STATE ERROR ANALYSIS USING SIMULINK

Objective:
The objective of this lab to analyze the steady state error analysis for different test signals in
Simulink.

Theory:

Steady state error is the difference between the input and the output for the prescribed test input as t
(time) approaches to infinity.

Procedure:

• Open the Simulink in MATLAB and then select the step input and transfer function and gain
block.
• Now make the model for step input, ramp input and for parabolic input.

Simulink Model:
For Step Input:

BILAL UZ ZAMAN KHAN 16JZELE0105


For Ramp Input:

For Parabolic Input:

BILAL UZ ZAMAN KHAN 16JZELE0105


Results:

For input 5u(t):


For k= 50:

For k=500:

BILAL UZ ZAMAN KHAN 16JZELE0105


For k=1000:

For k=5000:

BILAL UZ ZAMAN KHAN 16JZELE0105


For input 5tu(t):
For k=50:

For k=500:

BILAL UZ ZAMAN KHAN 16JZELE0105


For k=1000:

For k=5000:

BILAL UZ ZAMAN KHAN 16JZELE0105


For input 5𝒕𝟐 u(t):

For k=50:

For k=500:

BILAL UZ ZAMAN KHAN 16JZELE0105


For k=1000:

For k=5000:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 06:

DETERMINATION OF ROOT LOCUS PLOT USING MATLAB CONTROL SYSTEM


TOOLBOX FOR 2ND ORDER SYSTEM & OBTAIN CONTROLLER SPECIFICATION
PARAMETERS.
Objective:
To determine Root Locus plot of a 2nd order system

Theory:
Root locus: The locus of closed-loop poles as a system parameter is varied. Typically, the parameter
is gain. The locus is obtained from the open-loop poles and zeros.

Procedure:

• Open the MATLAB software and start to write the code.


• First define the nominator and denominator coefficients of the given transfer function.

For G(s)=(1+s) / s(1+(0.5)s):

MATLAB Code:
num = [1 1]
den = conv([1 0],[.5 1])
g = tf(num,den);
rlocus(g)

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


For G(s)=1 / s(1+s)(2+s)

MATLAB Code:
num = [1]
den = poly([0 -1 -2])
g = tf(num,den);
rlocus(g

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Lab task:

For G(s)=(s+6) / (3+s)(6+s)


MATLAB Code:

num = [1 6]
den = conv([1 3],[1 6])
g = tf(num,den);
rlocus(g)

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 07:

STUDY THE EFFECT OF PI, PD &PID CONTROLLER ON SYSTEM PERFORMANCE

Objective:
To determine
I. Effect of PI controller on system performance
II. Effect of PD controller on system performance

Theory:
Proportional-plus-derivative (PD) controller: A controller that feeds forward to the plant a
proportion of the actuating signal plus its derivative for the purpose of improving the transient
response of a closed-loop system.
Proportional-plus-integral (PI) controller: A controller that feeds forward to the plant a proportion
of the actuating signal plus its integral for the purpose of
improving the steady-state error of a closed-loop system.
Proportional-plus-integral-plus-derivative (PID) controller: A controller that feeds forward to the
plant a proportion of the actuating signal plus its integral plus its derivative for the purpose of
improving the transient response and steady-state error of a closed-loop system.

Effect of addition of a PD controller on the system performance:

MATLAB code:
num=1;
den=[1 10 20];
g1=tf (num,den)
t1=feedback(g1,1)
step(t1,'g')
hold on
num1=10;
den1=[1 10 20];
g2=tf (num1,den1)
t2=feedback(g2,1)
step(t2,'m')
hold on
Kp=500;
Kd=10;

BILAL UZ ZAMAN KHAN 16JZELE0105


numc=[Kd Kp];
numo=conv(numc,num)
deno=den
g3=tf(numo,deno)
t3=feedback(g3,1)
step(t3,'b')
hold on
Kp=500;
Kd=5;
numc=[Kd Kp];
numo=conv(numc,num)
deno=den
g3=tf(numo,deno)
t4=feedback(g3,1)
step(t4,'y')
hold on
Kp=500;
Kd=.01;
numc=[Kd Kp];
numo=conv(numc,num)
deno=den
g3=tf(numo,deno)
t5=feedback(g3,1)
step(t5,'r')
hold on

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Effect of addition of a PI controller on the system performance:

MATLAB code:
num=1;
den=[1 10 20];
g1=tf (num,den)
t1=feedback(g1,1)
step(t1,'g')
hold on
num1=10;
den1=[1 10 20];
g2=tf (num1,den1)
t2=feedback(g2,1)
step(t2,'m')
hold on
Kp=500;
Ki = 1
numc=[Kp Ki];
denc= [1 0]
numo=conv(numc,num)
deno=conv(den,denc)
g3=tf(numo,deno)
t3=feedback(g3,1)
step(t3,'b')
hold on
Kp=500;
Ki = 100
numc=[Kp Ki];
denc= [1 0]
numo=conv(numc,num)
deno=conv(den,denc)
g3=tf(numo,deno)
t4=feedback(g3,1)
step(t4,'r')
hold on
Kp=500;
Ki = 500
numc=[Kp Ki];
denc= [1 0]
numo=conv(numc,num)
deno=conv(den,denc)
g3=tf(numo,deno)
t5=feedback(g3,1)
step(t5,'g')
hold on

BILAL UZ ZAMAN KHAN 16JZELE0105


Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 08:

STUDY THE EFFECT OF ADDITION OF ZEROS TO THE FORWARD PATH TRANSFER


FUNCTION OF A CLOSED LOOP SYSTEM

Objective:
To study
I. Effect of addition of zeros to forward path of a open loop system.
II. Effect of addition of zeros to forward path of a closed loop system.

Theory:
The forward path transfer function of general second order system is given by,

Addition of zero to forward path transfer function:


When we add a zero the forward path transfer function becomes,

BILAL UZ ZAMAN KHAN 16JZELE0105


For G(s)=1/s*(s+1)

MATLAB Code:
n1=1
d1=[1 1 0]
g1=tf(n1,d1)
t1=feedback(g1,1)
step(t1,'r')
hold on
Tz=0.5
Z1=[Tz 1]
n2=conv(n1,Z1)
g2=tf(n2,d1)
t2=feedback(g2,1)
step(t2,'b')
hold on
Tz=1
Z2=[Tz 1]
n3=conv(n1,Z2)
g3=tf(n3,d1)
t3=feedback(g3,1)
step(t3,'y')
hold on
Tz=2
Z3=[Tz 1]
n4=conv(n1,Z3)
g4=tf(n4,d1)
t4=feedback(g4,1)
step(t4,'g')
hold on
Tz=3
Z4=[Tz 1]
n5=conv(n1,Z4)
g5=tf(n5,d1)
t5=feedback(g5,1)
step(t5,'m')

BILAL UZ ZAMAN KHAN 16JZELE0105


Result:

For T(s)=1/(s2 +s+1):

Matlab Code:
n1=[1]
d1=[1 1 1]
t1=tf(n1,d1)
step(t1,'r')
hold on
Tz=0.5
Z1=[Tz 1]
n2=conv(n1,Z1)
t2=tf(n2,d1)
step(t2,'b')
hold on
Tz=1
Z2=[Tz 1]
n3=conv(n1,Z2)
t3=tf(n3,d1)
step(t3,'y')
hold on
Tz=2
Z3=[Tz 1]
n4=conv(n1,Z3)
t4=tf(n4,d1)
step(t4,'g')
hold on
Tz=3
Z4=[Tz 1]

BILAL UZ ZAMAN KHAN 16JZELE0105


n5=conv(n1,Z4)
t5=tf(n5,d1)
step(t5,'m')

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 09:

STUDY THE EFFECT OF ADDITION OF POLES TO THE FORWARD PATH TRANSFER


FUNCTION OF A CLOSED LOOP SYSTEM
Objective:

To study
I. Effect of addition of poles to forward path of a open loop system.
II. Effect of addition of poles to forward path of a closed loop system.

Theory:
The forward path transfer function of general second order system is given by,

Addition of pole to forward path transfer function:


When we add a pole, the transfer function becomes,

For G(s)=1/s*(s+2):

BILAL UZ ZAMAN KHAN 16JZELE0105


MATLAB Code:
n1=1
d1=[1 2 0]
g1=tf(n1,d1)
t1=feedback(g1,1)
step(t1,'r')
hold on
Tp=1
P1=[Tp 1]
d2=conv(d1,P1)
g2=tf(n1,d2)
t2=feedback(g2,1)
step(t2,'g')
hold on
Tp=2
P2=[Tp 1]
d3=conv(d1,P2)
g3=tf(n1,d3)
t3=feedback(g3,1)
step(t3,'b')
hold on
Tp=4
P3=[Tp 1]
d4=conv(d1,P3)
g4=tf(n1,d4)
t4=feedback(g4,1)
step(t4,'m')

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


For T(s)=1/(s2 + 0.6s+1):

MATLAB Code:
n1=1
d1=[1 0.6 1]
t1=tf(n1,d1)
step(t1,'r')
hold on
Tp=1
P1=[Tp 1]
d2=conv(d1,P1)
t2=tf(n1,d2)
step(t2,'g')
hold on
Tp=2
P2=[Tp 1]
d3=conv(d1,P2)
t3=tf(n1,d3)
step(t3,'b')
hold on
Tp=4
P3=[Tp 1]
d4=conv(d1,P3)
t4=tf(n1,d4)
step(t4,'m')

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 10:

DETERMINATION OF BODE PLOT USING MATLAB CONTROL SYSTEM TOOLBOX FOR


2ND ORDER SYSTEM &OBTAIN CONTROLLER SPECIFICATION PARAMETERS

Objective:

To determine
I. Bode plot of a 2nd order system
II. Frequency domain specification parameter

Theory:

Bode diagram (plot): A sinusoidal frequency response plot where the magnitude response is plotted
separately from the phase response. The magnitude plot is dB versus log v, and the phase plot is
phase versus log v. In control systems, the Bode plot is usually made for the open-loop transfer
function. Bode plots can also be drawn as straight-line approximations.
For G(s) =s+1 / s(1+0.5s) :

Matlab Code:

num = [1 1]
den = conv([1 0],[.5 1])
g = tf(num,den);
bode(g)
margin(g)

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Lab Task:
2
For G(s) =(8+4s) / s(s +15s+50)

Matlab code:

num = [4 8]
den = conv([1 0],[1 15 50])
g = tf(num,den);
bode(g)
margin(g)

Result:

Question:

What do you mean by GM & PM?

Answer:

The gain margin Gm is defined as 1/G where G is the gain at. the -180 phase crossing. The gain
margin in dB is derived by Gm_dB = 20*log10(Gm) The phase margin Pm is in degrees.

Question:

How GM & PM affects system?

Answer:

The greater the Gain Margin or Phase Margin (PM), the greater will be the stability of the system.
The phase margin refers to the amount of phase, which can be increased or decreased without
making the system unstable.

BILAL UZ ZAMAN KHAN 16JZELE0105


Question:

What is gain cross over frequency?

Answer:

The phase crossover frequency is the frequency at which the phase angle first reaches −180° and thus
is the point where the Nyquist plot crosses the real axis.

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 11:

DETERMINATION OF NYQUIST PLOT USING MATLAB CONTROL SYSTEM TOOLBOX

Objective:
To determine Nyquist plot of a 2nd order system

Theory:
Nyquist criterion: If a contour, A, that encircles the entire right half-plane is mapped through
G(s)H(s), then the number of closed-loop poles, Z, in the right half-plane equals the number of open-
loop poles, P, that are in the right half-plane minus the number of counterclockwise revolutions, N,
around -1, of the mapping; that is, Z =P-N. The mapping is called the Nyquist diagram of G(s)H(s).

Nyquist Plot of a system having forward path transfer function of


G(s) = (2+𝑠)/ (𝑠+1)(𝑠 - 1)
Matlab code:

num = [1 2]
den = conv([1 1], [1 -1])
g = tf(num,den);
nyquist(g)

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Nyquist Plot of a system having forward path transfer function of
G(s) = 1/ s* (𝑠+1)(𝑠 - 1)
Matlab code:

num = [1]
a=[1 0]
b= [1 2 2]
den =conv(a,b)
g = tf(num,den)
nyquist(g)

Result:

BILAL UZ ZAMAN KHAN 16JZELE0105


Lab task:

Nyquist Plot of the following transfer function


G(s) = (3+𝑠)/ s(𝑠+6)(𝑠 +8)

Matlab code:

num = [1 3]
den = conv([1 0],[1 6], [1 8])
g = tf(num,den)
nyquist(g)

Result:

Question:

What is Nyquist contour?

Answer:

The Nyquist contour is a closed contour in the s-plane which completely encloses the entire right-
hand half of s-plane. In order to enclose the complete RHS of s-plane a large semicircle path is
drawn with diameter along jω axis and center at the origin.

Question:

What is polar plot? How it differs from Nyquist plot?

Answer:

Nyquist plot is a stability analysis which uses a polar plot, but saying it explicitly a polar plot creates
some confusion and gives meaning of polar coordinates of mathematics. The Polar plot is a plot,
which can be drawn between the magnitude and the phase angle of G(jω)H(jω) by varying ω from
zero to ∞.

BILAL UZ ZAMAN KHAN 16JZELE0105


Control System lab

Experiment no 12:

SYSTEM DESIGN USING SISOTOOL

Objective:
For K<2, design a system (second order) with the following characteristics:
• Percent overshoot < 50
• Damping ratio > 0.2
• Stable system

Theory:
Percent overshoot:
Systems may be stable system, unstable system and marginally stable system. A stable system
may overshoot for some values at the start before coming to the stable level. Similarly, in this lab a
system is designed whose percent overshoot is <50.
Damping ratio:
Damping ratio is a parameter that indicates that whether system is over damped(ς>1),
underdamped((ς<1) or critically stable((ς=1). In this lab a system is designed which must have
damping ratio > 0.2.
Stable system:
Third condition which the system must satisfy is it must be stable for K<2, also all the values
(damping ratio and % overshoot) are set. It must be unstable for K>=2

Procedure:

• Open the MATLAB software and start to write the code.


• First define the nominator and denominator coefficients of the given transfer function.
• To open the siso tool sisotool command was used.

For transfer function T(s)= (-1) / (s2 + 3*s+2):

MATLAB Code:
num=[0 0 -1];
den=[1 3 2];
sys=tf(num,den)
sisotool(sys)

BILAL UZ ZAMAN KHAN 16JZELE0105


Result:
Siso Tool:

BILAL UZ ZAMAN KHAN 16JZELE0105

You might also like