**Park-Clarke Transform **

With **Park-Clarke transform**, the three phase alternating current can be transformed into a two axis, time-invariant current. While being time-invariant, motor currents are easier to be controlled. Let’s name **I** the rms value of the current and **Iq **and **Id **its two components.

Since Iq lives in the imaginary axis and Id in the real, the three currents are being related by the following equations:

**I = sqrt((Iq^2) + (Id^2)) **

**Θ = tan -1 (Iq/Id)**

**Θ**** **is the angle difference between the rms current (I) and the real axis, which also reflects the angle difference between the **stator’s** and **rotor’s** magnetic field.

Because the motor torque is maximum when the angle difference between the two fields is 90 degrees (Torque = motor current * Kt * sin(Θ)), one could guess that the target of the motor control is to keep Θ equal to 90 degrees, by zeroing the Id current.

The below chart shows the relation between motor torque and the field angle (Θ). The torque is maximum when Sin(Θ) is 1, which happens at 90 degrees.

From the previous, it can be derived that Iq is the current responsible for the torque of the motor, while Id does not produce any useful motor torque…

**FOC PI loop**

The motor control algorithm will supply the motor voltage that way, so the angle between Id and Iq stays at the desired levels (that by default is 90 degrees). Although the angle of the rotor is known, it takes something more than just providing a motor voltage with a shifted angle to control the motor current. And this is because the field angle will vary depending on the motor speed, and it will also deviate during acceleration/deceleration and during load disturbances. The **FOC PI loop** will react in those angle variations and revert the field angle back to the desired value. How fast this error will be corrected is determined by the bandwidth of the FOC loop. The higher the bandwidth is, the quicker the algorithm will correct these angle errors.

Except from controlling the filed angle through Id, another additional operation of the FOC PI loop (alternative name is Torque loop) is to control the Iq current. When the **Torque FOC** loop is enabled, the Iq current will be controlled so the motor will go at the desired speed. How quickly this current goes to the desired point, again is determined by the bandwidth of the FOC torque loop.

The FOC loop can be tuned based only on the motor's RL specs. The tuning can be done by knowing the transfer function of the system and setting the PI controller poles and zeros that way so the system is always stable. The final equations use only the inductance and resistance of the motor and the only configurable parameter by the user is the FOC loop bandwidth (BW).

The equations used are the following:

**Kp = Phase Inductance (Henri) * 2 * pi * BW (Hz)**

**Ki = Phase resistance (Ohm) * 2 * pi * BW (Hz)**

So, to summarize, the dual function of the torque loop is to:

- Keep Id current equal to zero (unless if field weakening is applied)
- Control the Iq so the speed goes at the desired value

The Id control happens in Open loop and Closed loop operation, while the Iq control happens only in closed loop.

**The benefits of FOC control**

As mentioned, the FOC loop will optimize the motor torque by controlling the Id current. Also, since it is applied in sinusoidal commutation mode, all the benefits of sinusoidal mode will co-exist, such as the noiseless commutation and the minimized torque ripple. By controlling the current in speed mode (instead of controlling only the voltage), the possibility of current spikes that can give high current errors or damage the controller will be much lower.