ME 305
|
This page serves to detail the control methods and overall workings of developing a platform that can automatically center and balance a ball using a STM32 Nucleo L476. The system is composed of a touch panel to track the ball's position and velocity, an IMU BNO055 to track the platform's orientation, and two DC motors that can alter the orientation of platform.
As discussed in more detail in the section below, cascade control with two closed loops was used to accomplish sufficient balancing. The program is composed of various task files that are executed sequentially using cooperative multitasking. Each task file runs at a different frequency depending on the importance of its data collection to balance the ball. Within each closed loop, the user can decide which gains (proportional, derivative, or integral) to set. Aside from the gain values set, the IMU was modified with an angle offset to more easily center the bal, and the duty cycle of each motor was limited to prevent any excessive reactions to the ball's position. Within the class used to interact with the touch panel, we also implement alpha-beta filtering to decrease noise of each reading for our calculaiton of the balls position and velocity.
A video demonstration of the ball balancing platform can be found in the link below. Data was collected and is discussed in the results section.
Video demonstration: https://vimeo.com/689892995
See the link below for the code respository to this lab. Code repository for this lab: https://bitbucket.org/rdeanr/me305/src/master/TermProject/
The image below shows the user interface of the program
This section shows the results of balancing the ball. Under our program, balancing of the ball was successful. However, the ball was not able to sit still in the center of the platform and instead would continue to oscillate around the center point.
As can be seen in the graph below, the ball starts with a positive 65mm initial condition in the x- direction and is then released. In a little under a second, the balls motion appears to settle down, but it quickly follows its oscilatory motion as seen in the video above. You can also see how the x_dot leads the x position measurement and the theta_y leads the thetay_dot measurement. This is typical behavior of osicillatory motion, as any sinusoidal behavior will have its derivative be cosignusoidal.
These oscialltions could be because the system is still not perfectly tuned. We did not account for the static friction in the bearings and U-joint of the platform and did not account for the weight of actuating arms attached to the motors. There are also inherent glitches to the platforms that we used, as we found it difficult to balance a ball that didn't have sufficient enough weight to continually trigger the touch panel. All of these errors help contribute to the ball being unable to perfectly center in the middle of the platform.
The plots below show the position and velocity of the ball as a function of time in the x-direction defined on the touch panel. Below this is another plot showing the angle and angular velocity of the platform to change the ball's position over time.
This program implements cascaded closed loop control. The interaction between the ball and the touch panel is referred to as the 'outer loop' and the interaction between the platform IMU and the motors is referred to as the 'inner loop'. This system is cascaded because the output of the outer loop becomes the input to the inner loop. The outer loop outputs the reference platform angle for the inner loop which is then used calculate a duty cycle. This duty cycle is then sent to the motors that operate under pulse width modulation. See closedloop.ClosedLoop for more information on how the class functions.
Implemented as a finite state machine, this file handles all user inputs and sets flags or shares variables that can interact with all other tasks. The state transition diagram can be seen below. See the term project user task file for more information.
This task directly interfaces with the IMU BNO055 to collect platform position and angular velocity data. It is also used to calibrate the IMU and sends commands to BNO_driver.BNO055 to write and read calibration coefficients to and from a text file. A state transition diagram can be seen in the image below.
This task directly interacts with the motors and then alters flag values to be sent back to the user task and interpretted. Receiving input from the user task, it directly controls the duty cycle of each motor. The state transition diagram can be seen below.
This task directly interacts with the ADC_driver.ADC_Driver class to interact with the touch panel. It is used to run the calibration procedure for the touch panel and reads the ball's position and velocity. Withint the ADC_driver.ADC_Driver class, we also implemented alpha-beta filtering to decrease touch panel noise. The state transition diagram for this task can be seen below.
This diagram shows the interaction between the task files and which values are shared between them.