Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
74 views16 pages

EEE160.1 Lab-Report5

This document describes using the XCOS tool in Scilab to model and simulate physical systems. It provides details on modeling a mass-spring system, including deriving the differential equation and creating an XCOS block diagram to simulate it. It also includes the steps to execute the block diagram and generate plots of the output responses in Scilab.

Uploaded by

REHAM DEE CAMAMA
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)
74 views16 pages

EEE160.1 Lab-Report5

This document describes using the XCOS tool in Scilab to model and simulate physical systems. It provides details on modeling a mass-spring system, including deriving the differential equation and creating an XCOS block diagram to simulate it. It also includes the steps to execute the block diagram and generate plots of the output responses in Scilab.

Uploaded by

REHAM DEE CAMAMA
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/ 16

Name: JERICO R. MENDAÑA, PRINCE JOEL M.

MUTIA Course and Year: BSEE - 3


EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

Activity 5: Modeling of Physical Systems


using XCOS
Abstract
Modeling physical systems involves a comprehensive understanding of their operations.
This can be accomplished through various methods, including graphical representation
via block diagrams. Block diagrams offer a functional perspective on a system,
enhancing comprehension of its operations, workflows, and processes. Employing a
graphical user interface further facilitates the application of these block functions,
providing interactive visual elements such as icons and buttons. These elements
convey information and execute actions based on inputs, enhancing accuracy in system
analysis. The XCOS tool within SCILAB serves as a powerful graphical interface
dedicated to modeling and simulating hybrid dynamic systems. It equips users with the
necessary functionalities to create and execute programs, enabling the analysis of
variables and plotting of system inputs to achieve desired outputs and responses.

By employing the differential equation and adhering to the process of modeling a


second-order system using the XCOS tool, the system's response can be determined.
This is achieved by visualizing plots of its outputs, which depict displacement and
velocity over time. Manipulating system parameters enables observation of various
outputs, influencing the system's overall response.

Objectives
The objective of this exercise is to use graphical user interface diagrams to model the
physical systems for the purpose of design and analysis of control systems. We will
learn how SCILAB/XCOS helps in solving such models.

List of Equipment/Software
Following equipment/software is required:

 SCILAB/XCOS
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

Deliverables
A complete lab report including the following:

 Summarized learning outcomes.


 SCILAB scripts, XCOS diagrams and their results for all the assignments and
exercises should be properly reported.

Overview:
This lab introduces powerful graphical user interface (GUI), XCOS of Scilab. This
software is used to design hybrid dynamical systems models. Models can be designed,
loaded, saved, compiled and simulated.
Ergonomic and efficient solution for industrial and academics needs, Xcos provides
functionalities for modeling of mechanical systems (automotive, aeronautics…),
hydraulic circuits (dam, pipe modeling…), control systems, etc.
XCOS
Xcos provides access to an extensive set of blocks that accomplish a wide range of
functions useful for the simulation and analysis of dynamic systems. The blocks are
grouped into libraries, by general classes of functions.
 Mathematical functions such as summers and gains are in the Mathematical
Operations library.
 Integrators are in the Continuous time systems library.
 Constants, common input functions, and clock can all be found in the Sources
library.
 Scope, To Workspace blocks can be found in the Sinks library.
Xcos is a graphical interface that allows the user to create programs that are actually
run in SCILAB. When these programs run, they create arrays of the variables defined in
Xcos that can be made available to SCILAB for analysis and/or plotting. The variables
to be used in SCILAB must be identified by Xcos using a “To Workspace” block, which
is found in the Sinks library. Sinks library also contains a Scope, which allows variables
to be displayed as the simulated system responds to an input. This is most useful when
studying responses to repetitive inputs.
Xcos uses blocks to write a program. Blocks are arranged in various libraries according
to their functions. Properties of the blocks and the values can be changed in associated
dialog boxes.
You are encouraged to browse the Xcos libraries and consult the Help Browser
facility provided with SCILAB.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

GENERAL INSTRUCTIONS FOR WRITING AN XCOS PROGRAM


To create a simulation in Xcos, follow the steps:

 Start SCILAB
 Start Xcos by clicking Applications -> Xcos or just typing xcos in Scilab console.
(An Xcos window and Palette browser will appear)
 Open the libraries that contain the blocks you will need. These usually will include
the Sources, Sinks, Mathematical Operations, and Continuous time systems
libraries, and possibly others.
 Drag the needed blocks from their library folders to the Xcos window. The
Mathematical Operations library, for example, contains the Gain and Sum blocks.
 Arrange these blocks in an orderly way corresponding to the equations to be
solved.
 Interconnect the blocks by dragging the cursor from the output of one block to the
input of another block.
 Double-click on any blocks having parameters that must be established, and set
these parameters. For example, the gain of all Gain blocks must be set. The
number and signs of the inputs to a Sum block must be established. The
parameters of any source blocks should also be set in this way.
 It is necessary to specify a stop time for the solution. This is done by clicking on
the Simulation -> Setup on the Xcos toolbar.
At the Simulation -> Setup entry, several parameters can be selected in this dialog box,
but the default values of all of them should be adequate for almost all of the exercises. If
the response before time zero is needed, it can be obtained by setting the Start time to
a negative value. It may be necessary in some problems to reduce the maximum
integration step size used by the numerical algorithm. If the plots of the results of a
simulation appear “choppy” or composed of straight-line segments when they should be
smooth, reducing the maximum step size permitted can solve this problem.
Saving an Xcos diagram will produce a zcos-file.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

Mass-Spring System Model

Consider the Mass -Spring system used in the previous exercise as shown in the figure.
Where Fs(x) is the spring force, Ff(ẋ) is the friction coefficient, x(t) is the displacement
and Fa(t) is the applied force:

The differential equation for the above Mass-Spring system can then be written as follows

For Non-linear such case, (1) becomes

Exercise 1: Modeling of a second order system

Construct a XCOS diagram to calculate the response of the Mass-Spring system. The
input force increases from 0 to 8N at t = 1s. The parameter values are M = 2kg, K =
16N/m, and B = 4N.s/m.

Steps:
 Draw the free body diagram.
 Write the modeling equation from the free body diagram.
 Solve the equations for the highest derivative of the output.
 Draw a block diagram to represent this equation.
 Draw the corresponding XCOS diagram.
 Use Step block to provide the input fa(t).
 In the Step block, set the initial and final values and the time at which the step
occurs.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

 Use the “To Workspace” blocks for t, fa(t), x, and v in order to allow XCOS to
plot the desired responses. Set the save format to array in block parameters.
 Select the duration of the simulation to be 10 seconds from the
Simulation -> Parameters Final integration time on the toolbar then hit Ok.
Given below is a file that will set up the SCILAB workspace by establishing the values
of the parameters needed for the XCOS simulation of the given model.

SCE-file for parameters values


Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

XCOS block diagram

ex1_model.zcos
1. What is the used of the “To workspace” blocks? Explain the purpose of each To
workspace blocks.

 This block serves to input simulated data into the SCILAB workspace, capturing both
dates and values at each sampling interval. The "To Workspace Time" parameter
records time data, while "To Workspace Velocity" records the system's velocity, and
"To Workspace X_val" captures displacement values.

2. Redraw ex1_model.zcos to a block diagram with the same symbols used in the
textbook except for the scope, “To workspace” and clock blocks. Label the
signals and the systems/sub-systems.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

Plotting the outputs in SCILAB:


The file to create the plots of the output is given below. Create the file and save it by the
name given below.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

SCE-file to produce the plot

Program Execution:
Follow the following steps to execute these files:
 Execute the file ex1_parameter.sce. This will load the parameter values of the
model.
 Open the Xcos model ex1_model.zcos and start the simulation by clicking on the
toolbar Simulation > Start. Close the graphical window that will appear upon
clicking the Start button.
 Execute the file ex1_plot.sce to make the plot.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

Making Subplots in SCILAB:


When two or more variables are being studied simultaneously, it is frequently desirable
to plot them one above the other on separate axes, as can be done for displacement
and velocity in. This is accomplished with the subplot command. The following SCE-file
uses this command to produce both plots of displacement and velocity.

SCE-file to make subplots


Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

Exercise 2: Simulation with system parameter variation

The effect of changing B is to alter the amount of overshoot or undershoot. These are
related to a term called the damping ration. Simulate and compare the results of the
variations in B in exercise 1. Take values of B = 4, 8, 12, 25 Ns/m.

Steps:
Perform the following steps. Use the same input force as in Exercise 1.

 Begin the simulation with B = 4 Ns/m, but with the input applied at t = 0
 Plot the result
 Rerun it with B = 8 Ns/m
 Reissue the plot command plot(t,x), the second plot will superimpose on the first
 Repeat for B = 12 Ns/m and for B = 25 Ns/m
 Show your result.

B=4
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

B=8

B=12
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

B=25

Running XCOS from SCILAB console


If a complex plot is desired, in which several runs are needed with different parameters,
this can use the command called “xcos_simulate”. “xcos_simulate” command will run
the XCOS model file from the specific directory using Scilab command prompt. For
multiple runs with several plot it can be accomplished by executing ex1_model (to load
parameters) followed by given SCE-file. Executing the file ex1_plots results in multiple
runs with varying values of B and will plot the results.

SCE-file to use “xcos_simulate” function and produce multiple runs


and their plots
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

Exercise 3: System response from the stored energy with zero input

Find the response of the above system when there is no input for t>=0, but when the
initial value of the displacement x(0) is zero and the initial velocity v(0) is 1 m/s.

Steps:
In the previous program

 Set the size of the input step to zero


 Set the initial condition on Integrator for velocity to 1.0
 Plot the results by running sce-files.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

The depicted plot illustrates the system's response concerning displacement and velocity
over time. Initially, the displacement begins at x(0)=0, while the initial velocity stands at
v(0)=1m/s.

Exercise 4: Cruise System

As we know in the cruise system, the spring force Fs(x) = 0 which means that K = 0.
Equation(2) becomes

Find the velocity response of the above system by constructing an Xcos block diagram
and calling the block diagram from Scilab sce-file. Use M=750, B=30 and a constant
force Fa=300. Plot the response of the system such that it runs for 125 seconds.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

ex4_model.zcos

By adjusting the XCOS block diagram model according to the provided variables for the
cruise system, we can determine the responses for displacement and velocity over time.
Name: JERICO R. MENDAÑA, PRINCE JOEL M. MUTIA Course and Year: BSEE - 3
EEE160.1 Section: T45 Laboratory Schedule: Tuesday (12:00PM – 3:00PM)

Conclusion:

In summary, the utilization of XCOS within SCILAB offers a robust framework for
modeling and analyzing physical systems. Through the intuitive graphical user interface
and extensive library of blocks, users can construct complex system models with ease,
gaining insights into system behaviors and dynamics. By adhering to systematic
procedures and employing differential equations, XCOS enables the simulation of various
scenarios, allowing users to explore the effects of parameter variations and input stimuli
on system responses.

Furthermore, XCOS facilitates seamless integration with SCILAB, providing a


comprehensive environment for system analysis and design. From mathematical
operations to continuous-time systems, XCOS offers a diverse range of functionalities to
cater to different modeling needs, making it a versatile tool for both industrial and
academic applications. By enabling users to visualize system responses and analyze
data in real-time, XCOS empowers engineers and researchers to make informed
decisions and optimize system performance effectively.

You might also like