From fb5f09da6d365cb03db7abc01b18532740db3e6b Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Thu, 16 Jul 2020 17:47:48 +0200 Subject: [PATCH] Fix incorrect precedence for retraction phase The logic was inverted, causing the fastest isr to always retract instead of counter-balance the acceleration properly. --- Firmware/stepper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index 80c5be29..c5a6b69c 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -883,13 +883,13 @@ FORCE_INLINE void isr() { advance_spread(main_Rate); if (LA_phase >= 0) { if (step_loops == e_step_loops) - LA_phase = (current_block->advance_rate > main_Rate); + LA_phase = (current_block->advance_rate < main_Rate); else { // avoid overflow through division. warning: we need to _guarantee_ step_loops // and e_step_loops are <= 4 due to fastdiv's limit auto adv_rate_n = fastdiv(current_block->advance_rate, step_loops); auto main_rate_n = fastdiv(main_Rate, e_step_loops); - LA_phase = (adv_rate_n > main_rate_n); + LA_phase = (adv_rate_n < main_rate_n); } } }