0% found this document useful (0 votes)
51 views25 pages

LCS LAB 05 Asfar

This lab covered state space modeling in MATLAB and LabVIEW. Students learned to convert between frequency and state space representations, determine system responses using various inputs, and interconnect systems. Objectives like understanding state space modeling, system responses, and interconnection were achieved.

Uploaded by

Ahmed Razi Ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views25 pages

LCS LAB 05 Asfar

This lab covered state space modeling in MATLAB and LabVIEW. Students learned to convert between frequency and state space representations, determine system responses using various inputs, and interconnect systems. Objectives like understanding state space modeling, system responses, and interconnection were achieved.

Uploaded by

Ahmed Razi Ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

NUST School of Electrical Engineering and Computer Science

Faculty Member: Sir Yasir Rizwan Date: 5/03/2024

Semester: 6th Semester Section: BEE – 13D

Department of Electrical Engineering

EE-379: Control Systems

Lab No 5: State Space, Response of Systems to various inputs, and


interconnection of systems

PLO4/ PLO4/ PLO5/ PLO8/ PLO9/


CLO5 CLO5 CLO6 CLO7 CLO8

Name Reg. No Viva / Quiz Analysis of Modern Ethics and Individual


/ Lab data in Tool Usage Safety and Team
Performanc Lab Work
e Report

5 Marks 5 Marks 5 Marks 5 Marks 5 Marks


Malik Asfar Ahmad 374854

Umer Abdullah 375870


Khan

Abdul Rafay 393786

Abdullah Mustafa 372098


1. Introduction:

In this lab, we will be using both MATLAB and LabVIEW to create state space models of
systems and find the responses of systems to various inputs. State space is a method to model
dynamic systems in time-domain and is an alternative to modeling in frequency domain using
Laplace. We will also learn functions in MATLAB that are used to interconnect multiple
systems together.

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.

After completing the lab, the objectives we had set were reasonably achieved. We learnt
new concepts in system modeling.

2|Page
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

den=[a*c-(b^2) e*c -a*d -e*d 0];


num=[f*c 0 -f*d];

OUTPUT

5|Page
6|Page
7|Page
MATLAB CODE

den=[a*c-(b^2) e*c -a*d -e*d 0];


num=[f*b 0 0];

OUTPUT

8|Page
9|Page
Example 2 ( State Space representation of RLC circuit in LabVIEW)

Figure 4: Block Diagram

Figure 5: Settings for state space representation

10 | P a g e
EXERCISE 2

MATLAB CODE

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);

11 | P a g e
EXERCISE 3

BLOCK DIAGRAM

BLOCK DIAGRAM

12 | P a g e
13 | P a g e
BLOCK DIAGRAM

14 | P a g e
EXERCISE 4

15 | 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);

16 | P a g e
MATLAB CODE

num = [b*f, 0];


den = [(a*c-b^2), e*c, -d*a, -e*d];
G_s = tf(num,den);
impulse(G_s);

17 | 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);

18 | P a g e
MATLAB CODE

num = 11.624;
den = [1 1.193e04];
G_s = tf(num,den);

[u,t] = gensig("sine", 0.3142, 10, 0.0005);


lsim(G_s,u,t);

EXERCISE 7

MATLAB CODE

syms s;
step_input = 1/s ; G1 = 11.62/(s+11930);

Gs = G1 * step_input;

res = ilaplace(Gs);

19 | 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

syms s;
ramp_input = 1/(s^2) ; G1 = 11.62/(s+11930);

Gs = G1 * ramp_input;

res = ilaplace(Gs);

OUTPUT

20 | P a g e
21 | 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

22 | 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);

23 | P a g e
OUTPUT

24 | P a g e
Conclusion

In this lab, we were presented with novel ideas in system modeling. We developed
state-space models using MATLAB and LabVIEW, and gained insights into the
different responses achievable by implementing diverse inputs in dynamical systems.
The theoretical understanding we acquired regarding state space modeling and
system interconnection can be effectively utilized for modeling systems in software
applications like MATLAB and LabVIEW.

25 | P a g e

You might also like