diff --git a/src/accelerators/LinStepAccelerator.h b/src/accelerators/LinStepAccelerator.h index 8edb824..4ca4342 100644 --- a/src/accelerators/LinStepAccelerator.h +++ b/src/accelerators/LinStepAccelerator.h @@ -55,7 +55,11 @@ int32_t LinStepAccelerator::updateSpeed(int32_t curPos) return v_tgt; //deceleration phase -------------------------------------- - return sqrtf(two_a * ((stepsDone < delta_tgt - 1) ? delta_tgt - stepsDone - 2 : 0) + v_min2); + if(stepsDone < delta_tgt) + return sqrtf(two_a * ((stepsDone < delta_tgt - 1) ? delta_tgt - stepsDone - 2 : 0) + v_min2); + + //we are done, make sure to return 0 to stop the step timer + return 0; } uint32_t LinStepAccelerator::initiateStopping(int32_t curPos)