Prusa MMU2 (#12967)

This commit is contained in:
revilor
2019-02-01 02:10:52 +01:00
committed by Scott Lahteine
parent 996f7d1642
commit 6a57d0b381
180 changed files with 6218 additions and 49 deletions

View File

@ -27,11 +27,21 @@
#include "../../module/motion.h"
#endif
#if ENABLED(PRUSA_MMU2)
#include "../../feature/prusa_MMU2/mmu2.h"
#endif
/**
* T0-T3: Switch tool, usually switching extruders
* T0-T<n>: Switch tool, usually switching extruders
*
* F[units/min] Set the movement feedrate
* S1 Don't move the tool in XY after change
*
* For PRUSA_MMU2:
* T[n] Gcode to extrude at least 38.10 mm at feedrate 19.02 mm/s must follow immediately to load to extruder wheels.
* T? Gcode to extrude shouldn't have to follow. Load to extruder wheels is done automatically.
* Tx Same as T?, but nozzle doesn't have to be preheated. Tc requires a preheated nozzle to finish filament load.
* Tc Load to nozzle after filament was prepared by Tc and nozzle is already heated.
*/
void GcodeSuite::T(const uint8_t tool_index) {
@ -44,6 +54,13 @@ void GcodeSuite::T(const uint8_t tool_index) {
}
#endif
#if ENABLED(PRUSA_MMU2)
if (parser.string_arg) {
mmu2.toolChange(parser.string_arg); // Special commands T?/Tx/Tc
return;
}
#endif
#if EXTRUDERS < 2
tool_change(tool_index);

View File

@ -37,6 +37,10 @@
#include "../../../lcd/ultralcd.h"
#endif
#if ENABLED(PRUSA_MMU2)
#include "../../../feature/prusa_MMU2/mmu2_menu.h"
#endif
/**
* M600: Pause for filament change
*
@ -71,7 +75,7 @@ void GcodeSuite::M600() {
#endif
// Show initial "wait for start" message
#if HAS_LCD_MENU
#if HAS_LCD_MENU && DISABLED(PRUSA_MMU2)
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT, target_extruder);
#endif
@ -110,16 +114,23 @@ void GcodeSuite::M600() {
park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
#endif
// Unload filament
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
: fc_settings[active_extruder].unload_length);
#if ENABLED(PRUSA_MMU2)
// For MMU2 reset retract and load/unload values so they don't mess with MMU filament handling
constexpr float unload_length = 0.5f,
slow_load_length = 0.0f,
fast_load_length = 0.0f;
#else
// Unload filament
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
: fc_settings[active_extruder].unload_length);
// Slow load filament
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
// Slow load filament
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
// Fast load filament
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
: fc_settings[active_extruder].load_length);
// Fast load filament
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
: fc_settings[active_extruder].load_length);
#endif
const int beep_count = parser.intval('B',
#ifdef FILAMENT_CHANGE_ALERT_BEEPS
@ -130,8 +141,13 @@ void GcodeSuite::M600() {
);
if (pause_print(retract, park_point, unload_length, true DXC_PASS)) {
wait_for_confirmation(true, beep_count DXC_PASS);
resume_print(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, beep_count DXC_PASS);
#if ENABLED(PRUSA_MMU2)
mmu2_M600();
resume_print(slow_load_length, fast_load_length, 0, beep_count DXC_PASS);
#else
wait_for_confirmation(true, beep_count DXC_PASS);
resume_print(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, beep_count DXC_PASS);
#endif
}
#if EXTRUDERS > 1

View File

@ -38,6 +38,10 @@
#include "../../../lcd/ultralcd.h"
#endif
#if ENABLED(PRUSA_MMU2)
#include "../../../feature/prusa_MMU2/mmu2.h"
#endif
/**
* M701: Load filament
*
@ -67,7 +71,7 @@ void GcodeSuite::M701() {
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, ADVANCED_PAUSE_MODE_LOAD_FILAMENT, target_extruder);
#endif
#if EXTRUDERS > 1
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Change toolhead if specified
uint8_t active_extruder_before_filament_change = active_extruder;
if (active_extruder != target_extruder)
@ -79,21 +83,25 @@ void GcodeSuite::M701() {
do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
// Load filament
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
: fc_settings[active_extruder].load_length);
load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
true, thermalManager.still_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
#if ENABLED(DUAL_X_CARRIAGE)
, target_extruder
#endif
);
#if ENABLED(PRUSA_MMU2)
mmu2.loadFilamentToNozzle(target_extruder);
#else
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
: fc_settings[active_extruder].load_length);
load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
true, thermalManager.still_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
#if ENABLED(DUAL_X_CARRIAGE)
, target_extruder
#endif
);
#endif
// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
#if EXTRUDERS > 1
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Restore toolhead if it was changed
if (active_extruder_before_filament_change != active_extruder)
tool_change(active_extruder_before_filament_change, 0, false);
@ -134,7 +142,7 @@ void GcodeSuite::M702() {
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_UNLOAD, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, target_extruder);
#endif
#if EXTRUDERS > 1
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Change toolhead if specified
uint8_t active_extruder_before_filament_change = active_extruder;
if (active_extruder != target_extruder)
@ -146,28 +154,32 @@ void GcodeSuite::M702() {
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, false);
unload_filament(-fc_settings[e].unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
#if ENABLED(PRUSA_MMU2)
mmu2.unload();
#else
#if EXTRUDERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
if (!parser.seenval('T')) {
HOTEND_LOOP() {
if (e != active_extruder) tool_change(e, 0, false);
unload_filament(-fc_settings[e].unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
}
}
}
else
#endif
{
// Unload length
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
: fc_settings[target_extruder].unload_length);
else
#endif
{
// Unload length
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
: fc_settings[target_extruder].unload_length);
unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
}
unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
}
#endif
// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
#if EXTRUDERS > 1
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Restore toolhead if it was changed
if (active_extruder_before_filament_change != active_extruder)
tool_change(active_extruder_before_filament_change, 0, false);

View File

@ -0,0 +1,49 @@
/**
* 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(PRUSA_MMU2)
#include "../../gcode.h"
#include "../../../feature/prusa_MMU2/mmu2.h"
/**
* M403: Set filament type for MMU2
*
* Valid filament type values:
*
* 0 Default
* 1 Flexible
* 2 PVA
*/
void GcodeSuite::M403() {
int8_t index = parser.intval('E', -1),
type = parser.intval('F', -1);
if (WITHIN(index, 0, 4) && WITHIN(type, 0, 2))
mmu2.setFilamentType(index, type);
else
SERIAL_ECHO_MSG("M403 - bad arguments.");
}
#endif // PRUSA_MMU2

View File

@ -557,6 +557,10 @@ void GcodeSuite::process_parsed_command(
case 402: M402(); break; // M402: Stow probe
#endif
#if ENABLED(PRUSA_MMU2)
case 403: M403(); break;
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
case 404: M404(); break; // M404: Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
case 405: M405(); break; // M405: Turn on filament sensor for control

View File

@ -191,6 +191,7 @@
* M400 - Finish all moves.
* M401 - Deploy and activate Z probe. (Requires a probe)
* M402 - Deactivate and stow Z probe. (Requires a probe)
* M403 - Set filament type for PRUSA MMU2
* M404 - Display or set the Nominal Filament Width: "W<diameter>". (Requires FILAMENT_WIDTH_SENSOR)
* M405 - Enable Filament Sensor flow control. "M405 D<delay_cm>". (Requires FILAMENT_WIDTH_SENSOR)
* M406 - Disable Filament Sensor flow control. (Requires FILAMENT_WIDTH_SENSOR)
@ -699,6 +700,10 @@ private:
static void M402();
#endif
#if ENABLED(PRUSA_MMU2)
static void M403();
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
static void M404();
static void M405();

View File

@ -143,12 +143,27 @@ void GCodeParser::parse(char *p) {
while (*p == ' ') p++;
// Bail if there's no command code number
if (!NUMERIC(*p)) return;
// Prusa MMU2 has T?/Tx/Tc commands
#if DISABLED(PRUSA_MMU2)
if (!NUMERIC(*p)) return;
#endif
// Save the command letter at this point
// A '?' signifies an unknown command
command_letter = letter;
#if ENABLED(PRUSA_MMU2)
if (letter == 'T') {
// check for special MMU2 T?/Tx/Tc commands
if (*p == '?' || *p == 'x' || *p == 'c') {
string_arg = p;
return;
}
}
#endif
// Get the code number - integer digits only
codenum = 0;
do { codenum *= 10, codenum += *p++ - '0'; } while (NUMERIC(*p));