From af78d0cbfae1dbf2c5d37a363603d3411a8c02e0 Mon Sep 17 00:00:00 2001 From: daid Date: Fri, 15 Mar 2013 01:03:53 -0700 Subject: [PATCH] Merge pull request #1 from illuminarti/Fix_E_Speed Fix step rate bug (especially for retraction) --- Marlin/stepper.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 4ed8bef40e..3bc5e9c892 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -62,6 +62,7 @@ static long acceleration_time, deceleration_time; static unsigned short acc_step_rate; // needed for deccelaration start point static char step_loops; static unsigned short OCR1A_nominal; +static unsigned short step_loops_nominal; volatile long endstops_trigsteps[3]={0,0,0}; volatile long endstops_stepsTotal,endstops_stepsDone; @@ -288,6 +289,8 @@ FORCE_INLINE void trapezoid_generator_reset() { deceleration_time = 0; // step_rate to timer interval OCR1A_nominal = calc_timer(current_block->nominal_rate); + // make a note of the number of step loops required at nominal speed + step_loops_nominal = step_loops; acc_step_rate = current_block->initial_rate; acceleration_time = calc_timer(acc_step_rate); OCR1A = acceleration_time; @@ -665,6 +668,8 @@ ISR(TIMER1_COMPA_vect) } else { OCR1A = OCR1A_nominal; + // ensure we're running at the correct step rate, even if we just came off an acceleration + step_loops = step_loops_nominal; } // If current block is finished, reset pointer