The camera was con gured to provide a grayscale rectangle of 50 x 2040 pixels to track the path of the ball. The Autothreshold block of the Simulink Computer Vision System Toolbox was then used to reduce the image from grayscale to binary. This binary image was quickly scanned to give the approximate position of the ball, and then the grayscale image was analysed using interpolation to further improve accuracy.
To control the position of the ball, the ball’s current position and angular velocity, and the velocity of the wheel, had to be determined. The velocities were computed using finite differences. Control of the motor was by a state feedback.
Several different excitation modes were implemented:
■ Wheel and ball kept at standstill.
■ Wheel rotating at a constant speed while keeping the ball balanced on top.
■ Delaying of control activation until ball reaches a maximum angle, in order to assess the region of attraction of the equilibrium point.
■ Ball position made to oscillate by imposing a sine wave using a feed-forward controller.
A panel was developed on Simulink Real-Time Explorer running on the host computer to enable the parameters of the different excitation modes to be modified online, while the real-time application created from Simulink was running on the target machine.