Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 27

System Modelling and the Transfer Function

Simulation in SCILAB and XCOS

Francisco, Angela
Selera, Ken Archer
BSECE 3-A1
I. Introduction and Basic Theory
According to Nise, Norman S., an esteemed authority in control systems, the transfer
function stands as a potent mathematical tool, offering valuable insights into the intricate
behavior of circuits. It acts as a crucial bridge, connecting the input signals applied to a
circuit with the resulting output signals, unveiling the transformative processes within the
circuit's network of components.
The transfer function proves to be a convenient and powerful representation for linear,
time-invariant systems, effectively capturing their input-output relationship. This
mathematical expression is derived by applying a Laplace transform to the differential
equations that describe the dynamics of the system, assuming zero initial conditions.
Alternatively, when the governing equations are unavailable, engineers can estimate the
transfer function from measured input-output data. Widely employed in block diagram
representations of systems, transfer functions play a pivotal role in time-domain and
frequency-domain analyses, as well as in controller design.
The significant advantage lies in the simplicity transfer functions bring to the analysis
and design of systems. By employing straightforward algebraic equations instead of
intricate differential equations, engineers can navigate and comprehend the complexities of
circuits with greater ease, ultimately facilitating efficient system analysis and design
processes (Nise, Norman S., "Control Systems Engineering,").
Procedure for determining the transfer function of a control system are as follows:
1. We form the equations for the system.
2. Now we take Laplace transform of the system equations, assuming initial
conditions as zero.
3. Specify system output and input.
4. Lastly, we take the ratio of the Laplace transform of the output and the Laplace
transform of the input which is the required transfer function.

In control systems, input and output categories can differ. Electric motors, for instance,
take electrical input and produce mechanical output, while electric generators take mechanical
input and generate electrical output.

But for mathematical analysis, of a system all kinds of signals should be represented in a
similar form. This is done by transforming all kinds of signal to their Laplace form. Also, the
transfer function of a system is represented by Laplace form by dividing output Laplace transfer
function to input Laplace transfer function. Hence a basic block diagram of a control system can
be represented as:

Where r(t) and c(t) are time domain function of input and output signal respectively.
II. Objectives
In this section, the objectives of learning system modeling and Transfer Function
Simulation in SCILAB and XCOS are as follows:
Overall Objective:
To understand and practice system modeling and transfer function simulation
using SCILAB and XCOS software.

Specific Objectives:
Learn the basics of system modeling:
 Identify different types of systems (continuous-time, discrete-time, linear, non-
linear).
 Apply appropriate mathematical models to represent simple systems (e.g.,
differential equations, transfer functions).
Understand the concept of transfer functions:
 Define the transfer function and its relationship to input and output signals.
 Analyze the frequency response of a system using its transfer function.
Gain proficiency in using SCILAB and XCOS:
 Navigate the SCILAB environment and use basic commands for mathematical
operations and data manipulation.
 Utilize the Control System Toolbox in SCILAB for system modeling and analysis.
 Create block diagrams in XCOS to represent system models and perform
simulations.
 Analyze and interpret simulation results obtained from XCOS
Apply theoretical knowledge to practical examples:
 Develop a mathematical model of the chosen system using transfer functions.
 Design and implement the model in SCILAB and XCOS.
 Analyze the simulated response of the system to various inputs and
disturbances.
 Compare the simulation results with theoretical predictions and real-world
expectations.

III. Equipment /Tools/Materials/Components Needed


In this section, it shows the essential tools and components needed for System
Modeling and SCILAB/XCOS Simulation.
i. Laptop/Computer
ii. Scilab Application
IV. Diagram
The diagram shows the derivation of the transfer function or model of the given
circuits.
V. Procedure
By using SCILAB XCOS for simulation, you can gain a more comprehensive
understanding of the system's behavior based on the given transfer function. These
are the detailed for system modelling and the transfer function simulation in SCILAB
and XCOS

1. Installation:
 Download SCILAB from the official website.
 Follow the installation instructions for your operating system.

2. Launch SCILAB:
 Open SCILAB after successful installation.

3. Command Line Window and SciNotes:


3.1 Command Line Window:
 Scilab provides an interactive console where you can directly type and
execute commands.
3.2 SciNotes:
 SciNotes is SCILAB's integrated development environment (IDE).
 Open SciNotes from the "Applications" menu.

4. Explore the SciLab software


4.1 Basic Usage of Scilab
 First of all is using the user console and using simple calculations and
press ‘Enter’ key to execute them. Like pressing 2+3 it will output a 5 in
the console.
 Next is the use of variables which is very important especially that we are
making a mathematical model in this laboratory experiment.
 We can declare variables in the console like this example code below.

 If you are dealing with longer codes, use the SciNotes which is located
here as it is easier to code and this is useful for dealing with more
complex functions.

 After inputting your line of codes you can press the run button to
automatically run all the lines in the main window console
4.2 Don’t limit yourself and explore more
 Start with the introductory tutorials on the Scilab website
(https://www.scilab.org/scilab-for-beginners-tutorial) to get comfortable
with the basic syntax and commands.

 Never hesitate to experiment and try different things. Scilab provides a


forgiving environment for learning. Use the help system and online
resources whenever you need clarification on specific functions or
concepts. The help system can be found by pressing “F1” in your
keyboard or the picture here below:

 As you progress, you can always check this help browser to explore more
advanced features like control flow, functions, and data structures to
write more complex programs.

5. Simulating Transfer Function:


 Before the simulation in the software, derive the transfer function of the
given circuits.
For example:
Solution:
Using Voltage Divider,
C
V o ( t )=V i ( t ) [ ]
R +C
1
sC
V o ( s )=V i ( s ) [ ](sC)
1
R+
sC
1 1
V o ( s )=V i ( s ) [ ]( )
sRC +1 RC
1
RC
V o ( s )=V i ( s ) [ ]
1
s+
RC
V o ( s) 1 1
=H ( s ) = ( )
V i (s ) RC 1
s+
RC
At R=1 Ohm and C= 1F, the transfer function is:
1
H ( s )=
s +1

 Open the command line or SciNotes and enter this code.


 In command line

 In SciNotes
6. Execution:
 Execute the script in the command line or SciNotes.
 Observe the Bode plot that shows the frequency response of the given
transfer function.

7. Analyzing:
 Analyze the Bode plot to understand the frequency response characteristics
of the given transfer function.

8. Using SCILAB XCOS to Simulate Transfer Function Response:


 Open SCILAB XCOS, the graphical editor for modeling, simulation, and control
system design.
 Create a model in XCOS. Using the following
i. CLOCK_c – found in the “Event handling” palette
ii. CSCOPE – found in the “Sink” palette
iii. STEP_FUNCTION – found in the “Sources” palette
iv. CLR – found in the “Continuous time systems” palette
 Use the Transfer Function block to represent the given transfer function G.

 Connect the input and output blocks accordingly.

 After connecting, we can now run the simulation and check its waveform but
before that we need to set up some variables so that we can see the graph
much more clearly.
9. Discussing the Resulting Waveform:
 Simulate the XCOS model to obtain the response of the given transfer
function.

 Analyze the resulting waveform, observing how the system responds to


changes in input or frequency.

10. Comparing Manual Plot and Simulation Results:


 Compare the waveform obtained from the XCOS simulation with the
manually plotted Bode graph.
 Note any similarities or differences in the frequency response characteristics.
 Consider factors such as amplitude, phase shift, and frequency at critical
points.

11. Implications of Simulation Results:


 Analyze the simulation results to gain insights into the dynamic behavior of
the system.
 Consider the system's stability, response time, and sensitivity to input
variations.
 Assess how well the simulation aligns with theoretical expectations and
manual analysis.

By using SCILAB XCOS for simulation, you can gain a more comprehensive
understanding of the system's behavior based on the given transfer function.
Comparing the results with the manual plot provides a holistic view of the system's
response across different tools. Analyzing the implications of the simulation results
helps draw conclusions about the system's performance and aids in further
refinement or optimization if necessary.

VI. Results and Discussions

Bode plot Figure #1 XCOS simulation Figure#1


The results of the figure #1 shows that the bode plot graph acts as a low pass filter the
capacitor behaves like an open circuit at low freuqency, and the magnitude is relatively
high. So that means it attenuates high frequencies but allows low frequency to pass. As the
frequency increases, the impedance of the capacitor decreases, causing a gradual roll-off in
the magnitude plot.

In the phase plot, At low frequencies, the phase shift is minimal.


As the frequency increases, the phase shift becomes more negative due to the increasing
capacitive reactance, leading to a phase lag.

The Xcos simulation shows that we are trying to graph the UNIT STEP RESPONSE of the RC
circuit. And so the transfer function in the system is
1
H ( s )=( )
s+ 1
To find the unit step response, you can take the inverse Laplace transform of the transfer
function multiplied by the Laplace transform of the unit step function 1/s . and this will
output Y(s)=G(s)⋅U(s).
Where U(s) is the Laplace transform of the unit step function, which is 1/s .

( )( )
Y ( s )=
1
s+ 1

1
s
Now, you can find the inverse Laplace transform of Y(s) to obtain the unit step response
y(t).
−t
y ( t ) =1−e
The response signifies a quick rise to the final value of 1, with an exponential decay and
underdamped behavior. If you were to plot this response graphically, you would see a
curve that rises rapidly and approaches 1 with decreasing oscillations.
Bode plot Figure #2 XCOS simulation Figure #2

The results of the figure #2 shows that the bode plot graph acts as a high pass filter as the
capacitor behaves like a short circuit, and the magnitude is relatively low. As the frequency
increases, the impedance of the capacitor increases, causing a gradual roll-off in the
magnitude plot. The roll-off is also characterized by a slope of -20 dB/decade (first-order
system). Phase Plot: At low frequencies, the phase shift is minimal. As the frequency
increases, the phase shift becomes more positive due to the decreasing capacitive
reactance, leading to a phase lead.
The Xcos simulation shows that we are trying to graph the UNIT STEP RESPONSE of the CR
circuit. And so the transfer function in the system is
s
H ( s )=( )
s+ 1
To find the unit step response, you can take the inverse Laplace transform of the transfer
function multiplied by the Laplace transform of the unit step function 1/s . and this will
output Y(s)=G(s)⋅U(s).
Where U(s) is the Laplace transform of the unit step function, which is 1/s .

( )( )
Y ( s )=
s
s+ 1

1
s
Now, you can find the inverse Laplace transform of Y(s) to obtain the unit step response
y(t).
−t
y ( t ) =u(t)+ e
The response signifies a that it will rise instantly to the max value, with an exponential
decay that decreases continuously to u(t). If you were to plot this response graphically, you
would see a curve that will have an impulse response 1 with a slowly decreasing value until
it reaches u(t). Take note our initial value from the unit step is zero so that means it will
have an exponential decay that eventually will reach to zero
Bode plot Figure #3 XCOS simulation Figure #3

The results of the figure #3 shows that the bode plot graph acts as a high pass filter as the
inductor behaves like a short circuit, and the magnitude is relatively low. As the frequency
increases, the impedance of the capacitor increases, causing a gradual roll-off in the
magnitude plot. The roll-off is also characterized by a slope of -20 dB/decade (first-order
system). Phase Plot: At low frequencies, the phase shift is minimal. As the frequency
increases, the phase shift becomes more positive due to the decreasing inductive
reactance, leading to a phase lead.
The Xcos simulation shows that we are trying to graph the UNIT STEP RESPONSE of the RL
circuit. And so the transfer function in the system is
s
H ( s )=( )
s+ 1
To find the unit step response, you can take the inverse Laplace transform of the transfer
function multiplied by the Laplace transform of the unit step function 1/s . and this will
output Y(s)=G(s)⋅U(s).
Where U(s) is the Laplace transform of the unit step function, which is 1/s .

( )( )
Y ( s )=
s
s+ 1

1
s
Now, you can find the inverse Laplace transform of Y(s) to obtain the unit step response
y(t).
−t
y ( t ) =u(t)+ e
The response signifies a that it will rise instantly to the max value, with an exponential
decay that decreases continuously to u(t). If you were to plot this response graphically, you
would see a curve that will have an impulse response 1 with a slowly decreasing value until
it reaches u(t). Take note our initial value from the unit step is zero so that means it will
have an exponential decay that eventually will reach to zero
Bode plot Figure #4 XCOS simulation Figure #4

The results of the figure #4 shows that the bode plot graph acts as a low pass filter the
inductor behaves like an open circuit at low freuqency, and the magnitude is relatively
high. So that means it attenuates high frequencies but allows low frequency to pass. As the
frequency increases, the impedance of the inductor increases, causing a gradual roll-off in
the magnitude plot.

In the phase plot, At low frequencies, the phase shift is minimal.


As the frequency increases, the phase shift becomes more negative due to the increasing
inductive reactance, leading to a phase lag.

The Xcos simulation shows that we are trying to graph the UNIT STEP RESPONSE of the LR
circuit. And so the transfer function in the system is
1
H ( s )=( )
s+ 1
To find the unit step response, you can take the inverse Laplace transform of the transfer
function multiplied by the Laplace transform of the unit step function 1/s . and this will
output Y(s)=G(s)⋅U(s).
Where U(s) is the Laplace transform of the unit step function, which is 1/s .

( )( )
Y ( s )=
1
s+ 1

1
s
Now, you can find the inverse Laplace transform of Y(s) to obtain the unit step response
y(t).
−t
y ( t ) =1−e
The response signifies a quick rise to the final value of 1, with an exponential decay and
underdamped behavior. If you were to plot this response graphically, you would see a
curve that rises rapidly and approaches 1 with decreasing oscillations.
Bode plot Figure #5 XCOS simulation Figure #5

At low frequencies, the magnitude is determined by the constant term in the numerator. In this
case, it is 1. At high frequencies, the magnitude decreases at a rate of -40 dB/decade (for each
power of 10 increase in frequency) due to the second-order term in the denominator.
The phase behavior of a critically damped system is that the phase lags; it approaches -90
degrees per pole at higher frequencies. In this case, with complex conjugate poles due to the

transfer function (
−1
2 2
3
)
± j √ the phase starts at 0 degrees and decreases with a slope of -90

degrees per pole as the frequency increases. The phase plot shows a phase lag. The amount of
phase lag at the resonant frequency can provide insights into the damping ratio. The presence
of phase lag indicates that the system is reactive, and the amount of lag provides information
about the system's response time.

On the XCOS simulation,


The Xcos simulation shows that we are trying to graph the UNIT STEP RESPONSE of the RLC
circuit. And so the transfer function in the system is
1
H ( s )=( 2 )
s + s+1
To find the unit step response, you need to use partial fraction decomposition then find the
inverse laplace of each term.

( s +s1 +1 )=( s−sA 1 )+( s−sB 1 )


2

And the general solution should be

y ( t ) =( A s1∗t ) + ( Bs 2∗t ) +¿
After that we need to find the roots of the quadratic equiation s^2+s+1

−1 √ 3
s 1∧s 2= ±i
2 2
Therefore, the unit step response will involve terms with exponentials and trigonometric functions.

The unit step response y(t) for the transfer function 1/(s^2 + s +1) will exhibit oscillatory behavior due
to the presence of complex roots in the denominator.
VII. Observations
I have noticed an intriguing contrast in the Bode plot outputs between RC
(Resistor-Capacitor) and RL (Resistor-Inductor) circuits. In an RC circuit, at low
frequencies, the capacitor emulates an open circuit, resulting in a relatively high
magnitude. Conversely, in an RL circuit, at low frequencies, the inductor emulates a
short circuit, leading to a relatively low magnitude. As the frequency increases in the
RC circuit, the magnitude decreases, accompanied by a lagging phase. In contrast, in
the RL circuit, the magnitude also decreases with increasing frequency, but the
phase exhibits a leading behavior instead of lagging.

VIII. Conclusions
In conclusion, the combined use of Scilab and Xcos software emerges as a robust
approach for simulating and analyzing the responses of electrical circuits, specifically
those configured as RLC, RL or RC circuits. These software platforms offer versatile
tools that facilitate a comprehensive understanding of system behavior, allowing for
dynamic visualization of responses across different frequencies.
In Scilab, both the command line and SciNotes provide versatile options for
plotting the transfer function based on specified ranges or points. On the other
hand, Xcos serves as a valuable tool for simulating the input response of the transfer
function.
The consistent congruence observed between manual analysis in Scilab SciNotes
and dynamic simulations in Xcos underscores the reliability and effectiveness of
these platforms in accurately representing the complexities of RL and RC circuit
responses.

IX. Recommendations
The inclusion of higher-degree order circuits in System Modeling and Transfer
Function Simulation using SCILAB and XCOS is highly recommended.
Control systems are designed to manipulate the behavior of dynamic systems to
achieve desired outputs. Higher-degree order circuits, often involving higher-order
differential equations, arise in the modeling of complex systems where multiple
energy storage elements (such as capacitors and inductors) and energy dissipative
elements (such as resistors) are interconnected.
Therefore, it is advisable to undertake this recommendation to further augment
the capabilities of individuals who have successfully completed tasks involving the
understanding of transfer functions and frequency responses in simple RC, RL, and
RLC circuits. Embracing the challenge of higher-degree order circuits represents a
significant advancement, introducing complexity that can significantly broaden one's
knowledge beyond the fundamentals. This progression provides an opportunity to
delve into more intricate circuit dynamics, offering a valuable extension to the
foundational understanding already acquired.
X. Simulation

Bode plot Figure #1 XCOS simulation Figure#1

Bode plot Figure #2 XCOS simulation Figure #2


Bode plot Figure #3 XCOS simulation Figure #3

Bode plot Figure #4 XCOS simulation Figure #4


Bode plot Figure #5 XCOS simulation Figure #5

XCOS transfer function block diagrams

You might also like