Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →

This part is for members

Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.

Keep watching the free parts
Current loop · 9a

The current loop 1: one tick through the pipeline

In one 50 µs tick, current_ctl_loop_task (generated by Simulink, one function of about 400 lines) turns two phase currents into three phase voltages. Seven stops, each with one setting: Clarke reads only phases a and b (phase_dir can swap them); before Park the angle is pushed 4 ticks ahead (elec_angle_compensation); a series PI (the integrator adds the error already multiplied by kp); ±Vmax and the voltage circle (d first); inverse Park and the mode switch (mode 0 uses the caller's voltages: the disabled state's 0 V, R/L identification); max-min SVPWM (subtract the midpoint, line-to-line voltages unchanged); dead-time compensation (0 V on Y01). One real tick followed through: in the SIL the rotor rests at 72° electrical, the iq target steps 0 → 2 A at 300 ms, and every intermediate value of call 6001 is measured: 1.974 A of error → 1.249 V proportional, integral 0.001 → 0.067, uq 1.316 V, phases −1.119, 1.119, 0.375 V, the board's compare values 3441, 3160, 3254. The opening guess: with phase_dir set wrong the loop reads exactly 2.00 A and raises no error, but the real iq is 0 and the rotor locks at 15°. Your turn: work out the next tick's uq by hand.

Up next9b · The current loop 2: the angle pushed four ticks ahead→