mike moore
Inverted pendulum2026-09-295 min read

A hundred simulated pendulums and one real one

I built a simulation of a pendulum, and I have the real one on my bench. This post is how closely the two agree.

Fig. 1
source the rig's CAD terms motor, gravity, friction
The whole machine. One motor, one arm, gravity and friction. The angle θ is measured from rest: 0 hanging straight down, π straight up.

Read it as a tug of war. The motor pushes. Gravity pulls the arm back down, hardest when the arm is horizontal. Friction eats whatever is left. What survives is how quickly the arm speeds up.

Two combinations do most of the work, and they are what the simulation varies. ω₀ is how fast the arm swings on its own, the way a pendulum keeps its own time — it sets how long a swing-up takes. Kt/mgL is the motor's push measured against the arm's own weight — it sets how many swings it needs.

Energy is motion plus height. The controller feeds it in, swing by swing, until there is enough to stand the arm up.

One machine, a hundred models

The rig is one arm on one motor. The simulation is a hundred of them. The numbers describing the real arm — weight, friction, motor strength — are measurements, and each has a margin of error, so I draw a hundred machines from those margins and run them all. Below, the hundred are faint and ten real runs solid. The arm starts hanging; the motor pumps it up.

Fig. 2
sim 100 machines bench 10 runs 0 hanging · 180 upright
Angle from rest. Zero is hanging, 180 is straight up. The swing grows evenly about rest until the arm can reach the top. Every run is mirrored onto one side, which costs nothing because the machine is symmetric.

Where the faint lines bunch, the model is sure of itself. Where they spread, it is not.

The same thing, as physics

Each loop is one swing, wider than the last as the motor feeds energy in. The green band is where the balancer may take over. It leans rather than sitting square around straight-up, because the arm does not need to be at the top — it needs to be heading there at the right speed. Too fast and it sails past; too slow and it falls back.

Fig. 3
axes speed against angle green the capture window
The same swing-up, as speed against angle. It starts in the middle — at rest, not moving — spirals outward as the motor feeds it, and leaves along the green window where the balancer takes over.

Across ten runs the rig hands over about a degree and a half from the middle of that window, and never more than three and a half.

The same run, on the bench

Here is that swing-up as the rig performs it, with five simulated versions as ghosts. The screens replay the same run at the same instant, and the film drops to an eighth speed as the arm enters the green window.

Film
solid hardware run ghosts simulation slow section playback only
The rig's own recorded swing-up, rendered from the CAD. The solid arm follows measured hardware; the five ghosts are simulated draws. Both monitors replay the same run at the same instant, so the traces and the arm cannot drift apart. The slow section is playback only — no trace was altered to produce it.

Where the hundred machines come from

Every ghost is one draw from these ranges. The widths are not guesses — they are what my bench could resolve, and one is far wider than the rest.

Fig. 4
each curve one quantity ticks ±1σ
What I am unsure about. Each curve is one number's range, scaled to its own center so units that do not compare can share one axis.

One number in there is not a measurement at all. The model needs a 3.5% correction to the torque the motor delivers, and I cannot yet explain that from physics, so I hold it fixed rather than give it a range it has not earned. All hundred machines carry it, and so does the agreement below.

Friction is the interesting one. There are two kinds: the sticking kind, and the kind that grows with speed. I draw them as a pair, because the bench measured them together. Treating them as independent would invent machines that cannot exist.

Fig. 5
contours 1σ and 2σ tilt the correlation
The two frictions, together. The tilt of the contours is their correlation: more Coulomb means less viscous.

How close

The median simulated machine catches the arm about 65 milliseconds later than the rig — near two and a half percent. Every bench run lands inside what the model predicted, but the prediction is not centered on the rig: the model runs consistently slow. That is a different problem from being merely uncertain.

I know where to look, and it is not the arm. Over one downswing six of the eight things I measure agree — the angle it falls from, the time it takes, the energy released, the friction, the speed at the bottom. Two do not, and they are one fact twice: about eight of the rig's fifty-nine millijoules of motor work never become motion. Either I am reading the current high, or my friction law is missing a loss.

The pictures leave out two model behaviors the rig rarely shows: runs needing a fifth swing, and runs that miss the catch. Both are real and both are tracked.