Scuola Superiore S. Anna

Research Teaching Personal Contact


Quick links


Courses 2012







Embedded Systems - Model-Based Design

Amazing ball (PID control)

The project consists in the control of a simple device with two degrees of freedom (pitch/roll) in order to keep a ball always in the center of the plate.
The device is shown in the picture.

The ball position is sensed by a touchscreen placed on top of the plate. The pitch and roll angles are controlled by two servomotors with an integrated controller controlling the plate position by means of mechanical joints.

Plant model

On the roll and pitch axis, the geometry of the assembly motor-plate is shown in figure

The equations of the closed kinematic chain define the relationship between the motor angle alpha and the plate angle theta. (download the pdf document for a full description) Once the theta angle is known, the acceleration on the ball can be computed as the sum of the centrifugal acceleration and the acceleration caused by gravity (assuming rotation without slip).

Document with the description of the assembly and the ball dynamics

Controller model

The Flex motion board is used to sense the position of the ball using the x,y input from the touchscreen (connected to two ADC channels on the board) and to control the position of the motors on the two axis, using the board PWM outputs.

Simulink model

The Simulink model that is provided as part of the examples is shown in the following picture. It includes a model of the ball-and plate dynamics for the two axis, a 3D renderer of the ball and plate, a 2D scope showing the ball position on the plate and the PID controller.

The Simulink model is available from the following link

Simulink model and VRML description of the 3d rendering