Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
An Introduction to Xcos
A. B. Raju Ph.D
Professor and Head,Electrical and Electronics Engineering Department,
B. V. B. College of Engineering and Technology,HUBLI-580 031, KARNATAKA
28th September 2010
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Outline of Presentation
1 Ordinary Differential Equations
2 Why Scilab/Xcos?
3 How do I construct dynamic models?
4 More examples
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Ordinary Differential Equations
These equations are of great importance in Science andEngineering
Many physical laws and relations appear mathematically inthe form of differential equations
A physical law involving a rate of change of function, such asvelocity or acceleration–it leads to a differential equation
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Example (1): Experiments show that a radioactive substancedecomposes at a rate proportional to the amount present. Startingwith a given amount of substance, say, 2 gms, at a certain time,say, t=0, what can be said about the amount available at a latertime?
dy
dt= ky
where k is a constant, whose value depends on the radioactivesubstance.
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Example (2): The tank shown below contains 200 gal of water inwhich 40 lb of salt are dissolved. Five gal of water, each containing2 lb of dissolved salt, run into the tank per minute, and themixture, kept uniform by stirring, run out at the same rate. Findthe amount of salt y(t) in the tank at any time t.
dy
dt= inflow rate− outflow rate
= 10− 0.025y
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Example (3): A body slides on a surface, it experiences frictionforce F. Experiments show that |F | = µ|N |. Assume that the bodyweighs 45 nt (about 10 lb), µ = 0.20, α = 300, the slide is 10 mtrlong, initial velocity is zero. Find the velocity of the body at theend of the slide.
W
α
Ν
y
x
(W/g )*a
F
WNv(t)
s(t)
Equating horizontal and vertical forces, we get
N = W cosα
F = µN
= µW cosα
0 = W sinα− µW cosα− W
g
dx
dtA. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Example (4): Find the transfer function, X(s)/F(s) for the systemgiven below.
M
K
D
x(t)
f(t)
Equating horizontal forces, we get
f(t) = Md2x(t)
dt2+D
dx(t)
dt+Kx(t)
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Example (5): RL circuit
R
V
L
i
−
+
The corresponding differential equation is given by:
di
dt=
1
L(V − iR)
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I solve such differential equations?
1 Get all the data required for the solution (viz., all constants,initial conditions, time-step etc)
2 Select a suitable numerical integration algorithm among manyavailable methods
3 Write a program to implement selected algorithm using anyprograming languages (viz., C, C++, Fortran, Scilab, Matlabetc)
4 Collect data required for visualization
5 Interpret results so obtained
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I solve such differential equations?
1 Get all the data required for the solution (viz., all constants,initial conditions, time-step etc)
2 Select a suitable numerical integration algorithm among manyavailable methods
3 Write a program to implement selected algorithm using anyprograming languages (viz., C, C++, Fortran, Scilab, Matlabetc)
4 Collect data required for visualization
5 Interpret results so obtained
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I solve such differential equations?
1 Get all the data required for the solution (viz., all constants,initial conditions, time-step etc)
2 Select a suitable numerical integration algorithm among manyavailable methods
3 Write a program to implement selected algorithm using anyprograming languages (viz., C, C++, Fortran, Scilab, Matlabetc)
4 Collect data required for visualization
5 Interpret results so obtained
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I solve such differential equations?
1 Get all the data required for the solution (viz., all constants,initial conditions, time-step etc)
2 Select a suitable numerical integration algorithm among manyavailable methods
3 Write a program to implement selected algorithm using anyprograming languages (viz., C, C++, Fortran, Scilab, Matlabetc)
4 Collect data required for visualization
5 Interpret results so obtained
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I solve such differential equations?
1 Get all the data required for the solution (viz., all constants,initial conditions, time-step etc)
2 Select a suitable numerical integration algorithm among manyavailable methods
3 Write a program to implement selected algorithm using anyprograming languages (viz., C, C++, Fortran, Scilab, Matlabetc)
4 Collect data required for visualization
5 Interpret results so obtained
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Let us see the implementation of aforementioned steps in action:Run rlckt1.sce from Scilab
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Why Scilab/Xcos?
1 Xos/Scicos: Scilab connected object simulator → visual editor
2 Scilab package for modelling and simulation of dynamicsystems
3 Dynamic systems can include continuous or discretesub-systems
4 It has a friendly GUI for editing models by interconnectingXcos blocks
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Why Scilab/Xcos?
1 Xos/Scicos: Scilab connected object simulator → visual editor
2 Scilab package for modelling and simulation of dynamicsystems
3 Dynamic systems can include continuous or discretesub-systems
4 It has a friendly GUI for editing models by interconnectingXcos blocks
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Why Scilab/Xcos?
1 Xos/Scicos: Scilab connected object simulator → visual editor
2 Scilab package for modelling and simulation of dynamicsystems
3 Dynamic systems can include continuous or discretesub-systems
4 It has a friendly GUI for editing models by interconnectingXcos blocks
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Why Scilab/Xcos?
1 Xos/Scicos: Scilab connected object simulator → visual editor
2 Scilab package for modelling and simulation of dynamicsystems
3 Dynamic systems can include continuous or discretesub-systems
4 It has a friendly GUI for editing models by interconnectingXcos blocks
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I construct dynamic models?
1 Starting Xcos with an empty diagram
2 Opening one or more palettes
3 Copying blocks of interest from the palettes into the diagram
4 Setting parameters of the blocks to desired values
5 Connecting the blocks’ input and output ports
6 Compiling and simulating the diagram
7 Renaming and saving the diagram
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I construct dynamic models?
1 Starting Xcos with an empty diagram
2 Opening one or more palettes
3 Copying blocks of interest from the palettes into the diagram
4 Setting parameters of the blocks to desired values
5 Connecting the blocks’ input and output ports
6 Compiling and simulating the diagram
7 Renaming and saving the diagram
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I construct dynamic models?
1 Starting Xcos with an empty diagram
2 Opening one or more palettes
3 Copying blocks of interest from the palettes into the diagram
4 Setting parameters of the blocks to desired values
5 Connecting the blocks’ input and output ports
6 Compiling and simulating the diagram
7 Renaming and saving the diagram
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I construct dynamic models?
1 Starting Xcos with an empty diagram
2 Opening one or more palettes
3 Copying blocks of interest from the palettes into the diagram
4 Setting parameters of the blocks to desired values
5 Connecting the blocks’ input and output ports
6 Compiling and simulating the diagram
7 Renaming and saving the diagram
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I construct dynamic models?
1 Starting Xcos with an empty diagram
2 Opening one or more palettes
3 Copying blocks of interest from the palettes into the diagram
4 Setting parameters of the blocks to desired values
5 Connecting the blocks’ input and output ports
6 Compiling and simulating the diagram
7 Renaming and saving the diagram
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I construct dynamic models?
1 Starting Xcos with an empty diagram
2 Opening one or more palettes
3 Copying blocks of interest from the palettes into the diagram
4 Setting parameters of the blocks to desired values
5 Connecting the blocks’ input and output ports
6 Compiling and simulating the diagram
7 Renaming and saving the diagram
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
How do I construct dynamic models?
1 Starting Xcos with an empty diagram
2 Opening one or more palettes
3 Copying blocks of interest from the palettes into the diagram
4 Setting parameters of the blocks to desired values
5 Connecting the blocks’ input and output ports
6 Compiling and simulating the diagram
7 Renaming and saving the diagram
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Xcos implementation RL circuit will be
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Xcos response of this circuit for R=10Ω, L=100mH and a stepinput voltage of 50 V is applied
0
1
2
3
4
5
6
0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10
Time (s)
Current (A)
Graphic 1
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
RLC circuit with step input voltage
V
R L
C
i
Vc−
+
The corresponding differential equations are given by:
di
dt=
1
L(V − iR− vc)
dvcdt
=i
C
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Xcos block diagram is
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Xcos response for R=2Ω, L=100mH, C=1000µF and a step inputvoltage of 50 V is applied
-5
-4
-3
-2
-1
0
1
2
3
4
5
0.0 0.1 0.2 0.3 0.4 0.5
Time (s)
Current (A)
Graphic 1
-20
0
20
40
60
80
100
0.0 0.1 0.2 0.3 0.4 0.5
Time (s)
Voltage (V)
Graphic 2
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
A Variable Frequency Oscillator
d2y1dt2
= −ω2y1
Converting this equation into two first-order differential equations
y2 =
(1
ω
)dy1dt
dy2dt
= −ωy1
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Xcos implementation isOD
-10
-8
-6
-4
-2
0
2
4
6
8
10
0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10
Time (s)
y
Graphic 1
-10
-8
-6
-4
-2
0
2
4
6
8
10
0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10
Time (s)
y
Graphic 2
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Separately excited/permanent magnet dc motor
Motor parameters:
Rated power = 2 kWRated armature voltage = 125 VRated armature current = 16 ARated speed = 1750 rpmRa = 0.24 Ω, La = 18 mH,Kaφ = 0.6699, J = 0.5 kgm2,Tl = 0.01 + 3.189× 10−4 × ω2
m
DC Motor defining equations are:
Va = Raia + Ladiadt
+Kaφω
Kaφia = Jdω
dt+Bω + Tl
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Xcos response is
0
50
100
150
200
250
300
350
400
0.0 0.5 1.0 1.5 2.0 2.5 3.0
Time (s)
Current (A)
Graphic 1
0
20
40
60
80
100
120
140
160
180
200
0.0 0.5 1.0 1.5 2.0 2.5 3.0
Time (s)
Speed (rps)
Graphic 2
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
DC motor closed loop speed control system
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Xcos response is
0
5
10
15
20
25
30
35
40
45
50
0 2 4 6 8 10 12 14 16 18 20
Time (s)
Current (A)
Graphic 1
0
50
100
150
0 2 4 6 8 10 12 14 16 18 20
Time (s)
y
Graphic 2
A. B. Raju BVBCET, Hubli
An Introduction to Xcos
Ordinary Differential Equations Why Scilab/Xcos? How do I construct dynamic models? More examples
Thank YouAny Questions?
A. B. Raju BVBCET, Hubli
An Introduction to Xcos