|
|
@ -116,8 +116,6 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void parking_extruder_tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {
|
|
|
|
inline void parking_extruder_tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {
|
|
|
|
constexpr float z_raise = PARKING_EXTRUDER_SECURITY_RAISE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!no_move) {
|
|
|
|
if (!no_move) {
|
|
|
|
|
|
|
|
|
|
|
|
const float parkingposx[] = PARKING_EXTRUDER_PARKING_X,
|
|
|
|
const float parkingposx[] = PARKING_EXTRUDER_PARKING_X,
|
|
|
@ -140,7 +138,7 @@
|
|
|
|
SERIAL_ECHOLNPGM("Starting Autopark");
|
|
|
|
SERIAL_ECHOLNPGM("Starting Autopark");
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("current position:", current_position);
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("current position:", current_position);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
current_position[Z_AXIS] += z_raise;
|
|
|
|
current_position[Z_AXIS] += PARKING_EXTRUDER_SECURITY_RAISE;
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
SERIAL_ECHOLNPGM("(1) Raise Z-Axis ");
|
|
|
|
SERIAL_ECHOLNPGM("(1) Raise Z-Axis ");
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Moving to Raised Z-Position", current_position);
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Moving to Raised Z-Position", current_position);
|
|
|
@ -350,6 +348,8 @@ inline void invalid_extruder_error(const uint8_t e) {
|
|
|
|
|
|
|
|
|
|
|
|
#endif // DUAL_X_CARRIAGE
|
|
|
|
#endif // DUAL_X_CARRIAGE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DO_SWITCH_EXTRUDER (SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Perform a tool-change, which may result in moving the
|
|
|
|
* Perform a tool-change, which may result in moving the
|
|
|
|
* previous tool out of the way and the new tool into place.
|
|
|
|
* previous tool out of the way and the new tool into place.
|
|
|
@ -381,127 +381,53 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|
|
|
// Save current position to destination, for use later
|
|
|
|
// Save current position to destination, for use later
|
|
|
|
set_destination_from_current();
|
|
|
|
set_destination_from_current();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_LEVELING
|
|
|
|
|
|
|
|
// Set current position to the physical position
|
|
|
|
|
|
|
|
const bool leveling_was_active = planner.leveling_active;
|
|
|
|
|
|
|
|
set_bed_leveling_enabled(false);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
|
|
|
|
|
|
|
dualx_tool_change(tmp_extruder, no_move); // Can modify no_move
|
|
|
|
dualx_tool_change(tmp_extruder, no_move); // Can modify no_move
|
|
|
|
|
|
|
|
|
|
|
|
#else // !DUAL_X_CARRIAGE
|
|
|
|
#else // !DUAL_X_CARRIAGE
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(PARKING_EXTRUDER)
|
|
|
|
#if ENABLED(PARKING_EXTRUDER) // Dual Parking extruder
|
|
|
|
parking_extruder_tool_change(tmp_extruder, no_move);
|
|
|
|
parking_extruder_tool_change(tmp_extruder, no_move);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
|
|
|
#define DONT_SWITCH (SWITCHING_EXTRUDER_SERVO_NR == SWITCHING_NOZZLE_SERVO_NR)
|
|
|
|
// Always raise by at least 0.3
|
|
|
|
// <0 if the new nozzle is higher, >0 if lower. A bigger raise when lower.
|
|
|
|
const float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
|
|
|
const float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
|
|
|
|
current_position[Z_AXIS] += (z_diff > 0.0 ? z_diff : 0.0) + 0.3;
|
|
|
|
z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Always raise by some amount
|
|
|
|
|
|
|
|
current_position[Z_AXIS] += z_raise;
|
|
|
|
|
|
|
|
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
|
|
|
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
|
|
|
move_nozzle_servo(tmp_extruder);
|
|
|
|
move_nozzle_servo(tmp_extruder);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
const float xdiff = hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
|
|
|
|
* Set current_position to the position of the new nozzle.
|
|
|
|
ydiff = hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder];
|
|
|
|
* Offsets are based on linear distance, so we need to get
|
|
|
|
|
|
|
|
* the resulting position in coordinate space.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* - With grid or 3-point leveling, offset XYZ by a tilted vector
|
|
|
|
|
|
|
|
* - With mesh leveling, update Z for the new position
|
|
|
|
|
|
|
|
* - Otherwise, just use the raw linear distance
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Software endstops are altered here too. Consider a case where:
|
|
|
|
|
|
|
|
* E0 at X=0 ... E1 at X=10
|
|
|
|
|
|
|
|
* When we switch to E1 now X=10, but E1 can't move left.
|
|
|
|
|
|
|
|
* To express this we apply the change in XY to the software endstops.
|
|
|
|
|
|
|
|
* E1 can move farther right than E0, so the right limit is extended.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Note that we don't adjust the Z software endstops. Why not?
|
|
|
|
|
|
|
|
* Consider a case where Z=0 (here) and switching to E1 makes Z=1
|
|
|
|
|
|
|
|
* because the bed is 1mm lower at the new position. As long as
|
|
|
|
|
|
|
|
* the first nozzle is out of the way, the carriage should be
|
|
|
|
|
|
|
|
* allowed to move 1mm lower. This technically "breaks" the
|
|
|
|
|
|
|
|
* Z software endstop. But this is technically correct (and
|
|
|
|
|
|
|
|
* there is no viable alternative).
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if ABL_PLANAR
|
|
|
|
|
|
|
|
// Offset extruder, make sure to apply the bed level rotation matrix
|
|
|
|
|
|
|
|
vector_3 tmp_offset_vec = vector_3(hotend_offset[X_AXIS][tmp_extruder],
|
|
|
|
|
|
|
|
hotend_offset[Y_AXIS][tmp_extruder],
|
|
|
|
|
|
|
|
0),
|
|
|
|
|
|
|
|
act_offset_vec = vector_3(hotend_offset[X_AXIS][active_extruder],
|
|
|
|
|
|
|
|
hotend_offset[Y_AXIS][active_extruder],
|
|
|
|
|
|
|
|
0),
|
|
|
|
|
|
|
|
offset_vec = tmp_offset_vec - act_offset_vec;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
|
|
|
|
tmp_offset_vec.debug(PSTR("tmp_offset_vec"));
|
|
|
|
|
|
|
|
act_offset_vec.debug(PSTR("act_offset_vec"));
|
|
|
|
|
|
|
|
offset_vec.debug(PSTR("offset_vec (BEFORE)"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
offset_vec.apply_rotation(planner.bed_level_matrix.transpose(planner.bed_level_matrix));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) offset_vec.debug(PSTR("offset_vec (AFTER)"));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Adjustments to the current position
|
|
|
|
|
|
|
|
const float xydiff[2] = { offset_vec.x, offset_vec.y };
|
|
|
|
|
|
|
|
current_position[Z_AXIS] += offset_vec.z;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#else // !ABL_PLANAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const float xydiff[2] = {
|
|
|
|
|
|
|
|
hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
|
|
|
|
|
|
|
|
hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_MESH && PLANNER_LEVELING
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (planner.leveling_active) {
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before: ", current_position[Z_AXIS]);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
float x2 = current_position[X_AXIS] + xydiff[X_AXIS],
|
|
|
|
|
|
|
|
y2 = current_position[Y_AXIS] + xydiff[Y_AXIS],
|
|
|
|
|
|
|
|
z1 = current_position[Z_AXIS], z2 = z1;
|
|
|
|
|
|
|
|
planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], z1);
|
|
|
|
|
|
|
|
planner.apply_leveling(x2, y2, z2);
|
|
|
|
|
|
|
|
current_position[Z_AXIS] += z2 - z1;
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING))
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPAIR(" after: ", current_position[Z_AXIS]);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HAS_MESH && PLANNER_LEVELING
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !HAS_ABL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
SERIAL_ECHOPAIR("Offset Tool XY by { ", xydiff[X_AXIS]);
|
|
|
|
SERIAL_ECHOPAIR("Offset Tool XY by { ", xdiff);
|
|
|
|
SERIAL_ECHOPAIR(", ", xydiff[Y_AXIS]);
|
|
|
|
SERIAL_ECHOPAIR(", ", ydiff);
|
|
|
|
SERIAL_ECHOLNPGM(" }");
|
|
|
|
SERIAL_ECHOLNPGM(" }");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// The newly-selected extruder XY is actually at...
|
|
|
|
// The newly-selected extruder XY is actually at...
|
|
|
|
current_position[X_AXIS] += xydiff[X_AXIS];
|
|
|
|
current_position[X_AXIS] += xdiff;
|
|
|
|
current_position[Y_AXIS] += xydiff[Y_AXIS];
|
|
|
|
current_position[Y_AXIS] += ydiff;
|
|
|
|
|
|
|
|
|
|
|
|
// Set the new active extruder
|
|
|
|
// Set the new active extruder
|
|
|
|
active_extruder = tmp_extruder;
|
|
|
|
active_extruder = tmp_extruder;
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !DUAL_X_CARRIAGE
|
|
|
|
#endif // !DUAL_X_CARRIAGE
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#if HAS_LEVELING
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Sync After Toolchange", current_position);
|
|
|
|
// Restore leveling to re-establish the logical position
|
|
|
|
|
|
|
|
set_bed_leveling_enabled(leveling_was_active);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// Tell the planner the new "current position"
|
|
|
|
// Tell the planner the new "current position"
|
|
|
@ -509,17 +435,11 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DELTA)
|
|
|
|
#if ENABLED(DELTA)
|
|
|
|
//LOOP_XYZ(i) update_software_endstops(i); // or modify the constrain function
|
|
|
|
//LOOP_XYZ(i) update_software_endstops(i); // or modify the constrain function
|
|
|
|
// Do a small lift to avoid the workpiece in the move back (below)
|
|
|
|
|
|
|
|
const bool safe_to_move = current_position[Z_AXIS] < delta_clip_start_height - 1;
|
|
|
|
const bool safe_to_move = current_position[Z_AXIS] < delta_clip_start_height - 1;
|
|
|
|
if (safe_to_move && !no_move && IsRunning()) {
|
|
|
|
|
|
|
|
++current_position[Z_AXIS];
|
|
|
|
|
|
|
|
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
constexpr bool safe_to_move = true;
|
|
|
|
constexpr bool safe_to_move = true;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// Move to the "old position" (move the extruder into place)
|
|
|
|
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
|
|
|
destination[Z_AXIS] += z_diff; // Include the Z restore with the "move back"
|
|
|
|
destination[Z_AXIS] += z_diff; // Include the Z restore with the "move back"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -544,7 +464,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|
|
|
#if ENABLED(EXT_SOLENOID) && !ENABLED(PARKING_EXTRUDER)
|
|
|
|
#if ENABLED(EXT_SOLENOID) && !ENABLED(PARKING_EXTRUDER)
|
|
|
|
disable_all_solenoids();
|
|
|
|
disable_all_solenoids();
|
|
|
|
enable_solenoid_on_active_extruder();
|
|
|
|
enable_solenoid_on_active_extruder();
|
|
|
|
#endif // EXT_SOLENOID
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
feedrate_mm_s = old_feedrate_mm_s;
|
|
|
|
feedrate_mm_s = old_feedrate_mm_s;
|
|
|
|
|
|
|
|
|
|
|
@ -565,7 +485,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HOTENDS <= 1
|
|
|
|
#endif // HOTENDS <= 1
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(SWITCHING_EXTRUDER) && !DONT_SWITCH
|
|
|
|
#if DO_SWITCH_EXTRUDER
|
|
|
|
stepper.synchronize();
|
|
|
|
stepper.synchronize();
|
|
|
|
move_extruder_servo(active_extruder);
|
|
|
|
move_extruder_servo(active_extruder);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|