Hall effect Sensor (skip calibration)

Sorry to bump this old thread but I have one doubt.
If I understand correctly, during sensor align, SimpleFOC is setting a particular electrical angle, and then measuring the electric angle from the sensor, which is a whole sector with hall sensors.

I have been trying to implement something different in the hoverboard foc firmware based on what I learned from other firmwares, and I was wondering if there would be interest in this feature for simpleFOC.

  • initialize ELECTRIC_SECTORS array with -1 values
  • run the motor in openloop angle mode, move to 360 and back
  • average the angle for each hall position ( VESC averages sin and cos of the angle as it’s more difficult to average an angle that wraps around). This should give the middle electric angle for each sector and also gives the right ELECTRIC_SECTORS table but with angles instead of the sector number. It works better then identifying the edges of the sectors because of the cogging. The angle that should be used is the middle angle -30 or +30 depending on the direction.

In the current ELECTRIC_SECTORS array, position 0 and 7 are impossible because we assume the hall sensors are 120 degrees apart. This is not true with a 60 degrees hall sensor configuration. So with this method the -1 values are on other hall positions that are impossible with the 60 degree configuration.

One additional check I was doing is making sure each hall sensor state is changing during the calibration. Like MIN state <> MAX state for each hall sensor, to identify hall sensors that are defective.