Field-Oriented Control, from scratch
An interactive, build-in-public series that takes you from spinning magnets to a self-tuning motor drive — the ideas behind the open Modular Motor Controller.
Motor control feels like a wall of Greek letters. It isn't.
Field-oriented control is how nearly every drone, robot arm, EV, and CNC axis makes a motor produce smooth, precise torque. The math looks intimidating — Clarke, Park, space vectors, observers — but every piece maps onto something you can see spinning.
So instead of derivations, each part gives you something interactive to work with. Drag a slider, watch the field turn, break the controller and fix it. The same ideas — the same code, even — run on Rhobic's open Modular Motor Controller, a simulation-first FOC drive that goes from a virtual motor in CI to a real STM32. You're working with the actual thing, not a simplified stand-in.
Six parts, from spinning magnets to a self-tuning drive.
Read them in order or jump to what you need. New parts land as the controller itself hits each milestone.
What field-oriented control actually does
LiveThree phase currents, one spinning magnetic field. Play with the waveforms and watch the stator vector FOC exists to aim.
Clarke & Park: turning AC into DC
LiveThe two transforms at the heart of every FOC drive. Spin the rotor and watch three wild AC currents collapse into two steady knobs: torque and flux.
The loop that runs the motor
LiveA PI controller, an R–L winding, and a step response. Tune the exact current loop that runs at 20 kHz on real silicon — and see why bandwidth is the only knob that matters.
Finding the rotor without a sensor
Coming soonA flux observer and a PLL estimate rotor angle from nothing but voltage and current — the trick that lets a drive spin a motor it has never seen.
From simulation to silicon
Coming soonThe same control core runs in CI against a virtual motor and, unchanged, on an STM32G474 driving a real inverter. How the sim-first workflow catches bugs before the smoke does.
Position control & robotics
Coming soonStack a position loop on top of torque and speed, add an encoder, and put a motor exactly where you want it — the foundation for every robot joint.
Every part maps to real code.
The series doubles as working documentation for the Modular Motor Controller. Each part points back at the milestone it explains, the modules that implement it, and a command to run it. MS1–MS5 have shipped; MS6 is in progress and MS7 is planned. For the real traces behind these claims — sim and hardware alike — see Results.
| Part | Milestone | In the code | Status |
|---|---|---|---|
| 1What field-oriented control actually does | MS2 | mmc-core::svpwm::svpwmmmc-core::transformsmmc-sim::motor | Live |
| 2Clarke & Park: turning AC into DC | MS2 | mmc-core::transforms::clarkemmc-core::transforms::parkmmc-core::transforms::inverse_park | Live |
| 3The loop that runs the motor | MS2 | mmc-core::tuning::current_pi_gainsmmc-core::pi::Pi::updatemmc-core::current_loop::CurrentLoop::update | Live |
| 4Finding the rotor without a sensor | MS4MS5 | mmc-core::observermmc-core::sensorlessmmc-core::angle::AngleEstimator | Coming soon |
| 5From simulation to silicon | MS3MS5 | mmc-core::foc::Foc::stepmmc-protommc-fw-g474 | Coming soon |
| 6Position control & robotics | MS6MS7 | mmc-core::tuning::speed_pi_gainsmmc-core::anglemmc-host::profile + tools/profile.py | Coming soon |