Skip to content

Commit b216af7

Browse files
committed
Motor didn't stop at target in rare cases -> fixed
1 parent b156c1b commit b216af7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/accelerators/LinStepAccelerator.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ int32_t LinStepAccelerator::updateSpeed(int32_t curPos)
5555
return v_tgt;
5656

5757
//deceleration phase --------------------------------------
58-
return sqrtf(two_a * ((stepsDone < delta_tgt - 1) ? delta_tgt - stepsDone - 2 : 0) + v_min2);
58+
if(stepsDone < delta_tgt)
59+
return sqrtf(two_a * ((stepsDone < delta_tgt - 1) ? delta_tgt - stepsDone - 2 : 0) + v_min2);
60+
61+
//we are done, make sure to return 0 to stop the step timer
62+
return 0;
5963
}
6064

6165
uint32_t LinStepAccelerator::initiateStopping(int32_t curPos)

0 commit comments

Comments
 (0)