Skip to content

Commit af78d0c

Browse files
daidSTB3
authored andcommitted
Merge pull request #1 from illuminarti/Fix_E_Speed
Fix step rate bug (especially for retraction)
1 parent 9a78f32 commit af78d0c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Marlin/stepper.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static long acceleration_time, deceleration_time;
6262
static unsigned short acc_step_rate; // needed for deccelaration start point
6363
static char step_loops;
6464
static unsigned short OCR1A_nominal;
65+
static unsigned short step_loops_nominal;
6566

6667
volatile long endstops_trigsteps[3]={0,0,0};
6768
volatile long endstops_stepsTotal,endstops_stepsDone;
@@ -288,6 +289,8 @@ FORCE_INLINE void trapezoid_generator_reset() {
288289
deceleration_time = 0;
289290
// step_rate to timer interval
290291
OCR1A_nominal = calc_timer(current_block->nominal_rate);
292+
// make a note of the number of step loops required at nominal speed
293+
step_loops_nominal = step_loops;
291294
acc_step_rate = current_block->initial_rate;
292295
acceleration_time = calc_timer(acc_step_rate);
293296
OCR1A = acceleration_time;
@@ -665,6 +668,8 @@ ISR(TIMER1_COMPA_vect)
665668
}
666669
else {
667670
OCR1A = OCR1A_nominal;
671+
// ensure we're running at the correct step rate, even if we just came off an acceleration
672+
step_loops = step_loops_nominal;
668673
}
669674

670675
// If current block is finished, reset pointer

0 commit comments

Comments
 (0)