100% found this document useful (1 vote)
138 views

Circut Simulation (Project)

This report describes the mathematical modeling and simulation of first and second order circuit systems. For the first order circuit system (FOS), the authors derive the differential equation, transfer function, state-space representation, and analytical output expression. Simulations using Simulink, transfer functions, state-space, and analytical solutions are presented for three FOS combinations. For the second order circuit system (SOS), the same analyses are performed and simulations shown for three SOS combinations. Experimental validation of the FOS is also described using an Arduino data acquisition card. The results show good agreement between the mathematical models and simulations and the experimental measurements.

Uploaded by

Mahmoud Kassab
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
100% found this document useful (1 vote)
138 views

Circut Simulation (Project)

This report describes the mathematical modeling and simulation of first and second order circuit systems. For the first order circuit system (FOS), the authors derive the differential equation, transfer function, state-space representation, and analytical output expression. Simulations using Simulink, transfer functions, state-space, and analytical solutions are presented for three FOS combinations. For the second order circuit system (SOS), the same analyses are performed and simulations shown for three SOS combinations. Experimental validation of the FOS is also described using an Arduino data acquisition card. The results show good agreement between the mathematical models and simulations and the experimental measurements.

Uploaded by

Mahmoud Kassab
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/ 27

Mahmoud Ahmed El-Sayed

Mahmoud Mohamed Tawhid


Anton Tamer Shafique
Ayman Hisham Mahmoud

Group “F” of four undergraduates


Mechanical Design & Production Department
3rd year of two-semester system
Faculty of Engineering,
Cairo University, Giza, Egypt 12613

Prof. Yasser H. Anis


Associate Professor,
Mechanical Design & Production Department
Faculty of Engineering,
Cairo University, Giza, Egypt 12613
[email protected]

December 17th, 2019


Subject: Phase one of MDP307 Fall 2019 Course Project

Dear Prof.: Yasser H. Anis

Attached in this report the requested second phase of our course project.

As you requested, this phase includes selected designs of first and second order circuit systems,
detailed writing of the differential equations of each system, determination of their transfer
functions, the state-space representations, deriving analytical expressions of the output voltage of
each system and Simulations of the systems by selecting three different combinations using
SIMULINK & MATLAB for each mathematical representation.

Our group hopes this report meets a good representation of FOS& SOS. Please let us know your
feedback to help us improve our work.

Sincerely,

Group F
Four Undergraduates engineers.
Mechanical Design & Production Department,
Faculty of Engineering, Cairo University.

Enclosure: The second Phase of “Report on Modeling& Simulation of First and Second Order
Systems”
Faculty of Engineering – Cairo University
Mechanical Design and Production Engineering
Two-Semester System – 3rd Year
MDP 307: Modeling and Simulation of Dynamic
Systems and Robots– Fall 2019

Report On
(Modeling& Simulation of First and Second Order Systems)
(Phase Two)

Submitted to
A.P: Yasser H. Anis

Prepared by Group F
Mahmoud Ahmed EL-Sayed
Mahmoud Mohamed Tawhid
Anton Tamer Shafique
Ayman Hisham Mahmoud

December 17th, 2019


Table of Contents

List of Figures ------------------------------------------------------------------------------------------------ III


List of Tables--------------------------------------------------------------------------------------------------IV
Abstract ---------------------------------------------------------------------------------------------------------V
Introduction ---------------------------------------------------------------------------------------------------- 1
Design of a first order circuit system (FOS)--------------------------------------------------------------- 2
Mathematical modeling of the first order Circuit system ------------------------------------------------ 2
1. Differential equations of the system---------------------------------------------------------------- 2
2. The Transfer Function 𝑮𝒔 = 𝑽𝒐𝒖𝒕(𝒔)/𝑽𝒊𝒏(𝒔) -------------------------------------------------- 2
3. The State-Space Representation (A, B, C, D matrices)------------------------------------------ 3
4. The Analytical Expression for the output Voltage 𝒗𝒐𝒖𝒕(𝒕) ------------------------------------ 3
Design of a second order circuit system (SOS) ----------------------------------------------------------- 4
Mathematical modeling of the second order circuit system --------------------------------------------- 4
1. Differential equations of the system---------------------------------------------------------------- 4
2. The Transfer Function 𝑮𝒔 = 𝑽𝒐𝒖𝒕(𝒔)/𝑽𝒊𝒏(𝒔) -------------------------------------------------- 4
3. The State-Space Representation (A, B, C, D matrices)------------------------------------------ 5
4. The Analytical Expression of the output voltage 𝒗𝒐𝒖𝒕(𝒕) ------------------------------------- 6
Simulations for FOS Circuit (Using three combinations of R & C) ----------------------------------- 7
1. Simulink Simulation of 𝒗𝒐𝒖𝒕(𝒕) for step input 𝒗𝒊𝒏(𝒕) = 𝟓𝑽 --------------------------------- 7
2. Transfer Function Simulation of 𝒗𝒐𝒖𝒕(𝒕) for step input 𝒗𝒊𝒏(𝒕) = 𝟓𝑽 ---------------------- 8
3. State-Space Simulation of 𝒗𝒐𝒖𝒕(𝒕) for step input 𝒗𝒊𝒏(𝒕) = 𝟓𝑽 ------------------------------ 8
4. Analytical Time Response of 𝒗𝒐𝒖𝒕(𝒕) for step input 𝒗𝒊𝒏(𝒕) = 𝟓𝑽 -------------------------- 9
Simulations for SOS Circuit (Using three combinations of R & C) ---------------------------------- 11
1. Simulink Simulation of 𝒗𝒐𝒖𝒕(𝒕) for step input 𝒗𝒊𝒏𝒕 = 𝟓𝑽 ---------------------------------- 11
2. Transfer Function Simulation of 𝒗𝒐𝒖𝒕(𝒕) for step input 𝒗𝒊𝒏(𝒕) = 𝟓𝑽 --------------------- 12
3. State-Space Simulation of 𝒗𝒐𝒖𝒕(𝒕) for step input 𝒗𝒊𝒏(𝒕) = 𝟓𝑽 ----------------------------- 12
4. Analytical Time Response of 𝒗𝒐𝒖𝒕(𝒕) for step input 𝒗𝒊𝒏(𝒕) = 𝟓𝑽 ------------------------- 13
Result conclusion --------------------------------------------------------------------------------------------- 14
Experimental Validation for FOS Circuit ----------------------------------------------------------------- 14
1. Experimental Setup ---------------------------------------------------------------------------------- 14
2. sequence of experimental work -------------------------------------------------------------------- 14

I
3. Validate the results ----------------------------------------------------------------------------------- 15
Appendices ---------------------------------------------------------------------------------------------------- 17
References ----------------------------------------------------------------------------------------------------- 20

II
List of Figures

Figure 1: First Order Circuit System (RC Circuit) ------------------------------------------------------- 2


Figure 2: Second Order Circuit System (RLC Circuit) -------------------------------------------------- 4
Figure 3: FOS Circuit using SIMULINK Simulation ---------------------------------------------------- 7
Figure 4: Recorded scopes for the three combinations of FOS using SIMULINK inspector ------ 7
Figure 5: Transfer Function Simulation Using MATLAB for FOS (For step input 𝑣𝑖𝑛(t)=5V) -- 8
Figure 6: State-Space Simulation Using MATLAB for FOS (For step input 𝑣𝑖𝑛(t)=5V) ---------- 9
Figure 7:Analytical Time Response Using MATLAB for FOS (For step input 𝑣𝑖𝑛(t)=5V) ------ 10
Figure 8: SOS Circuit using Simulink Simulation------------------------------------------------------- 11
Figure 9: Recorded scopes for the three combinations of SOS using SIMULINK inspector ---- 11
Figure 10: Transfer Function Simulation Using MATLAB for SOS (For step input 𝑣𝑖𝑛(t)=5V) 12
Figure 11:State-Space Simulation Using MATLAB for SOS (For step input 𝑣𝑖𝑛(t)=5V) -------- 13
Figure 12: Analytical Time Response Using MATLAB for SOS (For step input 𝑣𝑖𝑛(t)=5V) ---- 13
Figure 13: Connections of the real FOS Circuit --------------------------------------------------------- 14
Figure 14:Monitoring Data Using ARDUINO Serial Plotter for Combination 1 Circuit ---------- 15
Figure 15: Monitoring Data Using ARDUINO Serial Plotter for Combination 2 Circuit --------- 15
Figure 16: Monitoring Data Using ARDUINO Serial Plotter for Combination 3 Circuit --------- 16
Figure 17: Data Plotting via Excel ------------------------------------------------------------------------ 16

III
List of Tables

Table 1: Three Combinations of R and C for FOS Circuit ---------------------------------------------- 7


Table 2: Three Combinations of R, L and C for SOS Circuit ------------------------------------------ 11

IV
Abstract

The procedure to design any needed function should be carried out by following six main
steps. First, you must transform the requirements to a physical system, then draw a functional
block diagram, after that is creating a schematic drawing of the system. To understand how the
system works you will come to the step number four, which focuses on developing a
mathematical model by writing the system equations, then by representing the system model
using one of representation methods, you will be able to analyze the system even by analytical
solutions or computer simulation.

In this Report we are going to build two simple RLC electric circuits, which will
represent a first and a second order systems respectively, using the previous procedure to
develop a mathematical modeling and representation for each system, then simulating each
system using three different combinations of R, L and Cs to study each system output. Then we
are exposed to test experimental validation for the same three combinations using a DAQ card.

V
Introduction

During the past century, our definition of a control system has become “A control system
consists of subsystems and processes (or plants) assembled for the purpose of obtaining a desired
output with desired performance”[1]. That’s the meaning of under control concept, looking at
your body -as a system- for example, it’s fully under control. Imagine you are going to throw an
arrow for the first time in your life, by aiming a target (the desired output) you will begin to set
your body (the system) to the most perfect conditions, using your subsystems, which are
assembled to the main system, like vision to estimate the aiming distance, the muscles to
estimate the most probable force to make the arrow able to reach the target, the feeling to
eliminate the affecting conditions like gravity, wind direction and so on. In this example your
purpose is to obtain a desired output -hit the target- and to obtain performance -like how fast you
will hit the target-. Systems like this could be classified into two types, first is the open loop
system which focuses on the desired output and just relies on the inputs, and second is the closed
loop system which also aims the desired output, but relies on the feedback to measure the
difference between the actual output and the desired one. We can consider each system which
fulfills these conditions as a control system, systems with mechanical components, systems with
electrical components, systems with hydraulic or pneumatic components, systems combining
those components together, and even a system without engineering background like servicing
system in one of the restaurants.

It’s important to look at the system with other configuration which determines the
behavior of the system and letting us know how to deal with the system. This configuration is the
order of the system, which is the number of derivatives (or integrals) needed to model the
dynamics of the system. When taking the Laplace transform of the model’s differential
equations, those derivatives will be replaced by the “s” variable and one can build the transfer
function between the input and the output. The largest exponent of “s” in the denominator (or the
number of poles) will also match the order of the system. In this report we will focus on the first
and the second order systems.

First order system is often a good mathematical model to represent the behavior of many
real-world systems. Examples include a temperature change in an oven due to heat input, R-C or
R-L circuit behavior, liquid level change in leaky tank and others. First-order systems do not
exhibit overshoot or oscillatory behavior and are not suitable models in certain cases[2]. A
second-order model is more appropriate in such cases. A second-order model is used to represent
systems that can exhibit a variety of responses to input stimulus, including overshoot, undershoot
or oscillatory behavior. Examples include R-L-C circuits, car suspension system and others.
First-order and second-order systems are easy to analyze and design. Hence, they are widely
used in preliminary analysis and design related to real-world systems. More complex models can
then be used to verify the design using simulation methods. Like we mentioned, the focus in our
report will be only on the first and the second order systems, and for specific, previously selected
two electric circuits one for FOS and the other for SOS.

Page | 1
Design of a first order circuit system (FOS)

1. Using a resistance and a capacitance (RC Circuit)


2. Circuit input: Voltage 𝑉𝑖𝑛 (𝑡)
3. Circuit output: Voltage 𝑉𝑜𝑢𝑡 (𝑡)

Figure 1: First Order Circuit System (RC Circuit)

Mathematical modeling of the first order Circuit system

1. Differential equations of the system

1
𝑣𝑖𝑛 (𝑡) = 𝑖(𝑡)𝑅 + ∫ 𝑖(𝑡) . 𝑑𝑡 (1)
𝑐
1
𝑣𝑜𝑢𝑡 (𝑡) = ∫ 𝑖(𝑡) . 𝑑𝑡 (2)
𝑐

2. The Transfer Function 𝑮(𝒔) = 𝑽𝒐𝒖𝒕 (𝒔)/𝑽𝒊𝒏 (𝒔)

Taking Laplace Transformation for (1) & (2):


𝐼
𝑉𝑖𝑛 = 𝐼𝑅 + (3)
𝐶𝑠
𝐼
𝑉𝑜𝑢𝑡 = (4)
𝐶𝑠
𝐼
𝑉𝑜𝑢𝑡 𝐶𝑠 1
From (3) & (4) 𝐺(𝑠) = = 𝐼 =
𝑉𝑖𝑛 𝐼𝑅+ 1+𝑅𝐶𝑠
𝐶𝑠

𝑎
Making it in the first order general formula :
𝑎+𝑠
1
𝑉𝑜𝑢𝑡 𝑅𝐶 1
𝐺(𝑠) = = 1 (5) Hence 𝑎=
𝑉𝑖𝑛 +𝑠 𝑅𝐶
𝑅𝐶

Page | 2
3. The State-Space Representation (A, B, C, D matrices)

𝑖
𝑣𝑐̇ = (6)
𝐶

𝑣𝑖𝑛 = 𝑖𝑅 + 𝑣𝑐 (7)

𝑣𝑖𝑛 −𝑣𝑐 𝑣𝑖𝑛 𝑣𝑐


𝑖= = − (8)
𝑅 𝑅 𝑅

From (5), (6) & (7)


𝑣𝑖𝑛 𝑣𝑐
𝑣𝑐̇ = −
𝑅𝐶 𝑅𝐶

State equation:
1 1
[𝑣𝑐̇ ] = [− ] [𝑣𝑐 ] + [ ] [𝑣𝑖𝑛 ] (9)
𝑅𝐶 𝑅𝐶

Output equation:

𝑦 = 𝑣𝑜𝑢𝑡 = 𝑣𝑐
𝑦 = [1][𝑣𝑐 ] + [0][𝑣𝑖𝑛 ] (10)

The State-Space Representation:

1 1
𝐴 = [− ] 𝐵=[ ] 𝐶 = [1] 𝐷 = [0]
𝑅𝐶 𝑅𝐶

4. The Analytical Expression for the output Voltage 𝒗𝒐𝒖𝒕 (𝒕)

𝑣𝑜𝑢𝑡 (𝑡) = 𝑣𝑖𝑛 − 𝑣𝑖𝑛 𝑒 −𝑎𝑡 For the first order system
1
𝑣𝑜𝑢𝑡 (𝑡) = 𝑣𝑖𝑛 − 𝑣𝑖𝑛 𝑒 −𝑅𝐶𝑡 (11)

Page | 3
Design of a second order circuit system (SOS)

1. Using a resistance, an inductance& a capacitance (RLC Circuit)


2. Circuit input: Voltage 𝑉𝑖𝑛 (𝑡)
3. Circuit output: Voltage 𝑉𝑜𝑢𝑡 (𝑡)

Figure 2: Second Order Circuit System (RLC Circuit)

Mathematical modeling of the second order circuit system

1. Differential equations of the system

𝑑𝑖(𝑡) 1
𝑣𝑖𝑛 = 𝑖(𝑡)𝑅 + 𝐿 + ∫ 𝑖(𝑡) . 𝑑𝑡 (1)
𝑑𝑡 𝐶
1
𝑣𝑜𝑢𝑡 = ∫ 𝑖(𝑡) . 𝑑𝑡 (2)
𝐶

2. The Transfer Function 𝑮(𝒔) = 𝑽𝒐𝒖𝒕 (𝒔)/𝑽𝒊𝒏 (𝒔)

𝑉𝑖𝑛
𝐼= 1 (3)
[𝑅+𝐿𝑠+ ]
𝐶𝑠

𝑉𝑜𝑢𝑡
𝐼= 1 (4)
𝐶𝑠

𝑉𝑖𝑛 𝑉𝑜𝑢𝑡
From (3) & (4) 1 = 1
[𝑅+𝐿𝑠+ ] 𝐶𝑠
𝐶𝑠

Page | 4
𝑣𝑜𝑢𝑡 1
= 𝐺(𝑠) = [𝑅𝐶𝑠+𝐿𝐶𝑠2
𝑣𝑖𝑛 +1]
𝑏
Make it in the second order system general formula
𝑠 2 +𝑎𝑠+𝑏2
1
𝐿𝐶
𝐺(𝑠) = 𝑅 1 (5)
[𝑠 2 + 𝑠+ ]
𝐿 𝐿𝐶

3. The State-Space Representation (A, B, C, D matrices)

𝑖
𝑣𝑐̇ = (6)
𝐶
𝑣𝐿
𝑖̇𝐿̇ = (7)
𝐿

𝑖 = 𝑖𝐿 (8)

𝑣𝑖𝑛 = 𝑖𝑅 + 𝑣𝐿 + 𝑣𝑐 (9)

𝑣𝐿 = 𝑣𝑖𝑛 − 𝑣𝑐 − 𝑖𝐿 𝑅 (10)
From (2), (3), (4) & (5)
𝑣𝑖𝑛 𝑣𝐶 𝑅
𝑖̇𝐿̇ = − − 𝑖𝐿 (11)
𝐿 𝐿 𝐿

From (1) & (6)


State equation:
1
𝑣𝑐̇ 0 𝑣𝑐 0
𝐶
[ ̇ ] = [−1 −𝑅 𝑖𝐿 ]
] [ + [ 1 ] [𝑣𝑖𝑛 ] (12)
𝑖̇𝐿 𝐿
𝐿 𝐿

Output equation:

𝑦 = 𝑣𝑜𝑢𝑡 = 𝑣𝑐
𝑣𝑐
𝑦 = [1 0] [ 𝑖 ] + [0][𝑣𝑖𝑛 ] (13)
𝐿

Page | 5
The State-Space Representation:
1
0 0
𝐶
𝐴 = [−1 −𝑅 ] 𝐵 = [1] 𝐶 = [1 0 ] 𝐷 = [0]
𝐿
𝐿 𝐿

4. The Analytical Expression of the output voltage 𝒗𝒐𝒖𝒕 (𝒕)

According to R, L and C values combination the expression could be:

I. Under damped: 𝑣𝑜𝑢𝑡 (𝑡) = 𝐴 + 𝐵𝑒 −𝜎𝑑𝑡 (𝐶𝑜𝑠𝜔𝑑 𝑡 − 𝜑) (14)


II. Over damped: 𝑣𝑜𝑢𝑡 (𝑡) = 𝐴 + 𝐵𝑒 −𝜎1𝑡 + 𝐶𝑒 −𝜎2𝑡 (15)
III. Critically damped: 𝑣𝑜𝑢𝑡 (𝑡) = 𝐴 + 𝐵𝑒 −𝜎𝑡 + 𝐶𝑡𝑒 −𝜎𝑡 (16)

Page | 6
Simulations for FOS Circuit (Using three combinations of R & C)

Table 1: Three Combinations of R and C for FOS Circuit

Combination R C
1 4.7 kΩ 100 µF
2 4.7 kΩ 220 µF
3 10 kΩ 100 µF

1. Simulink Simulation of 𝒗𝒐𝒖𝒕 (𝒕) for step input 𝒗𝒊𝒏 (𝒕) = 𝟓𝑽

Figure 3: FOS Circuit using SIMULINK Simulation

Figure 4: Recorded scopes for the three combinations of FOS using SIMULINK inspector

Page | 7
2. Transfer Function Simulation of 𝒗𝒐𝒖𝒕 (𝒕) for step input 𝒗𝒊𝒏 (𝒕) = 𝟓𝑽

100
𝑉𝑜𝑢𝑡 47
For Combination 1 …………𝐺(𝑠) = = 100
𝑉𝑖𝑛 𝑠+
47

500
𝑉𝑜𝑢𝑡 517
For Combination 2………….𝐺(𝑠) = = 500
𝑉𝑖𝑛 𝑠+
517

𝑉𝑜𝑢𝑡 1
For Combination 3………….𝐺(𝑠) = =
𝑉𝑖𝑛 𝑠+1

For MATLAB Code see


Appendix A

Figure 5: Transfer Function Simulation Using MATLAB for FOS (For step input 𝑣𝑖𝑛 (t)=5V)

3. State-Space Simulation of 𝒗𝒐𝒖𝒕 (𝒕) for step input 𝒗𝒊𝒏 (𝒕) = 𝟓𝑽

100 100
For Combination 1…..𝐴 = [− ] 𝐵=[ ] 𝐶 = [1] 𝐷 = [0]
47 47
500 500
For Combination 2… .𝐴 = [− ] 𝐵=[ ] 𝐶 = [1] 𝐷 = [0]
517 517

For Combination 3…. 𝐴 = [−1] 𝐵 = [1] 𝐶 = [1] 𝐷 = [0]

Page | 8
For MATLAB Code see
Appendix B

Figure 6: State-Space Simulation Using MATLAB for FOS (For step input 𝑣𝑖𝑛 (t)=5V)

4. Analytical Time Response of 𝒗𝒐𝒖𝒕 (𝒕) for step input 𝒗𝒊𝒏 (𝒕) = 𝟓𝑽

100
− 𝑡
For Combination 1….…𝑣𝑜𝑢𝑡 (𝑡) = 5 − 5𝑒 47
500
− 𝑡
For Combination 2 ……𝑣𝑜𝑢𝑡 (𝑡) = 5 − 5𝑒 517

For Combination 3 𝑣𝑜𝑢𝑡 (𝑡) = 5 − 5𝑒 −𝑡

Page | 9
For MATLAB Code see
Appendix C

Figure 7:Analytical Time Response Using MATLAB for FOS (For step input 𝑣𝑖𝑛 (t)=5V)

Page | 10
Simulations for SOS Circuit (Using three combinations of R & C)

Table 2: Three Combinations of R, L and C for SOS Circuit

Combination R L C
1 10 KΩ 500 H 10 µF Under damped
2 10 KΩ 500 H 20 µF Critically Damped
3 10 KΩ 200 H 20 µF Over Damped

1. Simulink Simulation of 𝒗𝒐𝒖𝒕 (𝒕) for step input 𝒗𝒊𝒏 (𝒕) = 𝟓𝑽

Figure 9: SOS Circuit using Simulink Simulation

Figure 8: Recorded scopes for the three combinations


of SOS using SIMULINK inspector Page | 11
2. Transfer Function Simulation of 𝒗𝒐𝒖𝒕 (𝒕) for step input 𝒗𝒊𝒏 (𝒕) = 𝟓𝑽

200
For Combination 1……….𝐺(𝑠) =
[𝑠 2 +20𝑠+200]
100
For Combination 2……….𝐺(𝑠) =
[𝑠 2 +20𝑠+100]
250
For Combination 3……….𝐺(𝑠) =
[𝑠 2 +50𝑠+250]

For MATLAB Code see


Appendix D

Figure 10: Transfer Function Simulation Using MATLAB for SOS (For step input 𝑣𝑖𝑛 (t)=5V)

3. State-Space Simulation of 𝒗𝒐𝒖𝒕 (𝒕) for step input 𝒗𝒊𝒏 (𝒕) = 𝟓𝑽

For Combination 1………𝐴 = [ 0 105 ] 𝐵=[


0
] 𝐶 = [1 0] 𝐷 = [0]
0.002 −20 0.002

For Combination 2………𝐴 = [ 0 5 ∗ 104 ] 0


𝐶 = [1
𝐵=[ ] 0] 𝐷 = [0]
0.002 −20 0.002

For Combination 3………𝐴 = [ 0 5 ∗ 104 ] 0


𝐶 = [1
𝐵=[ ] 0] 𝐷 = [0]
0.005 −50 0.005

Page | 12
For MATLAB Code see
Appendix E

Figure 11:State-Space Simulation Using MATLAB for SOS (For step input 𝑣𝑖𝑛 (t)=5V)

4. Analytical Time Response of 𝒗𝒐𝒖𝒕 (𝒕) for step input 𝒗𝒊𝒏 (𝒕) = 𝟓𝑽

For Combination 1 𝑣𝑜𝑢𝑡 (𝑡) = 5 − 5𝑒 −10𝑡 (𝐶𝑜𝑠10𝑡 − 𝑆𝑖𝑛10𝑡)


For Combination 2 𝑣𝑜𝑢𝑡 (𝑡) = 5 + 50𝑡𝑒 −10𝑡 − 5𝑒 −10𝑡
√15
For Combination 3 𝑣𝑜𝑢𝑡 (𝑡) = 5 − 5𝑒 −25𝑡 (𝐶𝑜𝑠ℎ5√15𝑡 − 𝑆𝑖𝑛ℎ√15𝑡)
3

For MATLAB Code see


Appendix F

Figure 12: Analytical Time Response


Page | 13
Using MATLAB for SOS (For step input 𝑣𝑖𝑛 (t)=5V)
Result conclusion

For the FOS and SOS circuits using simulation of MATLAB via SIMULINK, transfer function,
State-Space or analytical time response simulations, the results are identical if we used small
time step ex (t=.01 sec).

Experimental Validation for FOS Circuit

1. Experimental Setup

Using the same three combinations mentioned in Table 1

Figure 13: Connections of the real FOS Circuit

2. sequence of experimental work

By connecting resistance and capacitor in series, then making a wiring connection between the
ground port in ARDUINO and the resistance end point (1) and a wiring connection between 5V
port in ARDUINO with the capacitor end point (2). For monitoring the output voltage of
capacitor, we used wiring connection between the analog port 𝐴𝑜 in ARDUINO and the
capacitor point (3) and using ARDUINO code (Look Appendix G).

Page | 14
3. Validate the results

Figure 14:Monitoring Data Using ARDUINO Serial Plotter for Combination 1 Circuit

Figure 15: Monitoring Data Using ARDUINO Serial Plotter for Combination 2 Circuit

Page | 15
Figure 16: Monitoring Data Using ARDUINO Serial Plotter for Combination 3 Circuit

By Generating the data readings for the output voltage and manipulating it in EXCEL

Figure 17: Data Plotting via Excel

The experiment validates the result we got from the simulation except there is small shift in slope
due to resistance in wires.

Page | 16
Appendices
Appendix A
MATLAB Code of FOS Transfer Function Simulation

syms s
R2 = 4700; R1 = R2; R3=10000;C3 = .0001; C1 = C3; C2=.00022;
num1=[1/(R1*C1)]; num2=[1/(R2*C2)]; num3=[1/(R3*C3)];
den1=[1 1/(R1*C1)]; den2=[1 1/(R2*C2)]; den3=[1 1/(R3*C3)];
sys1=tf(5*num1,den1); sys2=tf(5*num2,den2); sys3=tf(5*num3,den3);
stepplot(sys1,'r',sys2,'g',sys3,'b--')
legend('Combination 1', 'Combination 2', 'Combination 3')
grid on

Appendix B
MATLAB Code of FOS State-Space Simulation

R2 = 4700; R1 = R2; R3=10000;C3 = .0001; C1 = C3; C2=.00022;


a1=[-1/(R1*C1)]; a2=[-1/(R2*C2)]; a3=[-1/(R3*C3)];
b1=[1/(R1*C1)]; b2=[1/(R2*C2)]; b3=[1/(R3*C3)];
c=[1]; d=[0];
[num1,den1]=ss2tf(a1,b1,c,d); [num2,den2]=ss2tf(a2,b2,c,d); [num3,den3]=ss2tf(a3,b3,c,d);
sys1=tf(5*num1,den1); sys2=tf(5*num2,den2); sys3=tf(5*num3,den3);
stepplot(sys1,'r',sys2,'g',sys3,'b--')
legend('Combination 1', 'Combination 2', 'Combination 3')
grid on

Page | 17
Appendix C
MATLAB Code of FOS Analytical Time Response Simulation

syms s
R2 = 4700; R1 = R2; R3=10000;C3 = .0001; C1 = C3; C2=.00022;
num1=[1/(R1*C1)]; num2=[1/(R2*C2)]; num3=[1/(R3*C3)];
den1=[s+1/(R1*C1)]; den2=[s+1/(R2*C2)]; den3=[s+1/(R3*C3)];
r=5/s;
c1=r*(num1/den1); c2=r*(num2/den2); c3=r*(num3/den3);
N1=matlabFunction(ilaplace(c1)); N2=matlabFunction(ilaplace(c2)); N3=matlabFunction(ilaplace(c3));
t=[0:.01:10];
plot(t,N1(t),'r' , 'LineWidth', 2)
hold on
plot(t,N2(t),'g' , 'LineWidth', 2)
plot(t,N3(t),'b--' , 'LineWidth', 2)
xlabel('Time (seconds)')
ylabel('Amplitude')
title('Step Response')
legend('Combination 1', 'Combination 2', 'Combination 3')
grid on

Appendix D

MATLAB Code of SOS Transfer Function Simulation

syms s
L2 = 500; L1 = L2; L3=200;R3 = 10000; R2 = R3; R1 = R2; C1=.00001;C3 = .00002; C2 = C3;
num1=[1/(L1*C1)]; num2=[1/(L2*C2)]; num3=[1/(L3*C3)];
den1=[1 (R1/L1) 1/(L1*C1)]; den2=[1 (R2/L2) 1/(L2*C2)]; den3=[1 (R3/L3) 1/(L3*C3)];
sys1=tf(5*num1,den1); sys2=tf(5*num2,den2); sys3=tf(5*num3,den3);
stepplot(sys1,'r',sys2,'k',sys3,'b')
legend('Combination 1', 'Combination 2', 'Combination 3')
grid on

Appendix E

MATLAB Code of SOS State-Space Simulation

L2 = 500; L1 = L2; L3=200;R3 = 10000; R2 = R3; R1 = R2; C1=.00001;C3 = .00002; C2 = C3;


a1=[0 (1/C1);(-1/L1) (-R1/L1)]; a2=[0 (1/C2);(-1/L2) (-R2/L2)]; a3=[0 (1/C3);(-1/L3) (-R3/L3)];
b1=[0;(1/L1)]; b2=[0;(1/L2)]; b3=[0;(1/L3)];
c=[1 0]; d=[0];
[num1,den1]=ss2tf(a1,b1,c,d); [num2,den2]=ss2tf(a2,b2,c,d); [num3,den3]=ss2tf(a3,b3,c,d);
sys1=tf(5*num1,den1); sys2=tf(5*num2,den2); sys3=tf(5*num3,den3);
stepplot(sys1,'r',sys2,'k',sys3,'b')
legend('Combination 1', 'Combination 2', 'Combination 3')
grid on

Page | 18
Appendix F

MATLAB Code of SOS Analytical Time Response Simulation

syms s
L2 = 500; L1 = L2; L3=200;R3 = 10000; R2 = R3; R1 = R2; C1=.00001;C3 = .00002; C2 = C3;
num1=[1/(L1*C1)]; num2=[1/(L2*C2)]; num3=[1/(L3*C3)];
den1=[s^2+s*(R1/L1)+1/(L1*C1)]; den2=[s^2+s*(R2/L2)+1/(L2*C2)]; den3=[s^2+s*(R3/L3)+1/(L3*C3)];
r=5/s;
c1=r*(num1/den1); c2=r*(num2/den2); c3=r*(num3/den3);
N1=matlabFunction(ilaplace(c1)); N2=matlabFunction(ilaplace(c2)); N3=matlabFunction(ilaplace(c3));
t=[0:.01:1.2];
plot(t,N1(t),'r' , 'LineWidth', 2)
hold on
plot(t,N2(t),'k' , 'LineWidth', 2)
plot(t,N3(t),'b' , 'LineWidth', 2)
xlabel('Time (seconds)')
ylabel('Amplitude')
title('Step Response')
legend('Combination 1', 'Combination 2', 'Combination 3')
grid on

Appendix G
ARDUINO Code
int const inv= A0;
float volt ;
float reading;
void setup() {
Serial.begin(2400);
}
void loop() {
reading= analogRead(inv);
volt= reading *5/1024;
Serial.println(volt);
delay(1);
}}

Page | 19
References

[1] N. S. Nise, Control Systems Engineering, International Student Version. 2011.


[2] R. P. Regmi, “Application of differential equation in L-R and C-R circuit analysis by
classical method,” Janapriya J. Interdiscip. Stud., vol. 5, pp. 114–123, 2017.

Page | 20

You might also like