Inverse Pendulum Balancing Robot
The small cart will move forward and backwards in order to balance the stick with the weight on the end. I am using this to eventually being able to create a similar balancing robot with only two wheels placed side by side.
The Angle is sensed with this encoder attached to the long stick.
I used a pid controller with the angle as the input and the the motor controller PWM value as the output. The microcontroller board is an Arduino (see arduino.cc). I made the motor controller myself and used a wheel/motor assembly based around this.
Currently, it is able to balance itself with some assistance via a dial.
I still need to improve my control algorithm.
The controller is basically a PID based on the angle of the stick. I initially used the following:
where e is the angle error (angle from vertical).
However, I realized that this didn’t work. Since the I term didn’t seem to do anything, I removed it and added a manually adjusted bias to the angle:
where b is the manually adjusted angle bias. By constantly adjusting the angle bias, I was able to balance the stick as is seen below.
Next, I will add the wheel encoders to the control equation. Using this, I might be able to get it to balance unassisted.
A subversion repository with my code for some test programs, the microcontroller firmware, and a simulator is available here: http://keegan.webhop.net/svn/tipsybot/. The microcontroller firmware uses Arduino and the arduino IDE, while the programs that run on the computer use Processing which is Java with additional libraries and some preprocessing and a minimalistic IDE.
The simulator itself is available as a java applet here: http://keegan.webhop.net/applets/tipsybot_e_sim/
The mathematical model is based on an explanation here.
First successful assisted balance: