The VESC (Vedder Electronic Speed Controller) performs encoder calibration to align the mechanical position of the sensor with the electrical position of the motor’s magnetic field. This is critical for Field Oriented Control (FOC) to ensure the controller knows exactly when to fire each phase.
How the Calibration Works
Open-Loop Rotation: When you click "Detect Encoder," the VESC ignores the sensor at first. It applies a set amount of current to the motor phases to force the rotor to spin at a constant, slow speed (Open-Loop).
Mapping the Signal: As the motor spins, the VESC records the raw values coming from the encoder (whether it’s SPI, ABI, or Sin/Cos).
Calculating the Offset: The firmware compares the electrical angle (where the magnetic field is being pushed) to the mechanical angle (what the encoder reports). The difference between these two is the Encoder Offset.
Direction Check: It also determines if the encoder is "Inverted." If the encoder count increases while the motor is commanded to move in a positive electrical direction, it’s normal; otherwise, it marks it as inverted.
Key Parameters Obtained
Offset: The angular correction factor (usually in degrees).
Ratio/Counts: Confirms the pulses per revolution or the relationship between one mechanical turn and the number of motor pole pairs.
Inverted: A boolean (True/False) that ensures the software doesn't fight against the hardware direction.
Common Requirements for Success
No Load: The motor must spin freely. If there is a belt or gearbox attached, the "drag" can cause the rotor to lag behind the magnetic field, resulting in an inaccurate offset.
Sufficient Current: The "Calibration Current" must be high enough to overcome the motor's cogging torque, ensuring a smooth, steady rotation during the test.