LCS Lab 05
LCS Lab 05
2. Objectives:
For attempting this lab, we need to remember the things that we learnt in previous labs. We
will be working with the transfer functions of motor and pendulum that we already made in
MATLAB and the DC motor model we made in LabVIEW.
It is expected that after finishing this lab, we will have learnt the basics of state space
modeling in MATLAB and LabVIEW. We will be familiar with how to convert
between frequency domain and state space representations of systems in MATLAB,
how to know the response of various inputs to a system using functions in MATLAB
and blocks in Simulink, determine system response using LabVIEW, and interconnect
systems together.
EXERCISE 1
MATLAB CODE
J=1.84*(exp(-6));
m=0.027; r=0.0826;
Kg=1;
Jm=1.8*exp(-4);
ng=1; nm=0.69;
L=0.0955;
g=9.8;
Kt=0.0334;
R=8.7; e=2.178;
a=J+m*(r^2)+ng*J*(Kg^2);
b=m*L*r; c=(4*m*(L^2))/3;
d=m*g*L;
f=(ng*nm*Kg*Kt)/R;
numS=[f*c 0 -d*f];
denS=[(a*c-b^2) e*c -a*d -
e*d]; ms_tf=tf(numS, denS)
ms_ss = ss(ms_tf)
OUTPUT
3|Page
4|Page
MATLAB CODE
5|Page
OUTPUT
6|Page
7|Page
MATLAB CODE
OUTPUT
8|Page
9|Page
Example 2 ( State Space representation of RLC circuit in LabVIEW)
MATLAB CODE
10 | P a g e
num = 11.624; den
= [1 1.193e04];
G_s = tf(num,den);
MATLAB CODE
num = 11.409;
den = [1 1.193e04 0];
G_s = tf(num,den);
MATLAB CODE
a = 3.6605e-04; b =
2.1298e-04; c
= 3.2833e-04;
d = 0.0253; e
= 2.718; f =
0.0026;
num = [b*f, 0];
den = [(a*c-b^2), e*c, -d*a, -e*d];
G_s = tf(num,den);
EXERCISE 3
BLOCK DIAGRAM
11 | P a g e
BLOCK DIAGRAM
12 | P a g e
BLOCK DIAGRAM
13 | P a g e
EXERCISE 4
14 | P a g e
EXERCISE 5 (IMPULSE RESPONSE)
MATLAB CODE
num = 11.624;
den = [1 1.193e04];
G_s = tf(num,den);
impulse(G_s);
MATLAB CODE
clear all;
num = 11.409;
den = [1 1.193e04 0];
G_s = tf(num,den);
impulse(G_s);
15 | P a g e
MATLAB CODE
16 | P a g e
EXERCISE 6
MATLAB CODE
num = 11.624;
den = [1 1.193e04];
G_s = tf(num,den);
t = 0:0.1:5;
u = t;
lsim(G_s,u,t);
MATLAB Code
num = 11.624;
den = [1 1.193e04];
G_s = tf(num,den);
T = 5;
[u,t] = gensig("square", T,30,0.1);
17 | P a g e
MATLAB CODE
num = 11.624;
den = [1 1.193e04];
G_s = tf(num,den);
EXERCISE 7
MATLAB CODE
syms s;
step_input = 1/s ; G1 = 11.62/(s+11930);
Gs = G1 * step_input;
res = ilaplace(Gs);
18 | P a g e
OUTPUT
This expression obtained for step response agrees with the plots we had obtained earlier for
step response. The response eventually settles to the value 9.7402e-04 and our plots verify this.
MATLAB CODE
Gs = G1 * ramp_input;
res = ilaplace(Gs);
OUTPUT
19 | P a g e
MATLAB CODE
syms s;
impulse_input = 1; G1 = 11.62/(s+11930);
Gs = G1 * impulse_input;
res = ilaplace(Gs);
OUTPUT
EXERCISE 8
MATLAB CODE
20 | P a g e
num1 = (5);
den1 = (1);
H_s =
tf(num1,den1); num =
11.624; den = [1 1.193e04];
G_s = tf(num,den);
sys = feedback(G_s,H_s);
21 | P a g e
OUTPUT
22 | P a g e
Conclu
sion
23 | P a g e