Field-oriented control, or FOC, is the technique that makes brushless motors run smoothly, quietly, and efficiently at any speed, by controlling the motor's magnetic field directly instead of blindly commutating phases. It is the difference between a motor that coggs and whines and one that spins like it is on bearings made of silence. Setting up FOC involves current sensing, rotor position feedback, and a tuning sequence that rewards patience. This article walks through the setup logic from first principles.
What FOC does differently
A simple brushless driver switches phases in a six-step pattern based on rough rotor position, which produces torque ripple: the motor surges and sags as the field jumps between steps. FOC instead computes the exact current vector needed to produce smooth torque, decomposing the phase currents into a torque-producing component and a field-producing component, then driving the waste component to zero. The result is maximum torque per amp, minimal ripple, and quiet operation across the speed range.
The price is complexity. FOC needs to know the rotor angle precisely and continuously, and it needs to measure phase currents in real time. That means position feedback, an encoder or Hall sensors at minimum, and low-side or inline current shunts with fast ADC sampling. Sensorless FOC exists, estimating position from back-EMF, but it struggles at standstill and low speed, exactly where robots need control most.
Hardware prerequisites
Start with a driver board that supports FOC in hardware or firmware, with current sensing on at least two phases. Pair it with a motor whose parameters you know or can measure: winding resistance, inductance, pole pair count, and the encoder's counts per revolution. Wrong motor parameters are the most common setup failure; the controller's math assumes them, and garbage in means oscillation out.
The encoder deserves respect. An incremental encoder with an index pulse works, but absolute encoders simplify startup by reporting position immediately. Whatever you use, it must be rigidly coupled to the shaft with no backlash; a slipping encoder coupling produces a special kind of madness where the tuning seems to drift randomly. Verify the encoder counts correctly through full rotations before touching any control gains. Hall sensors alone are a compromise: they report position in coarse 60-degree sectors, which makes low-speed FOC rough. If smooth slow motion matters, use an encoder.
Pick your platform before you tune
The calibration steps below are the same everywhere, but the buttons you press live in a specific ecosystem. SimpleFOC is the open-source route: an Arduino-compatible library with a tuning tool that walks you through alignment and loop setup on inexpensive driver boards. ODrive and VESC are integrated controller boards with their own configuration software and auto-calibration routines. Pick one, then follow its calibration sequence. The concepts in this article tell you what each step is doing and why the order matters, so when the tool asks for pole pairs or runs an alignment routine, you know what it is actually measuring.
The calibration sequence
Calibration follows a fixed order because each step depends on the last. First, measure or enter the motor's electrical parameters: resistance and inductance from a meter or the driver's auto-measurement routine, pole pairs from the datasheet or counted on the bench by spinning the shaft one full turn and counting back-EMF cycles on a scope. Second, calibrate the encoder offset: the driver energizes the phases to a known electrical angle and records the encoder reading, establishing the mapping between sensor counts and field angle. Repeat this a few times; it should return the same value within a tight tolerance.
Third, verify current sensing by commanding small known currents and checking the reported measurements track. Fourth, run the motor open-loop at low speed to confirm the direction convention: positive command must produce positive encoder change. A sign error here inverts every loop that follows, so check it explicitly rather than assuming. If the motor runs backwards, swap any two of the three phase wires; that reverses direction without touching the tuning.
Tuning the current and velocity loops
FOC stacks control loops: an inner current loop per axis, a velocity loop around that, and optionally a position loop outside. Tune inside out. The current loop needs high bandwidth and is usually set from the motor's electrical time constant; many drivers auto-tune it from the measured resistance and inductance, and the auto values are a fine starting point. Verify with a current step command: the response should be fast with minimal overshoot.
The velocity loop is where feel comes from. Raise the proportional gain until the motor tracks speed commands crisply without oscillation, then add integral action to kill steady-state error. Too much integral gain causes windup on large commands, so set output limits and anti-windup behavior deliberately. Test under the real load, not free-spinning: inertia changes everything, and a tune that is perfect unloaded can oscillate badly under load.
Past a certain speed the motor runs out of voltage: back-EMF rises with RPM until the driver cannot push more current. Field weakening buys extra speed by injecting negative current on the field axis, deliberately fighting the rotor's magnets to drop the effective flux. It works, and every FOC platform supports it, but it costs efficiency and pours heat into the motor. Treat it as a deliberate choice with a thermal budget, not a free speed upgrade.
Common failure modes and fixes
Oscillation at standstill usually means the encoder offset is wrong or the current loop is too aggressive; re-run offset calibration first since it is the cheaper fix. A motor that energizes and locks but refuses to spin on a speed command almost always skipped encoder alignment: the controller knows the rotor is there but not where it is. Re-run the alignment routine. A motor that runs roughly in one direction and smoothly in the other has a direction or offset asymmetry; check the offset calibration in both directions. Overheating at standstill under load is normal for FOC holding torque: it is dumping current to hold position, so size the thermal path for the holding current, not just the running current.
If the motor suddenly loses sync under load, the current limits are likely too low for the demanded torque, or the velocity loop cannot keep up with the acceleration command. Raise current limits within the motor's thermal ratings, or soften the motion profile. FOC cannot create torque the hardware cannot deliver; it just delivers available torque optimally.
Sequence, not guesswork
FOC setup is a sequence, not a guess: correct parameters, solid encoder, calibrated offset, verified current sensing, then loops tuned inside out under real load. Follow the order and the motor rewards you with silent, efficient, precise motion. Skip steps and you get expensive random behavior. The discipline is the whole trick.
Related Guides
- Harmonic Drive Backlash Measurement in Robot Arms: Harmonic drives, also called strain wave gears, are the precision gearboxes inside most robot arms: enormous reduction ratios, near-zero backlash, but measuring what little backlash remains takes a careful setup. This guide walks through the measurement.
- Planetary Gearhead Efficiency Limits Under Load: Planetary gearheads, the compact concentric reducers that multiply a motor's torque, are rated with efficiency numbers that look reassuring on the datasheet. Under real load those numbers sag, and this guide explains why and how to plan for it.
- Magnetic Absolute Encoder Drift in Robot Arm Joints: A robot arm that cannot trust its own joint angles is not a robot arm. It is a suggestion. Magnetic absolute encoders are popular in hobby and prosumer robot arms, but temperature and mounting shift their readings over time. Here is how to spot the drift and compensate.
- Cycloidal Drive Tolerances for High-Torque Joints: Cycloidal drives deliver enormous gear reduction in a compact package with near-zero backlash, which makes them attractive for robot joints that need big torque in a small space. This guide covers the tolerances that decide whether yours runs smooth or binds.