A real, notoriously tricky control problem. Try P-only control first — this system is famous in control courses specifically because it fails without derivative action.
Control Systems · PID

Ball and Beam Control Simulator

The classic PID teaching plant — balance a rolling ball by tilting the beam it sits on.
x″ = (5/7)g·sinθ · RK4
PD · setpoint 0.30 m

PID gains

Setup

Try it

Live simulation

t = 0.0 s
speed
Result
Detail
Field notes

Why this system is a control-theory classic

How it works

A double integrator in disguise

Tilt the beam by angle θ and a rolling ball accelerates along it at x″ = (5/7)g·sin θ — the 5/7 factor comes from a solid sphere's rotational inertia sharing the load with its linear motion. Critically, there's no damping term at all in that equation: nothing in the physics itself slows the ball down. The beam angle is driven by a simulated servo with a small response lag (τ ≈ 0.15 s), and the PID controller commands that angle from the ball's position error. The whole thing is integrated with RK4, the same verified method used throughout this site.

Worked example

Set every gain to zero except Kp = 6 and the ball doesn't oscillate gently — it accelerates off the end of the beam in well under a second. Add Kd = 4 and the identical proportional gain now settles smoothly at the target. Nothing about the ball changed — only the controller's ability to react to its velocity, not just its position.

Why does pure P control actively fail here, not just oscillate?

The plant is a pure double integrator (position needs two integrations from angle, with zero natural damping) — under proportional-only feedback that combination is only marginally stable in the idealised case, and the small extra lag from the simulated servo tips it into genuine instability. It's one of the cleanest classroom demonstrations of why "just add more P" doesn't always work.

Why does derivative gain fix it?

Since nothing in the physical system opposes the ball's motion, the controller has to supply that damping itself. The derivative term reacts to how fast the error is changing, which is exactly the missing velocity feedback the system needs to settle instead of overshoot forever.

What does the integral term add here?

With a well-tuned P and D, the ball already settles very close to the setpoint — integral action mops up any small remaining steady-state offset, but too much of it (relative to P and D) can reintroduce oscillation, the same trade-off as any PID loop.

What real systems does this represent?

Any balancing problem built on a double integrator with no natural damping: a Segway or self-balancing robot, a rocket balancing on its thrust, magnetic levitation, or the classic inverted pendulum. Ball-and-beam rigs are a staple of university control labs precisely because they're a physical, visible version of this family of problems.