Professional Documents
Culture Documents
TAN Activity2 Section5.1
TAN Activity2 Section5.1
Tan
EE 179.1 Section: M45
Objectives
To grasp the important role of mathematical models of physical
systems in the design and analysis of control systems.
To learn how Scilab helps in solving such models.
List of equipment/software
Personal Computer
Scilab
Deliverables
Scilab scripts and their results for all the assignments and exercises
properly discussed and explained.
Analytical conclusion for this lab activity.
4.1
Consider the following Mass -Spring system shown in Figure 1 where K is the
spring force, fv is the friction coefficient, x(t) is the displacement and f(t) is
the applied force:
d2 x ( t )
dx ( t )
+f v
+ Kx(t)=f (t )
2
dt
dt
(1)
The second order linear differential equation (1) describes the relationship
between the displacement and the applied force. The differential equation
can then be used to study the time behavior of x(t) under various changes
of the applied force.
The objectives behind modeling the mass-damper system can be many and
may include:
4.2
Scilab can help solve linear or nonlinear ordinary differential equations (ODE)
using ode tool. To show how you can solve ODE using Scilab, we will proceed
in two ways. We first see how we can solve a first order ODE and then see
how we can solve a second order ODE.
4. 3 First Order ODE: Speed Cruise Control Example
Assume a zero spring force which means that K = 0. Equation (1) becomes
M
d2 x ( t )
dx ( t )
+f v
=f (t)
2
dt
dt
(2)
or
M
dv ( t )
+f v v (t )=f (t )
dt
(3)
since
2
a(t )=
and
dv ( t ) d x (t )
=
dt
d t2
v (t )=
,
dx ( t )
dt
Equation (3) is a first order linear ODE and we can use Scilab to solve for this
differential equation.
We can model and solve for equation (3) by writing the following script in
Scilab. You can also input the codes directly into the Scilab Console.
Code:
such
case,
equation
(1)
becomes
d x (t)
dx ( t )
+f v
+ K x r ( t)=f (t)
2
dt
dt
(4)
Equation (3) represents another possible model that describes the dynamic
behavior of the mass-damper system under external force. Unlike equation
(1), this is said to be a nonlinear differential equation.
We can also solve equation (3) using Scilab ode tool but this time, the second
order differential equation has to be decomposed in a set of first order
differential equations as follows:
Let
x ( t )=X 1
d X1
= X2
dt
so
d X 2 f v
f (t )
K
=
X 2 X 1r +
dt
M
M
M
so
[ ][]
X=
X1
x
= '
X2
x
dx(t)
=X 2 ,
dt
and
[ ][ ]
d X1
dX
dt
x'
=
=
dt
d X2
x' '
dt
so we get
X2
dX
= f v
f (t )
K
dt
X 2 X 1 r +
M
M
M
K = 15
r = 1
//differential equation definition
function xprime = f(t,x)
xprime(1) = x(2);
xprime(2) = -(B/M)*x(2)-(K/M)*((x(1))^r)+(Fa/M);
endfunction
t0 = 0
t = 0:0.1:5;
x0 = 0; //set initial position
xprime0 = 0; //set initial velocity
x = ode([x0; xprime0], t0, t, f);
clf;
plot2d(t, x(1,:))
form
// with dimension n x T
Assessment
5.1
Assignment
1. Show and discuss the graphs obtained from the sample simulations.
The first graph shows
the
velocity-time
relation of an object,
having a mass of 750
kg, being influenced
by a force of Fa =
300N moving at one
direction,
all
while
friction
of
magnitude 30 N/m.
The objects given
initial condition is vo = 0 m/s at to = 0 s.
At first glance, the function appears to
be linear, when in fact, it is not.
We used the ode function (ordinary
differential
equation).
Ode
solves
y (t 0)= y 0
The second sample code yields the graph
shown to the right.
This graph plots the position of any point
in the spring with respect to time.
Notice that the rate by which the position
changes over time increases, hence the
upward parabolic characteristic of the
graph.
Screenshots
Sample code 1
Sample code 2
5.2
Exercise 1
When r=3
Position
It can be said
that vs.
Velocity vs.
Time
Time
3. With r = 1, vary the value of K (multiply by 5 and 10) and discuss the
results.
With K = 75
With K = 150
5.3
Exercise 2
Consider the mechanical system depicted in the
The input is given by f(t), and the output
figure.
is
= 1, and b
References