From ef61efbf704af5ca736e87905155fefedea8be83 Mon Sep 17 00:00:00 2001 From: Simen Svale Skogsrud Date: Fri, 11 Feb 2011 01:31:44 +0100 Subject: [PATCH] makes sure steppers cruise at exactly nominal rate to eliminate rounding errors. Possibly fixes the problem where some moves have a long tail of slow steps. (Untested) --- planner.c | 2 ++ stepper.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/planner.c b/planner.c index 8878390..7a5945f 100644 --- a/planner.c +++ b/planner.c @@ -18,6 +18,8 @@ along with Grbl. If not, see . */ +/* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ + /* Reasoning behind the mathematics in this module (in the key of 'Mathematica'): diff --git a/stepper.c b/stepper.c index 131aa0a..92091a5 100644 --- a/stepper.c +++ b/stepper.c @@ -19,8 +19,7 @@ */ /* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith - and Philipp Tiefenbacher. The ring buffer implementation gleaned from the wiring_serial library - by David A. Mellis */ + and Philipp Tiefenbacher. */ #include "stepper.h" #include "config.h" @@ -108,6 +107,12 @@ inline void trapezoid_generator_tick() { trapezoid_adjusted_rate -= current_block->rate_delta; } set_step_events_per_minute(trapezoid_adjusted_rate); + } else { + // Make sure we cruise at exactly nominal rate + if (trapezoid_adjusted_rate != current_block->nominal_rate) { + trapezoid_adjusted_rate = current_block->nominal_rate; + set_step_events_per_minute(trapezoid_adjusted_rate); + } } } }