Aleph-B Lab

FOC Explorer

How do you make an AC motor behave like a DC motor without changing the motor? You change how you control it. This page runs a surface magnet PMSM and its field oriented current loop live. Every stage below is drawn from the same running numbers, so drag a slider and watch the whole loop react.
Measure
abc
a +0.05b +6.90c -6.95 A
Clarke
αβ
α +0.05β +8.00 Aθe 360°
Park
dq
d +0.00q +8.00 A
Regulate
vd* vq*
vd -0.12vq +3.91 Vlinear
Inverse
vα vβ
α -0.10β +3.91 V|v| 3.9 V
SVPWM
duty
a 0.50b 0.57c 0.43
Switch
motor
20 Hz elec300 rpm0.58 N·m
00

The machine

surface PMSM

The rotor carries p pole pairs of magnets. The stator carries the three phase windings in slots, one slot per pole per phase, so 6p slots. Every mechanical turn is p electrical cycles, and the angle the transforms need is θe = p·θm. Each slot is shaded by its phase color and the size of its current; ⊙ is current out of the page, ⊗ into it. A slot is a conductor, not a pole: the currents set up the stator field, whose poles sit 90° electrical from the slots that carry them. Those poles are drawn on the bore in the rotor's N and S colors. With positive iq the stator S pole leads the rotor N pole by 90° electrical and pulls it forward; positive id lines the stator S up with the rotor N and only adds flux.

Cross section, mechanical frame
NSbore arcs = stator poles · inner ring = rotor magnets
Stator S pole leads rotor N by 90° electrical (90° = all torque, 0° = all flux).
θ mech
360.0
deg
θ elec
359.6
deg
f elec
20.0
Hz
Torque
0.58
N·m
θe = p · θm T = 1.5 · p · λm · iq
01

Clarke

abc → αβ

Three phase currents become two components in a stationary frame. a, b, c are the three motor phases. α, β are perpendicular stationary axes. Nothing physical changed, only the basis: three coupled wires became two orthogonal axes.

Phase currents, A
abc
Stationary αβ plane
iα = ⅔ · (ia − ½ ib − ½ ic) iβ = (ib − ic) / √3 amplitude invariant form: a balanced set returns iα = ia at full scale
02

Park

αβ → dq

The stationary components are projected onto axes rotating with the rotor's electrical position. d is the direct axis, aligned with the magnet flux. q is the quadrature axis, 90 electrical degrees ahead. In steady state the sinusoids become two near constants, so the control problem splits into two DC problems.

αβ plane with the rotating d axis
Rotor dq frame
id = iα·cosθe + iβ·sinθe iq = −iα·sinθe + iβ·cosθe
03

Regulate

id, iq → vd*, vq*

Two PI loops compare measured currents with their targets and compute the voltage commands that correct the error. For a surface magnet PMSM, iq sets torque and id sets flux. Feeding forward the ωe cross terms makes each PI see a plain RL circuit. Switch decoupling off and press Reverse torque to see the axes fight each other.

dq currents vs targets, A
iqiddashed = target
vd*
-0.12
V
vq*
3.91
V
Kp
0.113
V/A
Ki
283
V/A·s
Voltage headroom, |v*| of Vdc/√3
Voltage headroom available.
vd* = Kp·(id* − id) + Ki·∫(id* − id)dt − ωe·Lq·iq vq* = Kp·(iq* − iq) + Ki·∫(iq* − iq)dt + ωe·Ld·id + ωe·λm Kp = L·ωbw, Ki = R·ωbw (zero cancels the RL pole, closed loop = ωbw/(s + ωbw)) valid while ωbw·Ts ≪ 1 (Ts = PWM period): the loop updates once per period, so above about 0.3 the step overshoots and with a short L/R the loop can go unstable
04

Inverse transforms and SVPWM

dq → αβ → abc → switches

The voltage commands return to the stationary frame and become three phase references. Space vector PWM then picks the switching sequence that synthesizes the requested vector over one PWM period: two adjacent active vectors for T1 and T2, the zero vectors for the rest. In the hexagon the dashed arrow is the requested vector V*; the two thick segments are the time weighted corner vectors that add up to it. The strip under the gate pattern names the inverter state applied in each stretch of the period. Each phase leg is held high for the duty shown, center aligned. The motor responds, its currents are measured again, and the loop repeats.

Voltage hexagon
Sector
2
of 6
|v*| / (Vdc/√3)
0.14
modulation
Dwell time per period Ts
T1, time on V23.38 µs T2, time on V33.68 µs T0, zero vectors V0 + V742.95 µs
Phase duty cycle
a
0.497 b
0.571 c
0.429
Gate pattern, one PWM period, center aligned
vα = vd·cosθe − vq·sinθe vβ = vd·sinθe + vq·cosθe T1 = (√3·Ts/Vdc)·|v*|·sin(60° − θs) T2 = (√3·Ts/Vdc)·|v*|·sin θs T0 = Ts − T1 − T2 duty_x = ½ + (v_x + v_cm)/Vdc, v_cm = −(max(va,vb,vc) + min(va,vb,vc))/2 (min max injection, identical to symmetric SVPWM)
Measure → Transform → Regulate → Reconstruct → Switch → Repeat. The motor's physics never changed. We changed the coordinates until torque control became a problem we could manage.

Model, assumptions, sources

What runs on this page

Plant

Ld·did/dt = vd − R·id + ωe·Lq·iq Lq·diq/dt = vq − R·iq − ωe·Ld·id − ωe·λm with Ld = Lq = L (surface magnet machine)

Integrated with forward Euler at four substeps per PWM period, or more when the electrical time constant L/R is short, so that each substep is at most half of L/R. Mechanical speed is held by the slider, as if a stiff load or dyno sets it, so there is no mechanical dynamic. ωe = p·ωm.

Controller

One control update per PWM period. The PI gains follow the pole zero cancellation rule shown in stage 03, derived from the RL plant above. Anti windup is back calculation with tracking time Kp/Ki. The voltage vector is limited to the SVPWM linear range Vdc/√3; when that limit is hit the headroom bar turns red and the loop can no longer reach its targets, which is where field weakening (negative id*) starts to matter. Try 3000 rpm at 48 V.

Inverter

Ideal averaged inverter: the applied dq voltage equals the command, and it passes power in both directions, so when back EMF exceeds the available voltage the simulation shows regenerated current that a real bridge would carry through its body diodes instead. Dead time, device drop, switching ripple and current sensor noise are not modeled. The gate pattern panel shows the center aligned duties the modulator would hand to the timer.

Default example motor

4 pole pairs, 0.3 Ω, 120 µH, 12 mWb, 48 V bus, 20 kHz PWM. These are round numbers chosen to sit in the range of small robot joint motors on a 48 V bus. They are an example, not a datasheet.

Sources