I’m trying to understand FOC on BLDC motors and I’m hitting a roadblock.

Suppose I take a 3 phase BLDC with concentrated field windings. If I run a constant DC current through one of the coils, I will get a square wave shape magnetic field spatially around the air gap - not a sinusoid. The same story holds for the other two coils, but with electrical angle offset of 2PI/3 and 4PI/3 respectively.

Consider if I run the same current through coils A (blue) and B (yellow) independently and try to determine the net field using phasors.

This diagram would suggest that the net field would be the gray curve, which is the blue curve shifted by a PI/3 phase.

However, the net magnetic field generated by the stator will be the sum of the individual waves pictured and actually looks like this.

So the sum of phasors (gray) does not represent the sum of the fields (blue and yellow) when the waves are square. In fact, it’s unclear what quantity the phasor sum is supposed to mean. But the point of FOC is to arrange the state of the currents so that the sum of the phasors has a certain angle, under the assumption that the phasor sum represents the underlying field. Am I missing something?

I have done some further research on this subject. In FOC for BLDCs, your drive currents are still sinusoidal which means the phasor math works out. However, the trapezoidal back emf introduces harmonics into the torque production, which leads to torque ripple.

This ripple can be partially suppressed by introducing countering harmonics in the drive current.

Source: H. Le-Huy, R. Perret, and R. Feuillet. Minimization of Torque Ripple in Brushless DC Motor Drives

Yes, first thing to consider is that the magnetic field is created by the current not by the voltages. The currents have a certain dynamics and are not changed instantaneously and that is the behavior we are exploiting by using the PWM signal. PWM is square wave at the very high frequency, since the current cannot follow such a high frequency waves it will essentially follow the average value of the pwm signal.
Here is a simple figure.

On the image you can see that even though we have a square wave we still can control the magnitude of the current in the continuous space.

There is also a type of control of BLDC motors that is called six-step control and it basically uses the square waves, not the PWM. It is very similar to what you have shown in the picture of the coil A and B but the idea with it is that the coil A and coil B magnetic fields do not overlap. This type of control has good behavior only on high velocities where the current becomes almost sinusoidal due to the high rate of change in between 6 steps.

Yes, sinusoidal modulation for the BLDC motors does not exactly match the hardware. BLDC’s windings are made in a way to have trapezoidal back emf signal. So in that sense probably it would be the best to use trapezoidal currents not sinusoidal. But in many cases this behavior can be neglected, especially for velocity/position controlled smaller motors.

In the SimpleFOClibrary I implemented two types of FOC modulation standard sinusoidal and the space vector pwm modulation which takes the 1st and 3rd harmonic.

Here are the phase voltage waveforms generated by the modulation approaches for the Uq = 0.5.
The modulation type you can change by during the motor setup:

// default modulation is SinePWM
motor.foc_modulation = FOCModulationType::SinePWM;
// or
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;

Each motor and the application is different and you can see for yourself which modulation type works better in your case.