Fix mixing extruder filament change (#13803)

This commit is contained in:
Thomas Moore
2019-05-01 22:55:58 -04:00
committed by Scott Lahteine
parent bf54251a10
commit ee243e4edf
15 changed files with 182 additions and 52 deletions

View File

@ -41,6 +41,10 @@
#include "../../../lcd/menu/menu_mmu2.h"
#endif
#if ENABLED(MIXING_EXTRUDER)
#include "../../../feature/mixing.h"
#endif
/**
* M600: Pause for filament change
*
@ -58,8 +62,21 @@
void GcodeSuite::M600() {
point_t park_point = NOZZLE_PARK_POINT;
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
#if ENABLED(MIXING_EXTRUDER)
const int8_t target_e_stepper = get_target_e_stepper_from_command();
if (target_e_stepper < 0) return;
const uint8_t old_mixing_tool = mixer.get_current_vtool();
mixer.T(MIXER_DIRECT_SET_TOOL);
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0);
mixer.normalize();
const int8_t target_extruder = active_extruder;
#else
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
#endif
#if ENABLED(DUAL_X_CARRIAGE)
int8_t DXC_ext = target_extruder;
@ -155,6 +172,10 @@ void GcodeSuite::M600() {
if (active_extruder_before_filament_change != active_extruder)
tool_change(active_extruder_before_filament_change, 0, false);
#endif
#if ENABLED(MIXING_EXTRUDER)
mixer.T(old_mixing_tool); // Restore original mixing tool
#endif
}
#endif // ADVANCED_PAUSE_FEATURE

View File

@ -42,10 +42,15 @@
#include "../../../feature/prusa_MMU2/mmu2.h"
#endif
#if ENABLED(MIXING_EXTRUDER)
#include "../../../feature/mixing.h"
#endif
/**
* M701: Load filament
*
* T<extruder> - Optional extruder number. Current extruder if omitted.
* T<extruder> - Extruder number. Required for mixing extruder.
* For non-mixing, current extruder if omitted.
* Z<distance> - Move the Z axis by this distance
* L<distance> - Extrude distance for insertion (positive value) (manual reload)
*
@ -59,9 +64,21 @@ void GcodeSuite::M701() {
if (axis_unhomed_error()) park_point.z = 0;
#endif
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
#if ENABLED(MIXING_EXTRUDER)
const int8_t target_e_stepper = get_target_e_stepper_from_command();
if (target_e_stepper < 0) return;
const uint8_t old_mixing_tool = mixer.get_current_vtool();
mixer.T(MIXER_DIRECT_SET_TOOL);
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0);
mixer.normalize();
const int8_t target_extruder = active_extruder;
#else
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
#endif
// Z axis lift
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
@ -107,6 +124,10 @@ void GcodeSuite::M701() {
tool_change(active_extruder_before_filament_change, 0, false);
#endif
#if ENABLED(MIXING_EXTRUDER)
mixer.T(old_mixing_tool); // Restore original mixing tool
#endif
// Show status screen
#if HAS_LCD_MENU
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
@ -116,7 +137,8 @@ void GcodeSuite::M701() {
/**
* M702: Unload filament
*
* T<extruder> - Optional extruder number. If omitted, current extruder
* T<extruder> - Extruder number. Required for mixing extruder.
* For non-mixing, 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)
@ -131,8 +153,32 @@ void GcodeSuite::M702() {
if (axis_unhomed_error()) park_point.z = 0;
#endif
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
#if ENABLED(MIXING_EXTRUDER)
const uint8_t old_mixing_tool = mixer.get_current_vtool();
#if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
float mix_multiplier = 1.0;
if (!parser.seenval('T')) {
mixer.T(MIXER_AUTORETRACT_TOOL);
mix_multiplier = MIXING_STEPPERS;
}
else
#endif
{
const int8_t target_e_stepper = get_target_e_stepper_from_command();
if (target_e_stepper < 0) return;
mixer.T(MIXER_DIRECT_SET_TOOL);
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0);
mixer.normalize();
}
const int8_t target_extruder = active_extruder;
#else
const float unload_length_multiplier = 1.0;
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
#endif
// Z axis lift
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
@ -171,7 +217,11 @@ void GcodeSuite::M702() {
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, PAUSE_MODE_UNLOAD_FILAMENT);
unload_filament(unload_length, true, PAUSE_MODE_UNLOAD_FILAMENT
#if ALL(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
, mix_multiplier
#endif
);
}
#endif
@ -185,6 +235,10 @@ void GcodeSuite::M702() {
tool_change(active_extruder_before_filament_change, 0, false);
#endif
#if ENABLED(MIXING_EXTRUDER)
mixer.T(old_mixing_tool); // Restore original mixing tool
#endif
// Show status screen
#if HAS_LCD_MENU
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);

View File

@ -72,17 +72,32 @@ bool GcodeSuite::axis_relative_modes[] = AXIS_RELATIVE_MODES;
int8_t GcodeSuite::get_target_extruder_from_command() {
if (parser.seenval('T')) {
const int8_t e = parser.value_byte();
if (e >= EXTRUDERS) {
SERIAL_ECHO_START();
SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
SERIAL_ECHOLNPAIR(" " MSG_INVALID_EXTRUDER " ", int(e));
return -1;
}
return e;
if (e < EXTRUDERS) return e;
SERIAL_ECHO_START();
SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
SERIAL_ECHOLNPAIR(" " MSG_INVALID_EXTRUDER " ", int(e));
return -1;
}
return active_extruder;
}
/**
* Get the target e stepper from the T parameter
* Return -1 if the T parameter is out of range or unspecified
*/
int8_t GcodeSuite::get_target_e_stepper_from_command() {
const int8_t e = parser.intval('T', -1);
if (WITHIN(e, 0, E_STEPPERS - 1)) return e;
SERIAL_ECHO_START();
SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
if (e == -1)
SERIAL_ECHOLNPGM(" " MSG_E_STEPPER_NOT_SPECIFIED);
else
SERIAL_ECHOLNPAIR(" " MSG_INVALID_E_STEPPER " ", int(e));
return -1;
}
/**
* Set XYZE destination and feedrate from the current GCode command
*

View File

@ -298,6 +298,7 @@ public:
FORCE_INLINE static void reset_stepper_timeout() { previous_move_ms = millis(); }
static int8_t get_target_extruder_from_command();
static int8_t get_target_e_stepper_from_command();
static void get_destination_from_command();
static void process_parsed_command(