Discrete Compensation Control
In field-oriented control (FOC), the inner current control loop serves as the foundation for all higher-level control loops. PI controllers are a common choice, designed as compensation controllers. However, in digital implementation, there are several pitfalls that can be avoided early in the design process.
Plant Model
We begin by considering a linear, already compensated and decoupled voltage equation:
where \(R\) represents the resistance and \(L\) the inductance. The transfer function of the plant model is given by
Continuous Design
The compensation controller should be designed in such a way that the closed-loop transfer function
matches the transfer function of a first-order system with the desired time constant \(T_w\). This time constant can alternatively be defined by the desired bandwidth \(f_w\) as
Compensation control can be achieved with a PI controller
using the control parameters
This leads to the closed-loop transfer function
Discrete Implementation
For implementation on a microcontroller, the controller algorithm needs to be discretized. A discrete PI controller (using backward rectangular rule) with the transfer function
and sampling time \(t_s\) is a common choice. Excluding considerations for feedforward-terms, limitations, and anti-windup methods, the PI controller can be efficiently implemented on the target hardware as follows:
However, if the same control parameters from the continuous design are applied, the discrete closed-loop transfer function
will not achieve the desired compensation and bandwidth. This discrepancy leads to a transfer behavior that deviates from that of the continuous design:

The differences become more pronounced as the desired bandwidth and sampling frequency approach each other: when they are far apart, the transfer behavior approximates that of the continuous compensation controller. When they are close together, the differences can even lead to instability in the discrete controller.
Direct Discrete Design
The good news is, that there is no need to reduce the desired bandwidth or increase the sampling frequency. If the compensation control is directly designed for the discrete model equations, the control parameters calculate to
This ensures that, in the discrete case as well, both the pole compensation and the desired bandwidth are preserved. Now, during sampling the control variable matches that of the continuous compensation controller exactly:
