simplefoc / Arduino-FOC-drivers

Drivers and support code for SimpleFOC
https://docs.simplefoc.com/drivers_library
MIT License
146 stars 63 forks source link

Negate zero electrical angle if sensor direction is CCW #25

Closed SwapnilPande closed 1 year ago

SwapnilPande commented 1 year ago

Fix for #24.

When using the calibration method with the CalibratedSensor, the computed zero electrical angle is incorrect if the sensor direction is CCW. This is fixed by negating the computed zero electrical angle if the sensor is CCW (followed by normalizing it to 0-2*PI). After this change, calibrate in CalibratedSensor returns the same electrical angle as alignSensor in BLDCMotor for CW and CCW sensor directions.

runger1101001 commented 1 year ago

Now merged. Thanks so much for finding and solving this!