# Field Oriented Control for Dummies

Through my recent research into creating a brushless gimbal controller, I’ve been exploring the technique of FOC, or field oriented control. Most of the existing literature on the internet assumes that you have taken courses in Electromagnetics, Motor Control, Control Theory, Complex Variables, and a bunch of other things. It’s true that FOC requires math, but I thought I’d take a crack at explaining the concept behind it. This is not a technical reference; for details on math/implementation/other stuff consult other material. If you find anything incorrect about this article, please email me at `kalyan@coderkalyan.com`.

FOC is a technique for controlling certain types of 3 phase brushless motors. In this case, I will be talking about 3 phase brushless DC (BLDC) motors that are common in hobby robotics and gimbals. The motivation for FOC comes from two (related) goals:

1. In certain applications, especially when motors need to be spun slowly, it’s important to minimize torque ripple. This essentially means that torque on the motor should as consistent as possible during a full rotation cycle of the motor, and the rotor should not “snap” or “lag” at any orientation compared to the stator. This ensures smooth and predictable motion.
2. Naturally, it’s nice to drive your motor as efficiently as possible. The most efficient way to drive a 3 phase motor is when all the energy applied to the phases in the stator (to create a magnetic field) directly cause a torque on the rotor.

FOC is in many ways similar to sinusoidal control. In fact, in many cases, the output waveforms are the same/similar. However, FOC’s differences come from how it approaches deriving these waveforms. Let me explain.

Motors work by inducing an electromagnetic field in the stator that attracts/repels the permanent magnet in the rotor, causing the rotor to rotate some fraction of a revolution. The poles in the stator are then commutated, switching the current so that the rotor turns again. This is repeated to create continuous motion.

FOC begins by noting the following: torque on the rotor is maximized (and therefore constant) when the magnetic fields in the stator and rotor are perpendicular. When this is the case, all of the force between the magnetic fields creates a torque on the rotor. This makes sense; recall from physics that torque is created by forces that act tangentially; radial force does not cause angular acceleration.

The question then becomes: how do we ensure that the torque on the rotor is maximized at all times? To do this, we need to know the current torque on the rotor. However, we have a problem: the voltages driven to the motor are 3 phase, in the frame of reference of the stator. To solve this, we apply a direct-quadrature-zero transformation. Basically, this is a two step mathematical process that converts the 3 voltages into something more useful for us. The first step is a Clarke transform. This converts the 3 phase currents into a 2D complex plane (alpha being the real part of the current, beta being the imaginary part) in terms of the rotor, instead of the stator. However, to complete this transformation, a second transform is applied: the Park transform. The results of the Park transform are still in a fixed frame of reference. The Park transform converts these two currents into a rotating frame of reference that rotates along with the rotor. The results are I_d and I_q, the direct and quadrature currents. In this way, we’ve neatly converted our currents being applied to the stator to the point of view of the rotor. The direct current acts radially, while the quadrature current acts tangentially.

To maximize the torque on the rotor, we want to apply all current tangentially. Thus, the target “direct current” value is 0, while the target “tangential current” varies depending on how fast or how far we want to spin the motor. This can now be trivially regulated using two PI controllers; set the direct current setpoint to 0 and the tangential current setpoint to whatever you want.

Now we have the quadrature and direct corrections (output of the PI controllers) to apply to the rotor to create a certain amount of torque, and make sure all the energy applied goes towards applying that torque. However, we still need to control the 3 phases of our motor. So now, we apply an inverse Park transform followed by an inverse Clarke transform, and we end up with the 3 phase current setpoints to apply, in terms of the fixed frame of reference of the stator. When this is applied to each of the phases correctly, we create a magnetic field in the rotor that is exactly perpendicular to the field in the stator, maximizing efficiency. Remember that this is guaranteed because we are regulating direct current to be 0, so that means there must be no parallel component between the stator and rotor magnetic field vectors. The strength/magnitude of the magnetic field vector affects how fast the motor should spin; this can be adjusted based on what you’re trying to achieve (i.e. RPM regulation).

The last step of creating setpoints for each phase can be replaced with a more energy efficient “Space vector PWM” technique; however, that deserves an article of its own.

It’s worth noting that in the case of sensored systems (motors with encoders, or the brushless gimbal controller I’m developing, which uses an inertial measurement unit) skip the first step of converting measured 3 phase currents to a direct current. Since sensored systems already know the angle of the rotor compared to the stator, this can be used directly as an input to the inverse Park/Clarke transforms.