Skip to content

Commit

Permalink
refactor/fix loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dzid26 committed Nov 4, 2024
1 parent 40b87bb commit 748dce7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions firmware/src/BSP/calibration.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,18 @@ int8_t Estimate_motor_k_bemf() {
StepperCtrl_setCurrent(-MAX_CURRENT); //accelerate
delay_ms(300);
}

StepperCtrl_setCurrent(0);
for (int16_t i = 0; i < 10; ++i) {
int16_t i = 0;
while ((fastAbs(speed_slow) > base_speed * 9 / 10) && (i < 10)) {
++i;
delay_ms(100);
if (fastAbs(speed_slow) < base_speed * 9 / 10) {
break;
delay_ms(200);
}else{
// decay motor_k_bemf
motor_k_bemf = (int16_t)((int32_t)motor_k_bemf * 999 / 1000);
}
}
// decay motor_k_bemf
motor_k_bemf = (int16_t)((int32_t)motor_k_bemf * 999 / 1000);
}
delay_ms(200);
}


StepperCtrl_setMotionMode(STEPCTRL_OFF);
return motor_k_bemf;
}

0 comments on commit 748dce7

Please sign in to comment.