CST - 3130905-Lab Manual - Winter-2002
CST - 3130905-Lab Manual - Winter-2002
Certificate
Place:
Date:
engineering systems.
CO-5 Express and solve system equations in state-variable form (state variable
models).
Lab Work: SCILAB/ MATLAB based assignments and simulations covering design,
analysis and modelling of control systems relevant tocurriculum.
Sr.
Objective(s) of Experiment CO1 CO2 CO3 CO4 CO5
No.
Using MATLAB plot the various
1. continuous graphs and perform open √
loop and close loop control system.
Using MATLAB plot the various step √
2. graphs.
To plot graph of some mathematical √
3. function like sin, cos, tan, Exponential.
To evaluate transfer function model √
4. using different methods.
To do block diagram reduction using √
5. MATLAB commands.
Reduce the block diagram using √
6. MATLAB function.
Using Simulink check Step function and
√
impulse function and verify with
7. MATLAB code. Also verify the
waveform for response of control
system using CRO.
To plot Root Locus of different system √
8. using MATLAB.
To plot bode plot using MATLAB
9. functions. Also verify the response for √
Compensators using CRO.
To perform PID controller using
√
10. MATLAB Simulink and verify its
response.
11 To obtain time response specifications and
√
time response of second order system.
12 To obtain transfer function from state
√
model and state model from transfer
function.
CONTROL SYSTEM ENGINEERING (3130905)
Preface
Main motto of any laboratory/practical/field work is for enhancing required skills as well as
creating ability amongst students to solve real time problem by developing relevant
competencies in psycho-motor domain. By keeping in view, GTU has designed competency
focused outcome-based curriculum for engineering degree programs where sufficient weightage
is given to practical work. It shows importance of enhancement of skills amongst the students
and it pays attention to utilize every second of time allotted for practical amongst students,
instructors and faculty members to achieve relevant outcomes by performing the experiments
rather than having merely study type experiments. It is must for effective implementation of
competency focused outcome-based curriculum that every practical is keenly designed to serve
as a tool to develop and enhance relevant competency required by the various industry among
every student. These psycho-motor skills are very difficult to develop through traditional chalk
and board content delivery method in the classroom. Accordingly, this lab manual is designed
to focus on the industry defined relevant outcomes, rather than old practice of conducting
practical to prove concept and theory.
By using this lab manual students can go through the relevant theory and procedure in advance
before the actual performance which creates an interest and students can have basic idea prior to
performance. This in turn enhances pre-determined outcomes amongst students. Each
experiment in this manual begins with competency, industry relevant skills, course outcomes as
well as practical outcomes (objectives). The students will also achieve safety and necessary
precautions to be taken while performing practical.
This manual also provides guidelines to faculty members to facilitate student centric lab
activities through each experiment by arranging and managing necessary resources. It also gives
an idea that how students will be assessed by providing rubrics.
Utmost care has been taken while preparing this lab manual along with assignments however
always there is chance of improvement. Therefore, we welcome constructive suggestions for
improvement and removal of errors if any. Also this is a suggested list of
Experiments/Assignments, faculty may modify & add as per the feasibility and the resources
available change & update in any part/program or else as per the requirement.
CONTROL SYSTEM ENGINEERING (3130905)
Vision
Mission
• To develop state-of-the-art laboratories and well-equipped academic infrastructure.
• To motivate faculty and staff for qualification up-gradation, and enhancement of subject
knowledge.
• To promote research, innovation and real life problem solving skills.
• To strengthen linkages with industries, academic and research organizations.
• To reinforce concern for sustainability, natural resource conservation and social
responsibility.
Vision
Mission
• Use various electrical testing tools and equipment’s in industry, be an Entrepreneur, Enroll in post-
graduate courses, Pursue Research and Innovation in the field of Electrical Engineering.
• Use knowledge of various electrical machines and electrical power system in solving complicated
electrical circuits and networks by using latest design and simulation tools.
• Use technical expertise and suggest modifications in existing electrical systems.
.
EXPERIMENT: - 1
MATLAB Functions: -
1. Plot: - Plot function can able to plot various graphs.
The plot function takes two parameters, the first is X-axis values and the
second is Y-axis values.
Plot function plot continuous graph.
Function syntax: Plot(x, y)
2. Subplot: - subplot function can show more than 1 graph in the output window
at the same time.
Subplot function takes three parameters, the first is number of rows the
second is number of columns and the third is graph number.
Function syntax: subplot(rows, columns, no. of graph)
MATLAB code: -
n=-5:1:5;
y=(n==2)
subplot (3,1,1)
plot(n,y)
xlabel('t')
ylabel('u(t)')
n=0:0.5:10;
y=(n>=3)
subplot (3,1,2)
plot (n,y)
xlabel('t')
ylabel('u(t)')
n=0:1:10;
y=n;
subplot (3,1,3)
plot(n,y)
xlabel('x')
ylabel('y')
output: -
MATLAB code: -
n=0:0.2:10;
y=(n==4);
subplot (3,1,1)
stem(n,y)
xlabel('t')
ylabel('u(t)')
n=0:0.2:10;
y=(n>=5);
subplot (3,1,2)
stem(n,y)
xlabel('t')
ylabel('u(t)')
n=-5:0.2:5;
y=n;
subplot (3,1,3)
stem(n,y)
xlabel('x')
ylabel('y')
Output: -
AIM: - To plot graph of some mathematical function like sin, cos, ten, Exponential.
MATLAB functions: -
1. Trigonometric functions: - MATLAB support all trigonometric functions like
sin, cos, tan, cosec, sec, cot. These are takes suitable angle for print graph.
Function syntax: sin(x), cos(x), ten(x), etc.
MATLAB code: -
t=0:0.2:20;
y =exp(t);
subplot (4,2,1);
plot(y,'r');
title('exponential');
subplot (4,2,2);
stem(y,'r');
title ('exponential discrete');
t=0:0.2:20;
y=sin(t);
subplot (4,2,3);
plot(y,'g');
title('sin');
subplot (4,2,4);
stem(y,'g');
title ('sine discrete');
t=0:0.2:20;
y=cos(t);
subplot (4,2,5);
plot(y,'b');
title('cos');
subplot (4,2,6);
stem(y,'b');
title ('cos discrete');
t=-1.5:0.1:1.5;
y=tan(t);
subplot (4,2,7);
plot(y,'y');
title('tan');
subplot (4,2,8);
stem(y,'y');
title ('tan discrete');
OUTPUT: -
MATLAB Functions: -
1. tf: - tf Construct transfer function or convert to transfer function.
tf functions takes two parameters first one is array of numerator and
second is array of denominator. It is creates-continuous time transfer
function.
Function syntax: sys = tf(num, den)
sys = tf (num, den, ts) creates a discrete-time transfer function
with sample time ts (set ts =-1 if the sample time is undetermined).
2. tf2zpk: - this function returns value of zeros, poles, and gain of input transfer
function.
Function syntax: [z, p, k] = tf2zpk (num, den)
3. zp2tf: - function zp2tf is use for conversion of zero, poles, and gain to transfer
function.
Function syntax: [num, den] = zp2tf (z, p, k)
6. pzmap: - pzmap computes the poles and zeros of the dynamic system and plots
them in the complex plane. The poles are plotted as x's and the zeros are plotted
as o's.
Function syntax: pzmap (num, dem)
[p, z] = pzmap(sys) returns the poles and zeros of the system in two
column vectors p and z. No plot is drawn on the screen.
Part A
Aim: - To get transfer function using tf function.
Input: -
num = input ('enter numerator')
den = input ('enter denotator')
Output: -
enter numerator [ 4 5 6]
num =
4 5 6
enter denotator [ 8 3 4 2]
den =
8 3 4 2
sys =
4 s^2 + 5 s + 6
8 s^3 + 3 s^2 + 4 s + 2
Part B
Aim: - To get all zeros, poles, and gain value from the transfer function.
Input: -
num = input ('enter numerator')
den = input ('enter denotator')
sys = tf (num, den)
[z, p, k] = tf2zpk (num, den)
Output: -
enter numerator [ 2 3 6 1]
num =
2 3 6 1
enter denotator [ 1 5 9 6 3]
den =
1 5 9 6 3
sys =
2 s^3 + 3 s^2 + 6 s + 1
z=
0.0000 + 0.0000i
-0.6595 + 1.5252i
-0.6595 - 1.5252i
-0.1811 + 0.0000i
p=
-2.1726 + 0.9491i
-2.1726 - 0.9491i
-0.3274 + 0.6531i
-0.3274 - 0.6531i
k=
Part C
Aim: - To get transfer function from the value of zeros, poles, and gain.
Input: -
z = input ('Enter the value of Zeros:')
p = input ('Enter the value of poles:')
k = input ('Enter the value of k:')
sys = tf (num, den)
rev = zpk (z, p, k)
Output: -
Enter the value of Zeros: [ 1 2 3]
z=
1 2 3
Enter the value of poles: [2 6 7 3]
p=
2 6 7 3
k=
2
sys =
2 s^3 + 3 s^2 + 6 s + 1
rev =
Part D
Aim: - To find roots of the transfer function and print graph on pzmap.
Input: -
num = input ('enter numerator')
den = input ('enter denotator')
sys = tf (num, den)
poles = roots(den)
zeros = roots(num)
pzmap (num, den)
Output: -
enter numerator [ 26 35 22 20]
num =
26 35 22 20
11 25 36 34 40
sys =
26 s^3 + 35 s^2 + 22 s + 20
11 s^4 + 25 s^3 + 36 s^2 + 34 s + 40
poles =
-1.2680 + 0.9262i
-1.2680 - 0.9262i
0.1317 + 1.2073i
0.1317 - 1.2073i
zeros =
-1.1811 + 0.0000i
-0.0825 + 0.8028i
-0.0825 - 0.8028i
MATLAB Function: -
1. Series: - series function can do Series connection of two input/output
models.
Function syntax: M = series (M1, M2, OUTPUTS1, INPUTS2)
Part A
Aim: - use series function to reduce given block diagram.
Input:
num1 = input ('enter the value of numerator:')
den1 = input ('enter the value of denominator:')
num2 = input ('enter the value of numerator:')
den2 = input ('enter the value of denominator:')
[num12, den12] = series (num1, den1, num2, den2)
printsys (num12, den12);
Output:
enter the value of numerator: [1 0]
num1 =
1 0
enter the value of denominator: [9 17]
den1 =
9 17
enter the value of numerator:9*[1 3]
num2 =
9 27
enter the value of denominator: [2 9 27]
den2 =
2 9 27
num12 =
0 9 27 0
den12 =
18 115 396 459
num/den =
9 s^2 + 27 s
Input:
num1 = [1 0]
den1 = [9 17]
num2 = 9*[1 3]
den2 = [2 9 27]
num12 =conv (num1, num2)
den12 = conv (den1, den2)
printsys (num12, den12)
Output
num1 =
1 0
den1 =
9 17
num2 =
9 27
den2 =
2 9 27
num12 =
9 27 0
den12 =
18 115 396 459
num/den =
9 s^2 + 27 s
Input:
num1 = input ('enter the value of numerator:')
den1 = input ('enter the value of denominator:')
num2 = input ('enter the value of numerator:')
den2 = input ('enter the value of denominator:')
[num12, den12] = parallel (num1, den1, num2, den2)
printsys (num12, den12)
Output:
enter the value of numerator: [1 2]
num1 =
1 2
enter the value of denominator: [1 2 3]
den1 =
1 2 3
enter the value of numerator: [1 3]
num2 =
1 3
enter the value of denominator: [1 -4 1]
den2 =
1 -4 1
num12 =
0 2 3 2 11
den12 =
1 -2 -4 -10 3
num/den =
2 s^3 + 3 s^2 + 2 s + 11
Input:
num = 9;
den = [1 5]
[numcl, dencl] = cloop (num, den, -1);
Printsys (numcl, dencl)
Output:
num =
9
den =
1 5
num/den =
9
s + 14
Part D
Aim: - If the feedback is not unity then we can use feedback command to simplify
the canonical form.
Input:
num1 = input ('enter the value of numerator:')
den1 = input ('enter the value of denominator:')
num2 = input ('enter the value of numerator:')
den2 = input ('enter the value of denominator:')
[numcl, dencl] = feedback (num1, den1, num2, den2, -1)
Printsys (numcl, dencl)
Output:
enter the value of numerator:[1]
num1 =
1
enter the value of denominator: [1 1]
den1 =
1 1
enter the value of numerator: [2]
num2 =
2
enter the value of denominator: [1 0]
den2 =
1 0
numcl =
0 1 0
dencl =
1 1 2
num/den =
s
s^2 + s + 2
Question. 1
1
s2
1
s
Input
numk = 10;
denk = 1;
num1 = 1;
den1 = [1 1];
numf1 = 1;
denf1 = [1 2];
numf2 = 1;
denf2 = [1 0];
output
sys1 =
s+1
sys2 =
10
s+1
sys3 =
10 s + 20
s^2 + 3 s + 12
sys =
10 s^2 + 20 s
s^3 + 3 s^2 + 22 s + 20
Input
numk = -10;
denk = 1;
num1 = [7 7];
den1 = [1 3 0];
num2 = 1;
den2 = [1 2 1];
output
sys1 =
7s+7
s^2 + 3 s
sysk1 =
-70 s - 70
s^2 + 3 s
sys12 =
sysf =
s^6 - 63 s^5 - 331 s^4 - 743 s^3 - 889 s^2 - 551 s - 140
Question. 3
Input
num1 = 1
den1 = [1 3]
num2 = 2
den2 = [1 1]
num3 = 1
den3 = [1 0]
numf1 = 0.3
denf1 = 1
numf2 = 0.4
denf2 = 1
numk = 10
denk = 1
(num11, den11)
sys = tf(num,den)
Output
sys1 =
10
s+3
10
s+6
sys3 =
20
s^2 + 7 s + 6
sys4 =
20
s^2 + 7 s + 14
sys =
20
s^3 + 7 s^2 + 14 s
Simulink Diagram
Output
2. Impulse Function
Simulink Diagram
Output
MATLAB Code
num = input ('Enter the value of Numerator:')
t = tf (num, den)
subplot (2,1,1)
stepplot(t)
subplot (2,1,2)
impulseplot(t)
Output
Enter the value of Numerator:[1]
num =
4 2 5
t=
4 s^2 + 2 s + 5
(Attach/ Write conclusion for the waveforms obtained on CRO for Input and Controlled response.)
MATLAB Functions: -
rlocus(sys): - rlocus(sys) computes and plots the root locus of the single-input,
single-output LTI model SYS. The root locus plot is used to analyze the negative
feedback loop. and shows the trajectories of the closed-loop poles when the feedback
gain K varies from 0 to Inf. rlocus automatically generates a set of positive gain values
that produce a smooth plot.
rlocus (sys, k): - rlocus (SYS, K) uses a user-specified vector K of gain values.
rlocus (sys1, sys2, …): - rlocus (SYS1, SYS2, …) draws the root loci of several
models SYS1, SYS2, ... on a single plot. You can specify a color, line style, and marker
for each model,
for example: rlocus (sys1,'r’, sys2,'y:’, sys3, 'b')
Part A
MATLAB Code
num = input ('Enter the value of numerator:')
s = tf (num, den)
rlocus(s)
Output
Enter the value of numerator: [ 1 3 10]
num =
1 3 10
den =
1 4 105 202
s=
s^2 + 3 s + 10
Part B
MATLAB Code
num =
1 2
den =
1 5 8 0 0
Enter the value of gain [10]
k=
10
s=
s+2
r=
-2.7286 + 0.7401i
-2.7286 - 0.7401i
0.2286 + 1.5652i
0.2286 - 1.5652i
Part C
MATLAB Code
num = input ('Enter the value of numerator:')
s = tf (num, den)
[r, k] = rlocus(s)
rlocus (s, k)
Output
Enter the value of numerator: [ 1 2]
num =
1 2
den =
1 5 8 0 0
s=
s+2
1.0e+02 *
Columns 1 through 6
0.0000 + 0.0000i 0.0000 - 0.0001i 0.0000 - 0.0001i 0.0000 - 0.0001i 0.0000 - 0.0002i
0.0000 - 0.0002i
-0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i
-0.0250 - 0.0132i
Columns 7 through 12
0.0000 - 0.0002i 0.0000 - 0.0002i 0.0000 - 0.0003i 0.0000 - 0.0003i 0.0000 - 0.0004i
0.0000 - 0.0004i
-0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i
-0.0250 - 0.0132i
Columns 13 through 18
0.0000 - 0.0005i 0.0000 - 0.0006i 0.0000 - 0.0007i 0.0000 - 0.0008i 0.0000 - 0.0009i
0.0000 - 0.0010i
-0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i
-0.0250 - 0.0132i
Columns 19 through 24
0.0000 + 0.0012i 0.0000 + 0.0014i 0.0000 + 0.0016i 0.0000 + 0.0018i 0.0000 +
0.0021i 0.0000 + 0.0024i
0.0000 - 0.0012i 0.0000 - 0.0014i 0.0000 - 0.0016i 0.0000 - 0.0018i 0.0000 - 0.0021i
0.0000 - 0.0024i
-0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0132i -0.0250 - 0.0131i -0.0250 - 0.0131i
-0.0250 - 0.0131i
Columns 25 through 30
0.0001 + 0.0028i 0.0001 + 0.0033i 0.0001 + 0.0038i 0.0001 + 0.0044i 0.0002 +
0.0051i 0.0002 + 0.0059i
0.0001 - 0.0028i 0.0001 - 0.0033i 0.0001 - 0.0038i 0.0001 - 0.0044i 0.0002 - 0.0051i
0.0002 - 0.0059i
-0.0251 - 0.0130i -0.0251 - 0.0130i -0.0251 - 0.0129i -0.0251 - 0.0127i -0.0252 - 0.0126i
-0.0252 - 0.0124i
Columns 31 through 36
0.0003 - 0.0068i 0.0005 - 0.0079i 0.0006 - 0.0091i 0.0009 - 0.0105i 0.0013 - 0.0121i
0.0018 - 0.0140i
-0.0253 + 0.0121i -0.0255 + 0.0117i -0.0256 + 0.0112i -0.0259 + 0.0105i -0.0263 +
0.0097i -0.0268 + 0.0086i
-0.0253 - 0.0121i -0.0255 - 0.0117i -0.0256 - 0.0112i -0.0259 - 0.0105i -0.0263 - 0.0097i
-0.0268 - 0.0086i
Columns 37 through 42
0.0024 - 0.0160i 0.0032 - 0.0182i 0.0036 - 0.0192i 0.0040 - 0.0202i 0.0040 - 0.0202i
0.0040 - 0.0202i
-0.0274 - 0.0071i -0.0282 - 0.0050i -0.0286 - 0.0035i -0.0290 - 0.0003i -0.0290 + 0.0000i
-0.0293 + 0.0000i
Columns 43 through 48
0.0042 + 0.0206i 0.0053 + 0.0232i 0.0067 + 0.0260i 0.0082 + 0.0291i 0.0099 +
0.0324i 0.0119 + 0.0361i
0.0042 - 0.0206i 0.0053 - 0.0232i 0.0067 - 0.0260i 0.0082 - 0.0291i 0.0099 - 0.0324i
0.0119 - 0.0361i
Columns 49 through 54
0.0140 + 0.0400i 0.0164 + 0.0443i 0.0190 + 0.0490i 0.0219 + 0.0542i 0.0251 +
0.0599i 0.0287 + 0.0661i
0.0140 - 0.0400i 0.0164 - 0.0443i 0.0190 - 0.0490i 0.0219 - 0.0542i 0.0251 - 0.0599i
0.0287 - 0.0661i
Columns 55 through 57
k=
1.0e+06 *
Columns 1 through 11
Columns 12 through 22
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000
Columns 23 through 33
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000
Columns 34 through 44
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000
Columns 45 through 55
0.0000 0.0000 0.0001 0.0001 0.0001 0.0001 0.0002 0.0003 0.0003 0.0005
0.0006
Columns 56 through 57
6.8615 Inf
Part D
MATLAB Code
num1 = input ('Enter the value of numerator1:')
den1 = input ('Enter the value of denominator1:')
s1 = tf (num1, den1)
s2 = tf (num2, den2)
Output
Enter the value of numerator1: [ 1 2]
num1 =
1 2
1 5 8 0 0
s1 =
s+2
num2 =
1 3 10
den2 =
1 4 105 202
s2 =
s^2 + 3 s + 10
MATLAB commands: -
bode (SYS): - bode (SYS) draws the Bode plot of the dynamic system SYS. The
frequency range and number of points are chosen automatically.
bode (SYS, {WMIN, WMAX}): - bode (SYS, {WMIN, WMAX}) draws the Bode
plot for frequencies between WMIN and WMAX in radians/Time Unit (relative to
the time units specified in SYS. Time Unit, the default being seconds).\
bode (SYS, W): - bode (SYS, W) uses the vector W of frequencies (in
radians/Time Unit) to evaluate the frequency response. See LOGSPACE to generate
logarithmically spaced frequency vectors.
bode (SYS1, SYS2, ….., W): - bode(SYS1,SYS2,...,W) graphs the Bode response
of several systems SYS1,SYS2,... on a single plot. The frequency vector W is optional.
You can specify a color, line style, and marker for each model, for
example: bode (sys1, 'r', sys2, 'y--', sys3, 'gx').
Part A
Input
num=input (‘Enter the numerator:’)
bode (sys)
grid on
Output
Enter the numerator:
[20]
num =
20
[ 0.1 1.0 0]
den =
0.1000 1.0000 0
sys =
20
0.1 s^2 + s
grid on
Output
num1 =
20
den1 =
0.1000 1.0000 0
num2 =
80
Enter the denominator2: [1 22 40 0]
den2 =
1 22 40 0
sys1 =
20
0.1 s^2 + s
sys2 =
80
s^3 + 22 s^2 + 40 s
Part C
Input
num1=input ('Enter the numerator1:')
grid on
Output
num1 =
20
den1 =
0.1000 1.0000 0
num2 =
80
den2 =
1 22 40 0
sys1 =
20
0.1 s^2 + s
sys2 =
80
s^3 + 22 s^2 + 40 s
Part D
Input
num=input (‘Enter the numerator:’)
grid on
Output
Enter the numerator: [20]
num =
20
den =
0.1000 1.0000 0
sys =
20
0.1 s^2 + s
bode(sys)
grid on
Output
num = 20
den =
0.1000 1.0000 0
sys =
20
0.1 s^2 + s
Page | 61
mag(:,:,34) = 0.0544
mag(:,:,26) =
0.5803
3.6180 mag(:,:,43) =
mag(:,:,35) = 0.0400
mag(:,:,27) =
0.4398
2.9890 mag(:,:,44) =
mag(:,:,36) = 0.0293
mag(:,:,28) =
0.3307
2.4469 mag(:,:,45) =
mag(:,:,37) = 0.0215
mag(:,:,29) =
0.2471
1.9822 mag(:,:,46) =
mag(:,:,38) = 0.0158
mag(:,:,30) =
0.1837
1.5875 mag(:,:,47) =
mag(:,:,39) = 0.0115
mag(:,:,31) =
0.1361
1.2560 mag(:,:,48) =
mag(:,:,40) = 0.0085
mag(:,:,32) =
0.1005
0.9819 mag(:,:,49) =
mag(:,:,41) =
0.0062
mag(:,:,33) = 0.0740
0.7588 mag(:,:,50) =
mag(:,:,42) =
Page | 62
0.0045
phase(:,:,7) =
mag(:,:,59) =
mag(:,:,51) = -91.4615
2.7327e-04
0.0033
phase(:,:,8) =
mag(:,:,60) =
mag(:,:,52) = -91.7083
1.9999e-04
0.0024
phase(:,:,9) =
phase(:,:,1) =
mag(:,:,53) = -91.9967
-90.5729
0.0018
phase(:,:,10) =
phase(:,:,2) =
mag(:,:,54) = -92.3337
-90.6697
0.0013
phase(:,:,11) =
phase(:,:,3) =
mag(:,:,55) = -92.7275
-90.7829
9.5256e-04
phase(:,:,12) =
phase(:,:,4) =
mag(:,:,56) = -93.1874
-90.9151
6.9715e-04
phase(:,:,13) =
phase(:,:,5) =
mag(:,:,57) = -93.7245
-91.0697
5.1022e-04
phase(:,:,14) =
phase(:,:,6) =
mag(:,:,58) = -94.3515
-91.2504
3.7340e-04
Page | 63
phase(:,:,15) = -107.2295
-95.0832 phase(:,:,32) =
phase(:,:,24) =
-141.6477
phase(:,:,16) = -109.9262
-95.9363 phase(:,:,33) =
phase(:,:,25) =
-145.9069
phase(:,:,17) = -112.9652
-96.9302 phase(:,:,34) =
phase(:,:,26) =
-149.9273
phase(:,:,18) = -116.3517
-98.0866 phase(:,:,35) =
phase(:,:,27) =
-153.6483
phase(:,:,19) = -120.0727
-99.4301 phase(:,:,36) =
phase(:,:,28) =
-157.0348
phase(:,:,20) = -124.0931
-100.9872 phase(:,:,37) =
phase(:,:,29) =
phase(:,:,21) = -160.0738
-128.3523
-102.7867
phase(:,:,38) =
phase(:,:,30) =
phase(:,:,22) = -162.7705
-132.7662
-104.8580
phase(:,:,39) =
phase(:,:,31) =
phase(:,:,23) = -165.1420
-137.2338
Page | 64
phase(:,:,48) =
phase(:,:,40) = -178.9303
-176.2755
-167.2133
phase(:,:,57) =
phase(:,:,49) =
phase(:,:,41) = -179.0849
-176.8126
-169.0128
phase(:,:,58) =
phase(:,:,50) =
phase(:,:,42) = -179.2171
-177.2725
-170.5699
phase(:,:,59) =
phase(:,:,51) =
phase(:,:,43) = -179.3303
-177.6663
-171.9134
phase(:,:,60) =
phase(:,:,52) =
phase(:,:,44) = -179.4271
-178.0033
-173.0698 wout =
phase(:,:,53) = 1.0e+03 *
phase(:,:,45) =
-178.2917 0.0001
-174.0637 0.0001
0.0001
phase(:,:,54) = 0.0002
phase(:,:,46) = 0.0002
-178.5385 0.0002
-174.9168 0.0003
0.0003
phase(:,:,55) = 0.0003
phase(:,:,47) = 0.0004
-178.7496 0.0005
-175.6485 0.0006
0.0007
phase(:,:,56) = 0.0008
Page | 65
0.0009 0.0126 0.1796
0.0010 0.0148 0.2099
0.0012 0.0173 0.2454
0.0014 0.0202 0.2868
0.0017 0.0236 0.3353
0.0019 0.0276 0.3919
0.0023 0.0322 0.4582
0.0027 0.0377 0.5356
0.0031 0.0441 0.6261
0.0036 0.0515 0.7318
0.0042 0.0602 0.8555
0.0050 0.0704 1.0000
0.0058 0.0823
0.0068 0.0962
0.0079 0.1124
0.0092 0.1314
0.0108 0.1536
Page | 66
Part F
Input
num=input (‘Enter the numerator:’)
den=input (‘Enter the denotator:’)
bode (sys)
grid on
Output
Enter the numerator:
[20]
num =
20
[0.1 1 0]
den =
0.1000 1.0000 0
sys =
Page | 67
20
0.1 s^2 + s
Page | 68
mag(:,:,13) = 9.3610
mag(:,:,24) =
19.9007
mag(:,:,19) = 3.2980
mag(:,:,14) = 7.9441
mag(:,:,25) =
17.7727
mag(:,:,20) = 2.7116
mag(:,:,15) = 6.7240
mag(:,:,26) =
15.1639
mag(:,:,21) = 2.2076
mag(:,:,16) = 5.6718
mag(:,:,27) =
12.9275
mag(:,:,22) = 1.7775
mag(:,:,17) = 4.7630
mag(:,:,28) =
11.0088
mag(:,:,23) = 1.4142
mag(:,:,18) = 3.9773
mag(:,:,29) =
Page | 69
mag(:,:,40) =
1.1116
mag(:,:,35) = 0.0462
0.8633 0.0339
mag(:,:,36) =
0.6631 0.0249
mag(:,:,37) =
0.5044 0.0199
mag(:,:,38) =
0.3804 0.0182
mag(:,:,39) =
0.2849 0.0133
Page | 70
mag(:,:,51) = -90.5729
mag(:,:,46) = 0.0020
phase(:,:,2) =
0.0098
mag(:,:,52) = -91.1458
mag(:,:,47) = 0.0015
phase(:,:,3) =
0.0071
mag(:,:,53) = -91.3398
mag(:,:,48) = 0.0011
phase(:,:,4) =
0.0052
mag(:,:,54) = -91.5666
mag(:,:,49) = 7.9984e-04
phase(:,:,5) =
0.0038
mag(:,:,55) = -91.8318
mag(:,:,50) = 1.9999e-04
phase(:,:,6) =
0.0028
phase(:,:,1) = -92.1418
Page | 71
phase(:,:,7) = -95.4629
phase(:,:,18) =
-92.5042
phase(:,:,13) = -101.8119
phase(:,:,8) = -95.7106
phase(:,:,19) =
-92.9277
phase(:,:,14) = -103.7421
phase(:,:,9) = -96.3811
phase(:,:,20) =
-93.4225
phase(:,:,15) = -105.9593
phase(:,:,10) = -97.4508
phase(:,:,21) =
-94.0005
phase(:,:,16) = -108.4908
phase(:,:,11) = -98.6949
phase(:,:,22) =
-94.6754
phase(:,:,17) = -111.3587
phase(:,:,12) = -100.1393
Page | 72
phase(:,:,23) = phase(:,:,34) =
-139.4647
phase(:,:,24) = phase(:,:,35) =
-143.8228
phase(:,:,25) = phase(:,:,36) =
phase(:,:,26) = -147.9802
phase(:,:,37) =
-126.1772
phase(:,:,32) = -166.2579
phase(:,:,27) = -151.8636
phase(:,:,38) =
-130.5353
phase(:,:,33) = -168.1881
phase(:,:,28) = -155.4251
phase(:,:,39) =
-135
Page | 73
-169.8607
phase(:,:,45) = -177.8582
phase(:,:,40) = -175.3246
phase(:,:,51) =
-171.3051
phase(:,:,46) = -178.1682
phase(:,:,41) = -175.9995
phase(:,:,52) =
-172.5492
phase(:,:,47) = -178.4334
phase(:,:,42) = -176.5775
phase(:,:,53) =
-173.6189
phase(:,:,48) = -178.6602
phase(:,:,43) = -177.0723
phase(:,:,54) =
-174.2894
phase(:,:,49) = -178.8542
phase(:,:,44) = -177.4958
phase(:,:,55) =
-174.5371
phase(:,:,50) = -179.4271
Page | 74
0.0039 0.2287
0.0046 0.2674
0.0063 0.3656
0.0086 0.5000
0.0002 0.0117
0.0002 0.0137
0.0003 0.0160
0.0003 0.0187
0.0004 0.0219
0.0004 0.0256
0.0005 0.0299
0.0006 0.0350
0.0007 0.0409
0.0008 0.0478
0.0010 0.0559
0.0010 0.0654
0.0011 0.0765
0.0013 0.0894
0.0015 0.1000
0.0018 0.1046
0.0021 0.1223
0.0024 0.1430
0.0029 0.1672
0.0033 0.1955
Page | 75
Page | 76
Also verify the response for Compensators using CRO.
(Attach /Explain the waveforms for response for various compensators using CRO.)
Page | 77
EXPERIMENT 10
Aim: To perform PID controller using MATLAB Simulink and verify its response.
Ki Kd*s
Kp + +
s Tf*s+1
The scalars Kp, Ki, Kd, and Tf specify the proportional gain, integral gain, derivative
gain, and filter time constant. The Tf value must be nonnegative for stability. The
default values are Kp=1, Ki=0, Kd=0, and Tf=0. If a parameter is omitted, its default
value is used. For example, pid(Kp,Ki,Kd) creates a pid controller with pure derivative
term. The resulting SYS is of type pid if Kp,Ki,Kd,Tf are all real, and of type GENSS if
SYS = pid (Kp,Ki,Kd,Tf,Ts) creates a discrete-time pid controllerwith sample time Ts>0.
The discrete-time pid formula is
Kd
Kp + Ki * IF(z) + --------------
Tf + DF(z)
where IF(z) and DF(z) are the discrete integrator formulas for theintegral and
Page | 78
properties to specify these formulas. Available formulas include:
'Trapezoidal' (Ts/2)*(z+1)/(z-1)
The default formula is Forward Euler. The 'I Formula' and 'D Formula'settings are
ignored for continuous-time PIDs. The following settings are disallowed because
Simulink Diagram:
Page | 79
Output:
Page | 80
EXPERIMENT: - 11
APPARATUS: Software-MATLAB
Computer.
THEORY:
The time response has utmost importance for the design and analysis of control systems
because these are inherently time domain systems where time is independent variable.
During the analysis of response, the variation of output with respect to time can be studied
and it is known as time response. To obtain satisfactory performance of the system with
respect to time must be within the specified limits. From time response analysis and
corresponding results, the stability of system, accuracy of system and complete evaluation
can be studied easily.
Due to the application of an excitation to a system, the response of the system is known as
timeresponse and it is a function of time. The two parts of response of any system:
Transient response: The part of the time response which goes to zero after large
interval oftime is known as transient response.
Steady state response: The part of response that means even after the transients have
died outis said to be steady state response.
The total response of a system is sum of transient response and steady state response:
A second order control system is one wherein the highest power of ‘s’ in the
denominator ofits transfer function equals 2. Transfer function is given by:
Page | 81
MATLAB PROGRAM:
Example No 1
>> wn=5
wn =
5
>> z=0.6
z=
0.600
0
>>
n=[wn*wn]
n=
25
Page | 82
>> p=sqrt(1-z^2)
p=
0.8000
>>
wd=wn*p
wd =
>>
h=[p/z]
h=
1.3333
>>
k=atan(h)
k=
0.9273
>> m=pi-k;
>>
tr=[m/wd]
tr =
0.5536
>>
tp=[pi/wd]
tp =
0.7854
Page | 83
>> q=z*wn
q=
3
>>
ts=[h/q]
ts =
0.4444
>> r=z*pi
r=
1.8850
>> f=[r/p]
f=
2.3562
>> mp=exp(-f)
mp =
0.0948
>> num=[0 0 n]
num =
0 0 25
den =
1 6 25
>>
Page | 84
s=tf(num,den)
Transfer
function:
25
s^2 + 6 s + 25
>> hold on
>> step(s)
>> impulse(s)
>> hold off
Page | 85
Example No 2
>> wn=4.899
wn =
4.8990
>> z=.5103
z = 0.5103
>>
n=[wn*wn]
n=
24.0002
>> p=sqrt(1-z^2)
p=
0.8600
>>
wd=wn*p
wd =
4.2131
>>
h=[p/z]
h=
1.6853
>>
k=atan(h)
Page | 86
k=
1.0353
>> m=pi-k;
>>
tr=[m/wd]
tr =
0.4999
>>
tp=[pi/wd]
tp =
0.7457
>> q=z*wn
q=
2.5000
>>
ts=[h/q]
ts =
0.6741
>> r=z*pi
r=
1.6032
>>
f=[r/p]
f=
1.8641
>> mp=exp(-f)
Page | 87
mp =
0.1550
>> num=[0 0 n]
num =
0 0 24.0002
den =
>>
s=tf(num,den)
Transfer
function:
24
s^2 + 5 s + 24
>> hold on
>> step(s)
>> impulse(s)
>> hold off
Page | 88
Date Sign Grade/Mark
Page | 89
EXPERIMENT: - 12
APPARATUS: Software-MATLAB
Computer.
THEORY:
The transfer function is defined as the ratio of Laplace transform of output to Laplace
transform ofinput. The transfer function of a given state model is given by:
MATLAB PROGRAM:-
Page | 90
Case 2 :- Multiple Input and Multiple Output (MIMO)
%This program is formulated for double input double output
system.
n=input('enter the order of the system=')
m=input('enter the number of inputs=')
p=input('enter the number of outputs=')
A=rand(n,n)
B=rand(n,m)
C=rand(p,n)
D=rand(p,m)
[num,den]=ss2tf(A,B,C,D,1)
[num1,den1]=ss2tf(A,B,C,D,2)
a=tf(num(1,:),den)
b=tf(num(2,:),den)
c=tf(num1(1,:),den1)
d=tf(num1(2,:),den1)
Example :- 1
>> n=[3]
n=
3
>> m=[1]
m=
1
>> p=[1]
p=
1
>>
A=rand(n,n)
A=
0.4218 0.9595 0.8491
0.9157 0.6557 0.9340
0.7922 0.0357 0.6787
>>
B=rand(n,m)
B=
0.7577
0.7431
0.3922
Page | 91
>>
C=rand(p,n)
C=
0.6555 0.1712 0.7060
>>
D=rand(p,m)
D=
0.0318
>> [num,den]=ss2tf(A,B,C,D,1)
num =
0.0318 0.8449 0.1902 -0.0510
den =
1.0000 -1.7562 -0.5768 0.1261
>>
a=tf(num(1,:),den)
Transfer function:
0.03183 s^3 + 0.8449 s^2 + 0.1902 s - 0.05098
Page | 92
Case 2 :- Multiple Input and Multiple Output (MIMO)
>> n=[3]
n=
3
>> m=[2]
m=
2
>> p=[2]
p=
2
>>
A=rand(n,n)
A=
0.2769 0.8235 0.9502
0.0462 0.6948 0.0344
0.0971 0.3171 0.4387
>>
B=rand(n,m)
B=
0.3816 0.1869
0.7655 0.4898
0.7952 0.4456
>>
C=rand(p,n)
C=
0.6463 0.7547 0.6797
0.7094 0.2760 0.6551
>> D=rand(p,m)
D=
0.1626 0.4984
0.1190 0.9597
Page | 93
>> [num,den]=ss2tf(A,B,C,D,1)
num =
0.1626 1.1355 -0.0207 -0.1865
den =
>>
[num1,den1]=ss2tf(A,B,C,D,2)
num1 =
0.4984 0.0903 0.2125 -0.1167
0.9597 -0.7941 0.6343 -0.1548
den1 =
1.0000 -1.4105 0.4775 -0.0173
>>
a=tf(num(1,:),den)
Transfer function:
0.1626 s^3 + 1.135 s^2 - 0.02065 s - 0.1865
>>
b=tf(num(2,:),den)
Transfer function:
0.119 s^3 + 0.8351 s^2 + 0.2715 s - 0.2363
Page | 94
>> c=tf(num1(1,:),den1)
Transfer function:
0.4984 s^3 + 0.09032 s^2 + 0.2125 s - 0.1167
There are three methods for obtaining state model from transfer function:
1. Phase variable method
2. Physical variable method
3. Canonical variable method
Out of three methods given above canonical form is probably the most straight forward
method for converting from the transfer function of a system to a state space model is to
generate a model in "controllable canonical form." This term comes from Control Theory
but its exact meaning is not important to us. To see how this method of generating a state
space model works, consider thethird order differential transfer function:
We start by multiplying by Z(s)/Z(s) and then solving for Y(s) and U(s) in terms of Z(s). We
alsoconvert back to a differential equation.
We can now choose z and its first two derivatives as our state variables
Page | 95
Now we just need to form the output
From these results we can easily form the state space model:
In this case, the order of the numerator of the transfer function was less than that of the
denominator.
MATLAB PROGRAM:-
num1=input('enter the numerator of the transfer function=')
den1=input('enter the denominator of the transfer function=')
[A,B,C,D]=tf2ss(num1,den1)
EXAMPLE:1
>> num=[0 0 1]
num =
0 0 1
>> den=[1 2 3]
den =
1 2 3
>>
s=tf(num,den)
Transfer
function:
1
s^2 + 2 s + 3
>> [A,B,C,D]=tf2ss(num,den)
A=
-2 -3
1 0
Page | 96
B=
1
0
C=
0 1
D=
EXAMPLE:2
>> num=[1 2 3]
num =
1 2 3
>> den=[1 2 5 6]
den =
1 2 5 6
>> s=tf(num,den)
Transfer
function:s^2 +
2s+3
s^3 + 2 s^2 + 5 s + 6
>> [A,B,C,D]=tf2ss(num,den)
A=
-2 -5 -6
1 0 0
0 1 0
B=
1
0
0
C=
1 2 3
D=
0
Page | 97
EXAMPLE:3
>> num=[ 1 3 5]
num =
1 3 5
>> den=[2 4 6 8]
den =
2 4 6 8
>> s=tf(num,den)
Transfer function:
s^2 + 3 s + 5
2 s^3 + 4 s^2 + 6 s + 8
>> [A,B,C,D]=tf2ss(num,den)
A=
-2 -3 -4
1 0 0
0 1 0
B=
1
0
0
C=
D=
Page | 98