Skip to main content
A custom rotary inverted pendulum
  1. projects/

A custom rotary inverted pendulum

Table of Contents

For education
#

In the last year of my degree, I was introduced to modern control systems. Naturally, courses have to be rushed to get through as much of the content as possible; I wasn’t satisfied with my understanding of the material. Over the summer of 2024 to 2025, I decided to work on a project that would improve my understanding of linear control systems, or at least give me a platform that I could experiment with. A balancing apparatus would be perfect as a project. In fact, one of the most common control systems projects is a linear inverted pendulum:

Diagram of a linear inverted pendulum.

A cart is moved in one axis to balance a pendulum vertically. This is similar to balancing a pencil vertically on your finger. But given that my workspace is small and the linear inverted pendulum requires many more parts, a rotary inverted pendulum was more appropriate:

A rotating inverted pendulum from wikipedia

Unlike the linear variant, a rotary inverted pendulum rotates the base instead of moving it horizontally, making it much more compact. No need for pulleys, chassis or extra space. The base can be simply rotated directly via a motor or through gearing.

Demonstration
#

My rotary inverted pendulum project in action.
Apologies for the bad lighting and quality. I was using a camera from the 2000s and my ring light wasn’t bright enough. But it definitely gives it a vibe.

The mechanical side of the build is simple. A motor drives a vertical shaft connected to a flange, which then links to a horizontal shaft and the pendulum:

Simplified diagram of the rotary inverted pendulum.

The rig needs a rigid 90 degree connection between the horizontal shaft and the pendulum. Since I couldn’t find a shaft with a fixed right-angle bend, I used a universal joint coupler instead:

An example of the universal joint coupler I am using.

These couplers are free to swivel as they rotate, which would cause the pendulum to bend in this manner:

Bent pendulum angle.

This is undesirable, so I ziptied the pendulum and horizontal shaft together.

Regarding the electronics, I used a stepper motor driven by a stepper driver. An Arduino Uno controls the stepper driver and processes the control algorithm. In addition, the rotary encoder is read directly by the Arduino Uno.

Bill of Materials
#

The total cost of the project, including electronics, summed to 142.44 NZD.

Mechanical
#

ItemQuantityCost (NZD)Source
Linear Shaft, 150mm length, 5mm diameter1$4.17Aliexpress
Rigid Shaft Coupler, 5mm to 5mm1$4.79Aliexpress
Rigid Shaft Coupler, 4mm to 6mm1$4.46Aliexpress
Universal Shaft Joint Coupler, 4mm to 4mm1$3.53Aliexpress
Rotary Encoder Mounting Bracket1$27.74Aliexpress
Linear Shaft, 125mm length, 4mm diameter2 (from 5pcs set)$7.36Aliexpress
Rigid Flange Coupler, 5mm1 (from 3pcs set)$14.94BigFace

Electronics
#

ItemQuantityCost (NZD)Source
Incremental Rotary Encoder 38S6G5-B-G24N 1000ppr1$26.34Aliexpress
Stepper Motor Nema 17 17HE19-2004S1$27.41Aliexpress
Stepper Motor Driver TMC22091$5.87Aliexpress 1
Arduino Uno1$20? 2

Notes
#

  1. I couldn't get the UART communication working but the STEP/DIR functionality worked just fine, which is all I needed.
  2. I reused an Arduino Uno I bought a long time ago, so the price is estimated.