Skip to content

Commit 61591fd

Browse files
🐛 Fix tool-change E prime (#26237)
Co-authored-by: Scott Lahteine <[email protected]>
1 parent e97d82f commit 61591fd

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

Marlin/src/module/tool_change.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -940,19 +940,20 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
940940
* sync_plan_position_e();
941941
*/
942942
void extruder_cutting_recover(const_float_t e) {
943-
if (!too_cold(active_extruder)) {
944-
const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract;
945-
FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s");
946-
unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed));
947-
planner.synchronize();
948-
FS_DEBUG("Set position to: ", e);
949-
current_position.e = e;
950-
sync_plan_position_e(); // Resume new E Position
951-
}
943+
if (too_cold(active_extruder)) return;
944+
945+
const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract;
946+
FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s");
947+
unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed));
948+
949+
FS_DEBUG("Set E position: ", e);
950+
current_position.e = e;
951+
sync_plan_position_e(); // Resume new E Position
952952
}
953953

954954
/**
955955
* Prime the currently selected extruder (Filament loading only)
956+
* Leave the E position unchanged so subsequent extrusion works properly.
956957
*
957958
* If too_cold(toolID) returns TRUE -> returns without moving extruder.
958959
* Extruders filament = swap_length + extra prime, then performs cutting retraction if enabled.
@@ -966,6 +967,8 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
966967

967968
feedRate_t fr_mm_s = MMM_TO_MMS(toolchange_settings.unretract_speed); // Set default speed for unretract
968969

970+
const float resume_current_e = current_position.e;
971+
969972
#if ENABLED(TOOLCHANGE_FS_SLOW_FIRST_PRIME)
970973
/**
971974
* Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime
@@ -1010,6 +1013,10 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
10101013
unscaled_e_move(-toolchange_settings.wipe_retract, MMM_TO_MMS(toolchange_settings.retract_speed));
10111014
#endif
10121015

1016+
// Leave E unchanged when priming
1017+
current_position.e = resume_current_e;
1018+
sync_plan_position_e();
1019+
10131020
// Cool down with fan
10141021
filament_swap_cooling();
10151022
}
@@ -1061,17 +1068,19 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
10611068
}
10621069
#endif
10631070

1071+
// Prime without changing E
10641072
extruder_prime();
10651073

10661074
// Move back
10671075
#if ENABLED(TOOLCHANGE_PARK)
10681076
if (ok) {
10691077
#if ENABLED(TOOLCHANGE_NO_RETURN)
1070-
const float temp = destination.z;
1071-
destination = current_position;
1072-
destination.z = temp;
1078+
destination.x = current_position.x;
1079+
destination.y = current_position.y;
10731080
#endif
1074-
prepare_internal_move_to_destination(TERN(TOOLCHANGE_NO_RETURN, planner.settings.max_feedrate_mm_s[Z_AXIS], MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE)));
1081+
do_blocking_move_to_xy(destination, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE));
1082+
do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
1083+
planner.synchronize();
10751084
}
10761085
#endif
10771086

0 commit comments

Comments
 (0)