Ball Balancer Project
|
The ME 305 final project relies on the use of 11 files that work in tandem to balance a ball on a tilting platform. These micropython files are flashed onto a Nucleo STM32 microcontroller, which acts as the controller for this dynamic system. The controller uses information from the BNO055 IMU to keep track of the x and y angles of the platform, while also using a resistive touchpanel to know the x and y position of the ball. With this information, the controller is able to calculate the appropriate duty cycles for each motor at any point in time so that that ball stays as close to the center of the platform as possible.
The following video shows a demonstration of our platform in closed-loop control mode as it balances a steel ball. We were able to tune our cascaded controllers through a long process of guessing and checking. After some time, we were able to find gain values that can keep the ball balanced for over a minute.
Considering a file hierarchy consisting of 3 layers, main.py and shares.py make up the high level layer. This layer instantiates objects and runs tasks. The middle layer is made up our our four tasks: taskUser.py, taskIMU.py, taskPanel.py, taskController.py and taskMotor.py which run sequentially, each with a period of 0.01 [s]. The bottom layer is the driver layer which consists of the drivers: BNO055.py, motor.py, touchpanel.py, and ClosedLoop.py. Each of these drivers is designed to be reusable, controlling only the most basic functionality of each of the physical components they represent.
To dive further into the specifics of this final project, some additional details are provided below.
The following diagram shows how the 5 middle-tier task files interact with each other using shares. Each of the tasks in our program is run at the same frequency of 100 Hz.
The following state transition diagrams show how each of our 5 task files operates as a finite state machine.
The user interface we constructed for this lab is very simple, but it operates smoothly and allows for multiple types of user input. The image below shows the "platform wizard" help menu that pops up when you first start up the microcontroller.
The following video shows a quick demonstration of our simple user interface from within PuTTY. This video demonstrates the functionality of each of the menu items in our "platform wizard" help menu.
The following video shows that the ball's position data and the platform's angular orientation are recorded over a 10 second period after the "G" key is pressed. This data is printed into PuTTY, where we can copy it over to Excel to plot later on.
After taking the data printed to our serial interface (PuTTY), we generated the following plots to show the performance of our balancing platform. The data used in these plots is from the same trial seen in the video shown above. It can be seen that all of the plots oscillate near or around zero. It can also be seen that the ball's x position is trailing the Y-angle while the y position trails the x angle.