MATLAB practicum IWS

4th IWS Matlab practicum, June 10, 2004.
1
Bouncing Ball
Bouncing Ball
IWS Matlab practicum voor INF (2004/3e trimester)
(Vakcode: 156057)
The purpose of this exercise is to study hybrid systems.
Consider a bouncing ball. At time t = 0, the ball is released from an initial height h(0) = h0 [meters] and
with a vertical initial velocity of v(0) =v0 [m/s] as it is seen in Figure 1. The ball has a mass of M [kg]. The ball
first moves upward, then stops (at time tm1 ) for a moment and begins to fall freely. At some later time t1 it hits
the ground with velocity v1 = dh( t1)/dt < 0 [m/s]. When the ball hits the ground a bump event is produced. The
collision is inelastic, and the ball bounces back up with velocity (- α v1), where α is some constant in (0,1). The
ball then rises to a certain height (reaching the second maximum at time tm2 ) and falls back to the ground
repeteadly.
The behaviour of the bouncing ball can be modelled as a hybrid system.
v0
h0
Figure 1. The Bouncing Ball starting from height h0 with vertical velocity v0.
Task 1:
Draw the block-diagram of the hybrid system as defined by the "zeventupel"
(see in Chapter 5 of syllabus).
Define each component, the guard, the jump condition etc.
Task 2:
Express the equation of motion for the ball between jumps.
HINT: Newton's law of gravity holds: forces = mass × acceleration (ΣF = m × a).
Task 3:
Determine the maximum heigth (hmax) the ball can reach based on the conservation of
energy. For numerical calculation use h(0) = h0 = 10 [m] and v(0) = v0 = 15 [m/s].
The ball has a mass of M = 3,1415926 [kg].
Determine how the mass influences the maximum height?
HINT: the total initial energy (kinetic=0.5mv2 and potential=mgh) equals the potential
energy at the first maximum height (mghmax).
4th IWS Matlab practicum, June 10, 2004.
2
Bouncing Ball
Task 4:
Determine the first maximum height of the ball (hmax1) and the corresponding time (tmax1)
from the equation of motion and give their expressions. For numerical calculation use
h0 = 10 [m] and v0 = 15 [m/s]. The ball has a mass of M = 3,1415926 [kg].
Task 5:
Now we are going to simulate the motion of the ball. First make a Simulink block diagram
to describe the motion of the ball.
Choose "variable step-size" (with a maximum step-size of 0.01) and "ode45(DormandPrince)" as an integration method. Run the simulation till 20 [sec].
HINT: be careful with the jump and guard condition. You have to reset the integrator
based on an external signal ("external reset: falling"), the initial condition depends on an
external signal and you also need the state-port of the integrator (to reset its initial
condition). Enable zero cross detection as well. (Look in SIMULINK at the properties of
an integrator).
Task 6:
Simulate the ball's motion with initial conditions: h0 = 10 [m], v0 = 15 [m/s], α = 0.8 and we
take the constant of gravity g = 10 [m/s2]. Plot the height h(t) and velocity v(t) as a
function of time on two separate figures below each other!
HINT: use the scope with two input signals (scope → parameters).
Task 7:
Now we try to "animate" to motion of the bouncing ball. Store the results of the
previous Simulink simulation in the "workspace" of MATLAB and plot the height
again. To slow it down (to see the motion, thus) write a "for" cycle to plot each point
(only the height must be plotted). First check the number of points and plot only
every 5-th point:
[nx,mx] = size(xout);
% It can very well happen that due to the "variable step-size" the number
% of points in "xout" is large.
% For animation purpose we just take every 5-th point:
nx5 = floor(nx/5);
plot(t1(1),x1(1,1),'o');
axis([0,max(t1),0,25]);
xlabel('time [sec]');
ylabel('h(t) [m]');
title('Height of a bouncing ball');
hold on;
for i=2:nx5;
k = 5*i;
plot(t1(k),xout(k,1),'o');
end;
hold off;
4th IWS Matlab practicum, June 10, 2004.
Bouncing Ball
3
Task 8:
Determine the times at which the first four "bumps" happens, the first five peaks in
meter and the corresponding times in seconds (i.e. the time when the ball reaches
a maximum height). Give the results in a Table containing the following columns:
velocity before a "bump" (tk−), velocity after a "bump" (tk+), time when "bump"
happens (tk), height of a peak in meters (hmaxk) and the time when a peak is
reached in seconds (tmaxk) and the period between the bumps (∆tk = tk - tk-1).
HINT: write a cycle either in MATLAB or in MAPLE to make the calculations.
Task 9:
Either from simulation or from Task 8 you may observe that the period between
consecutive jumps decreases monotonically. Using the equations you developed try to
determine how these periods decreases. Theooretically the ball will bounce infinitely
often. However, due to the dissipation rate α, consecutive jumps will follow faster and
faster. As a result the infinite number of jumps occur in finite time. Determine an
expression for this finite time and calculate its numerical value.
Compare your calculation results with that of the simulation!
REMARK: the sum of a (convergent) geometric series is:
∞
S =
;
a * α k = a + a * α + a * α 2 + a * α 3 + ... = a
∑
1−α
k =0
1
α <1
So far we have considered the ball's motion with a vertical initial velocity. Let us consider now, what
happens if the velocity has a horisontal component as well (Figure 2). The angle β determines the vertical
and horisontal component of the velocity vector, respectively. Suppose that the initial velocity has an
magnitude of | v0 | = v0.
v0
β
h0
Figure 2. The Bouncing Ball starting from height h0 and with velocity v0.
The velocity has now a vertical and a horizontal component.
Task 10:
Express the new equations of motions for the ball. Determine the first maximum height of
the ball (hmax1) and the corresponding time (tmax1) from the equation of motion and give
their expressions. For numerical calculation use h0 = 10 [m] and v0 = 21,216 [m/s] with
β = 45o. What is the effect of the angle β?
4th IWS Matlab practicum, June 10, 2004.
Bouncing Ball
4
Task 11:
Modify your SIMULINK model to include the horisontal velocity component.
Simulate the ball's motion with initial conditions: h0 = 10 [m], v0 = 21,216 [m/s],
α = 0.8 and β = 45 [grad]. Plot the vertical- and horisontal component of the velocity,
the height and the horisontal distance on the same Figure (either you can use a scope
with 4 inputs or make the plot in Matlab).
REMARK: to include the horizontal velocity component you need a second integrator
with zero input. To reset it you need the height variable. For the initial condition you need
the vertical velocity component. You do not need the state-port for this integrator.
Task 12:
Due to the horizontal velocity component the ball does not remain in the same place (and
keeps bouncing) but travels a certain distance from its original position when its stops.
Again, despite the infinite number of jumps, the horizontal distnace is finite. Determine an
expression for this distance and calculate its numerical value.
Use the same initial conditions as in Task 11. Compare your calculations with the
simulation results. Has the angle β any influence on this distance?
REMARK: the sum of a (convergent) geometric series is:
∞
S =
∑ a *α
k =0
k
= a + a * α + a * α 2 + a * α 3 + ... = a
1
;
1−α
α <1