Skip to content

Commit 7f54d6a

Browse files
authored
Merge pull request #3 from ansonl/bugfix-2.1.x-dondolo
Bugfix 2.1.x dondolo nozzle z offset fix
2 parents b8c96f2 + 2be5336 commit 7f54d6a

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

Marlin/src/module/tool_change.cpp

+41-17
Original file line numberDiff line numberDiff line change
@@ -940,13 +940,13 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
940940
* Cutting recovery -- Recover from cutting retraction that occurs at the end of nozzle priming
941941
*
942942
* If the active_extruder is up to temp (!too_cold):
943-
* Extrude filament distance = toolchange_settings.extra_resume + toolchange_settings.wipe_retract
943+
* Extrude filament distance = toolchange_settings.extra_resume + TOOLCHANGE_FS_WIPE_RETRACT
944944
* current_position.e = e;
945945
* sync_plan_position_e();
946946
*/
947947
void extruder_cutting_recover(const_float_t e) {
948948
if (!too_cold(active_extruder)) {
949-
const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract;
949+
const float dist = toolchange_settings.extra_resume + (TOOLCHANGE_FS_WIPE_RETRACT);
950950
FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s");
951951
unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed));
952952
planner.synchronize();
@@ -973,17 +973,17 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
973973
float fr = toolchange_settings.unretract_speed; // Set default speed for unretract
974974

975975
#if ENABLED(TOOLCHANGE_FS_SLOW_FIRST_PRIME)
976-
/**
977-
* Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime
978-
*/
979-
static Flags<EXTRUDERS> extruder_did_first_prime; // Extruders first priming status
980-
if (!extruder_did_first_prime[active_extruder]) {
981-
extruder_did_first_prime.set(active_extruder); // Log first prime complete
982-
// new nozzle - prime at user-specified speed.
983-
FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", MMM_TO_MMS(fr), " to ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s");
984-
fr = toolchange_settings.prime_speed;
985-
unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move
986-
}
976+
/*
977+
* Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime
978+
*/
979+
static Flags<EXTRUDERS> extruder_did_first_prime; // Extruders first priming status
980+
if (!extruder_did_first_prime[active_extruder]) {
981+
extruder_did_first_prime.set(active_extruder); // Log first prime complete
982+
// new nozzle - prime at user-specified speed.
983+
FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", MMM_TO_MMS(fr), " to ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s");
984+
fr = toolchange_settings.prime_speed;
985+
unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move
986+
}
987987
#endif
988988

989989
//Calculate and perform the priming distance
@@ -1011,8 +1011,8 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
10111011

10121012
// Cutting retraction
10131013
#if TOOLCHANGE_FS_WIPE_RETRACT
1014-
FS_DEBUG("Performing Cutting Retraction | Distance: ", -toolchange_settings.wipe_retract, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s");
1015-
unscaled_e_move(-toolchange_settings.wipe_retract, MMM_TO_MMS(toolchange_settings.retract_speed));
1014+
FS_DEBUG("Performing Cutting Retraction | Distance: ", -(TOOLCHANGE_FS_WIPE_RETRACT), " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s");
1015+
unscaled_e_move(-(TOOLCHANGE_FS_WIPE_RETRACT), MMM_TO_MMS(toolchange_settings.retract_speed));
10161016
#endif
10171017

10181018
// Cool down with fan
@@ -1271,7 +1271,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
12711271
magnetic_switching_toolhead_tool_change(new_tool, no_move);
12721272
#elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching ToolChanger
12731273
em_switching_toolhead_tool_change(new_tool, no_move);
1274-
#elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS // Switching Nozzle (single servo)
1274+
#elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS // Switching Nozzle (single servo)
12751275
// Raise by a configured distance to avoid workpiece, except with
12761276
// SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead.
12771277
if (!no_move) {
@@ -1285,6 +1285,11 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
12851285
fast_line_to_current(Z_AXIS);
12861286
}
12871287
move_nozzle_servo(new_tool);
1288+
#elif ENABLED(MECHANICAL_SWITCHING_EXTRUDER) || ENABLED(MECHANICAL_SWITCHING_NOZZLE)
1289+
if (!no_move) {
1290+
current_position.z = _MIN(current_position.z + toolchange_settings.z_raise, _MIN(TERN(HAS_SOFTWARE_ENDSTOPS, soft_endstop.max.z, Z_MAX_POS), Z_MAX_POS));
1291+
fast_line_to_current(Z_AXIS);
1292+
}
12881293
#endif
12891294

12901295
IF_DISABLED(DUAL_X_CARRIAGE, active_extruder = new_tool); // Set the new active extruder
@@ -1349,7 +1354,11 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
13491354
if (toolchange_settings.enable_park) do_blocking_move_to_xy_z(destination, destination.z, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE));
13501355
#else
13511356
do_blocking_move_to_xy(destination, planner.settings.max_feedrate_mm_s[X_AXIS]);
1352-
do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
1357+
1358+
// If using MECHANICAL_SWITCHING extruder/nozzle, set HOTEND_OFFSET in Z axis after running EVENT_GCODE_TOOLCHANGE further below.
1359+
#if NONE(MECHANICAL_SWITCHING_EXTRUDER, MECHANICAL_SWITCHING_NOZZLE)
1360+
do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
1361+
#endif
13531362
#endif
13541363

13551364
#endif
@@ -1411,6 +1420,21 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
14111420
gcode.process_subcommands_now(F(EVENT_GCODE_TOOLCHANGE_T1));
14121421
#endif
14131422

1423+
// If using MECHANICAL_SWITCHING extruder/nozzle, set HOTEND_OFFSET in Z axis after running EVENT_GCODE_TOOLCHANGE so that nozzle does not lower below print surface if new hotend Z offset is higher than old hotend Z offset.
1424+
#if EITHER(MECHANICAL_SWITCHING_EXTRUDER, MECHANICAL_SWITCHING_NOZZLE)
1425+
#if HAS_HOTEND_OFFSET
1426+
xyz_pos_t diff = hotend_offset[new_tool] - hotend_offset[old_tool];
1427+
TERN_(DUAL_X_CARRIAGE, diff.x = 0);
1428+
#else
1429+
constexpr xyz_pos_t diff{0};
1430+
#endif
1431+
1432+
if (!no_move) {
1433+
// Move to new hotend Z offset and reverse Z_RAISE
1434+
do_blocking_move_to_z(_MIN(_MAX((destination.z - diff.z) - toolchange_settings.z_raise, _MAX(TERN(HAS_SOFTWARE_ENDSTOPS, soft_endstop.min.z, Z_MIN_POS), Z_MIN_POS)), _MIN(TERN(HAS_SOFTWARE_ENDSTOPS, soft_endstop.max.z, Z_MAX_POS), Z_MAX_POS)), planner.settings.max_feedrate_mm_s[Z_AXIS]);
1435+
}
1436+
#endif
1437+
14141438
#ifdef EVENT_GCODE_AFTER_TOOLCHANGE
14151439
if (TERN1(DUAL_X_CARRIAGE, dual_x_carriage_mode == DXC_AUTO_PARK_MODE))
14161440
gcode.process_subcommands_now(F(EVENT_GCODE_AFTER_TOOLCHANGE));

0 commit comments

Comments
 (0)