PI feedback + ωL̂ decoupling. The gains are designed from a continuous-time model and the delay is ignored during tuning. The physical delay is still present when the controller is tested against the plant.
The complete drive loop · what is actually simulated
Start here before comparing the controllers. Both designs drive the same sampled-data plant: current references enter a digital controller, the command passes through the real actuation delay and inverter, the PMSM currents evolve, and sampled currents return at the next control update.
The \(z^{-1}\) block stores the voltage command, so the plant receives \(\mathbf u[k-1]\) during the next update. \(T_d\) is the physical time from current and angle sampling until that voltage becomes effective. In the exact dq plant it appears in the voltage-vector angle
It is therefore not a second hidden sample delay: it describes the orientation and timing of the applied voltage inside the sample interval.
Reference feedforward + current feedback + integral action + delayed-voltage feedback. The previous command u[k−1] is a controller state, so the design places poles with the actuation delay already included.
Block diagrams · hover any block
Hover or tap a block to see its role and live value at the inspected speed.
Hover or tap a block to see its role and live value at the inspected speed.
Same true plant on the right of both diagrams — the only difference is what the designer chose to model. The delay-aware structure has one extra feedback path (\(K_2\), on the delayed voltage): that single block is what keeps the poles inside the unit circle at speed. Convince yourself in the design studio.
Method & verification
Sampling frequency versus switching frequency
The sampling frequency \(f_s\) is the rate at which the phase currents and rotor angle are sampled and the current controller is executed. The switching frequency \(f_{sw}\) is the carrier rate of the three-phase two-level inverter.
The two frequencies are often equal, but they do not have to be. This release uses an average-value inverter model. Therefore \(f_{sw}\) is stored as part of the system definition, while PWM ripple is not injected into the current waveform or pole calculation.
The continuous-time PMSM current plant
\(R_s\) is the stator phase resistance represented in the dq equations. \(L_d\) and \(L_q\) are the d- and q-axis inductances. With \(\mathbf i_{dq}=[i_d\;i_q]^T\) and \(\mathbf u_{dq}=[u_d\;u_q]^T\), the electrical model is
The back-EMF is an affine disturbance. At a fixed operating point it changes the equilibrium voltage, but it does not change the eigenvalues of the linear current-state model.
Inverter, delay and exact discretization
The exact zero-order-hold state transition is
The voltage is held in the stator frame while the dq frame rotates. LoopForge obtains the exact input matrix from the upper-right block of a Van Loan exponential:
Separately, both closed-loop structures contain the explicit delayed-voltage state
The firmware angle advance is calculated from the estimated delay. Therefore an error in \(\hat T_d\) creates a residual dq-angle error that grows with electrical speed.
Delay-aware synthesis
The applied voltage from the previous update is augmented as a state:
The desired per-axis response is parameterized by
The gains are computed in closed form using direct discrete-time pole placement in the style of Hinkkanen et al., IEEE Transactions on Industry Applications, 2016.
The IMC PI baseline
The comparison controller uses the continuous-time IMC rules
with \(\omega_e\hat L\) decoupling and a forward-Euler integrator. The physical delay remains in the true plant, but it is ignored while the PI gains are designed.
Stability is measured using the spectral radius of the six-state closed loop:
Verification
Every engine release is checked by an independent Python/scipy implementation that recomputes the discretization, gains, closed-loop eigenvalues, DC tracking and stability sweeps. Discretization and gains agree to approximately \(10^{-9}\) or better, and eigenvalues to approximately \(10^{-7}\). The verification is included in verify/.
Simulation boundary
- \(R_s\), \(L_d\), \(L_q\), saliency and dq cross-coupling
- exact ZOH discretization and stator-frame voltage hold
- sampled current control, the \(z^{-1}\) voltage state and the \(T_d\) angle effect
- parameter/delay mismatch, speed sweeps, poles and linear step responses
- individual IGBT/MOSFET switching pulses and PWM ripple
- DC-link saturation, dead time, device voltage drops and nonlinear current limiting
- magnetic saturation, temperature drift, sensor noise and quantization
- mechanical dynamics, torque loop, field weakening and MTPA logic
Discuss a public technical topic
A short, non-confidential email about the model, mathematics or educational simulation is welcome.