book collections email follower instructable user
Picture of Inverted Pendulum: Control Theory and Dynamics

The inverted pendulum is a classic problem in dynamics and control theory that is generally elaborated in high-school and undergraduate physics or math courses. Being a math and science enthusiast myself, I decided to try and implement the concepts that I learned during my classes to build an inverted pendulum. Applying such concepts in real life not only helps strengthen your understanding of the concepts but also exposes you to a whole new dimension of problems and challenges that deal with practicality and real-life situations that one can never encounter in theory classes.

In this instructable, I will firstly introduce the inverted pendulum problem, then cover the theory aspect of the problem, and then discuss the hardware and software required to bring this concept to life.

I suggest you watch the video that is attached above while going through the instructable which will give you a better understanding.

And finally, please don't forget to drop a vote in the 'Classroom Science Contest' if you liked this project and feel free to leave any questions in the comment section below. Happy making! :)

Step 1: The Problem

Picture of The Problem

The inverted pendulum problem is analogous to balancing a broom or a long pole on the palm of your hand, which is something most of us have tried as a kid. When our eyes see the pole falling to a certain side, they send this information over to the brain which performs certain computations and then instructs your arm to move to a certain position with a certain velocity to counter the pole's movement, which would hopefully bring the tipping pole back up to vertical. This process is repeated several hundred times a second which keeps the pole completely under your control. The inverted pendulum functions in a similar manner. The aim is to balance a pendulum upside down on a cart that is allowed to move about. Instead of eyes, a sensor is used to detect the position of the pendulum which sends the information over to a computer which performs certain computations and instructs actuators to move the cart in a way to make the pendulum vertical again.

therealburk1 month ago
Very cool! Do you think it would be possible to control this to flip the pendulum from a hanging position or would you need greater speed and/or a longer track?
KousheekC (author)  therealburk1 month ago
Thank you for the feedback! I believe it should be possible, considering the power a nema17 stepper motor that I used... Although I still need to figure out the control algorithms and the equations of motion and then eventually attempt the experiment.
FerretPD1 month ago would seem that simple physics would indicate that the Ribbon Cable dangling from the top of the Pendulum would cause Drag, and therefore dampen/damage the response to an almost unusable level....
Might I suggest using a Flat flexi-cable (such as to bring the signal to the *base* of the pendulum...where the drag would not be magnified...and then take it off of that cable on individual coiled wires (picture a 2" 28ga wire formed around a pencil, and the result attached at both ends; again, to minimize drag) to the rest of the system?
Alternately, use the original cable, attach it to the Pendulum; and split the individual conductors at the base (coiled as previously outlined)

Other than that, an interesting build; outstanding for teaching Physics properties.
KousheekC (author)  FerretPD1 month ago
Thank you for the feedback! In fact, my initial idea was to use a similar Flexi cable ribbon cable and use coiled cables and brushes from the rotating axle. But there were two reasons I didn't continue with this idea. 1. I felt the brushes may cause disturbances if the system was not made accurately and considering the communication technique that I used was i2c a single bit not transmitted correctly can cause a big problem. 2. Like I mentioned in the 16th step, I plan on replacing the IMU with a rotary encoder attached at the axis of rotation of the pendulum in the next version, this will completely eliminate dangling wires. :)
bpark10001 month ago
There are wires going to the top of the pendulum. Why are they needed? The thing control system needs is the angle of the pendulum. Why can't that be measured at the bottom with a mechanical angle sensor?

The way you are doing it works but adds another layer of complexity. Ideally, the gyro could give the angle, but gyros drift. The accelerometer gives the angle, but corrupted by the vastly larger lateral accelerations (which average out to zero). So the high-frequency part of the angle must come from the gyro, and the low frequency part from the accelerometer. Segway-type balancing vehicles are forced to use this technique.

This project can make use of the angle measured directly between the pendulum and the base cart, using a mechanical sensor such as a pot or optical encoder. The wires from this will be right at the base on the cart. It would be interesting to compare the effectiveness of the 2 schemes. It would also be interesting to mount the gyro/accelerometer at the base of the pendulum (also getting rid of the wires to the top). The commanded accelerations of the cart could be subtracted from the accelerometer giving a cleaner signal.
KousheekC (author)  bpark10001 month ago
You are absolutely right. That is precisely why in step 16, I mention just that. I used an IMU simply because it was available at the moment, and plan on shifting to an optical encoder in the next version. I was aware of the drift that would occur while using a gyro+accelerometer setup, but this was regulated through software. Thank you for the feedback!
JohnC4301 month ago
Cool project. Thanks for sharing.
KousheekC (author)  JohnC4301 month ago
Thank you! :)
Raphango1 month ago
Awesome project!! Congratulations! :D God bless you!
KousheekC (author)  Raphango1 month ago
Thank you for the positive feedback!
Great project! Thanks for sharing your first instructable! :)
KousheekC (author)  WeTeachThemSTEM1 month ago
Thank you so much! :)