Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/common/base_classes/FOCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -954,4 +958,4 @@ int FOCMotor::absoluteZeroSearch() {
else { SIMPLEFOC_MOTOR_DEBUG("Success!"); }
}
return !sensor->needsSearch();
}
}