I am using an AS5147 Rotary Sensor to measure the position of a BLDC Motor. The motor is a 11 pole BLDC/PMSM. I have my own inverter circuit and right now doing a look up table based Space Vector PWM scheme to drive the motor.
For the sake of simplicity, lets assume the encoder gives me degrees (0-360, electrical not mechanical) and based on the measurement, i check my look up table (lets assume it also has 360 values, representing 1 cycle) and depending on the direction i want to drive, i get the duty cycles at the index [EncoderPosition +/- 90 ]. If i want to add a bit of field weakening, i add a few degrees.
This approach gives satisfactory results but what i described above is only valid if what I get from the rotary encoder is actually the rotor flux angle. As far as I've understood the encoder is not synchronized to the rotor flux and just gives me a measurement that has a constant offset to it.
Currently, i am finding this offset by just playing around and trying different values and this 1 SE post suggests that its not that important but for my current implementation that doesn't do current measurement, it really seems to affect the performance.
I tried to automate finding this offset by locking the motor to some position - with an arbitrary index from the look up table, take the measurement from the encoder and get the difference between them and use this as a software parameter. I was a bit lost with this approach since to my understanding, the look up table index represents the stator flux (that i generate) and the encoder measurement should represent (rotor flux + 180), since when the motor is locked, the rotor flux locks itself in the opposite direction of the stator flux. My idea was doing
Offset = (ChosenLookUpTableIndex + 180) - EncoderMeasurement
where (ChosenLookUpTableIndex + 180) is the rotor flux angle when the motor is locked.
I also had other problems such as different motor power cable orderings giving different offsets, some of them not even constant.
I would like to ask if there is a proper way to calculate this offset rather then experimenting with it.