From c462c2d4114eabc83eb1bd2bf7c66715fac5c3e2 Mon Sep 17 00:00:00 2001 From: justvlade Date: Sun, 16 Jul 2023 13:40:12 +0300 Subject: [PATCH] Change runout computation algorithm This should be considered as a draft idea, as there are some ideological contradictions in changing fundamental idea of runout. And needs approving that it does not harm other runout algorithms. This needs proper discussion with its pros and cons. I guess there is a reason(was not able to learn it though), why initial code excludes retraction/unretraction movement (or at least tries to do so). Initial idea of fixing issue #26061 Unlike patch #26082 this idea have alternative to conservative view. Instead of trying to figure out which E move is retract and which not, we take into account any E move, as those are connected to physical filament movement. All in all forward and backward movement will compensate itself. Modern slicers often introduce new approach to retraction movement. For example Super Slicer allows to enable retraction wipe, which makes retraction during horizontal movement. Also there is an old idea of filament unretract compensation, when unretract is slightly larger then retract movement. Not all printer needed this fix, but if we ignore retract/unretract we will loose those compensation move as well. This idea was inspired LCD_SHOW_E_TOTAL function. I do not actually checked the code of filament summary feed calculation, but from user experience LCD_SHOW_E_TOTAL shows actual filament movement with retraction and unretraction, as it may become smaller while printing. And as I understand it is considered to be precise. --- Marlin/src/feature/runout.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index a001459e9d99..dd7445fab3b1 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -389,18 +389,26 @@ class FilamentSensorBase { } static void filament_present(const uint8_t extruder) { - mm_countdown.runout[extruder] = runout_distance_mm; + if (mm_countdown.runout[extruder]steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state - // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. + if (b->steps.e) { // execute calculation if there is any extruder movement + // there is no need to ignore retract/unretract movement as they compensate each other const uint8_t e = b->extruder; const int32_t steps = b->steps.e; const float mm = (b->direction_bits.e ? steps : -steps) * planner.mm_per_step[E_AXIS_N(e)];