From 345fc41482098ef9f42988008a4b7ef4c08b186d Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 4 Nov 2016 22:43:50 -0400 Subject: [PATCH] extruder: Don't do pressure advance on velocity changes due to cornering Due to the lookahead, small changes in the direction of the toolhead cause minor changes in toolhead velocity. These "cornering" velocity changes cause the current extruder code to trigger pressure advance and its associated pressure retract. This causes the extruder to rapidly "jerk" the filament. This code change updates the extruder to detect velocity changes due solely to cornering and avoid pressure advance. Signed-off-by: Kevin O'Connor --- docs/Todo.md | 7 ------- klippy/extruder.py | 11 +++++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/Todo.md b/docs/Todo.md index 73b4cbc0..0f454d4c 100644 --- a/docs/Todo.md +++ b/docs/Todo.md @@ -150,13 +150,6 @@ Hardware features Misc features ============= -* The "pressure advance" algorithm does improve extruder - functionality. However, it's interaction with lookahead is not ideal - as it can cause rapid jerks of the filament when the head speed - changes briefly during cornering. Ideally, pressure advance would - interact better with lookahead to avoid advance during transient - speed changes. - * Possibly use cubic functions instead of quadratic functions in step compression code. diff --git a/klippy/extruder.py b/klippy/extruder.py index 4abbb7dd..12f43141 100644 --- a/klippy/extruder.py +++ b/klippy/extruder.py @@ -59,8 +59,15 @@ class PrinterExtruder: prev_pressure_d += extra_accel_d # Update decel and retract parameters when decelerating if decel_t: - npd = move.end_v * move_extrude_r * self.pressure_advance - extra_decel_d = prev_pressure_d - npd + if move.corner_min: + npd = move.corner_max*move_extrude_r * self.pressure_advance + extra_decel_d = prev_pressure_d - npd + if move.end_v > move.corner_min: + extra_decel_d *= ((move.cruise_v - move.end_v) + / (move.cruise_v - move.corner_min)) + else: + npd = move.end_v * move_extrude_r * self.pressure_advance + extra_decel_d = prev_pressure_d - npd if extra_decel_d > 0.: extra_decel_v = extra_decel_d / decel_t decel_v -= extra_decel_v