From 6919e876561eb2729419212e7887b6d34748bc93 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 28 May 2018 17:39:23 -0500 Subject: [PATCH] Minor cleanup of multi-stepping logic --- Marlin/src/feature/pause.cpp | 2 +- Marlin/src/module/stepper.h | 38 ++++++++++++------------------------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index fa06193ab..d2188c7c7 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -533,7 +533,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le // Move XY to starting position, then Z do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], NOZZLE_PARK_XY_FEEDRATE); - // Set Z_AXIS to saved position + // Move Z_AXIS to saved position do_blocking_move_to_z(resume_position[Z_AXIS], NOZZLE_PARK_Z_FEEDRATE); // Now all extrusion positions are resumed and ready to be confirmed diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index d10b8c32e..19c9d4b9b 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -267,41 +267,28 @@ class Stepper { // Set direction bits for all steppers static void set_directions(); + // Limit the speed to 10KHz for AVR + #ifndef STEP_DOUBLER_FREQUENCY + #define STEP_DOUBLER_FREQUENCY 10000 + #endif + FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate) { uint32_t timer; NOMORE(step_rate, uint32_t(MAX_STEP_FREQUENCY)); - // TODO: HAL: tidy this up, use Conditionals_post.h - #ifdef CPU_32_BIT - #if ENABLED(DISABLE_MULTI_STEPPING) - step_loops = 1; - #else - if (step_rate > STEP_DOUBLER_FREQUENCY * 2) { // If steprate > (STEP_DOUBLER_FREQUENCY * 2) kHz >> step 4 times - step_rate >>= 2; - step_loops = 4; - } - else if (step_rate > STEP_DOUBLER_FREQUENCY) { // If steprate > STEP_DOUBLER_FREQUENCY kHz >> step 2 times - step_rate >>= 1; - step_loops = 2; - } - else { - step_loops = 1; - } - #endif - #else - if (step_rate > 20000) { // If steprate > 20kHz >> step 4 times + #if DISABLED(DISABLE_MULTI_STEPPING) + if (step_rate > STEP_DOUBLER_FREQUENCY * 2) { // If steprate > (STEP_DOUBLER_FREQUENCY * 2) kHz >> step 4 times step_rate >>= 2; step_loops = 4; } - else if (step_rate > 10000) { // If steprate > 10kHz >> step 2 times + else if (step_rate > STEP_DOUBLER_FREQUENCY) { // If steprate > STEP_DOUBLER_FREQUENCY kHz >> step 2 times step_rate >>= 1; step_loops = 2; } - else { - step_loops = 1; - } + else #endif + step_loops = 1; #ifdef CPU_32_BIT // In case of high-performance processor, it is able to calculate in real-time @@ -309,8 +296,9 @@ class Stepper { timer = uint32_t(HAL_STEPPER_TIMER_RATE) / step_rate; NOLESS(timer, min_time_per_step); // (STEP_DOUBLER_FREQUENCY * 2 kHz - this should never happen) #else - NOLESS(step_rate, uint32_t(F_CPU / 500000U)); - step_rate -= F_CPU / 500000; // Correct for minimal speed + constexpr uint32_t min_step_rate = F_CPU / 500000U; + NOLESS(step_rate, min_step_rate); + step_rate -= min_step_rate; // Correct for minimal speed if (step_rate >= (8 * 256)) { // higher step rate const uint8_t tmp_step_rate = (step_rate & 0x00FF); const uint16_t table_address = (uint16_t)&speed_lookuptable_fast[(uint8_t)(step_rate >> 8)][0],