January 2022 - March 2022

Ball Balancer Project

For this project, I collaborated with a classmate to create a system that uses 11 python files flashed onto a Nucleo STM32 microcontroller to balance a ball on a tilting platform. The microcontroller acts as the controller for the dynamic system, using information from the BNO055 IMU to track the angles of the platform and a resistive touch panel to track the position of the ball. With this information, the controller is able to calculate the necessary duty cycles for the motors in real-time to keep the ball as close to the center of the platform as possible.


One of the main challenges I faced in this project was designing and implementing a PID controller to control the motors of the balancing system. The goal of the controller was to ensure that the motors could reach the designated speed quickly and smoothly. To do this, I used the controller design shown below. After implementing the code, I conducted experiments to determine the optimal gains for the controller.

Additionally, I encountered a critical problem that was preventing the ball from maintaining its balance on the tilting platform. The issue arose from the fact that the touch panel data, which was essential for the controller to function, was sometimes unreliable due to inadequate contact between the rolling ball and the panel. This resulted in the controller receiving a sequence of incorrect data, which prevented it from functioning properly.

To solve the problem with the touch panel data, I developed a filtering method that used a moving data set to determine the reliability of the data. If the readings were determined to be inaccurate, I utilized a method that used the past data to estimate the ball's current position. This involved keeping track of the accurate data points to determine the direction the ball was moving and calculating its speed using a derivative calculation. By combining this information with the last known position of the ball, I was able to accurately estimate its current position and enable the controller to function properly.

Through my implementation of this solution, I was able to overcome a critical issue and enable the ball-balancing system to function, which allowed my team to be one of the few that managed to successfully balance the ball on the tilting platform.

Github Project Repo