mike moore
Projects / Inverted pendulum

Inverted pendulum

A single arm on a bench that swings itself up and balances. Started as a way to get a real-time control loop onto hardware I actually own.

activewrite-ups coming Aug 2026 – now source not yet public
Render
source the rig's CADmotion recorded run
The rig on my desk. Rendered from the CAD and posed from a recorded run. The page switches between day and night with the theme.

A brushless motor at the shoulder, an absolute encoder on the shaft, and a Rust control loop running at 200 Hz on a Raspberry Pi. MuJoCo for the simulation, and Blender renders built from the CAD so I can watch a recorded run back on the real geometry.

It first swung up and balanced on 1 September 2026 — ten runs out of ten at the operating point I had predicted, and 14 of 22 across all the currents I tried that night. The posts below are in the order things happened. Most of them are about places the simulator and the bench disagreed, which turned out to be the part worth writing down.

Fig. 1
rig 105 swing-ups before 10 runs after 11 runs date 2026-09-16
Time to capture, one dot per swing-up. Left: a two-branch limit cycle, forty of forty pairs alternating. Right: after every cycle starts from a commanded angle, one branch with sd 0.0104 s.

The rig

Fig. 2
before 2026-09-01 model after 2026-09-07 model rig 5 runs window 2.4–4.4 s
Angular momentum from 2.4 to 4.4 s, where the swing-up is decided: the old prediction hatched grey, the re-fitted band in teal, and five real runs in amber. The old band was precise and in the wrong place.

The app

The rig has an owner app rather than a console. It says what the machine is doing in words a person can act on, and nothing moves unless somebody presses a button. The same app drives the simulator and the bench, with a label in the corner saying which.

Walkthrough
source simulator app the real client length 38 s
One pass through the app. Calm: press swing up and watch it stand the arm up and hold it. Show: try Sway, Steady and Show Me, with the live lean and current traces. Health: the connection and limits, and an honest note that this producer does not report faults. Then back to Calm. This is the real app, driven by the simulator, so the corner reads SOURCE SIM.

Posts, in order

Four more are drafted and not published yet: measuring the torque constant against cogging, a flag that only half applied itself, a safety monitor the simulator never modelled, and the prediction I committed before any of it ran. They will go up as I finish checking the numbers in them.

Where it stands

Swing-up and balance work at the studied operating point. Three things are still open: the velocity register hits a limit somewhere around 14 rad/s — in units I have not pinned down yet — and the fix is not in; the friction terms are stale; and cogging and stiction are not in the model at all. Next is the saturated-reading fix, because the control loop acts on that number.

Fig. 3
study pump-and-coast shows trajectory spread status pre-swing-up
← swipe to pan the plot →
Trajectory spread from the earlier pump-and-coast study, which is how the energy behaviour was characterised before the swing-up law existed.
10 / 10
held at 3.0 A
3.56 s
mean capture
0.51°
settled, mean of 10
200 Hz
control loop