Add volumetric extrusion limit (#17017)

This commit is contained in:
MoellerDi
2020-06-08 10:24:46 +02:00
committed by GitHub
parent 8994cc8b26
commit bac760207c
9 changed files with 176 additions and 25 deletions

View File

@ -171,6 +171,11 @@ float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step
Planner::volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
#endif
#if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT)
float Planner::volumetric_extruder_limit[EXTRUDERS], // max mm^3/sec the extruder is able to handle
Planner::volumetric_extruder_feedrate_limit[EXTRUDERS]; // pre calculated extruder feedrate limit based on volumetric_extruder_limit; pre-calculated to reduce computation in the planner
#endif
#if HAS_LEVELING
bool Planner::leveling_active = false; // Flag that auto bed leveling is enabled
#if ABL_PLANAR
@ -1407,10 +1412,28 @@ void Planner::check_axes_activity() {
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
refresh_e_factor(i);
}
#if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT)
calculate_volumetric_extruder_limits(); // update volumetric_extruder_limits as well.
#endif
}
#endif // !NO_VOLUMETRICS
#if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT)
/**
* Convert volumetric based limits into pre calculated extruder feedrate limits.
*/
void Planner::calculate_volumetric_extruder_limit(const uint8_t e) {
const float &lim = volumetric_extruder_limit[e], &siz = filament_size[e];
volumetric_extruder_feedrate_limit[e] = (lim && siz) ? lim / CIRCLE_AREA(siz * 0.5f) : 0;
}
void Planner::calculate_volumetric_extruder_limits() {
LOOP_L_N(e, EXTRUDERS) calculate_volumetric_extruder_limit(e);
}
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
/**
* Convert the ratio value given by the filament width sensor
@ -2077,10 +2100,33 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
if (mixer.get_current_vtool() == MIXER_AUTORETRACT_TOOL)
current_speed.e *= MIXING_STEPPERS;
#endif
const feedRate_t cs = ABS(current_speed.e),
max_fr = settings.max_feedrate_mm_s[E_AXIS_N(extruder)]
* TERN(HAS_MIXER_SYNC_CHANNEL, MIXING_STEPPERS, 1);
if (cs > max_fr) NOMORE(speed_factor, max_fr / cs);
if (cs > max_fr) NOMORE(speed_factor, max_fr / cs); //respect max feedrate on any movement (doesn't matter if E axes only or not)
#if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT)
const feedRate_t max_vfr = volumetric_extruder_feedrate_limit[extruder]
* TERN(HAS_MIXER_SYNC_CHANNEL, MIXING_STEPPERS, 1);
// TODO: Doesn't work properly for joined segments. Set MIN_STEPS_PER_SEGMENT 1 as workaround.
if (block->steps.a || block->steps.b || block->steps.c) {
if (max_vfr > 0 && cs > max_vfr) {
NOMORE(speed_factor, max_vfr / cs); // respect volumetric extruder limit (if any)
/* <-- add a slash to enable
SERIAL_ECHOPAIR("volumetric extruder limit enforced: ", (cs * CIRCLE_AREA(filament_size[extruder] * 0.5f)));
SERIAL_ECHOPAIR(" mm^3/s (", cs);
SERIAL_ECHOPAIR(" mm/s) limited to ", (max_vfr * CIRCLE_AREA(filament_size[extruder] * 0.5f)));
SERIAL_ECHOPAIR(" mm^3/s (", max_vfr);
SERIAL_ECHOLNPGM(" mm/s)");
//*/
}
}
#endif
}
#endif