Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,27 @@
* the E3D Tool Changer. Toolheads are locked with a servo.
*/
//#define SWITCHING_TOOLHEAD
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders

/**
* Magnetic Switching Toolhead
*
* Support swappable and dockable toolheads with a magnetic
* docking mechanism using movement and no servo.
*/
//#define MAGNETIC_SWITCHING_TOOLHEAD

#if EITHER(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_RELEASE 5 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_X_SECURITY -35 // (mm) Security distance X axis
#endif
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void menu_move() {
else
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));

#if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
#if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, MAGNETIC_SWITCHING_TOOLHEAD)

#if EXTRUDERS == 6
switch (active_extruder) {
Expand Down
145 changes: 144 additions & 1 deletion Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,133 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {

#endif // SWITCHING_TOOLHEAD

#if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)

inline void magnetic_switching_toolhead_tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {
if (no_move) return;

const float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS,
placexpos = toolheadposx[active_extruder],
grabxpos = toolheadposx[tmp_extruder];

/**
* 1. Raise Z to give enough clearance
* 2. Move to switch position of current toolhead
* 3. Release and place toolhead in the dock
* 4. Move to the new toolhead
* 5. Grab the new toolhead and move to security position
*/

if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);

// 1. Raise Z to give enough clearance

current_position[Z_AXIS] += toolchange_settings.z_raise;

if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);

planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
planner.synchronize();

// 2. Move to switch position current toolhead

current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR;

if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
DEBUG_POS("Move Y SwitchPos + Security", current_position);
}

planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
planner.synchronize();

current_position[X_AXIS] = placexpos + SWITCHING_TOOLHEAD_X_SECURITY;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move X SwitchPos + Security", current_position);

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;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);

planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
planner.synchronize();

current_position[X_AXIS] = placexpos;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move X SwitchPos", current_position);

planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[X_AXIS] * 0.25), active_extruder);
planner.synchronize();

// 3. Release and place toolhead in the dock

if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Release and Place Toolhead");

current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);

planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.1), active_extruder);
planner.synchronize();

current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_SECURITY;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);

planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
planner.synchronize();

// 4. Move to new toolhead position

if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");

current_position[X_AXIS] = grabxpos;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);

planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
planner.synchronize();

// 5. Grab the new toolhead and move to security position

if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab new toolhead and move to security position");

current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);

planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
planner.synchronize();

current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);

planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.2, active_extruder);
planner.synchronize();
safe_delay(100);

current_position[X_AXIS] = grabxpos + SWITCHING_TOOLHEAD_X_SECURITY;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X + Security", current_position);

planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.1, active_extruder);
planner.synchronize();
safe_delay(100);

current_position[Y_AXIS] += SWITCHING_TOOLHEAD_Y_CLEAR;

if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);

planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
planner.synchronize();
}

#endif // MAGNETIC_SWITCHING_TOOLHEAD

inline void invalid_extruder_error(const uint8_t e) {
SERIAL_ECHO_START();
SERIAL_CHAR('T'); SERIAL_ECHO(int(e));
Expand Down Expand Up @@ -557,6 +684,11 @@ inline void invalid_extruder_error(const uint8_t e) {
* previous tool out of the way and the new tool into place.
*/
void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {

#if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
if (tmp_extruder == active_extruder) return;
#endif

#if ENABLED(MIXING_EXTRUDER)

UNUSED(fr_mm_s); UNUSED(no_move);
Expand Down Expand Up @@ -686,6 +818,8 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
magnetic_parking_extruder_tool_change(tmp_extruder);
#elif ENABLED(SWITCHING_TOOLHEAD) // Switching Toolhead
switching_toolhead_tool_change(tmp_extruder, fr_mm_s, no_move);
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching Toolhead
magnetic_switching_toolhead_tool_change(tmp_extruder, fr_mm_s, no_move);
#elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS
// Raise by a configured distance to avoid workpiece, except with
// SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead.
Expand Down Expand Up @@ -755,7 +889,16 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
#endif

// Prevent a move outside physical bounds
apply_motion_limits(destination);
#if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
// If the original position is within tool store area, go to X origin at once
if (destination[Y_AXIS] < SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR) {
current_position[X_AXIS] = 0;
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
planner.synchronize();
}
#else
apply_motion_limits(destination);
#endif

// Move back to the original (or tweaked) position
do_blocking_move_to(destination);
Expand Down
28 changes: 21 additions & 7 deletions config/default/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,27 @@
* the E3D Tool Changer. Toolheads are locked with a servo.
*/
//#define SWITCHING_TOOLHEAD
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders

/**
* Magnetic Switching Toolhead
*
* Support swappable and dockable toolheads with a magnetic
* docking mechanism using movement and no servo.
*/
//#define MAGNETIC_SWITCHING_TOOLHEAD

#if EITHER(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_RELEASE 5 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_X_SECURITY -35 // (mm) Security distance X axis
#endif
#endif

/**
Expand Down
28 changes: 21 additions & 7 deletions config/examples/3DFabXYZ/Migbot/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,27 @@
* the E3D Tool Changer. Toolheads are locked with a servo.
*/
//#define SWITCHING_TOOLHEAD
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders

/**
* Magnetic Switching Toolhead
*
* Support swappable and dockable toolheads with a magnetic
* docking mechanism using movement and no servo.
*/
//#define MAGNETIC_SWITCHING_TOOLHEAD

#if EITHER(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_RELEASE 5 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_X_SECURITY -35 // (mm) Security distance X axis
#endif
#endif

/**
Expand Down
28 changes: 21 additions & 7 deletions config/examples/AlephObjects/TAZ4/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,27 @@
* the E3D Tool Changer. Toolheads are locked with a servo.
*/
//#define SWITCHING_TOOLHEAD
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders

/**
* Magnetic Switching Toolhead
*
* Support swappable and dockable toolheads with a magnetic
* docking mechanism using movement and no servo.
*/
//#define MAGNETIC_SWITCHING_TOOLHEAD

#if EITHER(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_RELEASE 5 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_X_SECURITY -35 // (mm) Security distance X axis
#endif
#endif

/**
Expand Down
28 changes: 21 additions & 7 deletions config/examples/AliExpress/CL-260/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,27 @@
* the E3D Tool Changer. Toolheads are locked with a servo.
*/
//#define SWITCHING_TOOLHEAD
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders

/**
* Magnetic Switching Toolhead
*
* Support swappable and dockable toolheads with a magnetic
* docking mechanism using movement and no servo.
*/
//#define MAGNETIC_SWITCHING_TOOLHEAD

#if EITHER(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_RELEASE 5 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_X_SECURITY -35 // (mm) Security distance X axis
#endif
#endif

/**
Expand Down
28 changes: 21 additions & 7 deletions config/examples/AliExpress/UM2pExt/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,27 @@
* the E3D Tool Changer. Toolheads are locked with a servo.
*/
//#define SWITCHING_TOOLHEAD
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders

/**
* Magnetic Switching Toolhead
*
* Support swappable and dockable toolheads with a magnetic
* docking mechanism using movement and no servo.
*/
//#define MAGNETIC_SWITCHING_TOOLHEAD

#if EITHER(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_RELEASE 5 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_X_SECURITY -35 // (mm) Security distance X axis
#endif
#endif

/**
Expand Down
Loading