From d5553f1830dfb662294eee18f2efb0799bb08754 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sun, 15 Mar 2020 19:29:18 -0400 Subject: [PATCH] Configurable SLOWDOWN divisor (#17171) --- Marlin/Configuration_adv.h | 6 +++++- Marlin/src/module/planner.cpp | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index bd22c3c53ba8..a52fccf5435d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -753,8 +753,12 @@ // Minimum time that a segment needs to take if the buffer is emptied #define DEFAULT_MINSEGMENTTIME 50000 // (ms) -// If defined the movements slow down when the look ahead buffer is only half full +// Slow down the machine if the look ahead buffer is (by default) half full. +// Increase the slowdown divisor for larger buffer sizes. #define SLOWDOWN +#if ENABLED(SLOWDOWN) + #define SLOWDOWN_DIVISOR 2 +#endif // Frequency limit // See nophead's blog for more info diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 74177490882f..3b2daf1812e9 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2041,7 +2041,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif #if ENABLED(SLOWDOWN) - if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) { + #ifndef SLOWDOWN_DIVISOR + #define SLOWDOWN_DIVISOR 2 + #endif + if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / (SLOWDOWN_DIVISOR) - 1)) { if (segment_time_us < settings.min_segment_time_us) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more. const uint32_t nst = segment_time_us + LROUND(2 * (settings.min_segment_time_us - segment_time_us) / moves_queued);