The classic inverted pendulum problem. Controls textbooks as well as instructors seem to really love it… Here we modeled the dynamics of an inverted pendulum on cart. The model was linearized about the upright position (theta = 0) using small angle approximation. Using the linear model, we are able to use classical design techniques such as pole placement, root locus, and Bode plots to stabilize the system. In order to stabilize the translational component as well as the rotational we implemented success loop closure. Due to the fact that the dynamics of the inner loop (pendulum) is much faster than the outer loop (cart), we can design two controller independently. It’s been a few years since I worked on this, when I have the time I may work out the math again and update it here.

From the hardware perspective, we have a BeagleBone Black, a custom cape (by James Strawson, UCSD ’18), two DC motors, a couple quadrature encoders, and a lithium ion battery. The cape is really a great piece of engineering. It includes the charging circuit for the battery, motor drivers, IMU, and interfaces for I2C and SPI. We used the on-board IMU to determine the angle of the pendulum. We fused the accelerometer data with the gyroscope data using a complimentary filter. The complementary filter worked in this case because we essentially low passed the accelerometer to remove noise and high passed the gyroscope to ignore sensor drift. Once the controller/filter designs were satisfactory, we used z-transform to convert the continuous-time differential equation to a discrete-time difference equation suitable for use in a micro-controller. Set a timer triggered interrupt service routine and voila, pendulum on cart!