# Self-Balancing Robot

## Introduction    top

The inverted pendulum is an interesting case in the study of control systems because of its unstable nature. A pendulum is considered inverted when its center of mass is placed above its pivot point, meaning that its only equilibrium point is when its center of mass is directly above the pivot point. This is an unstable system because if it deviates any arbitrarily small amount from equilibrium the forces acting on the system will cause it to move even further away. This problem is of particular interest in the study of control systems likely because it's a simple example of an unstable system, and it's very obvious when equilibrium is being maintained successfully. If we limit the system to a single degree of freedom by locking the pole to a single axis of rotation, the system is simple enough that we only need to monitor a single value in order to control the system, the angle between the pivot, center of mass, and the vertical axis. Recently, this topic has become relevant in many new practical applications, typically in the form of two-wheeled robots that are able to maintain balance and move around easily. Personal transportation machines such as the Segway PT and the self-balancing scooters often mislabelled as "hoverboards" both solve the problem of controlling an inverted pendulum well enough that they can handle supporting a human being on top of them.

Our project for the course ECE 4760 was to build our own self-balancing two-wheeled robot. Our robot is controlled by a PIC32 microcontroller, uses an inertial measurement unit to keep track of its pitch value and two motors to drive the wheels at the bottom of the robot, and it attempts to maintain equilibrium by using a PID controller to counteract its pitch value by driving the wheels such that they move beneath the center of mass. Working on this project allowed us to learn about the many challenges involved in controlling an unstable system, about how to efficiently debug a system by using a mixture of study and experimentation, and about the principles behind many good filtering systems that we used to filter data from our inertial measurement unit.

An image of the final version of our robot.

### F. Code Listing

• main.c - our main code file, contains all threads and ISRs, as well as the main function.
• i2c_lib.h - used to interface with IMU with I2C protocol, adapted from a previous project's I2C library.
• kalman_lib.h - our implementation of a Kalman filter. Ultimately not used in this project, but we included it here anyways.
• finalProject.X.zip - a zipped folder containing our full MPLabX project.

### G. Acknowledgements    top

We'd like to thank Bruce Land and his teaching assistants for their patience, support, and advice throughout this project.