Skip to content

Commit

Permalink
Change runout computation algorithm
Browse files Browse the repository at this point in the history
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 MarlinFirmware#26061

Unlike patch MarlinFirmware#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.
  • Loading branch information
justvlade authored Jul 16, 2023
1 parent 810c169 commit c462c2d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Marlin/src/feature/runout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]<runout_distance_mm) {
// reset runout only if it is smaller than runout_distance
// on bowden systems retract may be larger than runout_distance_mm, so if retract was added,
// we should leave it in place, so unretract will not cause runout event
mm_countdown.runout[extruder] = runout_distance_mm;
}
}

#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
static void filament_motion_present(const uint8_t extruder) {
mm_countdown.motion[extruder] = runout_distance_mm;
if (mm_countdown.motion[extruder]<runout_distance_mm) {
// same logic as filament_present function
mm_countdown.motion[extruder] = runout_distance_mm;
}
}
#endif

static void block_completed(const block_t * const b) {
if (b->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)];
Expand Down

0 comments on commit c462c2d

Please sign in to comment.