From 4b0b00c8da5eb193bb157d42e788da9586ed5ba7 Mon Sep 17 00:00:00 2001 From: studiodyne <42887851+studiodyne@users.noreply.github.com> Date: Fri, 20 Oct 2023 03:23:23 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Tool=20Migration-specific=20setting?= =?UTF-8?q?s=20(#26244)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 17 ++++++++ Marlin/src/inc/Conditionals_adv.h | 18 ++++++++ Marlin/src/module/tool_change.cpp | 68 ++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 23 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 4d6ed12e99..2219592a8b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2780,7 +2780,21 @@ * - Switch to a different nozzle on an extruder jam */ #define TOOLCHANGE_MIGRATION_FEATURE + #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) + // Override toolchange settings + // By default tool migration uses regular toolchange settings. + // With a prime tower, tool-change swapping/priming occur inside the bed. + // When migrating to a new unprimed tool you can set override values below. + //#define MIGRATION_ZRAISE 0 // (mm) + // Longer prime to clean out + //#define MIGRATION_FS_EXTRA_PRIME 0 // (mm) Extra priming length + //#define MIGRATION_FS_WIPE_RETRACT 0 // (mm) Retract before cooling for less stringing, better wipe, etc. + + // Cool after prime to reduce stringing + //#define MIGRATION_FS_FAN_SPEED 255 // 0-255 + //#define MIGRATION_FS_FAN_TIME 0 // (seconds) + #endif #endif /** @@ -2793,6 +2807,9 @@ #define TOOLCHANGE_PARK_XY_FEEDRATE 6000 // (mm/min) //#define TOOLCHANGE_PARK_X_ONLY // X axis only move //#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move + #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) + //#define TOOLCHANGE_MIGRATION_DO_PARK // Force park (or no-park) on migration + #endif #endif #endif // HAS_MULTI_EXTRUDER diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 25050d972f..5e3f86919a 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1275,6 +1275,24 @@ #undef TC_GCODE_USE_GLOBAL_Z #endif +// TOOLCHANGE_MIGRATION_FEATURE - Clean up after sloppy auto config +#if DISABLED(TOOLCHANGE_MIGRATION_FEATURE) + #undef MIGRATION_ZRAISE + #undef MIGRATION_FS_EXTRA_PRIME + #undef MIGRATION_FS_WIPE_RETRACT + #undef MIGRATION_FS_FAN_SPEED + #undef MIGRATION_FS_FAN_TIME + #undef TOOLCHANGE_MIGRATION_DO_PARK +#endif +// TOOLCHANGE_PARK - Clean up after sloppy auto config +#if DISABLED(TOOLCHANGE_PARK) + #undef TOOLCHANGE_PARK_XY + #undef TOOLCHANGE_PARK_XY_FEEDRATE + #undef TOOLCHANGE_PARK_X_ONLY + #undef TOOLCHANGE_PARK_Y_ONLY + #undef TOOLCHANGE_MIGRATION_DO_PARK +#endif + // Multi-Stepping Limit #ifndef MULTISTEPPING_LIMIT #define MULTISTEPPING_LIMIT 128 diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index b33b642966..22982fa91a 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -34,9 +34,6 @@ //#define DEBUG_TOOL_CHANGE //#define DEBUG_TOOLCHANGE_FILAMENT_SWAP -#define DEBUG_OUT ENABLED(DEBUG_TOOL_CHANGE) -#include "../core/debug_out.h" - #if HAS_MULTI_EXTRUDER toolchange_settings_t toolchange_settings; // Initialized by settings.load() #endif @@ -154,6 +151,9 @@ void _line_to_current(const AxisEnum fr_axis, const float fscale=1) { void slow_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.2f); } void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.5f); } +#define DEBUG_OUT ENABLED(DEBUG_TOOL_CHANGE) +#include "../core/debug_out.h" + #if ENABLED(MAGNETIC_PARKING_EXTRUDER) float parkingposx[2], // M951 R L @@ -895,11 +895,8 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. */ #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - #ifdef DEBUG_TOOLCHANGE_FILAMENT_SWAP - #define FS_DEBUG(V...) SERIAL_ECHOLNPGM("DEBUG: " V) - #else - #define FS_DEBUG(...) NOOP - #endif + #define DEBUG_OUT ENABLED(DEBUG_TOOLCHANGE_FILAMENT_SWAP) + #include "../core/debug_out.h" // Define any variables required static Flags extruder_was_primed; // Extruders primed status @@ -941,12 +938,11 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. */ void extruder_cutting_recover(const_float_t e) { if (too_cold(active_extruder)) return; - const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract; - FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s"); + DEBUG_ECHOLNPGM("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s"); unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed)); - FS_DEBUG("Set E position: ", e); + DEBUG_ECHOLNPGM("Set E position: ", e); current_position.e = e; sync_plan_position_e(); // Resume new E Position } @@ -961,7 +957,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. */ void extruder_prime() { if (too_cold(active_extruder)) { - FS_DEBUG("Priming Aborted - Nozzle Too Cold!"); + DEBUG_ECHOLNPGM("Priming Aborted - Nozzle Too Cold!"); return; // Extruder too cold to prime } @@ -978,7 +974,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. extruder_did_first_prime.set(active_extruder); // Log first prime complete // new nozzle - prime at user-specified speed. const feedRate_t prime_mm_s = MMM_TO_MMS(toolchange_settings.prime_speed); - FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", fr_mm_s, " to ", prime_mm_s, "mm/s"); + DEBUG_ECHOLNPGM("First time priming T", active_extruder, ", reducing speed from ", fr_mm_s, " to ", prime_mm_s, "mm/s"); fr_mm_s = prime_mm_s; unscaled_e_move(0, fr_mm_s); // Init planner with 0 length move } @@ -988,11 +984,11 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. if (toolchange_settings.extra_prime >= 0) { // Positive extra_prime value // - Return filament at speed (fr_mm_s) then extra_prime at prime speed - FS_DEBUG("Loading Filament for T", active_extruder, " | Distance: ", toolchange_settings.swap_length, " | Speed: ", fr_mm_s, "mm/s"); + DEBUG_ECHOLNPGM("Loading Filament for T", active_extruder, " | Distance: ", toolchange_settings.swap_length, " | Speed: ", fr_mm_s, "mm/s"); unscaled_e_move(toolchange_settings.swap_length, fr_mm_s); // Prime (Unretract) filament by extruding equal to Swap Length (Unretract) if (toolchange_settings.extra_prime > 0) { - FS_DEBUG("Performing Extra Priming for T", active_extruder, " | Distance: ", toolchange_settings.extra_prime, " | Speed: ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s"); + DEBUG_ECHOLNPGM("Performing Extra Priming for T", active_extruder, " | Distance: ", toolchange_settings.extra_prime, " | Speed: ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s"); unscaled_e_move(toolchange_settings.extra_prime, MMM_TO_MMS(toolchange_settings.prime_speed)); // Extra Prime Distance } } @@ -1000,8 +996,8 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. // Negative extra_prime value // - Unretract distance (swap length) is reduced by the value of extra_prime const float eswap = toolchange_settings.swap_length + toolchange_settings.extra_prime; - FS_DEBUG("Negative ExtraPrime value - Swap Return Length has been reduced from ", toolchange_settings.swap_length, " to ", eswap); - FS_DEBUG("Loading Filament for T", active_extruder, " | Distance: ", eswap, " | Speed: ", fr_mm_s, "mm/s"); + DEBUG_ECHOLNPGM("Negative ExtraPrime value - Swap Return Length has been reduced from ", toolchange_settings.swap_length, " to ", eswap); + DEBUG_ECHOLNPGM("Loading Filament for T", active_extruder, " | Distance: ", eswap, " | Speed: ", fr_mm_s, "mm/s"); unscaled_e_move(eswap, fr_mm_s); } @@ -1009,7 +1005,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. // Cutting retraction #if TOOLCHANGE_FS_WIPE_RETRACT - FS_DEBUG("Performing Cutting Retraction | Distance: ", -toolchange_settings.wipe_retract, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); + DEBUG_ECHOLNPGM("Performing Cutting Retraction | Distance: ", -toolchange_settings.wipe_retract, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); unscaled_e_move(-toolchange_settings.wipe_retract, MMM_TO_MMS(toolchange_settings.retract_speed)); #endif @@ -1027,7 +1023,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. */ void tool_change_prime() { - FS_DEBUG(">>> tool_change_prime()"); + DEBUG_SECTION(tcp, "tool_change_prime", true); if (!too_cold(active_extruder)) { destination = current_position; // Remember the old position @@ -1086,9 +1082,6 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. extruder_cutting_recover(destination.e); // Cutting recover } - - FS_DEBUG("<<< tool_change_prime"); - } #endif // TOOLCHANGE_FILAMENT_SWAP @@ -1203,7 +1196,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { else if (extruder_was_primed[old_tool]) { // Retract the old extruder if it was previously primed // To-Do: Should SingleNozzle always retract? - FS_DEBUG("Retracting Filament for T", old_tool, ". | Distance: ", toolchange_settings.swap_length, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); + DEBUG_ECHOLNPGM("Retracting Filament for T", old_tool, ". | Distance: ", toolchange_settings.swap_length, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); } } @@ -1567,6 +1560,34 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { // Migrate Linear Advance K factor to the new extruder TERN_(LIN_ADVANCE, planner.extruder_advance_K[active_extruder] = planner.extruder_advance_K[migration_extruder]); + // Temporary migration toolchange_settings restored on exit. i.e., before next tool_change(). + #if defined(MIGRATION_FS_EXTRA_PRIME) \ + || defined(MIGRATION_FS_WIPE_RETRACT) \ + || defined(MIGRATION_FS_FAN_SPEED) \ + || defined(MIGRATION_FS_FAN_TIME) \ + || defined(MIGRATION_ZRAISE) \ + || defined(TOOLCHANGE_MIGRATION_DO_PARK) + REMEMBER(tmp_mig_settings, toolchange_settings); + #ifdef MIGRATION_FS_EXTRA_PRIME + toolchange_settings.extra_prime = MIGRATION_FS_EXTRA_PRIME; + #endif + #ifdef MIGRATION_FS_WIPE_RETRACT + toolchange_settings.wipe_retract = MIGRATION_FS_WIPE_RETRACT; + #endif + #ifdef MIGRATION_FS_FAN_SPEED + toolchange_settings.fan_speed = MIGRATION_FS_FAN_SPEED; + #endif + #ifdef MIGRATION_FS_FAN_TIME + toolchange_settings.fan_time = MIGRATION_FS_FAN_TIME; + #endif + #ifdef MIGRATION_ZRAISE + toolchange_settings.z_raise = MIGRATION_ZRAISE; + #endif + #ifdef TOOLCHANGE_MIGRATION_DO_PARK + toolchange_settings.enable_park = ENABLED(TOOLCHANGE_MIGRATION_DO_PARK); + #endif + #endif + // Perform the tool change tool_change(migration_extruder); @@ -1586,6 +1607,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { planner.synchronize(); planner.set_e_position_mm(current_position.e); // New extruder primed and ready + DEBUG_ECHOLNPGM("Migration Complete"); return true; }