From c98ff4cc2e8ed9461e65a37cba85c8470233ca4e Mon Sep 17 00:00:00 2001 From: Sonny Jeon Date: Fri, 7 Oct 2011 15:51:40 -0600 Subject: [PATCH] Forgot something! Comments on what the last change does. --- stepper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stepper.c b/stepper.c index f39be06..a520038 100644 --- a/stepper.c +++ b/stepper.c @@ -207,7 +207,10 @@ SIGNAL(TIMER1_COMPA_vect) if ( iterate_trapezoid_cycle_counter() ) { // NOTE: We will only reduce speed if the result will be > 0. This catches small // rounding errors that might leave steps hanging after the last trapezoid tick. - if (trapezoid_adjusted_rate > current_block->rate_delta) { + // The if statement performs a bit shift multiply by 2 to gauge when to begin + // adjusting the rate by half increments. Prevents the long slope at the end of + // deceleration issue that occurs in certain cases. + if ((trapezoid_adjusted_rate << 1) > current_block->rate_delta) { trapezoid_adjusted_rate -= current_block->rate_delta; } else { trapezoid_adjusted_rate >>= 1; // Bit shift divide by 2