Inverted Pendulum PID Controller
"All models are wrong, but some are useful"
"All models are wrong, but some are useful"
Key Tech: 3D Printing, Arduino, Fusion
Date: Spring 2025
Project Goal and Personal Responsibilites
In this group project we were tasked with designing and assembling an inverted pendulum from scratch.
An optical encoder and controller code were provided, but it was up to us to tune our system to balance the pendulum and recover from perturbations
My personal roles included:
Part selection (Linear rails, bearings, DC motor, timing belt, etc.)
CAD design (Pendulum, gantry, timing belt base, etc.)
Electronic assembly and assisting in tuning
Physical Design
Two 0.8 m linear rails with bearing blocks
24 V, 14 A DC Motor and IBT-2 Motor Driver
GT2 Timing belt and pulleys
3D Printed pendulum filled with epoxy resin to increase weight
3D Printed gantry secured to the bearing blocks, base for pulleys
Arduino UNO, optical encoder, breadboard
XY Plot of Encoder Angle and the Resulting Control Signal and PWM Values
Controller Tuning
Used trial-and-error to settle on ideal values
First: Adjusted the proportional gain in order to "get under" the pendulum
Second: Adjusted derivative gain to dampen the oscillatory behavior
Third: Tweaked integral gain to minimize steady-state error
Problems Encountered and Overcame
Blown MOSFETs from Back-EMF
During tuning we noticed that after running our system for a while, our motor started to only move the gantry in one direction
After diagnosing the motor driver with a multimeter, it was determined that we had fried a pair of MOSFETs
As this motor likely wasn't designed for the high switching speeds we were using it for, we assumed that excess back-EMF had caused the MOSFET failure
We continued to tune the system using our backup driver and limiting test times
Under-spec'd Barrel Jack
A barrel jack was initially used to connect our power supply to the motor driver. However, during one of our tests, smoke was forming from the barrel jack and it was hot to the touch
We concluded that too much current was being drawn by our motor for the jack's rating and thus ended up splicing the power supply wires to hardwire it to the motor driver
Smoking Barrel Jack (~30 seconds in)
Data Collection Sample
Overshoot Calculation
System Robustness
To quantify system performance, the following was observed:
Balanced our pendulum for 30+ seconds
75 ms recovery time from 20° perturbations
2.8% overshoot when no perturbations applied
Calculated using a maximum 5 degree overshoot when no perturbations
Future Improvements
Despite our success with the proportional gain, improvements could have been made in the integral and derivative terms to further reduce the "steady-state" overshoot.
More work could be done to improve component mounting to our wood base to limit vibrations as we noticed mounting screws becoming loose.
Motor selection could likely be improved to allow for higher switching speeds and finer low-speed control
Software improvements could be implemented to make direction changes softer by using a defined speed ramp