diff --git a/src/common/base_classes/FOCMotor.cpp b/src/common/base_classes/FOCMotor.cpp index a193229a..0cdccccc 100644 --- a/src/common/base_classes/FOCMotor.cpp +++ b/src/common/base_classes/FOCMotor.cpp @@ -937,11 +937,15 @@ int FOCMotor::absoluteZeroSearch() { velocity_limit = velocity_index_search; voltage_limit = voltage_sensor_align; shaft_angle = 0; - while(sensor->needsSearch() && shaft_angle < _2PI){ - angleOpenloop(1.5f*_2PI); + // calculting elctrical angle equivalent for a 1.5 mechanical rotation + float search_rotation_target = _electricalAngle(1.5f*_2PI, pole_pairs); + while(sensor->needsSearch() && shaft_angle < search_rotation_target){ + angleOpenloop(search_rotation_target); // call important for some sensors not to loose count // not needed for the search sensor->update(); + // set the voltage to the motor + setPhaseVoltage(voltage_limit, 0, shaft_angle); } // disable motor setPhaseVoltage(0, 0, 0); @@ -954,4 +958,4 @@ int FOCMotor::absoluteZeroSearch() { else { SIMPLEFOC_MOTOR_DEBUG("Success!"); } } return !sensor->needsSearch(); -} \ No newline at end of file +}