0% found this document useful (0 votes)
12 views

Cycle - II Experiments

The document discusses simulating linear systems using state variable formulation in MATLAB. It describes simulating characteristics of first and second order systems with step and impulse inputs. It also discusses numerically simulating nonlinear differential equations using MATLAB.

Uploaded by

Er. Shaju
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)
12 views

Cycle - II Experiments

The document discusses simulating linear systems using state variable formulation in MATLAB. It describes simulating characteristics of first and second order systems with step and impulse inputs. It also discusses numerically simulating nonlinear differential equations using MATLAB.

Uploaded by

Er. Shaju
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/ 26

Expt.

No: Date:

ANALOG (OP-AMP BASED) SIMULATION OF LINEAR DIFFERENTIAL EQUATION


AIM
To digitally simulate the characteristics of Linear SISO systems using state variable formulation.

APPARATU REQUIRED
1. A PC with MATLAB package.

THEORY
State Variable approach is a more general mathematical representation of a system, which, along with
the output, yields information about the state of the system variables at some predetermined points along
the flow of signals. It is a direct time-domain approach, which provides a basis for modern control theory
and system optimization. SISO (single input single output) linear systems can be easily defined with
transfer function analysis. The transfer function approach can be linked easily with the state variable
approach.

The state model of a linear-time invariant system is given by the following equations:
Ẋ (t) = A X(t) + B U(t) State equation
Y(t) = C X(t) + D U(t) Output equation
Where A = n x n system matrix, B = n x m input matrix,
C= p x n output matrix and
D = p x m transmission matrix,
2. Impulse Input Open Loop –I Order
Impulse Response
4

3.5

2.5

Amplitude
2

1.5

0.5

0
0 0.5 1 1.5 2 2.5 3
Time (sec)

PROGRAM:
B. Close Loop Response
1. Response of Step input
n=[4];
d=[1 2];
sys=tf(n,d);
sys=feedback(sys,1,-1)
step(sys)
2. Response of Impulse input
n=[4];
d=[1 2];
sys=tf(n,d);
sys=feedback(sys,1,-1)
impulse(sys)

Simulink Model
1. Step Input Close Loop –I Order
Step Response
0.7

0.6

System: sys
Time (sec): 0.192
0.5 Amplitude: 0.456

0.4

Amplitude
0.3

0.2

0.1

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (sec)

2. Impulse Input Close Loop –I Order

Impulse Response
4

3.5

2.5
Amplitude

1.5

0.5

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (sec)

Second Order System


TF= 4/s2+6s+16
1. Open Loop Response of Step Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
step(sys)
2.Open Loop Response of impulse Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
impulse(sys)
Simulink Model
Step Input Open Loop –II Order

Step Response
0.35

0.3

0.25

0.2
Amplitude

0.15

0.1

0.05

0
0 0.5 1 1.5 2 2.5
Time (sec)

Impulse Input Open Loop –II Order

Impulse Response
0.45

0.4

0.35

0.3

0.25
Amplitude

0.2

0.15

0.1

0.05

-0.05
0 0.5 1 1.5 2 2.5 3
Time (sec)
Close Loop Response
1. Step Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
sys=feedback(sys,1,-1) ;
step(sys)
2. Impulse Input

n=[4];
d=[1 6 16];
sys=tf(n,d);
sys=feedback(sys,1,-1) ;
impulse(sys)
Simulink Model
1. Step Input Close Loop –II Order

Step Response
0.25

0.2

0.15
Amplitude

0.1

0.05

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
Time (sec)
2. Impulse Input Close Loop –II Order

Impulse Response
0.45

0.4

0.35

0.3

0.25
Amplitude

0.2

0.15

0.1

0.05

-0.05
0 0.5 1 1.5 2 2.5
Time (sec)
RESULT
Thus the digital simulation of time response characteristics of a first and second order linear system with
step and impulse inputs were simulated using MATLAB and outputs are observed for respective inputs.
PROGRAM:
syms p(t) m(t) l(t) T Y
Eqns = [diff(p(t),t) == (3*p(t)*(1-p(t)))-(30*(p(t)*m(t))); diff(m(t),t) == ((25*p(t)+l(t))*m(t)*(1-m(t)))-
m(t); diff(l(t),t) == (15*(1+tanh(2*m(t)-2)))-l(t)]
[DEsys,Subs] = odeToVectorField(Eqns);
DEFcn = matlabFunction(DEsys, 'Vars',{T,Y});
tspan = [0,25];
y0 = [0.01 0.05 0.539];

[T,Y] = ode45(DEFcn, tspan, y0);


figure(1)
plot(T,Y)
legend('p(t)','m(t)','l(t)')

grid
Expt. No: Date:

NUMERICAL SIMULATION OF GIVEN NON-LINEAR DIFFERENTIAL EQUATION


AIM
To digitally simulate the characteristics of Non Linear SISO systems using state variable formulation.

APPARATU REQUIRED
1. A PC with MATLAB package.

THEORY
An ordinary differential equation (ODE) is an equation that involves derivatives of an unknown function.
Ordinary differential equations are used to model changeover a single independent variable (it is usually
t for time). These equations do not involve any partial derivatives. Differential equations contain three
types of variables: an independent variable, at least one dependent variable (these will be functions of
the independent variable), and the parameters. ODE’s can contain multiple iterations of derivatives and
are named accordingly (i.e. if there are only first derivatives, then the ODE is called a first order ODE).

RESULT
Thus the digital simulation of time response characteristics of a nonlinear differential equations were
simulated using MATLAB and outputs are observed for respective inputs.
PROGRAM
1. First Order Differential Equation
function dy = f(t,y)

dy = -2*y + (t>=0)-(t>=1);

t= [0 5];

inity=0;

[t,y]=ode45(@f, t, inity);

plot(t,y)

Figure 1: Solution of first order differential equation

2. Second Order Differential Equation


function dz=f2(t,z)

dz=[-3*z(1)-2*z(2)+cos(2*t); z(1)];

t=[0 10];

initz=[1; 0];

[t,z]=ode45(@f2, t, initz);

plot(t, z(:,2))
Expt. No: Date:

MATHEMATICAL MODELING AND SIMULATION OF PHYSICAL SYSTEMS


a. Mechanical system
AIM:
To design and simulate a mathematical model for a linear mechanical system.

APPARATUS:

S.no Software

1. MATLAB

2. Simulink

FORMULA:
The corresponding differential equations are as follows:

Consider the parameters as given below:


M1 = M2 = 5 kg
K1 = 2 N/m
K2 = 6 N/m
f1 = 2N/m/s
f2 = 3N/m/s
The transfer function in s domain for the corresponding differential equation is:
𝑦2(𝑠) 5𝑠2 + 5𝑠 + 11
=
(𝑠) 25𝑠4 + 40𝑠3 + 91𝑠2 + 27𝑠 + 30

BLOCK DIAGRAM/CODE:

1. Code:

>>num=[5 5 11];
>>den=[25 40 91 27 30];
>>G=tf(num,den);
>>kp=dcgain(G);
>>ess=1/(1+kp);
>>step(G);
2. Simulink model:

OBSERVATIONS:

1. Code:
num = 5 5 11
den = 25 40 91 27 30

G=
5 s^2 + 5 s + 11
--- - - - - -

25 s^4 + 40 s^3 + 91 s^2 + 27 s + 30

Continuous-time transfer function.kp = 0.3667

ess = 0.7317
2. Simulink:
MEASUREMENTS VALUES

60.484%
Overshoot
0.806
Preshoot
5.563
Undershoot
1.8585 seconds
Rise Time
1.848 seconds
Fall Time
45.5 seconds
Settling Time
0.347
Final Value
0.7317
Steady state Error

INFERENCE:

 The differential equations for a linear mechanical system were established and itwas realized using
Simulink.
 The corresponding transfer function graph was plotted for step input, in Simulinkand MATLAB,
and the properties were analyzed.
 The damping effect of the spring system was established, and the correspondingdata was tabulated.

RESULT:

Thus, the mathematical model of the linear mechanical system was simulated, and the corresponding
parameters were noted.
b. ELECTRICAL SYSTEM

AIM
To design and simulate a mathematical model for a series RLC electrical circuitand analyze the
response graph.

APPARATUS

S.no Software

1. MATLAB

2. Simulink

BLOCK DIAGRAM/CODE:

1. MATLAB initialization parameters and Code:

Parameter initialization in MATLAB:


Parameters:
 R=3 Ohm
 L=1 H
 C= 0.05 F
Code:

>>R=3;

>>L=1;

>>C=0.05;

>>num=[1./L];
>>den=[1 (R/L) 1./(L*C) ];
>>G=tf(num,den);
>>step(G);

>>[w,zeta,p]=damp(G); %damp() gives the frequency domain


parameters
>>tau=1./w; %time constant
2. Simulink model:

OBSERVATIONS:

1. MATLAB code:
2. Simulink:

MEASUREMENTS VALUES

30.921%
Overshoot
0.658%
Pre shoot
9.302%
Undershoot
317.030 ms
Rise Time

RESULT

Thus, for a series RLC electrical circuit, the transfer function was obtained, and the corresponding
Simulink model and MATLAB codewas designed. For a step input, the resultant graph was plotted
andanalyzed.
BLOCK DIAGRAM:

1. Simulink model:

OBSERVATIONS:

1. Simulink:

Process A:

Process B:
20

Expt. No: Date:

STABILITY ANALYSIS USING POLE ZERO MAPS AND ROUTH HURWITZ


CRITERIONIN SIMULATION PLATFORM.
AIM

To analyze the stability of the following Transfer function, Using


i) Routh Hurwitz
G(S) = (6S2+1/ ( S3+3S2+3S+1))

APPARATUS REQUIRED

System with MATLAB

PROCEDURE

1. Open the mat lab command window from the start up or from the short cut
2. Type edit to open the tool box
3. Create the new file
4. Write the program file
5. Save the program and run it
6. Observe the wave form and verify the output with the theoretical values

PROGRAM

Pole-Zero Map

>>numg=[6 0 0 1]; deng=[1 3 3 1];


>>z=roots(n
umg);Z=
0+0.4082i
0-0.4082i
>>p=roots1(deng) P=
-1
-1
-1
>>n1=[1 1]; n2=[1 2]; d1=[1 2*i]; d2=[1 -2*i]; d3=[1 3];
>>numh=conv(n1,n2); denh=conv(d1,conv(d2,d3));
>>printsys(numh,den
h) num/den =
s^2+3s+2/s^3+3s^2+4
s+12
>>num=conv(numg,denh); den=conv(deng,numh);
>>printsys(num
,den)num/den =
6s^5+18s^4+25s^3+75s^2+4s+12 s^5+6s^4+14s^3+16s^2=9s+2
>>pzmap(num,den)
>>title(‘Pole-Zero Map’)
21

Routh-Hurwitz Criterion

G(s) = S3+S2+2S+24 = 0
>>numg=[1]; deng=[1 1 2 23];
>>[num,den]=cloop(num,deng);
>>roots(den) ans=
-3.0000
1.0000+2.
6458i
1.0000-2.6458i
Unstable Roots

RESULT
Thus the pole zero maps and Routh Hurwitz Criterion was analyzed using MATLAB software.
22

Expt. No: Date:

TEST OF OBSERVABILITY AND CONTROLLABILITY IN CONTINUOUS AND


DISCRETE DOMAIN IN SIMULATION PLATFORM

AIM
To test the controllability and observability of a given system in both s and zdomain using
MATLAB.

APPARATUS:

S.no Software

1. MATLAB

FORMULA/THEORY:

Controllability and observability are two important properties of state models which are
integral to the designing of a controller. These two properties suggestwhat modifications
should be made to the plant (actuators and sensors) so thatthe desired action is achieved.

Controllability deals with the possibility of forcing the system to a particular stateby
application of a control input. More formally, if a state is controllable, it meansthat there
exist some control signals that allow the system to reach any state in afinite amount of time.
Phase (deg)

It is also known as reachability. If a state is uncontrollable, then no input will be able to


control that state.
On the other hand, whether the initial states can be observed from the outputor not is
determined using observability property. If all states of a system can be known from the
system output, then the system is observable.

It is impractical to know all the states of a system. So, sometimes it is limited tothe critical
states. Thus, if a state is not observable then the controller will not be able to determine its
behavior from the system output and hence not be able to use that state to stabilize the
system.
23

Controllability and observability work together, as stated in a further theorem.

Controllability:

Consider a dynamic system as follows:

The state equation (or the pair (A, B)) is said to be completely state controllable or
simply state controllable if for any initial state x(0) and any final state x(N), there
exists an input sequence u(k), k = 0, 1, 2, · · · , N, whichtransfers x(0) to x(N) for
some finite N. Otherwise the state equation is stateuncontrollable.
1. The state equation (1) or the pair (A, B) is state controllable if and only if
the n × np state controllability matrix has rank n, i.e., full rowrank.
The state controllability matrix is given as follows:
𝑈𝑐 = [𝐵 𝐴𝐵 𝐴2𝐵 … … … 𝐴𝑛−1 𝐵]
The full rank condition can also be stated as follows: If the determinant of
the the controllability matrix is zero, then the matrixis full rank.

2. When the matrix ‘A’ has distinct eigenvalues and in Jordan/Diagonal


canonical form, the state model is controllable if and only if all the rowsof
matrix ‘B’ are non-zero.

Observability:
The state model (or the pair (A, C) ) is said to be observable if any initial state x(0)can be
uniquely determined from the knowledge of output y(k) and input sequence u(k), for k =
0, 1, 2, · · · , N, where N is some finite time. Otherwise, the state model is unobservable.
24

1. The state model (1) or the pair (A, C) is observable if the np × n


observability matrix has rank n, i.e., full column rank.

2. If the state model is in observable canonical form, then the system is


observable.

Theorem of Duality:

The pair (A, B) is controllable if and only if the pair ( 𝑇,𝐵𝑇 ) is observable.

QUESTIONS:
Q1. Test the controllability and observability of the given system in both continuousand
discrete domain.
Given characteristic equation: 5𝑧2 − 2𝑧 + 2 = 0

Assume: It is a unity feedback system.

PROCEDURE:
Finding the transfer function:
We know that any transfer function is of the form:

Here, as it is unity feedback, H(z) = 1.


25

The characteristic equation of the above transfer function is:

Thus,
The transfer function in z-domain is:

MATLAB CODE:

Q1.

disp('To check controllability and observability in z-domain')


disp(' ')
disp('Given characteristic equation: 5z^2 - 2z + 2 = 0')

H=tf([5,-2,1],[5,-2,2],0.1)
[b1 a1] = tfdata(H, 'v');
[A1,B1,C1,D1]=tf2ss(a1,b1);
g1=rank(ctrb(A1,B1));
g2=rank(obsv(A1,C1));
n = size(A1, 1);

if (g1==n || g2==n)
disp('Given system is both fully controllable and observable')elseif
(g1==n)
disp('Given system is fully controllable only')
elseif (g2==n)
disp('Given system is fully observable only')
else
disp('Given system is neither fully controllable nor observable')end

fprintf('\n')
disp('To check controllability and obsevability in s-domain')
s domain[a b] = tfdata(H, 'v');
[A,B,C,D]=tf2ss(b,a);
f1=rank(ctrb(A,B));
f2=rank(obs
v(A,C));n =
size(A, 1);
if (f1==n || f2==n)
disp('Given system is both fully controllable and
observable')elseif (f1==n)
disp('Given system is fully controllable
only')elseif (f2==n)
disp('Given system is fully observable
only')else
disp('Given system is neither fully controllable nor
observable')end

RESULT:

Thus, the given system was tested for controllability and observability in both S and Z domain.

You might also like