File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments