In my 5th semester at Aalborg University, I was introduced to the subject of control theory. In this course, I learned how to analyze and model physical systems with Newtonian differential equations, with the purpose of designing a stable control system. To put the knowledge I gained from the classes too use, I wanted to apply it to a real case system; by stabilizing an inverted pendulum. This idea grew into building a self-balancing two-wheeled robot (a segway), which as part of my education became my semester project. This project was my first attempt to design a control system using control theory.
As a prerequisite for designing and testing a controller, one must have a system to work with. The hardware design had no real requirements, other than having two wheels and a center of mass above the wheel axis. With that in mind, I used my experience in 3D CAD drawing to design a detailed 3D model, which can be viewed in the following.
In order to implement the designed control system, an electronics platform also had to be implemented. This included a battery, two stepper motors (and drivers), sensors and a microprocessor. Most of this was added to a custom PCB, to keep the complexity at a minimum.
The finished hardware platform, here using the servo to stand upright while power is turned off.
To design a controller capable of stabilizing the system, a good model of the system must first be established. can be modeled as a stick on a wheel.
An inverted pendulum is by nature marginally stable, as it has only one stable position. If the pendulum is in its stable state, then the smallest disturbance will make the system unstable.
Github source: https://github.com/SolidGeek/Selfbalancing-Robot-ESP32