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?