An electromagnet hangs above a small ferromagnetic puck. The attractive pull between them grows sharply as the gap shrinks and fades as the gap widens — which makes open-loop levitation fundamentally unstable: if the puck drifts a hair closer, the pull increases and yanks it in further; if it drifts away, the pull weakens and gravity wins. A gap sensor and a fast feedback controller close the loop, continuously trimming coil current to hold the puck at a fixed hover height — the same trick used in real maglev trains, active magnetic bearings, and levitating light bulbs.
I = I_bias + Kp·error + Kd·d(error)/dt, and the magnetic pull scales roughly with I² / gap² — the same nonlinearity that makes tuning tricky.Because a single electromagnet levitating a ferromagnetic object is an inherently unstable equilibrium (a consequence of Earnshaw's theorem for static magnetic fields), every real single-coil maglev demonstration — from desktop levitating globes to maglev-bearing turbines — relies on an active electronic feedback loop like this one rather than magnets alone.
An electromagnet hovers a ferromagnetic puck at a fixed gap using real-time feedback control — tune the gains and watch the same unstable equilibrium that governs real maglev trains and active magnetic bearings.
Magnetic pull grows sharply as the gap shrinks and fades as it widens, so an electromagnet alone can never hold a stable hover — only continuous feedback correction, driven by proportional and derivative gains, keeps the puck locked at the setpoint.
Adjust the proportional and derivative gains and the hover setpoint, then knock the puck or add sensor noise to see whether your tuning rejects the disturbance or lets the gap run away.
Earnshaw's theorem proves that no static arrangement of magnets alone can produce a stable levitation point — every real single-magnet maglev demo needs an active electronic control loop just like this one.