BLDC alignment of hall sensors and encoder

I am trying to build a BLDC motor controller using field oriented control. The motor I am going to use is equipped with hall sensors as well as with an incremental encoder that has 512 steps. I have implemented a SVPWM and the Clarke and Park transformations. However I encounter one problem. For correct commutation, the field oriented control needs to know the rotor position. However, at startup, the encoder does not give a correct position, because it is just an incremental encoder. On the other hand, if I use the hall sensors for startup, the rotor angle may be wrong up to 30 degrees, so I wonder what possibilities there are to properly align the encoder counts with the actual rotor position. One approach could be to force one voltage vector, wait until the motor has moved to that position and then initialise the encoder counter to that position. But this has the disadvantage that the motor needs to move shortly for the initialisation.

What are better options to initialise the encoder?

Further, the encoder gives the mechanical position. I assume, for the field oriented control, the electrical position is required, so I need to know the electrical position. How should I convert the encoder posotion (mechanical! 0 to 511 counts for 360°) to the electrical angle? just multiply with the number of poles? don't I lose some resolution of the encoder by doing that?

• "But this has the disadvantage that the motor needs to move shortly for the initialisation." - if that is a problem then you need a better encoder. But why is it a problem? Commented Sep 19, 2021 at 2:44

Motor controllers implement typically a "commutation phase" upon power-up. That is - blindly applying gradual and small coil current and establishing the angle. You may do it by moving between two electrical vector angles - applying gradually rising current to coil "A" while you observe the encoder moving (until you reach the steady position or your conservative current limit) and repeating for an adjacent coil "B". That way you can split the difference caused by mechanical friction. Then you establish your base angle and reset your incremental encoder coordinates accordingly.

The caveat here is that this may be done only when the system can tolerate some (small but random) move at the power up when you are aligning your phase.

There are many more sophisticated implementations but this seems to be the common principle.

• thanks, this method is simple and does work. However it seems unsuitable to me if an initial rotor movement is not possible or not allowed. So what other methods are there that are possible to implement? I will be using a STM32 microcontroller, so no really sophisticated, fancy, ultra-high speed DSP performance is available. Commented Sep 19, 2021 at 15:33

Two ways.

1 - use hall sensors to start motion, switch to encoder commutation as soon as you detect halls switching to next position. It's very accurate, unless you are using poor quality (in which case hall sensors wouldn't work at all).

2 - use current to move the rotor into a known position. then you can work without halls, but there are lots of nuances - friction, end of motion, current limits, etc.

Most BLDC motors have slight asymmetries in the rotor. The rotor has slightly variable reluctance relative to its position against the stator. Enough so that you can apply a sine wave to one winding and measure the current in other windings while applying a resistive load to them. This can be done for each winding. Do it at several frequencies and you can train a neural network that will give you an angle back based on the measured complex current.