Inverted Pendulum

Last Updated: 17th Oct 2022

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


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
1 x HEDS9000 Optical Encoder
1 x DRV8825 Stepper Driver
1 x Arduino Mega
3 x V-Wheels
1 x V-Slot Extruded Aluminium
1 x GT2 Timing Belt
2 x 5mm GT2 Timing Pulleys
4 x 625RS Bearings