Skip to content

Commit 0622b9f

Browse files
committed
Using dedicated function to calculate the target electrical angle for searching the zero position on the encoder
1 parent ef22c4c commit 0622b9f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/common/base_classes/FOCMotor.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,9 @@ int FOCMotor::absoluteZeroSearch() {
938938
voltage_limit = voltage_sensor_align;
939939
shaft_angle = 0;
940940
// TODO: Try the dedicated method for converting mec and elec angles
941-
while(sensor->needsSearch() && shaft_angle < pole_pairs*_2PI){
942-
angleOpenloop(pole_pairs*1.5f*_2PI);
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);
943944
// call important for some sensors not to loose count
944945
// not needed for the search
945946
sensor->update();

0 commit comments

Comments
 (0)