This website uses optional cookies to provide the best experience possible to the user. In line with GDPR regulations, please indicate if you would like to accept these optional cookies or reject them to only use essential cookies. You can learn more by reading our privacy policy.

Inverted Pendulum

Last Updated: 17th Oct 2022

All Files: Download Zip
Code: Go To GitHub
3D Files: Go To Thingiverse

About

In this project I built an inverted pendulum balancing robot using a stepper motor, optical encoder and an Arduino Mega.

I have a bit of a history with balancing robots and a mild obsession with the field of control theory. Back in college I studied control theory in great depth and it was one of my favourite topics. I think this might be my coolest balancing machine to date.

The machine is a fairly simple design consisting of a carriage that runs along a v-slot aluminium rail using v-wheels, very similar to a 3d-printer gantry. Onto the carriage is mounted a free spinning pendulum arm and an optical encoder coupled to the shaft around which the pendulum is allowed to swing. At one end of the aluminium extrusion is mounted a stepper motor which is looped around the length of the extrusion around a free spinning pulley and coupled to the carriage. As a motor spins it pulls the carriage side to side along the extrusion.

The brains of the machine is an Arduino Mega which receives input from the HEDS9000 optical encoder attached to the pendulum shaft and provides drive to the stepper motor via a DRV8825 stepper driver. The Arduino is programmed with a simple PID loop which is effectively able to control the speed of the carriage in order to balance the pendulum in a naturally unstable inverted position.

Parts List

*NOTE: I am based in Ireland, the links I provide are mostly for where I get parts in Europe. I provide the links mostly for context, if you are not in Europe, I hope they server as a rough outline for what to search for from your suppliers.
**NOTE: Links are valid at time of posting. I do not maintain the below links. Sorry if they go out of date and break.
1 x NEMA17 Stepper Motor https://www.amazon.co.uk/gp/product/B0814TTDZ3
1 x HEDS9000 Optical Encoder https://ie.rs-online.com/web/p/motion-control-sensors/1783260
1 x DRV8825 Stepper Driver https://www.amazon.co.uk/gp/product/B081JM828X
1 x Arduino Mega https://store.arduino.cc/products/arduino-mega-2560-rev3
3 x V-Wheels https://www.amazon.co.uk/gp/product/B07SJ3VZ68
1 x V-Slot Extruded Aluminium https://www.amazon.co.uk/gp/product/B087PVD55Y
1 x GT2 Timing Belt https://www.amazon.co.uk/gp/product/B0768YSR82
2 x 5mm GT2 Timing Pulleys https://www.amazon.co.uk/gp/product/B084KLTS84
4 x 625RS Bearings https://www.amazon.co.uk/gp/product/B08TW8GXPG