Skip to content

Commit 6ab97c8

Browse files
authored
Merge pull request #519 from F00LM1N4/dev
Fix for issue #518 absoluteZeroSearch not moving the motor to seek for the encoder zero
2 parents 0f5650f + 339164f commit 6ab97c8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/common/base_classes/FOCMotor.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,15 @@ int FOCMotor::absoluteZeroSearch() {
937937
velocity_limit = velocity_index_search;
938938
voltage_limit = voltage_sensor_align;
939939
shaft_angle = 0;
940-
while(sensor->needsSearch() && shaft_angle < _2PI){
941-
angleOpenloop(1.5f*_2PI);
940+
// calculting elctrical angle equivalent for a 1.5 mechanical rotation
941+
float search_rotation_target = _electricalAngle(1.5f*_2PI, pole_pairs);
942+
while(sensor->needsSearch() && shaft_angle < search_rotation_target){
943+
angleOpenloop(search_rotation_target);
942944
// call important for some sensors not to loose count
943945
// not needed for the search
944946
sensor->update();
947+
// set the voltage to the motor
948+
setPhaseVoltage(voltage_limit, 0, shaft_angle);
945949
}
946950
// disable motor
947951
setPhaseVoltage(0, 0, 0);
@@ -954,4 +958,4 @@ int FOCMotor::absoluteZeroSearch() {
954958
else { SIMPLEFOC_MOTOR_DEBUG("Success!"); }
955959
}
956960
return !sensor->needsSearch();
957-
}
961+
}

0 commit comments

Comments
 (0)