Three-phase motor drive: field-oriented control of a PM motor
A permanent-magnet synchronous motor (PMSM) on a three-phase inverter, under field-oriented control (FOC): a speed loop sets the torque current, and two current loops in the rotor's d-q frame set the voltages. You read the drive, simulate a speed step, and let the Design panel size the current and speed controllers. About 20 minutes.
Pictures: a numbered red box is what you click or read, Run is a button, Design › Design Steps › Current Loop a menu path, F5 a key.
1. Open the FOC example
Step 1 of 7 · about 1 minChoose File › Open Example › Motor drives › PM synchronous motor, field-oriented control.
File.Open Example.Motor drives.PM synchronous motor, field-oriented control.
2. Read the power stage
Step 2 of 7 · about 1 minFor these two pictures the side panels are hidden (View menu) so the schematic has the whole window.
Vdc: the 300 V DC link.Sah: the high side of phase a; the bridge has three legs,Sa,SbandSc.Ama: measures the phase-a current (AmbandAmcthe others) for the current loops.M1: the PMSM, 8 poles, 0.5 Ω, 4 mH, 0.12 Wb of magnet flux.Fan: a fan load, whose torque rises with the square of the speed.PS: the position sensor, which gives the rotor angle to the Park transforms.
3. Read the control
Step 3 of 7 · about 1 minSpeedRef: steps the speed command from 0 to 200 rad/s at 20 ms.SpdPI: the speed controller. Its output is the q-axis (torque) current command, limited to ±8 A.Park: turns the three phase currents intoidandiq, in the frame that turns with the rotor.PIq: the q-axis current controller.PId: the d-axis current controller. Its command is 0 (IdRef), so all the current makes torque.InvPark: turns the d-q voltages back into three phase voltages.SVM: space-vector modulation turns them into three duties.PWM: one 10 kHz carrier for the three legs.DTh: the 1 µs dead time of the three high sides, on the PWM's gate bus;NandDTlgive the three low sides the complement, and two bus demuxes hand the six gate signals (gahtogcl) to the bridge by label.
4. Run the speed step
Step 4 of 7 · about 1 minClick ▶ Run or press F5. The run is 350 ms and takes about a second. In the scope click Maximize at the panel's top right, then Fit in the scope's toolbar: the plot first shows only the last few switching cycles.
wm(M1): the rotor speed.wref: the command.
5. Design the current loop
Step 5 of 7 · about 1 minClick Restore at the panel's top right, choose Design › Design Steps › Current Loop, then click Design again.
Current Loopis the task. It reads R and L from the motor and finds the two PIs from the wiring.Proportional gain (d axis)= 25.13 andIntegral gain (d axis)= 3.142k 1/s:Kp = L·ωcandKi = R·ωccancel the motor's R-L pole. The crossover is 1 kHz (a tenth of the switching frequency) with 72° of margin: 90° less 18° for the half-sample PWM delay.ApplywritesKpiandKii, the circuit variables both current PIs use.
6. Design the speed loop
Step 6 of 7 · about 1 minClick Apply, then the Speed Loop task, then Design again.
Speed Loopis the task. It models the current loop you just applied as a first-order lag of 1 kHz.Proportional gain= 3.386 andIntegral gain= 531.9 1/s, by the symmetrical optimum with a symmetry factor of 4. The loop crosses at 99.5 Hz (the speed bandwidth, a tenth of the current loop's) with 70° of margin.ApplywritesKpwandKiw.
7. Run again
Step 7 of 7 · about 1 minClick Apply, close the Design page with the × on its tab and press F5. When the run ends, click Maximize and Fit as in step 4.
wm(M1): the same ramp to 200 rad/s. A large step drives the speed PI into its current limit, so the ramp depends on the 8 A limit and the inertia, not on the gains. The new gains act on small steps and load changes, where the loop stays linear.- The
Runstab: the second run and the four variablesApplychanged.
The same steps from a script
powercraft-cli run \
--cmd file.openExample --params '{"name":"pmsmFoc"}' \
--cmd simulation.run --params '{}' \
--cmd design.currentLoop --params '{"apply":true}' \
--cmd design.speedLoop --params '{"apply":true}' \
--cmd simulation.run --params '{}' \
--cmd scope.measure --params '{"signals":["wm(M1)"],"t0":"0.3"}'






