2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-10-17 18:11:41 +02:00
|
|
|
#include "../inc/MarlinConfigPre.h"
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
#include "tool_change.h"
|
|
|
|
|
2018-09-24 16:40:48 +02:00
|
|
|
#include "probe.h"
|
2017-09-06 13:28:31 +02:00
|
|
|
#include "motion.h"
|
|
|
|
#include "planner.h"
|
2018-10-08 00:06:14 +02:00
|
|
|
#include "temperature.h"
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2020-01-03 02:01:38 +01:00
|
|
|
#include "../MarlinCore.h"
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#include "../core/debug_out.h"
|
|
|
|
|
2018-10-17 18:11:41 +02:00
|
|
|
#if EXTRUDERS > 1
|
|
|
|
toolchange_settings_t toolchange_settings; // Initialized by settings.load()
|
|
|
|
#endif
|
|
|
|
|
2018-10-08 00:06:14 +02:00
|
|
|
#if ENABLED(SINGLENOZZLE)
|
|
|
|
uint16_t singlenozzle_temp[EXTRUDERS];
|
|
|
|
#if FAN_COUNT > 0
|
|
|
|
uint8_t singlenozzle_fan_speed[EXTRUDERS];
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2019-02-06 13:30:53 +01:00
|
|
|
#if ENABLED(MAGNETIC_PARKING_EXTRUDER) || (ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0)
|
2017-09-16 03:44:40 +02:00
|
|
|
#include "../gcode/gcode.h" // for dwell()
|
|
|
|
#endif
|
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, SWITCHING_TOOLHEAD)
|
2019-02-04 10:41:55 +01:00
|
|
|
#include "servo.h"
|
2017-11-19 20:39:46 +01:00
|
|
|
#endif
|
|
|
|
|
2018-08-24 23:35:55 +02:00
|
|
|
#if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
|
2017-09-17 10:43:45 +02:00
|
|
|
#include "../feature/solenoid.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-17 23:58:16 +02:00
|
|
|
#if ENABLED(MK2_MULTIPLEXER)
|
|
|
|
#include "../feature/snmm.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-18 07:06:16 +02:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
#include "../feature/mixing.h"
|
2017-09-25 23:18:26 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_LEVELING
|
|
|
|
#include "../feature/bedlevel/bedlevel.h"
|
2017-09-18 07:06:16 +02:00
|
|
|
#endif
|
|
|
|
|
2017-11-05 03:01:41 +01:00
|
|
|
#if HAS_FANMUX
|
|
|
|
#include "../feature/fanmux.h"
|
|
|
|
#endif
|
|
|
|
|
2019-02-01 02:10:52 +01:00
|
|
|
#if ENABLED(PRUSA_MMU2)
|
|
|
|
#include "../feature/prusa_MMU2/mmu2.h"
|
|
|
|
#endif
|
|
|
|
|
2018-10-30 22:34:45 +01:00
|
|
|
#if HAS_LCD_MENU
|
2018-09-24 16:40:48 +02:00
|
|
|
#include "../lcd/ultralcd.h"
|
|
|
|
#endif
|
|
|
|
|
2019-07-20 08:55:34 +02:00
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
|
|
|
#include "../feature/pause.h"
|
|
|
|
#endif
|
|
|
|
|
2018-05-18 20:16:59 +02:00
|
|
|
#if DO_SWITCH_EXTRUDER
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if EXTRUDERS > 3
|
2018-08-25 04:53:42 +02:00
|
|
|
#define _SERVO_NR(E) ((E) < 2 ? SWITCHING_EXTRUDER_SERVO_NR : SWITCHING_EXTRUDER_E23_SERVO_NR)
|
2017-09-06 13:28:31 +02:00
|
|
|
#else
|
2018-08-25 04:53:42 +02:00
|
|
|
#define _SERVO_NR(E) SWITCHING_EXTRUDER_SERVO_NR
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void move_extruder_servo(const uint8_t e) {
|
2018-05-12 08:38:02 +02:00
|
|
|
planner.synchronize();
|
2017-09-06 13:28:31 +02:00
|
|
|
#if EXTRUDERS & 1
|
|
|
|
if (e < EXTRUDERS - 1)
|
|
|
|
#endif
|
|
|
|
{
|
2018-08-25 04:53:42 +02:00
|
|
|
MOVE_SERVO(_SERVO_NR(e), servo_angles[_SERVO_NR(e)][e]);
|
2017-09-06 13:28:31 +02:00
|
|
|
safe_delay(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-12 04:29:31 +02:00
|
|
|
#endif // DO_SWITCH_EXTRUDER
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
2019-02-04 07:19:56 +01:00
|
|
|
|
|
|
|
#if SWITCHING_NOZZLE_TWO_SERVOS
|
|
|
|
|
|
|
|
inline void _move_nozzle_servo(const uint8_t e, const uint8_t angle_index) {
|
|
|
|
constexpr int8_t sns_index[2] = { SWITCHING_NOZZLE_SERVO_NR, SWITCHING_NOZZLE_E1_SERVO_NR };
|
|
|
|
constexpr int16_t sns_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES;
|
|
|
|
planner.synchronize();
|
|
|
|
MOVE_SERVO(sns_index[e], sns_angles[angle_index]);
|
|
|
|
safe_delay(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
void lower_nozzle(const uint8_t e) { _move_nozzle_servo(e, 0); }
|
|
|
|
void raise_nozzle(const uint8_t e) { _move_nozzle_servo(e, 1); }
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void move_nozzle_servo(const uint8_t angle_index) {
|
|
|
|
planner.synchronize();
|
2019-04-10 01:33:40 +02:00
|
|
|
MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, servo_angles[SWITCHING_NOZZLE_SERVO_NR][angle_index]);
|
2019-02-04 07:19:56 +01:00
|
|
|
safe_delay(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif // SWITCHING_NOZZLE
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
inline void _line_to_current(const AxisEnum fr_axis, const float fscale=1) {
|
|
|
|
line_to_current_position(planner.settings.max_feedrate_mm_s[fr_axis] * fscale);
|
2019-03-05 02:09:31 +01:00
|
|
|
}
|
2019-09-14 10:05:10 +02:00
|
|
|
inline void slow_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.5f); }
|
|
|
|
inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis); }
|
2019-03-05 02:09:31 +01:00
|
|
|
|
2019-02-06 13:30:53 +01:00
|
|
|
#if ENABLED(MAGNETIC_PARKING_EXTRUDER)
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-07-18 09:44:08 +02:00
|
|
|
float parkingposx[2], // M951 R L
|
|
|
|
parkinggrabdistance, // M951 I
|
|
|
|
parkingslowspeed, // M951 J
|
|
|
|
parkinghighspeed, // M951 H
|
|
|
|
parkingtraveldistance, // M951 D
|
2019-02-12 21:25:35 +01:00
|
|
|
compensationmultiplier;
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
inline void magnetic_parking_extruder_tool_change(const uint8_t new_tool) {
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
const float oldx = current_position.x,
|
2019-07-22 02:33:37 +02:00
|
|
|
grabpos = mpe_settings.parking_xpos[new_tool] + (new_tool ? mpe_settings.grab_distance : -mpe_settings.grab_distance),
|
2019-09-14 10:05:10 +02:00
|
|
|
offsetcompensation = (0
|
2019-02-06 13:30:53 +01:00
|
|
|
#if HAS_HOTEND_OFFSET
|
2019-09-29 11:25:39 +02:00
|
|
|
+ hotend_offset[active_extruder].x * mpe_settings.compensation_factor
|
2019-02-06 13:30:53 +01:00
|
|
|
#endif
|
2019-09-14 10:05:10 +02:00
|
|
|
);
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-09-26 04:01:29 +02:00
|
|
|
if (axis_unhomed_error(_BV(X_AXIS))) return;
|
2019-02-06 13:30:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Z Lift and Nozzle Offset shift ar defined in caller method to work equal with any Multi Hotend realization
|
|
|
|
*
|
|
|
|
* Steps:
|
|
|
|
* 1. Move high speed to park position of new extruder
|
|
|
|
* 2. Move to couple position of new extruder (this also discouple the old extruder)
|
|
|
|
* 3. Move to park position of new extruder
|
|
|
|
* 4. Move high speed to approach park position of old extruder
|
|
|
|
* 5. Move to park position of old extruder
|
|
|
|
* 6. Move to starting position
|
|
|
|
*/
|
|
|
|
|
|
|
|
// STEP 1
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = mpe_settings.parking_xpos[new_tool] + offsetcompensation;
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-07-22 02:33:37 +02:00
|
|
|
DEBUG_ECHOPAIR("(1) Move extruder ", int(new_tool));
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_POS(" to new extruder ParkPos", current_position);
|
|
|
|
}
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
|
2019-02-06 13:30:53 +01:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 2
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = grabpos + offsetcompensation;
|
2019-02-12 21:25:35 +01:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-07-22 02:33:37 +02:00
|
|
|
DEBUG_ECHOPAIR("(2) Couple extruder ", int(new_tool));
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_POS(" to new extruder GrabPos", current_position);
|
|
|
|
}
|
2019-02-12 21:25:35 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
|
2019-02-06 13:30:53 +01:00
|
|
|
planner.synchronize();
|
2019-02-12 21:25:35 +01:00
|
|
|
|
2019-02-06 13:30:53 +01:00
|
|
|
// Delay before moving tool, to allow magnetic coupling
|
|
|
|
gcode.dwell(150);
|
2019-02-12 21:25:35 +01:00
|
|
|
|
2019-02-06 13:30:53 +01:00
|
|
|
// STEP 3
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = mpe_settings.parking_xpos[new_tool] + offsetcompensation;
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-07-22 02:33:37 +02:00
|
|
|
DEBUG_ECHOPAIR("(3) Move extruder ", int(new_tool));
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_POS(" back to new extruder ParkPos", current_position);
|
|
|
|
}
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
|
2019-02-06 13:30:53 +01:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 4
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = mpe_settings.parking_xpos[active_extruder] + (active_extruder == 0 ? MPE_TRAVEL_DISTANCE : -MPE_TRAVEL_DISTANCE) + offsetcompensation;
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-07-22 02:33:37 +02:00
|
|
|
DEBUG_ECHOPAIR("(4) Move extruder ", int(new_tool));
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_POS(" close to old extruder ParkPos", current_position);
|
|
|
|
}
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
|
2019-02-06 13:30:53 +01:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 5
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = mpe_settings.parking_xpos[active_extruder] + offsetcompensation;
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-07-22 02:33:37 +02:00
|
|
|
DEBUG_ECHOPAIR("(5) Park extruder ", int(new_tool));
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_POS(" at old extruder ParkPos", current_position);
|
|
|
|
}
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
|
2019-02-06 13:30:53 +01:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 6
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = oldx;
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-07-22 02:33:37 +02:00
|
|
|
DEBUG_ECHOPAIR("(6) Move extruder ", int(new_tool));
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_POS(" to starting position", current_position);
|
|
|
|
}
|
2019-02-06 13:30:53 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
|
2019-02-06 13:30:53 +01:00
|
|
|
planner.synchronize();
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Autopark done.");
|
2019-02-06 13:30:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#elif ENABLED(PARKING_EXTRUDER)
|
|
|
|
|
|
|
|
void pe_solenoid_init() {
|
2017-09-18 08:05:44 +02:00
|
|
|
for (uint8_t n = 0; n <= 1; ++n)
|
|
|
|
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
2019-02-06 13:30:53 +01:00
|
|
|
pe_activate_solenoid(n);
|
2017-09-18 08:05:44 +02:00
|
|
|
#else
|
2019-02-06 13:30:53 +01:00
|
|
|
pe_deactivate_solenoid(n);
|
2017-09-18 08:05:44 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-02-06 13:30:53 +01:00
|
|
|
void pe_set_solenoid(const uint8_t extruder_num, const uint8_t state) {
|
2017-09-06 13:28:31 +02:00
|
|
|
switch (extruder_num) {
|
|
|
|
case 1: OUT_WRITE(SOL1_PIN, state); break;
|
|
|
|
default: OUT_WRITE(SOL0_PIN, state); break;
|
|
|
|
}
|
|
|
|
#if PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
|
2017-09-16 03:44:40 +02:00
|
|
|
gcode.dwell(PARKING_EXTRUDER_SOLENOIDS_DELAY);
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
inline void parking_extruder_tool_change(const uint8_t new_tool, bool no_move) {
|
2018-03-30 01:11:02 +02:00
|
|
|
if (!no_move) {
|
|
|
|
|
2018-11-07 01:03:10 +01:00
|
|
|
constexpr float parkingposx[] = PARKING_EXTRUDER_PARKING_X;
|
|
|
|
|
|
|
|
#if HAS_HOTEND_OFFSET
|
2019-09-29 11:25:39 +02:00
|
|
|
const float x_offset = hotend_offset[active_extruder].x;
|
2018-11-07 01:03:10 +01:00
|
|
|
#else
|
|
|
|
constexpr float x_offset = 0;
|
|
|
|
#endif
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
const float midpos = (parkingposx[0] + parkingposx[1]) * 0.5f + x_offset,
|
2019-07-22 02:33:37 +02:00
|
|
|
grabpos = parkingposx[new_tool] + (new_tool ? PARKING_EXTRUDER_GRAB_DISTANCE : -(PARKING_EXTRUDER_GRAB_DISTANCE)) + x_offset;
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2018-03-30 01:11:02 +02:00
|
|
|
/**
|
2019-04-22 04:06:46 +02:00
|
|
|
* 1. Move to park position of old extruder
|
|
|
|
* 2. Disengage magnetic field, wait for delay
|
|
|
|
* 3. Move near new extruder
|
|
|
|
* 4. Engage magnetic field for new extruder
|
|
|
|
* 5. Move to parking incl. offset of new extruder
|
|
|
|
* 6. Lower Z-Axis
|
2018-03-30 01:11:02 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
// STEP 1
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Start PE Tool-Change", current_position);
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = parkingposx[active_extruder] + x_offset;
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-04-22 04:06:46 +02:00
|
|
|
DEBUG_ECHOLNPAIR("(1) Park extruder ", int(active_extruder));
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_POS("Moving ParkPos", current_position);
|
|
|
|
}
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(X_AXIS);
|
2018-03-30 01:11:02 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// STEP 2
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-07-18 09:44:08 +02:00
|
|
|
planner.synchronize();
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Disengage magnet");
|
2019-02-06 13:30:53 +01:00
|
|
|
pe_deactivate_solenoid(active_extruder);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// STEP 3
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x += active_extruder ? -10 : 10; // move 10mm away from parked extruder
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
DEBUG_ECHOLNPGM("(3) Move near new extruder");
|
|
|
|
DEBUG_POS("Move away from parked extruder", current_position);
|
|
|
|
}
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(X_AXIS);
|
2018-03-30 01:11:02 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// STEP 4
|
2018-03-30 01:11:02 +02:00
|
|
|
|
2019-07-18 09:44:08 +02:00
|
|
|
planner.synchronize();
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Engage magnetic field");
|
2018-03-30 01:11:02 +02:00
|
|
|
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
2019-07-18 09:44:08 +02:00
|
|
|
pe_activate_solenoid(active_extruder); // Just save power for inverted magnets
|
2018-03-30 01:11:02 +02:00
|
|
|
#endif
|
2019-07-22 02:33:37 +02:00
|
|
|
pe_activate_solenoid(new_tool);
|
2018-03-30 01:11:02 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// STEP 5
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = grabpos + (new_tool ? -10 : 10);
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(X_AXIS);
|
2019-07-18 09:44:08 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = grabpos;
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("(5) Unpark extruder", current_position);
|
|
|
|
}
|
2019-09-14 10:05:10 +02:00
|
|
|
slow_line_to_current(X_AXIS);
|
2018-03-30 01:11:02 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// STEP 6
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = midpos
|
2018-11-07 01:03:10 +01:00
|
|
|
#if HAS_HOTEND_OFFSET
|
2019-09-29 11:25:39 +02:00
|
|
|
- hotend_offset[new_tool].x
|
2018-11-07 01:03:10 +01:00
|
|
|
#endif
|
|
|
|
;
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("(6) Move midway between hotends", current_position);
|
|
|
|
}
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(X_AXIS);
|
2019-07-18 09:44:08 +02:00
|
|
|
planner.synchronize(); // Always sync the final move
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("PE Tool-Change done.", current_position);
|
2018-03-30 01:11:02 +02:00
|
|
|
}
|
|
|
|
else { // nomove == true
|
|
|
|
// Only engage magnetic field for new extruder
|
2019-07-22 02:33:37 +02:00
|
|
|
pe_activate_solenoid(new_tool);
|
2018-03-30 01:11:02 +02:00
|
|
|
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
2019-02-06 13:30:53 +01:00
|
|
|
pe_activate_solenoid(active_extruder); // Just save power for inverted magnets
|
2018-03-30 01:11:02 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PARKING_EXTRUDER
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-09-08 08:43:24 +02:00
|
|
|
#if ENABLED(SWITCHING_TOOLHEAD)
|
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
|
2018-09-08 08:43:24 +02:00
|
|
|
if (no_move) return;
|
|
|
|
|
|
|
|
constexpr uint16_t angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
|
|
|
|
|
2019-07-01 12:55:23 +02:00
|
|
|
constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
|
|
|
|
const float placexpos = toolheadposx[active_extruder],
|
2019-07-22 02:33:37 +02:00
|
|
|
grabxpos = toolheadposx[new_tool];
|
2018-09-08 08:43:24 +02:00
|
|
|
|
|
|
|
/**
|
2019-04-22 04:06:46 +02:00
|
|
|
* 1. Move to switch position of current toolhead
|
|
|
|
* 2. Unlock tool and drop it in the dock
|
|
|
|
* 3. Move to the new toolhead
|
|
|
|
* 4. Grab and lock the new toolhead
|
2018-09-08 08:43:24 +02:00
|
|
|
*/
|
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// 1. Move to switch position of current toolhead
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Start ST Tool-Change", current_position);
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = placexpos;
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-04-22 04:06:46 +02:00
|
|
|
DEBUG_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_POS("Move X SwitchPos", current_position);
|
|
|
|
}
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(X_AXIS);
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS - (SWITCHING_TOOLHEAD_Y_SECURITY);
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("Move Y SwitchPos + Security", current_position);
|
|
|
|
}
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(Y_AXIS);
|
2018-09-08 08:43:24 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// 2. Unlock tool and drop it in the dock
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-07-18 09:44:08 +02:00
|
|
|
planner.synchronize();
|
2019-04-22 04:06:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead");
|
2018-09-08 08:43:24 +02:00
|
|
|
MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
|
|
|
|
safe_delay(500);
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS;
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
|
2019-09-14 10:05:10 +02:00
|
|
|
slow_line_to_current(Y_AXIS);
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-07-18 09:44:08 +02:00
|
|
|
// Wait for move to complete, then another 0.2s
|
2018-09-08 08:43:24 +02:00
|
|
|
planner.synchronize();
|
|
|
|
safe_delay(200);
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(Y_AXIS); // move away from docked toolhead
|
2018-09-08 08:43:24 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// 3. Move to the new toolhead
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = grabxpos;
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
|
|
|
|
DEBUG_POS("Move to new toolhead X", current_position);
|
|
|
|
}
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(X_AXIS);
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS - (SWITCHING_TOOLHEAD_Y_SECURITY);
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("Move Y SwitchPos + Security", current_position);
|
|
|
|
}
|
2019-03-05 02:09:31 +01:00
|
|
|
fast_line_to_current(Y_AXIS);
|
2018-09-08 08:43:24 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// 4. Grab and lock the new toolhead
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS;
|
2019-07-18 09:44:08 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_ECHOLNPGM("(4) Grab and lock new toolhead");
|
|
|
|
DEBUG_POS("Move Y SwitchPos", current_position);
|
|
|
|
}
|
2019-09-14 10:05:10 +02:00
|
|
|
slow_line_to_current(Y_AXIS);
|
2018-09-08 08:43:24 +02:00
|
|
|
|
2019-07-18 09:44:08 +02:00
|
|
|
// Wait for move to finish, pause 0.2s, move servo, pause 0.5s
|
|
|
|
planner.synchronize();
|
2018-09-08 08:43:24 +02:00
|
|
|
safe_delay(200);
|
|
|
|
MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[0]);
|
|
|
|
safe_delay(500);
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
|
2019-07-18 09:44:08 +02:00
|
|
|
fast_line_to_current(Y_AXIS); // Move away from docked toolhead
|
|
|
|
planner.synchronize(); // Always sync the final move
|
2018-11-07 01:03:10 +01:00
|
|
|
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("ST Tool-Change done.", current_position);
|
2018-09-08 08:43:24 +02:00
|
|
|
}
|
|
|
|
|
2019-07-01 12:55:23 +02:00
|
|
|
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
inline void magnetic_switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
|
2019-04-11 20:29:17 +02:00
|
|
|
if (no_move) return;
|
|
|
|
|
2019-07-19 13:07:26 +02:00
|
|
|
constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS,
|
|
|
|
toolheadclearx[] = SWITCHING_TOOLHEAD_X_SECURITY;
|
|
|
|
|
2019-07-01 12:55:23 +02:00
|
|
|
const float placexpos = toolheadposx[active_extruder],
|
2019-07-19 13:07:26 +02:00
|
|
|
placexclear = toolheadclearx[active_extruder],
|
2019-07-22 02:33:37 +02:00
|
|
|
grabxpos = toolheadposx[new_tool],
|
|
|
|
grabxclear = toolheadclearx[new_tool];
|
2019-04-11 20:29:17 +02:00
|
|
|
|
|
|
|
/**
|
2019-04-22 04:06:46 +02:00
|
|
|
* 1. Move to switch position of current toolhead
|
|
|
|
* 2. Release and place toolhead in the dock
|
|
|
|
* 3. Move to the new toolhead
|
|
|
|
* 4. Grab the new toolhead and move to security position
|
2019-04-11 20:29:17 +02:00
|
|
|
*/
|
|
|
|
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Start MST Tool-Change", current_position);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// 1. Move to switch position current toolhead
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR;
|
2019-04-11 20:29:17 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-04-22 04:06:46 +02:00
|
|
|
SERIAL_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
|
2019-04-11 20:29:17 +02:00
|
|
|
DEBUG_POS("Move Y SwitchPos + Security", current_position);
|
|
|
|
}
|
2019-09-14 10:05:10 +02:00
|
|
|
fast_line_to_current(Y_AXIS);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = placexclear;
|
2019-07-18 09:17:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("Move X SwitchPos + Security", current_position);
|
|
|
|
}
|
2019-09-14 10:05:10 +02:00
|
|
|
fast_line_to_current(X_AXIS);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS;
|
2019-07-18 09:17:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("Move Y SwitchPos", current_position);
|
|
|
|
}
|
2019-09-14 10:05:10 +02:00
|
|
|
fast_line_to_current(Y_AXIS);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = placexpos;
|
2019-07-18 09:17:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("Move X SwitchPos", current_position);
|
|
|
|
}
|
2019-09-29 11:25:39 +02:00
|
|
|
line_to_current_position(planner.settings.max_feedrate_mm_s[X_AXIS] * 0.25f);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// 2. Release and place toolhead in the dock
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-07-18 09:17:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
2019-07-19 13:07:26 +02:00
|
|
|
DEBUG_ECHOLNPGM("(2) Release and Place Toolhead");
|
2019-07-18 09:17:46 +02:00
|
|
|
}
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
|
2019-04-11 20:29:17 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
|
2019-09-29 11:25:39 +02:00
|
|
|
line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.1f);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_SECURITY;
|
2019-07-18 09:17:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("Move Y SwitchPos + Security", current_position);
|
|
|
|
}
|
2019-09-29 11:25:39 +02:00
|
|
|
line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS]);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// 3. Move to new toolhead position
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-07-18 09:17:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
2019-07-19 13:07:26 +02:00
|
|
|
DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
|
2019-07-18 09:17:46 +02:00
|
|
|
}
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = grabxpos;
|
2019-04-11 20:29:17 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
|
2019-09-14 10:05:10 +02:00
|
|
|
fast_line_to_current(X_AXIS);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-04-22 04:06:46 +02:00
|
|
|
// 4. Grab the new toolhead and move to security position
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-07-18 09:17:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
2019-07-19 13:07:26 +02:00
|
|
|
DEBUG_ECHOLNPGM("(4) Grab new toolhead, move to security position");
|
2019-07-18 09:17:46 +02:00
|
|
|
}
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
|
2019-04-11 20:29:17 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
|
2019-09-29 11:25:39 +02:00
|
|
|
line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS]);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y = SWITCHING_TOOLHEAD_Y_POS;
|
2019-07-18 09:17:46 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
DEBUG_POS("Move Y SwitchPos", current_position);
|
|
|
|
}
|
2019-09-14 10:05:10 +02:00
|
|
|
_line_to_current(Y_AXIS, 0.2f);
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-07-19 13:07:26 +02:00
|
|
|
#if ENABLED(PRIME_BEFORE_REMOVE) && (SWITCHING_TOOLHEAD_PRIME_MM || SWITCHING_TOOLHEAD_RETRACT_MM)
|
|
|
|
#if SWITCHING_TOOLHEAD_PRIME_MM
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.e += SWITCHING_TOOLHEAD_PRIME_MM;
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_PRIME_FEEDRATE), new_tool);
|
2019-07-19 13:07:26 +02:00
|
|
|
#endif
|
|
|
|
#if SWITCHING_TOOLHEAD_RETRACT_MM
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.e -= SWITCHING_TOOLHEAD_RETRACT_MM;
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_RETRACT_FEEDRATE), new_tool);
|
2019-07-19 13:07:26 +02:00
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
planner.synchronize();
|
|
|
|
safe_delay(100); // Give switch time to settle
|
|
|
|
#endif
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = grabxclear;
|
2019-04-11 20:29:17 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X + Security", current_position);
|
2019-09-14 10:05:10 +02:00
|
|
|
_line_to_current(X_AXIS, 0.1f);
|
2019-04-11 20:29:17 +02:00
|
|
|
planner.synchronize();
|
2019-07-18 09:17:46 +02:00
|
|
|
safe_delay(100); // Give switch time to settle
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
|
2019-04-11 20:29:17 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
|
2019-09-14 10:05:10 +02:00
|
|
|
fast_line_to_current(Y_AXIS); // move away from docked toolhead
|
2019-07-18 09:17:46 +02:00
|
|
|
planner.synchronize(); // Always sync last tool-change move
|
2019-07-19 13:07:26 +02:00
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("MST Tool-Change done.", current_position);
|
2019-04-11 20:29:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-01 12:55:23 +02:00
|
|
|
#elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
|
|
|
|
|
|
|
|
inline void est_activate_solenoid() { OUT_WRITE(SOL0_PIN, HIGH); }
|
|
|
|
inline void est_deactivate_solenoid() { OUT_WRITE(SOL0_PIN, LOW); }
|
|
|
|
void est_init() { est_activate_solenoid(); }
|
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
inline void em_switching_toolhead_tool_change(const uint8_t new_tool, bool no_move) {
|
2019-07-01 12:55:23 +02:00
|
|
|
if (no_move) return;
|
|
|
|
|
|
|
|
constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
|
|
|
|
const float placexpos = toolheadposx[active_extruder],
|
2019-07-22 02:33:37 +02:00
|
|
|
grabxpos = toolheadposx[new_tool];
|
2019-09-29 11:25:39 +02:00
|
|
|
const xyz_pos_t &hoffs = hotend_offset[active_extruder];
|
2019-07-01 12:55:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 1. Raise Z-Axis to give enough clearance
|
|
|
|
* 2. Move to position near active extruder parking
|
|
|
|
* 3. Move gently to park position of active extruder
|
|
|
|
* 4. Disengage magnetic field, wait for delay
|
|
|
|
* 5. Leave extruder and move to position near new extruder parking
|
|
|
|
* 6. Move gently to park position of new extruder
|
|
|
|
* 7. Engage magnetic field for new extruder parking
|
|
|
|
* 8. Unpark extruder
|
|
|
|
* 9. Apply Z hotend offset to current position
|
|
|
|
*/
|
|
|
|
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Start EMST Tool-Change", current_position);
|
2019-07-01 12:55:23 +02:00
|
|
|
|
|
|
|
// 1. Raise Z-Axis to give enough clearance
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.z += SWITCHING_TOOLHEAD_Z_HOP;
|
2019-07-18 03:24:25 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis ", current_position);
|
2019-09-14 10:05:10 +02:00
|
|
|
fast_line_to_current(Z_AXIS);
|
2019-07-01 12:55:23 +02:00
|
|
|
|
|
|
|
// 2. Move to position near active extruder parking
|
|
|
|
|
2019-07-18 03:24:25 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
SERIAL_ECHOLNPAIR("(2) Move near active extruder parking", active_extruder);
|
|
|
|
DEBUG_POS("Moving ParkPos", current_position);
|
|
|
|
}
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.set(hoffs.x + placexpos,
|
|
|
|
hoffs.y + SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR);
|
2019-09-14 10:05:10 +02:00
|
|
|
fast_line_to_current(X_AXIS);
|
2019-07-01 12:55:23 +02:00
|
|
|
|
|
|
|
// 3. Move gently to park position of active extruder
|
|
|
|
|
2019-07-18 03:24:25 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
|
|
|
SERIAL_ECHOLNPAIR("(3) Move gently to park position of active extruder", active_extruder);
|
|
|
|
DEBUG_POS("Moving ParkPos", current_position);
|
|
|
|
}
|
2019-07-01 12:55:23 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
|
2019-09-14 10:05:10 +02:00
|
|
|
slow_line_to_current(Y_AXIS);
|
2019-07-01 12:55:23 +02:00
|
|
|
|
|
|
|
// 4. Disengage magnetic field, wait for delay
|
|
|
|
|
|
|
|
planner.synchronize();
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Disengage magnet");
|
2019-07-01 12:55:23 +02:00
|
|
|
est_deactivate_solenoid();
|
|
|
|
|
|
|
|
// 5. Leave extruder and move to position near new extruder parking
|
|
|
|
|
2019-07-18 03:24:25 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
2019-07-19 13:07:26 +02:00
|
|
|
DEBUG_ECHOLNPGM("(5) Move near new extruder parking");
|
2019-07-18 03:24:25 +02:00
|
|
|
DEBUG_POS("Moving ParkPos", current_position);
|
|
|
|
}
|
2019-07-01 12:55:23 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
|
2019-09-14 10:05:10 +02:00
|
|
|
slow_line_to_current(Y_AXIS);
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.set(hoffs.x + grabxpos,
|
|
|
|
hoffs.y + SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR);
|
2019-09-14 10:05:10 +02:00
|
|
|
fast_line_to_current(X_AXIS);
|
2019-07-01 12:55:23 +02:00
|
|
|
|
|
|
|
// 6. Move gently to park position of new extruder
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
|
2019-07-18 03:24:25 +02:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
planner.synchronize();
|
2019-07-19 13:07:26 +02:00
|
|
|
DEBUG_ECHOLNPGM("(6) Move near new extruder");
|
2019-07-18 03:24:25 +02:00
|
|
|
}
|
2019-09-14 10:05:10 +02:00
|
|
|
slow_line_to_current(Y_AXIS);
|
2019-07-01 12:55:23 +02:00
|
|
|
|
|
|
|
// 7. Engage magnetic field for new extruder parking
|
|
|
|
|
|
|
|
planner.synchronize();
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(7) Engage magnetic field");
|
2019-07-01 12:55:23 +02:00
|
|
|
est_activate_solenoid();
|
|
|
|
|
|
|
|
// 8. Unpark extruder
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(8) Unpark extruder");
|
2019-09-14 10:05:10 +02:00
|
|
|
slow_line_to_current(X_AXIS);
|
2019-07-19 13:07:26 +02:00
|
|
|
planner.synchronize(); // Always sync the final move
|
2019-07-01 12:55:23 +02:00
|
|
|
|
|
|
|
// 9. Apply Z hotend offset to current position
|
|
|
|
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("(9) Applying Z-offset", current_position);
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.z += hoffs.z - hotend_offset[new_tool].z;
|
2019-07-01 12:55:23 +02:00
|
|
|
|
2019-07-19 13:07:26 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("EMST Tool-Change done.", current_position);
|
2019-07-01 12:55:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // ELECTROMAGNETIC_SWITCHING_TOOLHEAD
|
2019-04-11 20:29:17 +02:00
|
|
|
|
2019-09-10 09:20:49 +02:00
|
|
|
#if EXTRUDERS
|
|
|
|
inline void invalid_extruder_error(const uint8_t e) {
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_CHAR('T'); SERIAL_ECHO(int(e));
|
|
|
|
SERIAL_CHAR(' '); SERIAL_ECHOLNPGM(MSG_INVALID_EXTRUDER);
|
|
|
|
}
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-03-30 01:11:02 +02:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
inline void dualx_tool_change(const uint8_t new_tool, bool &no_move) {
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
DEBUG_ECHOPGM("Dual X Carriage Mode ");
|
|
|
|
switch (dual_x_carriage_mode) {
|
2019-03-16 04:46:27 +01:00
|
|
|
case DXC_FULL_CONTROL_MODE: DEBUG_ECHOLNPGM("FULL_CONTROL"); break;
|
|
|
|
case DXC_AUTO_PARK_MODE: DEBUG_ECHOLNPGM("AUTO_PARK"); break;
|
|
|
|
case DXC_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DUPLICATION"); break;
|
|
|
|
case DXC_MIRRORED_MODE: DEBUG_ECHOLNPGM("MIRRORED"); break;
|
2018-03-30 01:11:02 +02:00
|
|
|
}
|
2019-03-14 08:25:42 +01:00
|
|
|
}
|
2018-03-30 01:11:02 +02:00
|
|
|
|
|
|
|
const float xhome = x_home_pos(active_extruder);
|
|
|
|
if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
|
2019-09-29 11:25:39 +02:00
|
|
|
&& IsRunning() && !no_move
|
|
|
|
&& (delayed_move_time || current_position.x != xhome)
|
2018-03-30 01:11:02 +02:00
|
|
|
) {
|
2018-11-07 04:52:20 +01:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("MoveX to ", xhome);
|
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
// Park old head
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = xhome;
|
|
|
|
line_to_current_position(planner.settings.max_feedrate_mm_s[X_AXIS]);
|
2018-05-12 08:38:02 +02:00
|
|
|
planner.synchronize();
|
2018-03-30 01:11:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Activate the new extruder ahead of calling set_axis_is_at_home!
|
2019-07-22 02:33:37 +02:00
|
|
|
active_extruder = new_tool;
|
2018-03-30 01:11:02 +02:00
|
|
|
|
|
|
|
// This function resets the max/min values - the current position may be overwritten below.
|
|
|
|
set_axis_is_at_home(X_AXIS);
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
|
2018-03-30 01:11:02 +02:00
|
|
|
|
|
|
|
switch (dual_x_carriage_mode) {
|
|
|
|
case DXC_FULL_CONTROL_MODE:
|
|
|
|
// New current position is the position of the activated extruder
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.x = inactive_extruder_x_pos;
|
2018-03-30 01:11:02 +02:00
|
|
|
// Save the inactive extruder's position (from the old current_position)
|
2019-09-29 11:25:39 +02:00
|
|
|
inactive_extruder_x_pos = destination.x;
|
2018-03-30 01:11:02 +02:00
|
|
|
break;
|
|
|
|
case DXC_AUTO_PARK_MODE:
|
2018-11-07 04:52:20 +01:00
|
|
|
// record current raised toolhead position for use by unpark
|
2019-09-29 11:25:39 +02:00
|
|
|
raised_parked_position = current_position;
|
2018-03-30 01:11:02 +02:00
|
|
|
active_extruder_parked = true;
|
|
|
|
delayed_move_time = 0;
|
|
|
|
break;
|
2018-11-20 06:59:48 +01:00
|
|
|
default:
|
|
|
|
break;
|
2018-03-30 01:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
DEBUG_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
|
|
|
|
DEBUG_POS("New extruder (parked)", current_position);
|
|
|
|
}
|
2018-03-30 01:11:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DUAL_X_CARRIAGE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform a tool-change, which may result in moving the
|
|
|
|
* previous tool out of the way and the new tool into place.
|
|
|
|
*/
|
2019-07-22 02:33:37 +02:00
|
|
|
void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
|
2019-04-11 20:29:17 +02:00
|
|
|
|
|
|
|
#if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
|
2019-07-22 02:33:37 +02:00
|
|
|
if (new_tool == active_extruder) return;
|
2019-04-11 20:29:17 +02:00
|
|
|
#endif
|
|
|
|
|
2018-11-13 11:56:10 +01:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
2018-08-21 16:06:10 +02:00
|
|
|
|
2019-06-24 03:00:48 +02:00
|
|
|
UNUSED(no_move);
|
2018-11-15 00:33:04 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
if (new_tool >= MIXING_VIRTUAL_TOOLS)
|
|
|
|
return invalid_extruder_error(new_tool);
|
2018-11-13 11:56:10 +01:00
|
|
|
|
2019-02-03 06:30:26 +01:00
|
|
|
#if MIXING_VIRTUAL_TOOLS > 1
|
2018-11-07 04:52:20 +01:00
|
|
|
// T0-Tnnn: Switch virtual tool by changing the index to the mix
|
2019-07-22 02:33:37 +02:00
|
|
|
mixer.T(new_tool);
|
2018-11-13 11:56:10 +01:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-02-01 02:10:52 +01:00
|
|
|
#elif ENABLED(PRUSA_MMU2)
|
|
|
|
|
2019-06-24 03:00:48 +02:00
|
|
|
UNUSED(no_move);
|
2019-02-01 02:10:52 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
mmu2.tool_change(new_tool);
|
2019-02-01 02:10:52 +01:00
|
|
|
|
2019-09-10 09:20:49 +02:00
|
|
|
#elif EXTRUDERS == 0
|
|
|
|
|
|
|
|
// Nothing to do
|
|
|
|
UNUSED(new_tool); UNUSED(no_move);
|
|
|
|
|
2018-11-09 07:15:07 +01:00
|
|
|
#elif EXTRUDERS < 2
|
|
|
|
|
2019-06-24 03:00:48 +02:00
|
|
|
UNUSED(no_move);
|
2018-11-15 00:33:04 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
if (new_tool) invalid_extruder_error(new_tool);
|
2018-11-09 07:15:07 +01:00
|
|
|
return;
|
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
#else // EXTRUDERS > 1
|
2018-11-07 04:52:20 +01:00
|
|
|
|
2018-11-13 11:56:10 +01:00
|
|
|
planner.synchronize();
|
2018-11-07 04:52:20 +01:00
|
|
|
|
2019-03-16 04:46:27 +01:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) // Only T0 allowed if the Printer is in DXC_DUPLICATION_MODE or DXC_MIRRORED_MODE
|
2019-07-22 02:33:37 +02:00
|
|
|
if (new_tool != 0 && dxc_is_duplicating())
|
|
|
|
return invalid_extruder_error(new_tool);
|
2018-11-07 04:52:20 +01:00
|
|
|
#endif
|
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
if (new_tool >= EXTRUDERS)
|
|
|
|
return invalid_extruder_error(new_tool);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-06-24 03:00:48 +02:00
|
|
|
if (!no_move && !all_axes_homed()) {
|
2018-10-10 23:49:59 +02:00
|
|
|
no_move = true;
|
2019-06-24 03:00:48 +02:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move (not homed)");
|
2018-10-10 23:49:59 +02:00
|
|
|
}
|
|
|
|
|
2018-11-08 16:48:09 +01:00
|
|
|
#if HAS_LCD_MENU
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.return_to_status();
|
2018-11-07 04:52:20 +01:00
|
|
|
#endif
|
2018-07-29 06:14:46 +02:00
|
|
|
|
2019-06-24 03:00:48 +02:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
const bool idex_full_control = dual_x_carriage_mode == DXC_FULL_CONTROL_MODE;
|
|
|
|
#else
|
|
|
|
constexpr bool idex_full_control = false;
|
|
|
|
#endif
|
|
|
|
|
2019-07-23 03:08:54 +02:00
|
|
|
const uint8_t old_tool = active_extruder;
|
2019-06-24 03:00:48 +02:00
|
|
|
const bool can_move_away = !no_move && !idex_full_control;
|
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
2019-06-24 03:00:48 +02:00
|
|
|
const bool should_swap = can_move_away && toolchange_settings.swap_length;
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
2019-07-22 02:33:37 +02:00
|
|
|
const bool too_cold = !DEBUGGING(DRYRUN) && (thermalManager.targetTooColdToExtrude(old_tool) || thermalManager.targetTooColdToExtrude(new_tool));
|
2018-11-07 04:52:20 +01:00
|
|
|
#else
|
|
|
|
constexpr bool too_cold = false;
|
|
|
|
#endif
|
|
|
|
if (should_swap) {
|
|
|
|
if (too_cold) {
|
2019-01-21 19:50:30 +01:00
|
|
|
SERIAL_ECHO_MSG(MSG_ERR_HOTEND_TOO_COLD);
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(SINGLENOZZLE)
|
2019-07-22 02:33:37 +02:00
|
|
|
active_extruder = new_tool;
|
2018-11-07 04:52:20 +01:00
|
|
|
return;
|
2018-09-24 16:40:48 +02:00
|
|
|
#endif
|
2018-11-07 04:52:20 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
|
|
|
do_pause_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed));
|
2018-09-08 08:43:24 +02:00
|
|
|
#else
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.e -= toolchange_settings.swap_length / planner.e_factor[old_tool];
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.retract_speed), old_tool);
|
2019-06-24 03:00:48 +02:00
|
|
|
planner.synchronize();
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
2018-11-07 04:52:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // TOOLCHANGE_FILAMENT_SWAP
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-07-17 10:41:04 +02:00
|
|
|
#if HAS_LEVELING
|
|
|
|
// Set current position to the physical position
|
|
|
|
TEMPORARY_BED_LEVELING_STATE(false);
|
|
|
|
#endif
|
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
if (new_tool != old_tool) {
|
2019-02-04 07:19:56 +01:00
|
|
|
|
|
|
|
#if SWITCHING_NOZZLE_TWO_SERVOS
|
2019-07-22 02:33:37 +02:00
|
|
|
raise_nozzle(old_tool);
|
2019-02-04 07:19:56 +01:00
|
|
|
#endif
|
|
|
|
|
2019-06-24 03:00:48 +02:00
|
|
|
REMEMBER(fr, feedrate_mm_s, XY_PROBE_FEEDRATE_MM_S);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-06-11 01:01:42 +02:00
|
|
|
#if HAS_SOFTWARE_ENDSTOPS
|
|
|
|
#if HAS_HOTEND_OFFSET
|
2019-07-22 02:33:37 +02:00
|
|
|
#define _EXT_ARGS , old_tool, new_tool
|
2019-06-11 01:01:42 +02:00
|
|
|
#else
|
|
|
|
#define _EXT_ARGS
|
|
|
|
#endif
|
|
|
|
update_software_endstops(X_AXIS _EXT_ARGS);
|
|
|
|
#if DISABLED(DUAL_X_CARRIAGE)
|
|
|
|
update_software_endstops(Y_AXIS _EXT_ARGS);
|
|
|
|
update_software_endstops(Z_AXIS _EXT_ARGS);
|
|
|
|
#endif
|
2018-11-07 04:52:20 +01:00
|
|
|
#endif
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
destination = current_position;
|
2018-11-20 07:04:11 +01:00
|
|
|
|
2019-06-24 03:00:48 +02:00
|
|
|
#if DISABLED(SWITCHING_NOZZLE)
|
|
|
|
if (can_move_away) {
|
2018-11-07 04:52:20 +01:00
|
|
|
// Do a small lift to avoid the workpiece in the move back (below)
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.z += toolchange_settings.z_raise;
|
2018-11-07 04:52:20 +01:00
|
|
|
#if HAS_SOFTWARE_ENDSTOPS
|
2019-09-29 11:25:39 +02:00
|
|
|
NOMORE(current_position.z, soft_endstop.max.z);
|
2018-05-22 07:53:00 +02:00
|
|
|
#endif
|
2019-04-22 04:06:46 +02:00
|
|
|
fast_line_to_current(Z_AXIS);
|
|
|
|
#if ENABLED(TOOLCHANGE_PARK)
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position = toolchange_settings.change_point;
|
2019-04-22 04:06:46 +02:00
|
|
|
#endif
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, feedrate_mm_s, old_tool);
|
2019-06-24 03:00:48 +02:00
|
|
|
planner.synchronize();
|
|
|
|
}
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-03-09 05:13:24 +01:00
|
|
|
#if HAS_HOTEND_OFFSET
|
2019-10-10 02:48:00 +02:00
|
|
|
xyz_pos_t diff = hotend_offset[new_tool] - hotend_offset[old_tool];
|
2018-11-07 05:56:23 +01:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2019-09-29 11:25:39 +02:00
|
|
|
diff.x = 0;
|
2018-11-07 05:56:23 +01:00
|
|
|
#endif
|
2018-11-07 04:52:20 +01:00
|
|
|
#else
|
2019-09-29 11:25:39 +02:00
|
|
|
constexpr xyz_pos_t diff{0};
|
2018-03-30 01:29:52 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-11-03 09:56:33 +01:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2019-07-22 02:33:37 +02:00
|
|
|
dualx_tool_change(new_tool, no_move);
|
2019-07-01 12:55:23 +02:00
|
|
|
#elif ENABLED(PARKING_EXTRUDER) // Dual Parking extruder
|
2019-07-22 02:33:37 +02:00
|
|
|
parking_extruder_tool_change(new_tool, no_move);
|
2019-07-01 12:55:23 +02:00
|
|
|
#elif ENABLED(MAGNETIC_PARKING_EXTRUDER) // Magnetic Parking extruder
|
2019-07-22 02:33:37 +02:00
|
|
|
magnetic_parking_extruder_tool_change(new_tool);
|
2019-07-01 12:55:23 +02:00
|
|
|
#elif ENABLED(SWITCHING_TOOLHEAD) // Switching Toolhead
|
2019-07-22 02:33:37 +02:00
|
|
|
switching_toolhead_tool_change(new_tool, no_move);
|
2019-07-01 12:55:23 +02:00
|
|
|
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching Toolhead
|
2019-07-22 02:33:37 +02:00
|
|
|
magnetic_switching_toolhead_tool_change(new_tool, no_move);
|
2019-07-01 12:55:23 +02:00
|
|
|
#elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching ToolChanger
|
2019-07-22 02:33:37 +02:00
|
|
|
em_switching_toolhead_tool_change(new_tool, no_move);
|
2019-07-01 12:55:23 +02:00
|
|
|
#elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS // Switching Nozzle (single servo)
|
2019-02-04 07:19:56 +01:00
|
|
|
// Raise by a configured distance to avoid workpiece, except with
|
|
|
|
// SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead.
|
2020-01-10 23:12:21 +01:00
|
|
|
if (!no_move) {
|
|
|
|
#if HAS_SOFTWARE_ENDSTOPS
|
|
|
|
const float maxz = _MIN(soft_endstop.max.z, Z_MAX_POS);
|
|
|
|
#else
|
|
|
|
constexpr float maxz = Z_MAX_POS;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Check if Z has space to compensate at least z_offset, and if not, just abort now
|
|
|
|
const float newz = current_position.z + _MAX(-diff.z, 0.0);
|
|
|
|
if (newz > maxz) return;
|
|
|
|
|
|
|
|
current_position.z = _MIN(newz + toolchange_settings.z_raise, maxz);
|
|
|
|
fast_line_to_current(Z_AXIS);
|
|
|
|
}
|
2019-07-22 02:33:37 +02:00
|
|
|
move_nozzle_servo(new_tool);
|
2018-08-04 03:47:29 +02:00
|
|
|
#endif
|
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
#if DISABLED(DUAL_X_CARRIAGE)
|
|
|
|
active_extruder = new_tool; // Set the new active extruder
|
|
|
|
#endif
|
2018-10-08 00:06:14 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
// The newly-selected extruder XYZ is actually at...
|
2020-01-10 23:12:21 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XYZ by { ", diff.x, ", ", diff.y, ", ", diff.z, " }");
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position += diff;
|
2018-10-08 00:06:14 +02:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
// Tell the planner the new "current position"
|
|
|
|
sync_plan_position();
|
2018-10-14 06:08:20 +02:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(DELTA)
|
|
|
|
//LOOP_XYZ(i) update_software_endstops(i); // or modify the constrain function
|
2019-09-29 11:25:39 +02:00
|
|
|
const bool safe_to_move = current_position.z < delta_clip_start_height - 1;
|
2018-11-07 04:52:20 +01:00
|
|
|
#else
|
|
|
|
constexpr bool safe_to_move = true;
|
|
|
|
#endif
|
2018-10-08 22:39:55 +02:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
// Return to position and lower again
|
|
|
|
if (safe_to_move && !no_move && IsRunning()) {
|
2018-10-08 00:06:14 +02:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(SINGLENOZZLE)
|
|
|
|
#if FAN_COUNT > 0
|
2019-07-22 02:33:37 +02:00
|
|
|
singlenozzle_fan_speed[old_tool] = thermalManager.fan_speed[0];
|
|
|
|
thermalManager.fan_speed[0] = singlenozzle_fan_speed[new_tool];
|
2018-10-12 22:19:03 +02:00
|
|
|
#endif
|
2018-10-14 06:08:20 +02:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
singlenozzle_temp[old_tool] = thermalManager.temp_hotend[0].target;
|
|
|
|
if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) {
|
|
|
|
thermalManager.setTargetHotend(singlenozzle_temp[new_tool], 0);
|
2019-07-17 10:12:39 +02:00
|
|
|
#if HAS_DISPLAY
|
2018-11-07 04:52:20 +01:00
|
|
|
thermalManager.set_heating_message(0);
|
|
|
|
#endif
|
|
|
|
(void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling
|
|
|
|
}
|
|
|
|
#endif
|
2018-10-08 00:06:14 +02:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
|
|
|
if (should_swap && !too_cold) {
|
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
2019-07-22 02:33:37 +02:00
|
|
|
do_pause_e_move(toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.prime_speed));
|
|
|
|
do_pause_e_move(toolchange_settings.extra_prime, ADVANCED_PAUSE_PURGE_FEEDRATE);
|
2018-11-07 04:52:20 +01:00
|
|
|
#else
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.e += toolchange_settings.swap_length / planner.e_factor[new_tool];
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed), new_tool);
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.e += toolchange_settings.extra_prime / planner.e_factor[new_tool];
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed * 0.2f), new_tool);
|
2018-11-07 04:52:20 +01:00
|
|
|
#endif
|
|
|
|
planner.synchronize();
|
2019-09-29 11:25:39 +02:00
|
|
|
planner.set_e_position_mm((destination.e = current_position.e = current_position.e - (TOOLCHANGE_FIL_EXTRA_PRIME)));
|
2018-11-07 04:52:20 +01:00
|
|
|
}
|
|
|
|
#endif
|
2018-10-08 00:06:14 +02:00
|
|
|
|
2019-03-05 02:09:31 +01:00
|
|
|
// Prevent a move outside physical bounds
|
2019-04-11 20:29:17 +02:00
|
|
|
#if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
|
|
|
|
// If the original position is within tool store area, go to X origin at once
|
2019-09-29 11:25:39 +02:00
|
|
|
if (destination.y < SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR) {
|
|
|
|
current_position.x = 0;
|
2019-07-22 02:33:37 +02:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], new_tool);
|
2019-04-11 20:29:17 +02:00
|
|
|
planner.synchronize();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
apply_motion_limits(destination);
|
|
|
|
#endif
|
2019-03-05 02:09:31 +01:00
|
|
|
|
2019-06-24 03:00:48 +02:00
|
|
|
// Should the nozzle move back to the old position?
|
|
|
|
if (can_move_away) {
|
|
|
|
#if ENABLED(TOOLCHANGE_NO_RETURN)
|
|
|
|
// Just move back down
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move back Z only");
|
2019-09-29 11:25:39 +02:00
|
|
|
do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
2019-06-24 03:00:48 +02:00
|
|
|
#else
|
|
|
|
// Move back to the original (or adjusted) position
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
|
|
|
|
do_blocking_move_to(destination);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move back skipped");
|
2019-03-05 02:09:31 +01:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
active_extruder_parked = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
|
|
|
else {
|
|
|
|
// Move back down. (Including when the new tool is higher.)
|
2019-09-29 11:25:39 +02:00
|
|
|
do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
2018-10-12 22:19:03 +02:00
|
|
|
}
|
2018-11-07 04:52:20 +01:00
|
|
|
#endif
|
2019-02-01 02:10:52 +01:00
|
|
|
|
|
|
|
#if ENABLED(PRUSA_MMU2)
|
2019-07-22 02:33:37 +02:00
|
|
|
mmu2.tool_change(new_tool);
|
2019-02-01 02:10:52 +01:00
|
|
|
#endif
|
|
|
|
|
2019-02-04 07:19:56 +01:00
|
|
|
#if SWITCHING_NOZZLE_TWO_SERVOS
|
2019-07-22 02:33:37 +02:00
|
|
|
lower_nozzle(new_tool);
|
2019-02-04 07:19:56 +01:00
|
|
|
#endif
|
2019-02-06 13:39:42 +01:00
|
|
|
|
2019-07-22 02:33:37 +02:00
|
|
|
} // (new_tool != old_tool)
|
2018-10-08 00:06:14 +02:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
planner.synchronize();
|
2018-10-08 00:06:14 +02:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
|
|
|
|
disable_all_solenoids();
|
|
|
|
enable_solenoid_on_active_extruder();
|
|
|
|
#endif
|
2018-10-08 00:06:14 +02:00
|
|
|
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(MK2_MULTIPLEXER)
|
2019-07-22 02:33:37 +02:00
|
|
|
if (new_tool >= E_STEPPERS) return invalid_extruder_error(new_tool);
|
|
|
|
select_multiplexed_stepper(new_tool);
|
2018-11-07 04:52:20 +01:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-03-30 01:29:52 +02:00
|
|
|
#if DO_SWITCH_EXTRUDER
|
2018-05-12 08:38:02 +02:00
|
|
|
planner.synchronize();
|
2017-09-06 13:28:31 +02:00
|
|
|
move_extruder_servo(active_extruder);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_FANMUX
|
|
|
|
fanmux_switch(active_extruder);
|
|
|
|
#endif
|
2018-08-21 16:06:10 +02:00
|
|
|
|
2020-01-21 09:51:23 +01:00
|
|
|
#ifdef EVENT_GCODE_AFTER_TOOLCHANGE
|
|
|
|
gcode.process_subcommands_now_P(EVENT_GCODE_AFTER_TOOLCHANGE);
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
SERIAL_ECHO_START();
|
2018-09-11 06:09:26 +02:00
|
|
|
SERIAL_ECHOLNPAIR(MSG_ACTIVE_EXTRUDER, int(active_extruder));
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
#endif // EXTRUDERS > 1
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|