Video:
I have to think about the full rotation counting, and if there aren’t some tricky edge cases around the 0-crossing.
If you always apply the correction just after reading the sensor, then I can’t see it should make a difference (I might of cause have overlooked something).
They way I organised the bins is such that the measured shaft angle determines the bin / correction to apply.
One could imagine that jumping to the next bin would change the offset such that in fact the corrected measurement would jump backward. (especially for a high resolution encoder).
This is equivalent to sensor noise and shouldn’t throw off the rotation counting algorithm.
The maximum difference in the bins are (with my encoder) is approximately 0.05 shaft degree (0.05 rad *180/pi/ 50 poles) equivalent to a resolution of 1/0.05 = 7200. So the backwards jump will happen with a 2^14 encoder (16384).
Still it should not be a problem.
Also I decided that it would be best to have a number of bins equal to the number of poles as the offset angle varies a lot with the electric angle… Using the same amount of poles made it easier to mean the results.