Skip to content

Commit

Permalink
Motor didn't stop at target in rare cases -> fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
luni64 committed May 5, 2019
1 parent b156c1b commit b216af7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/accelerators/LinStepAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b216af7

Please sign in to comment.