Magnetic Levitation Control Loop (2D)
A PID controller reads the gap between a steel ball and an overhead electromagnet and sets coil current in real time to hold the ball against gravity — the classic single-axis maglev-ball control problem, worked with a real inverse-square force law instead of a decorative dashboard.
The 3D version of this simulation renders levitating shapes with stat cards labelled "Stability" and "Power" that don't respond to any underlying physics — they're just slider values echoed back as percentages. This 2D companion builds the real mechanic the title promises instead: a single steel ball hangs below an electromagnet, held up purely by an electronically controlled current obeying F = k·I²/x², the standard inverse-square attraction law used to model real maglev actuators. Because that system is open-loop unstable — a ball that drifts closer gets pulled in harder, and one that drifts farther gets pulled in less — a PID controller measures the gap every tick and adjusts the coil current to cancel the error. Turn up Interference and the controller has to fight sensor noise and random gusts to stay stable; turn Kd too low and the loop starts to ring or drops the ball outright, exactly as a real under-damped control loop would.
2D magnetic-levitation lab with a genuine F = k·I²/x² force law, PID position control (Kp/Ki/Kd), sensor-noise and gust disturbance injection, and a perturb button to test closed-loop stability margin.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install