Inverted Pendulum on Cart

ME155C final project focused on full-state behavior control: swing-up from the hanging equilibrium, robust balancing around upright, and controlled catching back to downward equilibrium using a state-machine architecture.

System + Objectives

Hardware setup: cart-actuated pendulum with encoder feedback for both pendulum angle and cart position. A single motor drives the cart, and the rod is pinned to the cart with asymmetric mass distribution.
Primary control objectives:
  • Stabilize the downward equilibrium for repeatable catch/reset behavior.
  • Stabilize the upward (inverted) equilibrium for balancing.
  • Switch reliably between these equilibria through a state machine.
Identification workflow:
  • Logarithmic sine sweep excitation in approximately 0.3 to 3 Hz range.
  • `tfest` run across 30 experiments to estimate linear models.
  • Cart modeled with an assumed integrator + voltage-to-velocity fit.
  • Model structures used: cart (2 poles, 1 zero), pendulum (3 poles, 2 zeros).

Controller Architecture

Initialization: uses gravity-aligned calibration for accurate angle reference, especially near the inverted target state.
Swing-Up: energy injection around zero crossings by moving cart opposite angular velocity direction, with proportional position regulation and activation near ±30 degrees.
Balancing: enters near upright (about ±23 degrees) using LQR/LQG around the unstable equilibrium to regulate angle and cart position.
Catching: engages as pendulum falls (about ±90 degrees window) using LQR/LQG about the stable downward equilibrium to reset into a predictable next swing-up cycle.

Performance + Lessons

The state-machine design produced consistent behavior across swing-up, balance, and catch phases while reducing chaotic resets. Tuning focused on robust transitions and preserving controllability near region boundaries.
Key practical insight: transition logic was as important as controller gains. Good region definitions and fail-safe transitions significantly improved repeatability.

Project Assets

Add setup photo, block diagram, or response plots here
Future work listed in the presentation:
  • Add correction term for steady-state error.
  • Improve failure detection and robust fallback logic.