Bouncing Ball Using Hierarchical State Machines

This example shows a bouncing ball simulation using Hierarchical State Machines in a

QFIRE CTR-101

.

Introduction

A falling ball can be described by the equations:

dvdt=gdxdt=v\begin{matrix} \frac{\mathrm{d} v}{\mathrm{d} t} = -g \\ \\ \frac{\mathrm{d} x}{\mathrm{d} t} = v \end{matrix}

Furthermore, it is necessary to define an initial position above the floor (i. e. zero). Thereby, the ball is able to fall.

When the ball touches the floor, its speed changes due to the elasticity of the ball. This effect can be described by the equation:

vr=cr.vfv_{r} = -c_r.v_{f}
Where
vrv_{r}
is the rising speed (i. e. after the ball touching the floor),
crc_{r}
is the Coefficient of Restitution and
vfv_{f}
is the falling speed (i. e. before the ball touching the floor).
Simulation

Hierarchical State Machines are used in this example.

Figure 1 - Bouncing Ball Hierarchical State Machines

The first state is the Initial Condition State. It defines the initial position and the initial speed of the ball.

Figure 2 - Initial Condition State diagram using Shared Variables

The next state is the Falling State. It is responsible for calculating the fall of the ball. When the position is equal to zero, the transition is triggered and Rising State is executed.

Figure 3 - Falling State

In Figure 3, it is possible to see the Shared Variable 2 and 3. They are reset signals for the integrators sent using shared variable blocks.

The bounce is responsible for changing the speed of the ball. This event is executed only once time and the gain block is responsible for it.

Figure 4 - Rising State

The final result is possible to see in Figure 5. Due to the way that Finite State Machine works, the signal was plotted in another task.

Figure 5 - Bouncing ball signal

About MWF

MWF is a traditional Brazilian company that provides a wide range of electronic and mechatronic products for industry sectors such as automotive, agricultural machinery and aerospace.

Contact Us

Rua Doutor Siqueira, 139 / Sala 804 Campos dos Goytacazes - RJ, Brasil

contact@mwf-technologies.com

© 2018-2026 MWF. All rights reserved.