FOC: three phase currents into two DC values
The Clarke and Park transforms turn the rotating three-phase currents into d-axis and q-axis DC values in a frame fixed to the rotor, so torque is controlled directly.
Why change coordinates
The three phase currents are sine waves that keep changing with the rotation speed, so it is hard to make a PI controller follow them directly. Seen from a frame that rotates with the rotor, these currents become steady DC values, and DC is easy to control with PI.
Order of the transforms
- Clarke transform: ia, ib, ic → iα, iβ (stationary two-axis frame)
- Park transform: rotate by the rotor electrical angle θ → id, iq (rotating two-axis frame)
- PI control: id → target 0 (surface-magnet motor), iq → target torque current
- Inverse Park transform: vd, vq → vα, vβ
- SVPWM: vα, vβ → duty of the three phases
iq = -iα·sinθ + iβ·cosθ
id = iα·cosθ + iβ·sinθ
What the d and q axes mean
- q-axis current: produces torque (torque = 1.5 · p · λ · iq)
- d-axis current: along the flux. Held at 0 it gives maximum torque for the same current; made negative it allows field-weakening operation at high speed
What you need
- An accurate electrical angle θ: an encoder, interpolated Hall sensors, or a sensorless observer
- A fast current loop: the whole calculation above every PWM period (10 to 20 kHz)
- Accurate current sensing and timing
Compared with six-step it has less torque ripple, is quieter and more efficient, which is why electric vehicles, industrial servos and high-end drone ESCs use FOC.
In one sentence
Seen from a frame that rotates with the rotor, the three-phase AC currents look like two DC values. DC is easy to handle with PI controllers, so FOC changes coordinates, controls there, and transforms back.
What happens in one period
| Order | Stage | Input → output |
|---|---|---|
| 1 | Current measurement | Shunt resistors and ADC → ia, ib (ic = −ia − ib) |
| 2 | Clarke transform | ia, ib → iα, iβ (stationary two axes) |
| 3 | Park transform | iα, iβ, angle θ → id, iq (rotating two axes) |
| 4 | Two PI controllers | id error, iq error → vd, vq |
| 5 | Inverse Park transform | vd, vq, θ → vα, vβ |
| 6 | SVPWM | vα, vβ → duty of the three phases |
These six stages repeat every PWM period (usually 10 to 20 kHz).
The d and q axes
- q-axis current (iq): at right angles to the magnet flux. It produces torque. Torque is proportional to iq.
- d-axis current (id): in the same direction as the magnets. It does not contribute to torque, so it is normally controlled to 0. Making it negative to hold down the back-EMF at high speed is field-weakening control.
Transform code
// Clarke: three-phase → stationary two-axis (assumes ia + ib + ic = 0)
float i_alpha = ia;
float i_beta = (ia + 2.0f * ib) * 0.57735027f; // 1/√3
// Park: stationary two-axis → rotating two-axis
float s = sinf(theta), c = cosf(theta);
float id = i_alpha * c + i_beta * s;
float iq = -i_alpha * s + i_beta * c;
// Inverse Park: rotating two-axis → stationary two-axis
float v_alpha = vd * c - vq * s;
float v_beta = vd * s + vq * c;
theta is the electrical angle. It is the mechanical angle times the number of pole pairs, and you have to find, once, the electrical-angle offset at the point where the encoder reads 0 and add it.
What happens when the angle is wrong
With an angle error δ, torque falls by a factor of cos δ.
| Angle error | Remaining torque | Symptom |
|---|---|---|
| 0° | 100% | Normal |
| 30° | 87% | More current, more heat |
| 60° | 50% | Noticeably weak |
| 90° | 0% | Current flows but nothing turns |
| Over 90° | Negative | Turns backwards or runs away |
If the torque is low for the current you are putting in, or the motor runs unusually hot, suspect the angle offset first. You can see this relationship for yourself by moving the angle-error slider in the site's FOC lab.
Compared with six-step
| Six-step | FOC | |
|---|---|---|
| Current shape | Steps | Sine wave |
| Torque ripple | Large | Small |
| Sensors needed | Hall sensors | Current sensors + precise angle |
| Computation | Little | Trigonometry and two PI controllers |
| Use | Drones, power tools | Electric vehicles, robot joints, appliances |
Problems that come up in practice
- Current sampling instant: measuring at a switching instant picks up noise. Trigger the ADC at the centre of the PWM period.
- PI output limit: limit the combined magnitude of vd and vq so it does not exceed the available voltage, and stop integrating when saturated.
- Current sensor offset: measure the ADC value at zero current at start-up and subtract it.
- Wrong pole-pair count: the electrical angle is wrong, so the motor shakes at low speed and loses force at high speed.