mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-27 13:56:24 +00:00
Apply some tool-change cleanup
This commit is contained in:
parent
34ea458667
commit
5a470d4a49
@ -129,10 +129,17 @@
|
||||
inline void parking_extruder_tool_change(const uint8_t tmp_extruder, bool no_move) {
|
||||
if (!no_move) {
|
||||
|
||||
const float parkingposx[] = PARKING_EXTRUDER_PARKING_X,
|
||||
midpos = (parkingposx[0] + parkingposx[1]) * 0.5 + hotend_offset[X_AXIS][active_extruder],
|
||||
grabpos = parkingposx[tmp_extruder] + hotend_offset[X_AXIS][active_extruder]
|
||||
+ (tmp_extruder == 0 ? -(PARKING_EXTRUDER_GRAB_DISTANCE) : PARKING_EXTRUDER_GRAB_DISTANCE);
|
||||
constexpr float parkingposx[] = PARKING_EXTRUDER_PARKING_X;
|
||||
|
||||
#if HAS_HOTEND_OFFSET
|
||||
const float x_offset = hotend_offset[X_AXIS][active_extruder];
|
||||
#else
|
||||
constexpr float x_offset = 0;
|
||||
#endif
|
||||
|
||||
const float midpos = (parkingposx[0] + parkingposx[1]) * 0.5 + x_offset,
|
||||
grabpos = parkingposx[tmp_extruder] + (tmp_extruder ? PARKING_EXTRUDER_GRAB_DISTANCE : -(PARKING_EXTRUDER_GRAB_DISTANCE)) + x_offset;
|
||||
|
||||
/**
|
||||
* 1. Raise Z-Axis to give enough clearance
|
||||
* 2. Move to park position of old extruder
|
||||
@ -144,42 +151,54 @@
|
||||
*/
|
||||
|
||||
// STEP 1
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
|
||||
#endif
|
||||
|
||||
current_position[Z_AXIS] += toolchange_settings.z_raise;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
// STEP 2
|
||||
current_position[X_AXIS] = parkingposx[active_extruder] + hotend_offset[X_AXIS][active_extruder];
|
||||
|
||||
current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
SERIAL_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
|
||||
DEBUG_POS("Moving ParkPos", current_position);
|
||||
}
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
// STEP 3
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Disengage magnet ");
|
||||
#endif
|
||||
|
||||
pe_deactivate_magnet(active_extruder);
|
||||
|
||||
// STEP 4
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to position near new extruder");
|
||||
#endif
|
||||
|
||||
current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
@ -191,9 +210,11 @@
|
||||
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
||||
pe_activate_magnet(active_extruder); //just save power for inverted magnets
|
||||
#endif
|
||||
|
||||
pe_activate_magnet(tmp_extruder);
|
||||
|
||||
// STEP 6
|
||||
|
||||
current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
||||
current_position[X_AXIS] = grabpos;
|
||||
@ -203,13 +224,21 @@
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS]/2, active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
// Step 7
|
||||
current_position[X_AXIS] = midpos - hotend_offset[X_AXIS][tmp_extruder];
|
||||
// STEP 7
|
||||
|
||||
current_position[X_AXIS] = midpos
|
||||
#if HAS_HOTEND_OFFSET
|
||||
- hotend_offset[X_AXIS][tmp_extruder]
|
||||
#endif
|
||||
;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
SERIAL_ECHOLNPGM("Autopark done.");
|
||||
#endif
|
||||
@ -221,7 +250,10 @@
|
||||
pe_activate_magnet(active_extruder); // Just save power for inverted magnets
|
||||
#endif
|
||||
}
|
||||
current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
||||
|
||||
#if HAS_HOTEND_OFFSET
|
||||
current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
||||
#endif
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
|
||||
@ -251,80 +283,105 @@
|
||||
*/
|
||||
|
||||
// STEP 1
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
|
||||
#endif
|
||||
|
||||
current_position[Z_AXIS] += toolchange_settings.z_raise;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
// STEP 2
|
||||
|
||||
current_position[X_AXIS] = placexpos;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
SERIAL_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
|
||||
DEBUG_POS("Move X SwitchPos", current_position);
|
||||
}
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
// STEP 3
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Unlock and Place Toolhead");
|
||||
#endif
|
||||
|
||||
MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
|
||||
safe_delay(500);
|
||||
|
||||
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
|
||||
planner.synchronize();
|
||||
safe_delay(200);
|
||||
current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
|
||||
planner.synchronize();
|
||||
|
||||
// STEP 4
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");
|
||||
#endif
|
||||
|
||||
current_position[X_AXIS] = grabxpos;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
// STEP 5
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab and lock new toolhead ");
|
||||
#endif
|
||||
|
||||
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
|
||||
planner.synchronize();
|
||||
|
||||
@ -333,14 +390,19 @@
|
||||
safe_delay(500);
|
||||
|
||||
current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
|
||||
#endif
|
||||
|
||||
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
|
||||
planner.synchronize();
|
||||
|
||||
// STEP 6
|
||||
current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
||||
|
||||
#if HAS_HOTEND_OFFSET
|
||||
current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
||||
#endif
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Apply Z offset", current_position);
|
||||
|
Loading…
Reference in New Issue
Block a user