Balancing Robot

project1 project1

In this project I designed an created a self balancing robot using PID control. It not only balances, but maintains its relative position. This experience allowed me to demonstrate knowledge of control theory, real time embedded software, and integration skills.

Result:

Mechanical Design:

The Mechanical structure of the robot was built off of popular self balancing robots seen online. The choice here was to keep it simple, as most of the complexity would come from the control system and programming / interfacing with sensors. The body is comprised of a rectangular box shape that houses all the electronics of the system. On the bottom their are two motors responsible for being the inputs into the system for maintaining balance.

project1

Control Theory:

In order to balance the robot under dynamic circumstances, the system must use a controller. In this case the system's dynamics can be approximated to be an inverted pendulum on a cart, which exhibits nonlinear behavior. Although the system is nonlinear, if the system only deviates small angles from the target orientation, straight up, then it can be said that gravity's effect on the system is approximately promotional to the angle of deviation. Due to this approximation I can now model the system in software and utilize a linear controller. In this case I have opted to use a PID controller due to its simplicity and ability to be hand tuned.

project1

If the system only needed to maintain its angle one PID controller may have sufficed, but for the system to maintain both balance and position a second PID control must be added. The balancing robot implements two PID controllers which are cascaded. This allows the system to be more robust, and more tolerant to noise in IMU readings. The first PID controller takes in a target angle and throttles the motors accordingly to move the system towards the desired state. The second controller takes in a target position and modulates the target angle accordingly to reach the desired position.

Electronics:

The electronics that composed this robot are as follows:

  • ESP32 Mircocontroller : Does all the processing of for the sensors and control algorithm
  • MPU6050 IMU : A chip that has an embedded accelerometer and gyroscope, as well as onboard filtering
  • Motors with Encoders : Is the input to the system, used for evolving the state of the system to the desired state. Encoders provide position information