Field Oriented Control (FOC) Operation

1. Brushless DC Motor

A brushless direct-current (BLDC) motor consists of magnets and phase-winding coils. To illustrate its operating principle, consider a simplified model featuring one pair of magnetic poles and three coils.

In this model, the coils form the stator. When current flows through a coil, it generates a magnetic field that either attracts or repels the adjacent magnet on the rotor. This magnetic interaction causes the rotor to rotate.

2. A Simple Control Scheme: Six-Step Commutation

In a BLDC motor, the ends of the three coils are connected to form three external terminals that interface with the driving circuit. These coils can be connected either in a star (wye) configuration or a delta configuration. The star connection is more common: one end of each coil is accessible as an external lead, while the other ends are joined internally to form a neutral point.

To control the three wires, a three-phase inverter circuit is used. This inverter is composed of three half-bridge drivers, which can be viewed as six switches connecting between VDD and ground. Each half-bridge can operate in one of four states:

  • High-side ON, low-side OFF (1)

  • High-side OFF, low-side ON (0)

  • High-side ON, low-side ON (X)

  • High-side OFF, low-side OFF (N)

The X state is invalid because it directly connects VCC to ground, while the N state is not used because it leaves the phase coil in a floating condition, reducing the driver’s maximum output capability. This leaves only two valid states: state 1 connects the phase to VCC, and state 0 connects it to ground.

By combining these two valid states for the three phases, there are eight possible inverter states:

  • 000

  • 100

  • 110

  • 010

  • 011

  • 001

  • 101

  • 111

Out of these, the states 000 and 111 are non-driving because all phases are tied to the same voltage level (either VCC or ground), resulting in no voltage differential between them. The remaining six states are the driving states.

For example, consider the motor in state 100:

  • Phase A is connected to VCC.

  • Phases B and C are connected to ground.

In this configuration, current flows from phase A through the neutral point to phases B and C, and then to ground. This current generates a magnetic field oriented toward phase A (0°), which attracts the rotor's magnets and rotates the rotor to 0°.

Next, switching to state 110:

  • Phases A and B are connected to VCC.

  • Phase C is connected to ground.

This creates a magnetic field pointing between phases A and B (approximately 30°), which turns the rotor toward the 30° direction.

Similarly, the remaining driving states sequentially direct the rotor to 60°, 90°, 120°, 150°, and finally back to 0° when returning to state 100.

By switching through these states in order, the motor can be driven continuously and efficiently.

Reference: Six Step Commutation - MathWorks

3. Efficiency Improved: Vector Control

By analyzing the magnetic forces generated from the stator winding acting on the rotor, we can decompose the overall force into two orthogonal components: one aligned with the rotor’s magnetic field (the d-axis component, FdF_d) and one perpendicular to it (the q-axis component, FqF_q). In vector control, only the perpendicular component, FqF_q, contributes to generating torque. The component FdF_d, which is parallel to the rotor magnet, does not aid in rotation and is essentially wasted energy.

To drive the motor efficiently, the control strategy aims to minimize FdF_d while maximizing FqF_q, thereby ensuring that most of the electrical energy is converted into useful rotational force.

4. Frame Transformation

Since the motor’s phase voltages are floating and lack a fixed reference point, it is impractical to use power resistors for sampling. A simpler approach is to add resistors under the low-side MOSFETs, which allows us to sample and obtain three approximate sine-wave phase currents. However, the resulting measurement would yield three sinusoidal signals that are correlated with each other. This makes designing the controller for it very challenging. Instead, with the use of a series of mathematical transformations, we can convert the three phase BLDC motor model into a two phase DC motor model.

Tracking the transformation between these two models can be particularly challenging due to differences in reference frames. In the three-phase BLDC motor model, physical quantities are defined relative to each individual phase, with the reference frame rotating along with the rotor. In contrast, the simplified two-phase DC motor model defines quantities with respect to the orthogonal D (direct) and Q (quadrature) axes within a stationary reference frame.

It's essential to pay close attention to the frame in which each variable is defined. In the following discussion, we will clearly state the reference frame along with the corresponding variables.

Alpha Beta Transform

The three phase currents IaI_a, IbI_b, and IcI_c are three sinusoidal, rotating vectors, each offset by 120° relative to the others. Since they all lie in the same plane, the Clarke transform (also named alpha-beta transform) can be used to reduce them into two orthogonal components, IαI_\alpha and IβI_\beta.

First, we can express IαI_\alpha and IβI_\beta in terms of IaI_a, IbI_b, and IcI_c:

Iα=Ia+cos(23π)Ib+cos(43π)IcIβ=sin(23π)Ib+sin(43π)Ic\begin{aligned} I_\alpha &= I_a + \cos(\frac{2}{3}\pi)I_b + \cos(\frac{4}{3}\pi)I_c \\ I_\beta &= \sin(\frac{2}{3}\pi) I_b + \sin(\frac{4}{3}\pi)I_c \end{aligned}

Using Kirchhoff Circuit Laws, Ic=Ia+IbI_c = I_a + I_b, we can further simplify the equation to be the following

Iα=Ia+cos(23π)Ib+cos(43π)Ic=Ia+cos(23π)Ibcos(43π)Iacos(43π)Ib=Ia12Ib+12Ia+12Ib=32Ia\begin{aligned} I_\alpha &= I_a + \cos(\frac{2}{3}\pi)I_b + \cos(\frac{4}{3}\pi)I_c \\ &= I_a + \cos(\frac{2}{3}\pi)I_b - \cos(\frac{4}{3}\pi)I_a - \cos(\frac{4}{3}\pi)I_b \\ &= I_a - \frac{1}{2}I_b + \frac{1}{2}I_a + \frac{1}{2}I_b \\ &= \frac{3}{2}I_a \end{aligned}
Iβ=sin(23π)Ib+sin(43π)Ic=sin(23π)Ibsin(43π)Iasin(43π)Ib=32Ib+32Ia+32Ib=32Ia+3Ib\begin{aligned} I_\beta &= \sin(\frac{2}{3}\pi) I_b + \sin(\frac{4}{3}\pi)I_c \\ &= \sin(\frac{2}{3}\pi) I_b - \sin(\frac{4}{3}\pi)I_a - \sin(\frac{4}{3}\pi)I_b \\ &= \frac{\sqrt{3}}{2}I_b + \frac{\sqrt{3}}{2}I_a + \frac{\sqrt{3}}{2}I_b \\ &= \frac{\sqrt{3}}{2}I_a + \sqrt{3}I_b \end{aligned}

However, we also need to ensure that the magnitude of the signal should match. Therefore, we need to scale the result by factor of NN.

Note

In an amplitude-invariant transformation, the normalization factor NN should be set to 2/32 / 3, while a power-invariant transformation requires N=2/3N = \sqrt{2/3}.

For this FOC application, it is important to preserve the magnitude of the signals (i.e. phase current readings) during transformation, so we choose, so we set N=2/3N = 2/3.

reference

After magnitude scaling, we get the final Clarke transform equation:

{Iα=IaIβ=33Ia+233Iβ\begin{cases} I_\alpha = I_a \\ I_\beta = \frac{\sqrt{3}}{3}I_a + \frac{2\sqrt{3}}{3}I_\beta \end{cases}

or in matrix format:

[IαIβ]=[100332330][IaIbIc]\begin{bmatrix} I_\alpha \\ I_\beta \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ \frac{\sqrt{3}}{3} & \frac{2\sqrt{3}}{3} & 0 \end{bmatrix} \begin{bmatrix} I_a \\ I_b \\ I_c \end{bmatrix}

DQ Transform

Next, incorporating the information on rotor position θ\theta, the Park transform can be used to convert the IαI_\alpha and IβI_\beta components from the rotor reference frame to a stationary frame. This yields two stationary components, typically denoted as IdI_d (the direct axis component) and IqI_q (the quadrature axis component). These stationary components simplify the motor control strategy by decoupling the torque and flux control.

{Id=cos(θ)Iα+sin(θ)IβIq=sin(θ)Iα+cos(θ)Iβ\begin{cases} I_d = \cos(\theta)I_\alpha + \sin(\theta)I_\beta \\ I_q = -\sin(\theta)I_\alpha + \cos(\theta)I_\beta \end{cases}

or in matrix format:

[IdIq]=[cos(θ)sin(θ)sin(θ)cos(θ)][IαIβ]\begin{bmatrix} I_d \\ I_q \end{bmatrix} = \begin{bmatrix} \cos(\theta) & \sin(\theta) \\ -\sin(\theta) & \cos(\theta) \end{bmatrix} \begin{bmatrix} I_\alpha \\ I_\beta \end{bmatrix}

After converting the three phase currents into stationary DQ currents using the Clarke and Park transforms, we now have a simplified representation that is much easier to control. However, our control is limited to adjusting the applied voltages. To regulate the current, we employ a controller that modulates the input voltage. A detailed discussion of this controller will be provided in the next section. For now, let's explore how the DQ voltage is converted back into the three phase voltages.

Inverse DQ Transform

Similarly, we can take the desired voltages VdV_d and VqV_q and use the inverse Park transform to convert them into signals VαV_\alpha and VβV_\beta that rotate together with the rotor.

{Vα=cos(θ)Vdsin(θ)VqVd=sin(θ)Vd+cos(θ)Vq\begin{cases} V_\alpha = \cos(\theta)V_d -\sin(\theta)V_q \\ V_d = \sin(\theta)V_d + \cos(\theta)V_q \end{cases}

or in matrix format:

[VαVβ]=[cos(θ)sin(θ)sin(θ)cos(θ)][VqVd]\begin{bmatrix} V_\alpha \\ V_\beta \end{bmatrix} = \begin{bmatrix} \cos(\theta) & -\sin(\theta) \\ \sin(\theta) & \cos(\theta) \end{bmatrix} \begin{bmatrix} V_q \\ V_d \end{bmatrix}

Note

Since rotation matrices are orthogonal, A1=ATA^{-1} = A^T.

SVPWM

Unlike the process of transforming current signals, converting voltage signals involves a different approach. This is because the applied voltage ultimately controls digital signals—either 0 or 1—that determine the switching of the MOSFETs in the upper and lower bridge arms, rather than influencing analog values from current measurements. Consequently, we must adopt an alternative method to discretize our desired voltage.

From the six-step commutation scheme, we know that the motor driver can generate voltage vectors (or forces) pointing in six distinct directions. These can be thought of as six fundamental vectors originating from the center and directed toward 0°, 30°, 60°, and so on. By controlling the motor driver to rapidly switch between two states and adjusting the proportion of time spent in each state, we can synthesize a resultant voltage vector that points in a direction between the two fundamental vectors. Furthermore, by incorporating the two non-driving states—which effectively act as zero vectors—we can also adjust the magnitude of the resultant vector.

Va=cos(0)Vα+sin(0)Vβ=VαV_a = \cos(0)V_\alpha + \sin(0) V_\beta = V_\alpha
Vb=cos(23π)Vα+sin(23π)Vβ=12Vα+32VβV_b = \cos(\frac{2}{3}\pi)V_\alpha + \sin(\frac{2}{3}\pi) V_\beta = -\frac{1}{2} V_\alpha + \frac{\sqrt{3}}{2} V_\beta
Vc=cos(43π)Vα+sin(43π)Vβ=12Vα32VβV_c = \cos(\frac{4}{3}\pi)V_\alpha + \sin(\frac{4}{3}\pi) V_\beta = -\frac{1}{2} V_\alpha - \frac{\sqrt{3}}{2} V_\beta

As a result, we have:

{Va=VαVb=12Vα+32VβVb=12Vα32Vβ\begin{cases} V_a = V_\alpha \\ V_b = -\frac{1}{2}V_\alpha + \frac{\sqrt{3}}{2}V_\beta \\ V_b = -\frac{1}{2}V_\alpha - \frac{\sqrt{3}}{2}V_\beta \end{cases}

or in matrix format:

[VaVbVc]=[1012321232][VαVβ]\begin{bmatrix} V_a \\ V_b \\ V_c \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ -\frac{1}{2} & \frac{\sqrt{3}}{2} \\ -\frac{1}{2} & -\frac{\sqrt{3}}{2} \end{bmatrix} \begin{bmatrix} V_\alpha \\ V_\beta \end{bmatrix}

Theoratical Maximum RPM

To control the motor correctly during high speed region, the FOC commutation frequency must be significantly higher than the electrical frequency of the motor. A general rule is that commutation frequency must be at least 10x the electrical frequency.

The motor’s mechanical frequency can then be calculated from the electrical frequency and pole pair:

fmech=felecNppf_{mech} = \frac{f_{elec}}{N_{pp}}

NppN_{pp} is the number of pole pairs.

For example, for a motor with 14 pole pair, if FOC commutation is set to 10 kHz. Then, the maximum supported electrical frequency is 1 kHz.

The maximum mechanical frequency would then be:

fmech=1 kHz14=71 rad/s=678 RPMf_{mech} = \frac{1 \text{ kHz}}{14} = 71 \text{ rad/s} = 678 \text{ RPM}

5. Current Loop

As mentioned above, our objective is to regulate the currents IdI_d and IqI_q. To accomplish this, we control the voltages VdV_d and VqV_q applied to the motor. A straightforward method to map these voltage inputs to the desired current outputs is by using a proportional-integral (PI) controller.

DC Motor Model

In the simplified DC motor model, the motor can be seen as a resistor and inductor in series. Therefore, the voltage across the motor can be written as:

V=IR+LdIdt+kemfωV = IR + L\frac{dI}{dt} + k_{emf}\omega

where II is the current flowing through the motor winding, RR is the resistance of the motor winding, LL is the inductance of the motor winding, kemfk_{emf} is the back-EMF coefficient, and ω\omega is the rotation speed.

Note

The resistance here is not the winding resistance. It is the equivalent resistance we get after performing the Clarke and Park transformation. Same applies for the inductance.

Since we are focusing on low-rpm scenario, the back-EMF term can be ignored, simplifying the equation to be:

V=IR+LdIdtV = IR + L\frac{dI}{dt}

Performing Laplace transform to the equation, we get:

V(s)=I(s)R+LsI(s)LI(0)V(s) = I(s)R + LsI(s) - LI(0)

We can assume the initial condition to be I(0)=0I(0) = 0, hence getting:

V(s)=I(s)R+LsI(s)V(s) = I(s)R + LsI(s)

As a result, the transfer function of the motor is:

M(s)=I(s)V(s)=1R+Ls=1R1+LRsM(s) = \frac{I(s)}{V(s)} = \frac{1}{R + Ls} = \frac{\frac{1}{R}}{1 + \frac{L}{R}s}

PI Controllers

There are two configurations of PI controller, the parallel configuration (the most common one) and the series configuration.

Parallel PI Controller

For parallel configuration, we have

c(t)=kpe(t)+kie(t)dtC(s)=kp+kis=kps+kis\begin{aligned} c(t) &= k_p e(t) + k_i \int e(t) dt \\ C(s) &= k_p + \frac{k_i}{s} = \frac{k_p s + k_i}{s} \end{aligned}

Serial PI Controller

For series configuration, we have

c(t)=kpe(t)+kpkie(t)dtC(s)=kp(1+kis)=kps+kpkis\begin{aligned} c(t) &= k_p' e(t) + k_p' k_i' \int e(t) dt \\ C(s) &= k_p' (1 + \frac{k_i}{s}) = \frac{k_p's + k_p'k_i'}{s} \end{aligned}

Since the subsequent calculations are more straightforward with a series PI controller, we will adopt this configuration.

Example C implementation of the serial PI controller

float kp, ki;
float target, measured;
float limit;  // integrator anti-windup value
float dt;     // loop execution time
float integrator;

float error = target - measured;
integrator = clampf(integrator + kp * ki * error * dt, -limit, limit);
float result = kp * error + integrator;

System Model

For open loop control, we have the transfer function as:

Gopen(s)=M(s)C(s)=1R1+LRskps+kpkis=1R1+LRskpkiski+1s\begin{aligned} G_{open}(s) &= M(s)C(s) \\ &= \frac{\frac{1}{R}}{1 + \frac{L}{R}s} \frac{k_p's + k_p'k_i'}{s} \\ &= \frac{\frac{1}{R}}{1 + \frac{L}{R}s} k_p'k_i' \frac{\frac{s}{k_i'} + 1}{s} \end{aligned}

In order to simplify the equation, we want

1+LRs=ski+11 + \frac{L}{R}s = \frac{s}{k_i'} + 1

which means

ki=RLk_i' = \frac{R}{L}

Setting ki=RLk_i' = \frac{R}{L}, we can simplify the equation as

Gopen(s)=kpki1RsG_{open}(s) = k_p'k_i' \frac{\frac{1}{R}}{s}

For closed-loop feedback control, we have the transfer function as

Gclosed(s)=Gopen(s)1+Gopen(s)G_{closed}(s) = \frac{G_{open}(s)}{1 + G_{open}(s)}

Therefore,

Gclosed=kpki1Rs1+kpki1RsG_{closed} = \frac{k_p'k_i' \frac{\frac{1}{R}}{s}}{1 + k_p'k_i' \frac{\frac{1}{R}}{s}}

Substituting ki=RLk_i' = \frac{R}{L}, into the equation, we get:

Gclosed=kpRL1Rs1+kpRL1Rs=kp1Ls+kp1L=1skpL+1G_{closed} = \frac{k_p'\frac{R}{L} \frac{\frac{1}{R}}{s}}{1 + k_p'\frac{R}{L} \frac{\frac{1}{R}}{s}} = \frac{k_p' \frac{1}{L}}{s + k_p '\frac{1}{L}} = \frac{1}{\frac{s}{\frac{k_p'}{L}} + 1}

The coefficient kpL\frac{k_p'}{L} determines the frequency where the system response decreases by 3dB, or, the response cutoff bandwidth ω. The unit is rad / s.

In other words, we have

kp=Lωcutoffk_p' = L * \omega_{cutoff}
ωcutoff=kpL\omega_{cutoff} = \frac{k_p'}{L}

with ω=2πf\omega = 2\pi f,

fcutoff=12πkpLf_{cutoff} = \frac{1}{2\pi}\frac{k_p'}{L}

Usually in practice, we want to ensure that the current bandwidth is less than 10% of the switching frequency, i.e. 20% of the Nyquist rate.

{kp=2πfsampleLki=RL\begin{cases} k_{p}' = 2\pi f_{sample} L \\ k_i' = \frac{R}{L} \end{cases}

For example, if the switching frequency is 20kHz, the maximum bandwidth would be 2kHz.

{kp,2kHz=2πL2103ki=RL\begin{cases} k_{p, 2kHz}' = 2 \pi L * 2*10^3 \\ k_i' = \frac{R}{L} \end{cases}

Reference: Digital PI Controller Equations

6. Torque Control

Usually, we want to control the motor's output torque, instead of the current. Therefore, we must establish the relation between current IqI_q and the output torque τ\tau.

The torque is proportional to the phase current, with a factor of motor torque constant KτK_\tau.

τ=Kτ×Iphase\tau = K_\tau \times I_{phase}

However, for the drone BLDC motors, vendors typically only provide the KV rating, representing the revolution per minute per volt applied between the motor phases. A typical measurement process of this KV value is to rotate the motor at a specific rotation speed and measure the peak-to-peak voltage difference between two phases. Hence, this KV value equals to the line-to-line back EMF voltage of the motor.

To convert the KV rating to motor torque constant, two caveats need to be paied attention for. The first thing is the unit conversion. KV is given in revolution per minute. To convert it to the SI unit radius per second per volt, we need to use KV,SI=2π60KVK_{V,SI} = \frac{2\pi}{60}K_V.

Another aspect is that the measurement of KV is done between two phases of the motor, which the reference frame is different from the DQ frame the PI controller are situated at. To convert it to the correct DQ frame, the following equation establishes:

Kτ=12KV,SI=122π60KV0.0740KVK_\tau = \frac{1}{\sqrt{2}} K_{V,SI} = \frac{1}{\sqrt{2}}\frac{2\pi}{60} K_V \approx 0.0740 K_{V}

7. Position Loop

Similar to current control loop, we can build a PD controller to regulate the rotor position by controlling the target torque.

8. Conclusion

As a result, we get the following motor controller block diagram.

We can inject user control targets at different stage to achieve control of each quantity (e.g. position, velocity, torque, current, or voltage control).

Last updated