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
LiveA 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
LiveThe same control core runs in CI against a virtual motor and, unchanged, on two STM32 boards driving real inverters. How the sim-first workflow catches bugs before the smoke does.
Position control on hall sensors
LiveStack a position loop on top of FOC using only the motor's hall sensors: trapezoidal references, what to do between edges, and why stiction sets the limit.
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–MS6 have shipped. Position control on hall sensors (MS7), six-step (MS8) and the FOC operating envelope (MS9) are in progress. The whole controller is open source atgithub.com/rhobic/mmc; 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 | MS4MS5MS9 | mmc-core::observermmc-core::sensorlessmmc-core::angle::AngleEstimator | Live |
| 5From simulation to silicon | MS3MS5 | mmc-core::foc::Foc::stepmmc-drive::Engine::tickmmc-protommc-fw-g474 / mmc-fw-f302 | Live |
| 6Position control on hall sensors | MS7 | mmc-core::position::TrapRefmmc-core::hall::HallTrackermmc-core::hall::HallAngle | Live |