From c54474f2db5cf9f04e0308c3c6694fff671a7d65 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Thu, 16 Jul 2020 13:26:15 +0200 Subject: [PATCH] Guard against planning/numerical errors in short segments Turns out for high-res curved models the numerical error and the SLOWDOWN handling in the planner can cause enough variance in the calculated pressure to trigger LA to continuosly, making matters worse. Clamp LA again, but only during extrusion, so that the runaway error is limited by the current segment length. --- Firmware/stepper.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index c5a6b69c..949ffd58 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -809,8 +809,11 @@ FORCE_INLINE void isr() { acceleration_time += timer; #ifdef LIN_ADVANCE if (current_block->use_advance_lead) { - if (step_events_completed.wide <= (unsigned long int)step_loops) + if (step_events_completed.wide <= (unsigned long int)step_loops) { la_state = ADV_INIT | ADV_ACC_VARY; + if (e_extruding && current_adv_steps > target_adv_steps) + target_adv_steps = current_adv_steps; + } } #endif } @@ -832,6 +835,8 @@ FORCE_INLINE void isr() { if (step_events_completed.wide <= (unsigned long int)current_block->decelerate_after + step_loops) { target_adv_steps = current_block->final_adv_steps; la_state = ADV_INIT | ADV_ACC_VARY; + if (e_extruding && current_adv_steps < target_adv_steps) + target_adv_steps = current_adv_steps; } } #endif @@ -849,6 +854,8 @@ FORCE_INLINE void isr() { // acceleration or deceleration can be skipped or joined with the previous block. // If LA was not previously active, re-check the pressure level la_state = ADV_INIT; + if (e_extruding) + target_adv_steps = current_adv_steps; } #endif }