HomeArticlesControl Systems Theory

Maglev Control: Fighting a Force That Wants to Run Away

The 1/x² attraction law is inherently unstable — Earnshaw's theorem guarantees it — so every real levitating magnet is a feedback loop wearing a coil.

mysimulator teamUpdated June 2026≈ 9 min read▶ Open the simulation

A plant that is unstable by construction

An electromagnet pulling a steel ball toward it obeys an inverse-square attraction law in the coil current I and the gap x between magnet and ball:

F(I, x) = k · I² / x²          (attractive, always toward the magnet)
m ẍ = m g - F(I, x)             (gravity down, magnetic force up)

Balance the two forces at some equilibrium gap x₀ with a constant current I₀ and the ball hovers — in principle. But look at what happens to a small perturbation: if the ball drifts slightly closer to the magnet, x shrinks, and because F ∝ 1/x², the attractive force increases — which pulls the ball even closer. If it drifts slightly farther, force decreases and gravity wins, pulling it farther still. Every deviation from equilibrium is self-reinforcing. This is positive feedback built directly into the physics, and it is exactly why no open-loop magnetic levitation setup has ever held a ball still without active correction — Earnshaw's theorem generalises this observation to prove that no static arrangement of magnets can produce a stable equilibrium at all.

live demo · a field-coupled system holding an unstable balance point● LIVE

Linearising to see the instability as an eigenvalue

Linearise F(I, x) about the operating point (I₀, x₀) with a first-order Taylor expansion and the perturbed dynamics become a clean second-order linear system in the deviation δx:

m δẍ = -Kx·δx + Ki·δI
  where  Kx = ∂F/∂x |₀ < 0   (force INCREASES as gap shrinks — destabilising)
         Ki = ∂F/∂I |₀ > 0   (more current pulls harder, as expected)

Because Kx is negative, this linear system has one real, positive eigenvalue and one real negative eigenvalue — a saddle, exactly like the upright inverted pendulum. Any physical implementation of magnetic levitation is, structurally, the same open-loop-unstable problem as balancing a pendulum on end, just realised in an electromagnetic rather than a mechanical degree of freedom.

Why the controller needs a derivative term, not just proportional gain

A gap sensor measures x, and the natural first instinct is proportional control: increase current when the ball sags, decrease it when it rises, u = Kp·(x₀ - x). This can, for a narrow range of Kp, technically stabilise the linearised system — but only barely, and the margin is thin because proportional action alone reacts to position error with no information about how fast the gap is already changing, so it tends to either respond too late or overshoot and oscillate at the mechanical system's natural frequency. Adding a derivative term, u = Kp·(x₀ - x) - Kd·ẋ, gives the controller a genuine damping term — current increases not just when the ball has already sagged, but in anticipation, whenever the ball is moving toward the magnet, which is precisely the missing physical damping the plant itself does not provide (an ideal frictionless magnetic system has essentially none). PID maglev control is the standard configuration for exactly this reason: P for restoring force, D for damping an otherwise nearly undamped oscillation, and a small I term to null out steady-state gap error from model mismatch or a changing load, tuned carefully because too much integral action reintroduces the windup and lag problems any I-term brings to a system this fast and this marginally stable.

Current-mode vs voltage-mode control

Two practical architectures differ in what the controller actually commands. Current-mode control uses a fast inner current loop (a power-electronics feedback loop, often orders of magnitude faster than the mechanical dynamics) so the outer position controller can treat I as its direct, near-instantaneous input — this is what the linearised model above implicitly assumes, and it's why most textbook maglev designs are current-mode. Voltage-mode control commands coil voltage directly and has to deal with the coil's own electrical dynamics (inductance, back-EMF) coupling into the mechanical loop, which is harder to analyse and tune but avoids the cost and complexity of a dedicated current-control stage — a trade-off between control simplicity and hardware simplicity that shows up in real maglev bearing and levitation-melting furnace designs.

EMS and EDS: the two levitation principles behind real maglev trains

The ball-and-magnet problem above is exactly the control problem behind electromagnetic suspension (EMS) — used by the Transrapid and the Shanghai maglev — where electromagnets on the vehicle wrap under a steel guideway rail and are actively, continuously controlled to maintain a small attractive gap, typically around 10 mm, at update rates in the kHz range; lose that active control for more than a fraction of a second and the vehicle contacts the rail. Electrodynamic suspension (EDS) — used by the JR-Maglev (SCMaglev) in Japan — instead relies on eddy currents induced in the guideway by superconducting magnets moving over it, which produce a repulsive force that grows with speed and is passively stable without continuous active feedback once the train is moving fast enough; the price is that EDS needs a minimum speed (wheels support the train below it) and superconducting magnets, while EMS's active-control approach is what makes it stable down to zero speed but permanently dependent on the control loop this article has been describing never failing.

Frequently asked questions

Why is a magnetic levitation system unstable without feedback?

Because the attractive force between an electromagnet and a ferromagnetic object grows as the gap shrinks (F ∝ I²/x²), so any small drift toward the magnet increases the pull further, and any drift away lets gravity win further — a self-reinforcing, positive-feedback effect built into the physics. Earnshaw's theorem shows this instability is unavoidable for any static magnetic arrangement, not just a design flaw to engineer around.

Why does the controller need a derivative term, not just proportional?

Because the ideal magnetic system has almost no natural damping. Proportional control alone reacts to position error but not to how fast the ball is already moving, so it tends to oscillate near the system's natural frequency; a derivative term supplies the missing damping by increasing current in anticipation of motion toward the magnet, not just after the gap has already changed.

EMS vs EDS — what's the difference?

EMS (electromagnetic suspension, used by Transrapid) uses attractive electromagnets actively controlled to hold a small gap, and is stable at any speed including zero, but depends entirely on the control loop running continuously and fast. EDS (electrodynamic suspension, used by Japan's SCMaglev) uses repulsive forces from eddy currents induced by moving superconducting magnets, which are passively stable once above a minimum speed but need wheels for low-speed support and superconducting magnets.

Try it live

Everything above runs in your browser — open Magnetic Levitation Control and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Magnetic Levitation Control simulation

What did you find?

Add reproduction steps (optional)