Merge pull request #9042 from thinkyhead/bf2_M701_M702
[2.0.x] Improved Pause/Load/Unload, M701-M702
This commit is contained in:
@ -54,7 +54,7 @@ void GcodeSuite::M18_M84() {
|
||||
if (parser.seen('X')) disable_X();
|
||||
if (parser.seen('Y')) disable_Y();
|
||||
if (parser.seen('Z')) disable_Z();
|
||||
#if E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN // Only enable on boards that have separate ENABLE_PINS
|
||||
#if E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN // Only disable on boards that have separate ENABLE_PINS
|
||||
if (parser.seen('E')) disable_e_steppers();
|
||||
#endif
|
||||
}
|
||||
|
@ -33,24 +33,34 @@
|
||||
#include "../../../module/tool_change.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(ULTIPANEL)
|
||||
#include "../../../lcd/ultralcd.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* M600: Pause for filament change
|
||||
*
|
||||
* E[distance] - Retract the filament this far (negative value)
|
||||
* E[distance] - Retract the filament this far
|
||||
* Z[distance] - Move the Z axis by this distance
|
||||
* X[position] - Move to this X position, with Y
|
||||
* Y[position] - Move to this Y position, with X
|
||||
* U[distance] - Retract distance for removal (negative value) (manual reload)
|
||||
* L[distance] - Extrude distance for insertion (positive value) (manual reload)
|
||||
* U[distance] - Retract distance for removal (manual reload)
|
||||
* L[distance] - Extrude distance for insertion (manual reload)
|
||||
* B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
|
||||
* T[toolhead] - Select extruder for filament change
|
||||
*
|
||||
* Default values are used for omitted arguments.
|
||||
*
|
||||
*/
|
||||
void GcodeSuite::M600() {
|
||||
point_t park_point = NOZZLE_PARK_POINT;
|
||||
|
||||
if (get_target_extruder_from_command()) return;
|
||||
|
||||
// Show initial message
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT, target_extruder);
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
|
||||
// Don't allow filament change without homing first
|
||||
if (axis_unhomed_error()) home_all_axes();
|
||||
@ -58,22 +68,17 @@ void GcodeSuite::M600() {
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
// Change toolhead if specified
|
||||
uint8_t active_extruder_before_filament_change = -1;
|
||||
if (parser.seen('T')) {
|
||||
const uint8_t extruder = parser.value_byte();
|
||||
if (active_extruder != extruder) {
|
||||
active_extruder_before_filament_change = active_extruder;
|
||||
tool_change(extruder, 0, true);
|
||||
}
|
||||
}
|
||||
uint8_t active_extruder_before_filament_change = active_extruder;
|
||||
if (active_extruder != target_extruder)
|
||||
tool_change(target_extruder, 0, true);
|
||||
#endif
|
||||
|
||||
// Initial retract before move to filament change position
|
||||
const float retract = parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
|
||||
const float retract = -FABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
|
||||
#ifdef PAUSE_PARK_RETRACT_LENGTH
|
||||
- (PAUSE_PARK_RETRACT_LENGTH)
|
||||
+ (PAUSE_PARK_RETRACT_LENGTH)
|
||||
#endif
|
||||
;
|
||||
);
|
||||
|
||||
// Move XY axes to filament change position or given position
|
||||
if (parser.seenval('X')) park_point.x = parser.linearval('X');
|
||||
@ -88,22 +93,16 @@ void GcodeSuite::M600() {
|
||||
#endif
|
||||
|
||||
// Unload filament
|
||||
const float unload_length = parser.seen('U') ? parser.value_axis_units(E_AXIS) : 0
|
||||
#if defined(FILAMENT_CHANGE_UNLOAD_LENGTH) && FILAMENT_CHANGE_UNLOAD_LENGTH > 0
|
||||
- (FILAMENT_CHANGE_UNLOAD_LENGTH)
|
||||
#endif
|
||||
;
|
||||
const float unload_length = -FABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
|
||||
: filament_change_unload_length[active_extruder]);
|
||||
|
||||
// Load filament
|
||||
const float load_length = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
|
||||
#ifdef FILAMENT_CHANGE_LOAD_LENGTH
|
||||
+ FILAMENT_CHANGE_LOAD_LENGTH
|
||||
#endif
|
||||
;
|
||||
const float load_length = FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
|
||||
: filament_change_load_length[active_extruder]);
|
||||
|
||||
const int beep_count = parser.intval('B',
|
||||
#ifdef FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
|
||||
FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
|
||||
#ifdef FILAMENT_CHANGE_ALERT_BEEPS
|
||||
FILAMENT_CHANGE_ALERT_BEEPS
|
||||
#else
|
||||
-1
|
||||
#endif
|
||||
@ -111,14 +110,14 @@ void GcodeSuite::M600() {
|
||||
|
||||
const bool job_running = print_job_timer.isRunning();
|
||||
|
||||
if (pause_print(retract, park_point, unload_length, beep_count, true)) {
|
||||
if (pause_print(retract, park_point, unload_length, true)) {
|
||||
wait_for_filament_reload(beep_count);
|
||||
resume_print(load_length, ADVANCED_PAUSE_EXTRUDE_LENGTH, beep_count);
|
||||
}
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
// Restore toolhead if it was changed
|
||||
if (active_extruder_before_filament_change >= 0)
|
||||
if (active_extruder_before_filament_change != active_extruder)
|
||||
tool_change(active_extruder_before_filament_change, 0, true);
|
||||
#endif
|
||||
|
||||
|
65
Marlin/src/gcode/feature/pause/M603.cpp
Normal file
65
Marlin/src/gcode/feature/pause/M603.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/pause.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../module/printcounter.h"
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
#include "../../../module/tool_change.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* M603: Configure filament change
|
||||
*
|
||||
* T[toolhead] - Select extruder to configure, active extruder if not specified
|
||||
* U[distance] - Retract distance for removal, for the specified extruder
|
||||
* L[distance] - Extrude distance for insertion, for the specified extruder
|
||||
*
|
||||
*/
|
||||
inline void GcodeSuite::M603() {
|
||||
|
||||
if (get_target_extruder_from_command()) return;
|
||||
|
||||
// Unload length
|
||||
if (parser.seen('U')) {
|
||||
filament_change_unload_length[target_extruder] = FABS(parser.value_axis_units(E_AXIS));
|
||||
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
||||
NOMORE(filament_change_unload_length[target_extruder], EXTRUDE_MAXLENGTH);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Load length
|
||||
if (parser.seen('L')) {
|
||||
filament_change_load_length[target_extruder] = FABS(parser.value_axis_units(E_AXIS));
|
||||
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
||||
NOMORE(filament_change_load_length[target_extruder], EXTRUDE_MAXLENGTH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
165
Marlin/src/gcode/feature/pause/M701_M702.cpp
Normal file
165
Marlin/src/gcode/feature/pause/M701_M702.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../Marlin.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../libs/point_t.h"
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
#include "../../../module/tool_change.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(ULTIPANEL)
|
||||
#include "../../../lcd/ultralcd.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* M701: Load filament
|
||||
*
|
||||
* T[extruder] - Optional extruder number. Current extruder if omitted.
|
||||
* Z[distance] - Move the Z axis by this distance
|
||||
* L[distance] - Extrude distance for insertion (positive value) (manual reload)
|
||||
*
|
||||
* Default values are used for omitted arguments.
|
||||
*/
|
||||
void GcodeSuite::M701() {
|
||||
point_t park_point = NOZZLE_PARK_POINT;
|
||||
|
||||
if (get_target_extruder_from_command()) return;
|
||||
|
||||
// Z axis lift
|
||||
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
|
||||
|
||||
// Load filament
|
||||
const float load_length = FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) :
|
||||
filament_change_load_length[target_extruder]);
|
||||
|
||||
// Show initial message
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, ADVANCED_PAUSE_MODE_LOAD_FILAMENT, target_extruder);
|
||||
#endif
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
// Change toolhead if specified
|
||||
uint8_t active_extruder_before_filament_change = active_extruder;
|
||||
if (active_extruder != target_extruder)
|
||||
tool_change(target_extruder, 0, true);
|
||||
#endif
|
||||
|
||||
// Lift Z axis
|
||||
if (park_point.z > 0)
|
||||
do_blocking_move_to_z(min(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
|
||||
|
||||
load_filament(load_length, ADVANCED_PAUSE_EXTRUDE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS, true,
|
||||
thermalManager.wait_for_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT);
|
||||
|
||||
// Restore Z axis
|
||||
if (park_point.z > 0)
|
||||
do_blocking_move_to_z(max(current_position[Z_AXIS] - park_point.z, Z_MIN_POS), NOZZLE_PARK_Z_FEEDRATE);
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
// Restore toolhead if it was changed
|
||||
if (active_extruder_before_filament_change != active_extruder)
|
||||
tool_change(active_extruder_before_filament_change, 0, true);
|
||||
#endif
|
||||
|
||||
// Show status screen
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* M702: Unload filament
|
||||
*
|
||||
* T[extruder] - Optional extruder number. If omitted, current extruder
|
||||
* (or ALL extruders with FILAMENT_UNLOAD_ALL_EXTRUDERS).
|
||||
* Z[distance] - Move the Z axis by this distance
|
||||
* U[distance] - Retract distance for removal (manual reload)
|
||||
*
|
||||
* Default values are used for omitted arguments.
|
||||
*/
|
||||
void GcodeSuite::M702() {
|
||||
point_t park_point = NOZZLE_PARK_POINT;
|
||||
|
||||
if (get_target_extruder_from_command()) return;
|
||||
|
||||
// Z axis lift
|
||||
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
|
||||
|
||||
// Show initial message
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_UNLOAD, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, target_extruder);
|
||||
#endif
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
// Change toolhead if specified
|
||||
uint8_t active_extruder_before_filament_change = active_extruder;
|
||||
if (active_extruder != target_extruder)
|
||||
tool_change(target_extruder, 0, true);
|
||||
#endif
|
||||
|
||||
// Lift Z axis
|
||||
if (park_point.z > 0)
|
||||
do_blocking_move_to_z(min(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
|
||||
|
||||
// Unload filament
|
||||
#if EXTRUDERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
|
||||
if (!parser.seenval('T')) {
|
||||
HOTEND_LOOP() {
|
||||
if (e != active_extruder) tool_change(e, 0, true);
|
||||
unload_filament(-filament_change_unload_length[e], true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// Unload length
|
||||
const float unload_length = -FABS(parser.seen('U') ? parser.value_axis_units(E_AXIS) :
|
||||
filament_change_unload_length[target_extruder]);
|
||||
|
||||
unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
|
||||
}
|
||||
|
||||
// Restore Z axis
|
||||
if (park_point.z > 0)
|
||||
do_blocking_move_to_z(max(current_position[Z_AXIS] - park_point.z, Z_MIN_POS), NOZZLE_PARK_Z_FEEDRATE);
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
// Restore toolhead if it was changed
|
||||
if (active_extruder_before_filament_change != active_extruder)
|
||||
tool_change(active_extruder_before_filament_change, 0, true);
|
||||
#endif
|
||||
|
||||
// Show status screen
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(MK2_MULTIPLEXER)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../feature/snmm.h"
|
||||
#include "../../../Marlin.h"
|
||||
|
||||
/**
|
||||
* M702: Unload all extruders
|
||||
*/
|
||||
void GcodeSuite::M702() {
|
||||
for (uint8_t s = 0; s < E_STEPPERS; s++) {
|
||||
select_multiplexed_stepper(s);
|
||||
// TODO: standard unload filament function
|
||||
// MK2 firmware behavior:
|
||||
// - Make sure temperature is high enough
|
||||
// - Raise Z to at least 15 to make room
|
||||
// - Extrude 1cm of filament in 1 second
|
||||
// - Under 230C quickly purge ~12mm, over 230C purge ~10mm
|
||||
// - Change E max feedrate to 80, eject the filament from the tube. Sync.
|
||||
// - Restore E max feedrate to 50
|
||||
}
|
||||
// Go back to the last active extruder
|
||||
select_multiplexed_stepper(active_extruder);
|
||||
disable_e_steppers();
|
||||
}
|
||||
|
||||
#endif // MK2_MULTIPLEXER
|
@ -399,8 +399,7 @@ void GcodeSuite::process_parsed_command() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(PARK_HEAD_ON_PAUSE)
|
||||
case 125: // M125: Store current position and move to filament change position
|
||||
M125(); break;
|
||||
case 125: M125(); break; // M125: Store current position and move to filament change position
|
||||
#endif
|
||||
|
||||
#if ENABLED(BARICUDA)
|
||||
|
@ -198,9 +198,12 @@
|
||||
* M503 - Print the current settings (in memory): "M503 S<verbose>". S0 specifies compact output.
|
||||
* M540 - Enable/disable SD card abort on endstop hit: "M540 S<state>". (Requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
||||
* M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
|
||||
* M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
|
||||
* M605 - Set Dual X-Carriage movement mode: "M605 S<mode> [X<x_offset>] [R<temp_offset>]". (Requires DUAL_X_CARRIAGE)
|
||||
* M665 - Set delta configurations: "M665 L<diagonal rod> R<delta radius> S<segments/s> A<rod A trim mm> B<rod B trim mm> C<rod C trim mm> I<tower A trim angle> J<tower B trim angle> K<tower C trim angle>" (Requires DELTA)
|
||||
* M666 - Set delta endstop adjustment. (Requires DELTA)
|
||||
* M605 - Set dual x-carriage movement mode: "M605 S<mode> [X<x_offset>] [R<temp_offset>]". (Requires DUAL_X_CARRIAGE)
|
||||
* M701 - Load filament (requires FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
* M702 - Unload filament (requires FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
* M851 - Set Z probe's Z offset in current units. (Negative = below the nozzle.)
|
||||
* M852 - Set skew factors: "M852 [I<xy>] [J<xz>] [K<yz>]". (Requires SKEW_CORRECTION_GCODE, and SKEW_CORRECTION_FOR_Z for IJ)
|
||||
* M860 - Report the position of position encoder modules.
|
||||
@ -685,6 +688,7 @@ private:
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
static void M600();
|
||||
static void M603();
|
||||
#endif
|
||||
|
||||
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
|
||||
@ -699,7 +703,8 @@ private:
|
||||
static void M666();
|
||||
#endif
|
||||
|
||||
#if ENABLED(MK2_MULTIPLEXER)
|
||||
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
static void M701();
|
||||
static void M702();
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user