Skip to content

Commit

Permalink
✨ M217 G wipe retract length
Browse files Browse the repository at this point in the history
  • Loading branch information
studiodyne authored and thinkyhead committed Dec 16, 2022
1 parent 1f72c83 commit be14933
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2527,7 +2527,7 @@
// Longer prime to clean out a SINGLENOZZLE
#define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length
#define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/min) Extra priming feedrate
#define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Retract before cooling for less stringing, better wipe, etc.
#define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Cutting retraction out of park, for less stringing, better wipe, etc. Adjust with LCD or M217 G.

// Cool after prime to reduce stringing
#define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip
Expand Down
30 changes: 18 additions & 12 deletions Marlin/src/gcode/config/M217.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@
* S[linear] Swap length
* B[linear] Extra Swap resume length
* E[linear] Extra Prime length (as used by M217 Q)
* P[linear/min] Prime speed
* G[linear] Cutting wipe retract length (<=100mm)
* R[linear/min] Retract speed
* U[linear/min] UnRetract speed
* P[linear/min] Prime speed
* V[linear] 0/1 Enable auto prime first extruder used
* W[linear] 0/1 Enable park & Z Raise
* X[linear] Park X (Requires TOOLCHANGE_PARK)
* Y[linear] Park Y (Requires TOOLCHANGE_PARK)
* Y[linear] Park Y (Requires TOOLCHANGE_PARK and NUM_AXES >= 2)
* I[linear] Park I (Requires TOOLCHANGE_PARK and NUM_AXES >= 4)
* J[linear] Park J (Requires TOOLCHANGE_PARK and NUM_AXES >= 5)
* K[linear] Park K (Requires TOOLCHANGE_PARK and NUM_AXES >= 6)
Expand Down Expand Up @@ -79,6 +80,7 @@ void GcodeSuite::M217() {
if (parser.seenval('B')) { const float v = parser.value_linear_units(); toolchange_settings.extra_resume = constrain(v, -10, 10); }
if (parser.seenval('E')) { const float v = parser.value_linear_units(); toolchange_settings.extra_prime = constrain(v, 0, max_extrude); }
if (parser.seenval('P')) { const int16_t v = parser.value_linear_units(); toolchange_settings.prime_speed = constrain(v, 10, 5400); }
if (parser.seenval('G')) { const int16_t v = parser.value_linear_units(); toolchange_settings.wipe_retract = constrain(v, 0, 100); }
if (parser.seenval('R')) { const int16_t v = parser.value_linear_units(); toolchange_settings.retract_speed = constrain(v, 10, 5400); }
if (parser.seenval('U')) { const int16_t v = parser.value_linear_units(); toolchange_settings.unretract_speed = constrain(v, 10, 5400); }
#if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN
Expand Down Expand Up @@ -164,21 +166,24 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) {
SERIAL_ECHOPGM(" M217");

#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
SERIAL_ECHOPGM(" S", LINEAR_UNIT(toolchange_settings.swap_length));
SERIAL_ECHOPGM_P(SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume),
SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime),
SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed));
SERIAL_ECHOPGM(" R", LINEAR_UNIT(toolchange_settings.retract_speed),
" U", LINEAR_UNIT(toolchange_settings.unretract_speed),
" F", toolchange_settings.fan_speed,
" D", toolchange_settings.fan_time);
SERIAL_ECHOPGM_P(
PSTR(" S"), LINEAR_UNIT(toolchange_settings.swap_length),
SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume),
SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime),
SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed),
PSTR(" G"), LINEAR_UNIT(toolchange_settings.wipe_retract),
PSTR(" R"), LINEAR_UNIT(toolchange_settings.retract_speed),
PSTR(" U"), LINEAR_UNIT(toolchange_settings.unretract_speed),
PSTR(" F"), toolchange_settings.fan_speed,
PSTR(" D"), toolchange_settings.fan_time
);

#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
SERIAL_ECHOPGM(" A", migration.automode);
SERIAL_ECHOPGM(" L", LINEAR_UNIT(migration.last));
SERIAL_ECHOPGM(" A", migration.automode, " L", LINEAR_UNIT(migration.last));
#endif

#if ENABLED(TOOLCHANGE_PARK)
{
SERIAL_ECHOPGM(" W", LINEAR_UNIT(toolchange_settings.enable_park));
SERIAL_ECHOPGM_P(
SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x)
Expand All @@ -196,6 +201,7 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) {
)
#endif
);
}
#endif

#if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED)
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ namespace Language_en {
LSTR MSG_TOOL_CHANGE = _UxGT("Tool Change");
LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Z Raise");
LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Prime Speed");
LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Wipe Retract");
LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Retract Speed");
LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Park Head");
LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Recover Speed");
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/language/language_fr.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ namespace Language_fr {
LSTR MSG_TOOL_CHANGE = _UxGT("Changement outil");
LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Augmenter Z");
LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Vitesse primaire");
LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Purge Retract");
LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Vitesse rétract°");
LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Garer Extrudeur");
LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Vitesse reprise");
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/menu/menu_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ void menu_advanced_settings();
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_UNRETRACT_SPEED, &toolchange_settings.unretract_speed, 10, 5400);
EDIT_ITEM(float3, MSG_FILAMENT_PURGE_LENGTH, &toolchange_settings.extra_prime, 0, max_extrude);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_PRIME_SPEED, &toolchange_settings.prime_speed, 10, 5400);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_WIPE_RETRACT, &toolchange_settings.wipe_retract, 0, 100);
EDIT_ITEM_FAST(uint8, MSG_SINGLENOZZLE_FAN_SPEED, &toolchange_settings.fan_speed, 0, 255);
EDIT_ITEM_FAST(uint8, MSG_SINGLENOZZLE_FAN_TIME, &toolchange_settings.fan_time, 1, 30);
#endif
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/

// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V86"
#define EEPROM_VERSION "V87"
#define EEPROM_OFFSET 100

// Check the integrity of data offsets.
Expand Down Expand Up @@ -2876,6 +2876,7 @@ void MarlinSettings::reset() {
toolchange_settings.unretract_speed = TOOLCHANGE_FS_UNRETRACT_SPEED;
toolchange_settings.extra_prime = TOOLCHANGE_FS_EXTRA_PRIME;
toolchange_settings.prime_speed = TOOLCHANGE_FS_PRIME_SPEED;
toolchange_settings.wipe_retract = TOOLCHANGE_FS_WIPE_RETRACT;
toolchange_settings.fan_speed = TOOLCHANGE_FS_FAN_SPEED;
toolchange_settings.fan_time = TOOLCHANGE_FS_FAN_TIME;
#endif
Expand Down
30 changes: 15 additions & 15 deletions Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,13 +940,13 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
* Cutting recovery -- Recover from cutting retraction that occurs at the end of nozzle priming
*
* If the active_extruder is up to temp (!too_cold):
* Extrude filament distance = toolchange_settings.extra_resume + TOOLCHANGE_FS_WIPE_RETRACT
* Extrude filament distance = toolchange_settings.extra_resume + toolchange_settings.wipe_retract
* current_position.e = e;
* sync_plan_position_e();
*/
void extruder_cutting_recover(const_float_t e) {
if (!too_cold(active_extruder)) {
const float dist = toolchange_settings.extra_resume + (TOOLCHANGE_FS_WIPE_RETRACT);
const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract;
FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s");
unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed));
planner.synchronize();
Expand All @@ -973,17 +973,17 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
float fr = toolchange_settings.unretract_speed; // Set default speed for unretract

#if ENABLED(TOOLCHANGE_FS_SLOW_FIRST_PRIME)
/*
* Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime
*/
static Flags<EXTRUDERS> extruder_did_first_prime; // Extruders first priming status
if (!extruder_did_first_prime[active_extruder]) {
extruder_did_first_prime.set(active_extruder); // Log first prime complete
// new nozzle - prime at user-specified speed.
FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", MMM_TO_MMS(fr), " to ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s");
fr = toolchange_settings.prime_speed;
unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move
}
/**
* Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime
*/
static Flags<EXTRUDERS> extruder_did_first_prime; // Extruders first priming status
if (!extruder_did_first_prime[active_extruder]) {
extruder_did_first_prime.set(active_extruder); // Log first prime complete
// new nozzle - prime at user-specified speed.
FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", MMM_TO_MMS(fr), " to ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s");
fr = toolchange_settings.prime_speed;
unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move
}
#endif

//Calculate and perform the priming distance
Expand Down Expand Up @@ -1011,8 +1011,8 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.

// Cutting retraction
#if TOOLCHANGE_FS_WIPE_RETRACT
FS_DEBUG("Performing Cutting Retraction | Distance: ", -(TOOLCHANGE_FS_WIPE_RETRACT), " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s");
unscaled_e_move(-(TOOLCHANGE_FS_WIPE_RETRACT), MMM_TO_MMS(toolchange_settings.retract_speed));
FS_DEBUG("Performing Cutting Retraction | Distance: ", -toolchange_settings.wipe_retract, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s");
unscaled_e_move(-toolchange_settings.wipe_retract, MMM_TO_MMS(toolchange_settings.retract_speed));
#endif

// Cool down with fan
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/module/tool_change.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
float extra_prime; // M217 E
float extra_resume; // M217 B
int16_t prime_speed; // M217 P
int16_t wipe_retract; // M217 G
int16_t retract_speed; // M217 R
int16_t unretract_speed; // M217 U
uint8_t fan_speed; // M217 F
Expand Down

0 comments on commit be14933

Please sign in to comment.