0% found this document useful (0 votes)
82 views41 pages

Lab Manual

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)
82 views41 pages

Lab Manual

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/ 41

1

Expt. No: 1 Date:

ANALOG (OP AMP BASED) SIMULATION OF LINEAR DIFFERENTIAL EQUATIONS


AIM

To Study the analog (op amp based) simulation of linear differential equations using Mat lab-
Simulink.
APPARATUS REQUIRED

➢ A PC with MATLAB package

PROCEDURE

1. To build a SIMULINK model to obtain response of a amplifier, the following procedure is followed:

2. In MATLAB software open a new model in SIMULINK library browser.

3. From the continuous block in the library drag the transfer function block.

4. From the source block in the library drag the step input.

5. From the sink block in the library drag the scope.

6. From the math operations block in the library drag the summing point.

7. From the discrete block in the library drag the amplifier.

8. Connect all to form a system and give unity feedback to the system.

9. For changing the parameters of the blocks connected double click the respective block.

10. Start simulation and observe the results in scope.

11. Compare the simulated and theoretical results.

RESULT

Thus the (op amp based) simulation of linear differential equations has been verified by using Mat-lab
Simulink.
PROGRAMME
A.OPEN LOOP RESPONSE (FIRST ORDER SYSTEM)
T.F=4/(s+2)
2

1. Response of system to Step input


n=[4];
d=[1 2];
sys=tf(n,d);
step(sys)
2. Response of system to Impulse input
n=[4];
d=[1 2];
sys=tf(n,d);
step(sys)
impulse(sys)

Step Response
2

1.8

1.6

1.4

1.2
Amplitude

0.8

0.6

0.4

0.2

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

Expt. No:2 Date:

NUMERICAL SIMULATION OF GIVEN NONLINEAR DIFFERENTIAL EQUATIONS.


AIM
To digitally simulate the characteristics of Linear SISO systems using Numerical Simulation of given
nonlinear differential equations.

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,
4

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)

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)

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];
5

d=[1 6 16];
sys=tf(n,d);
impulse(sys)

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

n=[4];
d=[1 6 16];
sys=tf(n,d);
sys=feedback(sys,1,-1) ;
impulse(sys)

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)

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

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.
8

Exp. No:3 Date:

Real Time Simulation of differentials equations


Aim:
To simulate the behavior of a dynamic system described by a set of differential equations in real time.
Equipment’s Required:
Matlab software
Theory:
In a real time simulation, the time required to solve the internal state equations and functions
representing the system must be less than the fixed step. If calculation time exceeds the time of the fixed step,
an over run is said to have occurred and the simulation now lags behind the actual time.
Procedure:
• Create MATLAB variables to store the data you want to record. These variables can be arrays,
structures, or tables, depending on the nature of your data.

• Write MATLAB code to collect and process the data you want to record. This could involve reading
data from sensors, performing calculations, or simulating a system.

• As you collect data, append it to the data storage structure you initialized earlier. Ensure that the data
is formatted correctly for the chosen storage format.

• Periodically save the collected data to a file using MATLAB's file I/O functions. The specific function
you use will depend on the chosen storage format.

• Plot the collected data to visualize the system's response to the input signal.
Matlab code solution:
function Real time simulation( )
% Mechanical system parameters
m = 1; % Mass (kg)
k = 10; % Spring constant (N/m)
c = 0.5; % Damping coefficient (Ns/m)
% Initial conditions
initial_displacement = 0.1; % Initial displacement (m)
initial_velocity = 0; % Initial velocity (m/s)
% Time vector
t_start = 0;
t_end = 10;
dt = 0.01;
t = t_start:dt:t_end;
% Numerical integration using Euler's method
displacement = zeros(size(t));
velocity = zeros(size(t));
displacement(1) = initial_displacement;
velocity(1) = initial_velocity;
for i = 2:length(t)
acceleration = -k/m * displacement(i-1) - c/m * velocity(i-1);
9

velocity(i) = velocity(i-1) + acceleration * dt;


displacement(i) = displacement(i-1) + velocity(i) * dt;
end
% Plotting the results
figure;
subplot(2, 1, 1);
plot(t, displacement);
xlabel('Time (s)');
ylabel('Displacement (m)');
title('Displacement vs. Time');
grid on;
subplot(2, 1, 2);
plot(t, velocity);
xlabel('Time (s)');
ylabel('Velocity (m/s)');
title('Velocity vs. Time');
grid on;
end
Output:

Result :

Expt. No:4)a) Date:


10

Design and simulation of mathematical model fora linear mechanical system

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

APPARATUS:

S.no Software Version

1. MATLAB R2021

2. Simulink -

FORMULA:

The corresponding differential equations are as follows:


11

𝑑2 𝑑 𝑑

𝑀2 (𝑦2) + 𝑓2 ( (𝑦2) − (𝑦1)) + 𝐾2(𝑦2 − 𝑦1) = 𝐹(𝑡)


𝑑𝑡2 𝑑𝑡 𝑑𝑡

𝑑2 𝑑 𝑑 𝑑

𝑀1 (𝑦1) − 𝑓2 ( (𝑦2) − (𝑦1)) − 𝐾2(𝑦2 − 𝑦1) + 𝑓1 ( (𝑦1)) + 𝐾1𝑦1 = 0


𝑑𝑡2 𝑑𝑡 𝑑𝑡 𝑑𝑡

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

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
13

2. Simulink:
14

MEASUREMEN VALUES
TS
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 it
was realized using Simulink.

• The corresponding transfer function graph was plotted for step input, in Simulink
and MATLAB, and the properties were analyzed.

• The damping effect of the spring system was established, and the corresponding
data was tabulated.

RESULT:
Thus, the mathematical model of the linear mechanical system was simulated, and the
corresponding parameters were noted.
15

Expt. No:4)b) Date:

Design and simulation of mathematical model for a electrical system

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

APPARATUS:

S.no Software Version

1. MATLAB R2021

2. Simulink -

FORMULA/DERIVATION:
In a series RLC circuit, the resistor acts as the dissipating element, while the conductor and
inductor act as energy storing elements. We utilize the transfer function, and by giving the
input as a unit step signal, we can model the systemand obtain the respective graph.

Here, let:
• L = inductance (H)

• R = resistance ( R)

• C = capacitance(F)
16

• Vs = Unit step input

• I(t) = current through the circuit(clockwise)(A)

• q = charge

The current is moving in a clockwise manner. Using Kirchhoff’s voltage law:

𝐿𝑑𝑖(𝑡) 1
𝑉𝑠 (𝑡) − − 𝑖(𝑡)𝑅 − ∫ 𝑖(𝑡)𝑑𝑡 = 0
𝑑𝑡 𝐶

Here we know that 𝑖(𝑡) = 𝑑𝑞(𝑡)

,
𝑑𝑡

𝐿𝑑 𝑑𝑞(𝑡) 𝑅𝑑𝑞(𝑡) 1

𝑉(𝑡)𝑠 = ( )+ + ∫ 𝑑𝑞
𝑑𝑡 𝑑𝑡 𝐶
𝑑𝑡

𝐿𝑑2𝑞(𝑡) 𝑅𝑑𝑞 𝑞

𝑉𝑠 (𝑡) = + +
𝑑𝑡2
𝑑𝑡 𝐶
𝑑2𝑞(𝑡) 𝑑𝑞(𝑡)
1

𝐿 = 𝑅( )+ 𝑞(𝑡) = 𝑉𝑠 (𝑡)
𝑑𝑡2 𝑑𝑡 𝐶

Taking Laplace transform, assuming Vs = u(t) [unit step response];


1
𝐿𝑠2𝑄(𝑠) + 𝑅𝑠𝑄(𝑠) + 𝑄(𝑠) = 𝑉 (𝑠)
𝑠
𝐶

𝑄(𝑠) = (1/𝐿)
𝑉 (𝑠) 𝑅𝑠 1
𝑠 𝑠2 + 𝐿 + 𝐿𝐶
17

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:
18

OBSERVATIONS:

1. MATLAB code:

2. Simulink:
19

MEASUREMENTS VALUES
30.921%
Overshoot
0.658%
Pre shoot

9.302%
Undershoot

317.030 ms
Rise Time

INFERENCE:

• We know that current lags in the inductor, leads in capacitor and is in phase in
resistor.

• Here, the graph is divided into transient and steady state regions, where the
transient state is influenced by initial conditions(R,L,C), while the steady state
component remains unchanged.

• Hence from the graphs, we can observe the underdamping of the wave,
before reaching a steady state value. By changing the values of R, L and C, we
can change the damping ratio and in turn the response as well.

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.
20

Expt. No:5 Date:

System Identification through Process ReactionCurves


AIM:
To identify the given system using the process reaction curve using Simulink.

APPARATUS:

S.no Software Version

1. MATLAB R2021

2. Simulink -

FORMULA/THEORY:
A process reaction curve will be generated in response to a disturbance. This process
curve is then used to calculate the controller gain, integral time, and derivative time. It
is performed in open loop so that no control action occurs,and the process response can
be isolated.

To generate a process reaction curve, the process can reach steady state or as close to
steady state as possible. Then, in open loop, so that there is no controlaction, a small step
disturbance is introduced, and the reaction of the process variable is b recorded.

For an oscillatory reaction curve, the dimensionless equation for model 1 will be
adopted. To distinguish between process models that do not have a processzero (where 𝑎̅
= 0) and those which do have a zero (where 𝑎̅≠ 0) the following lemma is needed.
21
22
23

BLOCK DIAGRAM:

1. Simulink model:

OBSERVATIONS:

1. Simulink:

Process A:

Process B:
24

S.no Parameters Process A Process B


tm,0 2.897s 3.297s
1.

tp,1 10.33s 8.531s


2.
yp,1 1.206 1.385
3.
tp,2 24.73s 22.73s
4.
yp,2 1.005 1.01
5.
ym,1 0.97097 0.95816
6.

p 14.4 14.3
7.

CALCULATIONS:

1. Process A:

1 1.005 − 1
𝜒= 𝑙𝑛 ( )
10.33 − 24.73
1.206 − 1

𝝌 = 𝟎. 𝟐𝟓𝟖

ln(1.206 − 1)2
𝜍=√
𝜋2 + (𝑙𝑛1.206 − 1)2
25

𝝇 = 𝟎. 𝟒𝟒𝟗

14.4
𝑟=
√4𝜋2 + 14.42 ∗ 0.2582

𝑟 = 𝟏. 𝟗𝟕𝟐
26

1.9727
𝜃 = 10.33 + ln(1.206 − 1)
0.449

𝜽 = 𝟑. 𝟑𝟗

2. Process B:

1 1.01 − 1
𝜒= 𝑙𝑛 ( )
8.331 − 22.73
1.385 − 1

𝝌 = 𝟎. 𝟐𝟓𝟕

14.199 ∗ 0.257
𝜍=
√4𝜋2 + 14.1992 ∗ 0.2572

𝝇 = 𝟎. 𝟓

14.199
𝑟=
√4𝜋2 + 14.1992 ∗ 0.2572

𝑟 = 𝟏. 𝟗𝟓𝟒

𝑎′ = 0.5 + √0.52 + (1 − ( 1.385 − 1


2

) )
𝑒−0.5∗8.531

𝒂′ = 𝟏. 𝟓𝟑𝟗
27

𝜃 = 8.537 − 14.199 (π − tan−1 1.539√1 − 0.5


2

( ))
6.28
1 − 1.539 ∗ 0.5

𝜽 = 𝟒. 𝟔𝟓𝟕
28

S.no Parameters Process A Process B

1. ς 0.449 0.5

2. χ 0.258 0.257

3. τ 1.9727 1.954

4. a’ 0 1.539

5. θ 3.39 4.657

Thus, the equation of process A is:

𝑒−3.39𝑠

3.88𝑠2 + 1.771𝑠 + 1

The equation of process B is:

(1 + 1.539𝑠)𝑒−4.6575
3.818𝑠2 + 1.954𝑠 + 1

INFERENCE:
• From the graphs, we can analyze the process curve and obtain the necessary
parameters.

• The damping ratio for both the processes reinforce the fact that the curves are
underdamped.

• The delay time θ is higher for process B and it is indicative for the fact that
process reaction curve for process B takes longer than that of A.

RESULT:
Thus, using Simulink, it was possible to obtain the process reaction curves of thegiven
process. The parameters were obtained from the graph and additional values were
calculated as well. Thus, the resultant equations of the processes were modelled from these
values as well.
29

Expt. No:6 Date:

STABILITY ANALYSIS USING POLE ZERO MAPS AND ROUTH


HURWITZ CRITERION IN SIMULATION PLATFORM

AIM

To check the stability analysis is using Routh Hurwitz Criterion for the given system
or transfer function using MATLAB Software.

APPARATUS REQUIRED

➢ A PC with MATLAB package

PROCEDURE

➢ Open the MATLAB software using a MATLAB icon Open a blank M- File or
Simulink file (File, New, M file) Type the given program in M file
➢ Run the program using debug option or using F5 key
➢ Find the stability of the system in the output graph and compare it
with theoretical value

RESULT
Thus the stability analysis is using Routh Hurwitz Criterion for the given system or
transfer function using MATLAB Software was executed.
30

PROGRAM
num=[0 4 5];
den=[1 4 21];
sys1=tf(num, den);
rlocus(sys1)
grid
title('Root locus plot of system G(s) = (4s+5)/(s2+4s+21)')
31

Expt. No:7 Date:

ROOT LOCUS BASED ANALYSIS IN SIMULATION PLATFORM

AIM

To Check the stability analysis of the given system or transfer function of rootlocus
using MATLAB Software.

APPARATUS REQUIRED

➢ A PC with MATLAB package

PROCEDURE

➢ Open the MATLAB software using a MATLAB icon Open a blank M- File or
Simulink file (File, New, M file) Type the given program in M file
➢ Run the program using debug option or using F5 key
➢ Find the stability of the system in the output graph and compare it
with theoretical value

RESULT
Thus the designs of root locus for the given transfer function using MATLAB Software
was executed.
32

PROGRAM
%Bode Plot for the Transfer Function=10/(s3+8s2+12s)
nu=[10];
de=[1 8 12 0];
sys=tf(nu,de);
bode(sys);
grid on;

Bode Diagram
50

0
Magnitude (dB)

-50

-100

-150
-90

-135
Phase (deg)

-180

-225

-270
-2 -1 0 1 2 3
10 10 10 10 10 10
Frequency (rad/sec)
33

Expt. No: 8 Date:

DETERMINATION OF TRANSFER FUNCTION OF A PHYSICAL SYSTEM


USING FREQUENCY RESPONSE AND BODE’S ASYMPTOTES.
AIM

To Design the bode plot for the given system and also determine the gain and phase
margin using MATLAB Software.

APPARATUS REQUIRED

➢ A PC with MATLAB package

PROCEDURE

➢ Open the MATLAB software using a MATLAB icon Open a blank M- File or
Simulink file (File, New, M file) Type the given program in M file
➢ Run the program using debug option or using F5 key
➢ Find the stability of the system in the output graph and compare it
with theoretical value

RESULT
Thus the design of bode plot for the given system using MATLAB Software was
executed.
34

PROGRAM
1. Lag Compensator
K=9600
d1=conv([1 4 0],[1 80]) % used to formulate the polynomial
G=tf(K,d1) % generate the transfer function.
margin(G)
pmreq=input('Enter Required Phase Margin') % enter 33 as given in
question
pmreq=pmreq+5
phgcm=pmreq-180
wgcm=input('Enter new gain cross over frequency') % from the first
bode plot use the mouse pointer and locate wgcm corresponding to
phgcm.
[Beta,p]=bode(G,wgcm)
T=10/wgcm
Zc=1/T
Pc=1/(Beta*T)
Gc=tf([1 Zc],[1 Pc])
sys=Gc*G/Beta
margin(sys)

2..LEAD COMPENSATOR
clear variables;
% plant G parameters
s = tf('s');
a = 2.5; b = 27;
%% a) Gain K for PO=10
PO = 10; % percentage overshoot
zeta = log(100/PO)/sqrt(pi^2+ (log(100/PO))^2 ); % damping ratio
PM_d = round(100*zeta)+1; % PM desired at the nearest round value
h = tand(180-90-PM_d);
omega_c = roots([1 (a+b)/h -a*b]); % new omega_c
K = omega_c(2)*sqrt(omega_c(2)^2+a^2)*sqrt(omega_c(2)^2+b^2); % new
gain K
G = K/( s*(s+a)*(s+b) ); % Plant G
figure;
margin(G);
35
36

Expt. No:9 Date:

DESIGN OF LAG, LEAD COMPENSATORS AND EVALUATION OF


CLOSED LOOP PERFORMANCE
AIM

To design the lag, lead compensators and evaluation of closed loop Performance using
MATLAB Software.

APPARATUS REQUIRED

➢ A PC with MATLAB package

PROCEDURE

➢ Open the MATLAB software using a MATLAB icon Open a blank M- File or
Simulink file (File, New, M file) Type the given program in M file
➢ Run the program using debug option or using F5 key
➢ Find the stability of the system in the output graph and compare it
with theoretical value

RESULT
Thus the design of lag, lead compensators and evaluation of closed loop Performance
37

using MATLAB Software was executed.


PROGRAMME
% Step Response for TF 1/(s^2+10s+20)
num=[1];
den=[1 10 20];
figure(1);
step(num,den)
OUTPUT
% Step Response for TF 1/(s^2+10s+20)

% Proportional Controller
Kp=600;
num1=[Kp];
den1=[1 10 20+Kp];
t=0:0.01:2;
figure(2);
step(num1,den1,t)
grid;
OUTPUT
% Proportional Controller
38

Expt. No: 10 Date:

DESIGN OF PID CONTROLLERS AND EVALUATION OF CLOSED LOOP


PERFORMANCE
AIM

To Study the effect of P, PI, PID controllers using Mat lab-Simulink.

APPARATUS REQUIRED

➢ A PC with MATLAB package

PROCEDURE

12. To build a SIMULINK model to obtain response of a P, PI, PID Controllers, the
following procedure is followed:

13. In MATLAB software open a new model in SIMULINK library browser.

14. From the continuous block in the library drag the transfer function block.

15. From the source block in the library drag the step input.

16. From the sink block in the library drag the scope.

17. From the math operations block in the library drag the summing point.

18. From the discrete block in the library drag the PID controller.

19. Connect all to form a system and give unity feedback to the system.

20. For changing the parameters of the blocks connected double click the respective
block.

21. Start simulation and observe the results in scope.

22. Compare the simulated and theoretical results.


39

% Proportional Derivative Controller


Kp=300;
Kd=10;
num2=[Kd Kp];
den2=[1 10+Kd 20+Kp];
t=0:0.01:2;
figure(3);
step(num2,den2,t)
grid;
OUTPUT:
% Proportional Derivative Controller

% Proportional Integral Controller


Kp1=30;
Ki=70;
num3=[Kp1 Ki];
den3=[1 10 20+Kp1 Ki];
t=0:0.01:2;
figure(4);
step(num3,den3,t)
grid;
OUTPUT:
% Proportional Integral Controller
40

%Proportional Integral Derivative Controller


Kp2=350;
Kd2=50;
Ki2=300;
num4=[Kd2 Kp2 Ki2];
den4=[1 10+Kd2 20+Kp2 Ki2];
t=0:0.01:2;
figure(5);
step(num4,den4,t)
grid;
OUTPUT
%Proportional Integral Derivative Controller
41

RESULT

Thus the effect of P, PI, PD, and PID controller has been verified by using Matlab
coding.

You might also like