From 9bd5c25dfab9c7bfb8edede301b9272ac0636816 Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Mon, 13 Apr 2020 14:57:10 +0200 Subject: [PATCH 01/22] Added initial version of MMU2S feature --- Marlin/Configuration_adv.h | 3 +++ Marlin/src/feature/mmu2/mmu2.cpp | 31 +++++++++++++++++++++++++++++++ Marlin/src/feature/mmu2/mmu2.h | 9 +++++++++ Marlin/src/inc/SanityCheck.h | 11 +++++++++++ 4 files changed, 54 insertions(+) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6cc9f01ffc83..0562df5b84e4 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3155,6 +3155,9 @@ #define INTERNAL_SERIAL_PORT 2 #define MMU2_SERIAL internalSerial + // has MMU2S like sensor + #define PRUSA_MMU2_S_MODE + // Use hardware reset for MMU if a pin is defined for it //#define MMU2_RST_PIN 23 diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 4506883f464e..05d53ec095f3 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -91,6 +91,9 @@ MMU2 mmu2; #define mmuSerial MMU2_SERIAL bool MMU2::enabled, MMU2::ready, MMU2::mmu_print_saved; +#if ENABLED(PRUSA_MMU2_S_MODE) + bool MMU2::mmu2s_triggered; +#endif uint8_t MMU2::cmd, MMU2::cmd_arg, MMU2::last_cmd, MMU2::extruder; int8_t MMU2::state = 0; volatile int8_t MMU2::finda = 1; @@ -227,6 +230,9 @@ void MMU2::mmu_loop() { DEBUG_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED"); enabled = true; + #if ENABLED(PRUSA_MMU2_S_MODE) + mmu2s_triggered = false; + #endif state = 1; } break; @@ -291,6 +297,10 @@ void MMU2::mmu_loop() { tx_str_P(PSTR("P0\n")); state = 2; // wait for response } + + #if ENABLED(PRUSA_MMU2_S_MODE) + check_filament(); + #endif break; case 2: // response to command P0 @@ -309,6 +319,9 @@ void MMU2::mmu_loop() { else if (ELAPSED(millis(), last_request + MMU_P0_TIMEOUT)) // Resend request after timeout (3s) state = 1; + #if ENABLED(PRUSA_MMU2_S_MODE) + check_filament(); + #endif break; case 3: // response to mmu commands @@ -327,6 +340,9 @@ void MMU2::mmu_loop() { } state = 1; } + #if ENABLED(PRUSA_MMU2_S_MODE) + check_filament(); + #endif break; } } @@ -632,6 +648,21 @@ void MMU2::filament_runout() { planner.synchronize(); } +#if ENABLED(PRUSA_MMU2_S_MODE) + void MMU2::check_filament() { + const bool runout = (FIL_RUNOUT_INVERTING) ? !READ(FIL_RUNOUT_PIN) : READ(FIL_RUNOUT_PIN); + if (runout && !mmu2s_triggered) { + DEBUG_ECHOLNPGM("MMU <= 'A'"); + tx_str_P(PSTR("A\n")); + mmu2s_triggered = true; + } + else if (!runout) { + if (mmu2s_triggered) + mmu2s_triggered = false; + } + } +#endif + #if HAS_LCD_MENU && ENABLED(MMU2_MENUS) // Load filament into MMU2 diff --git a/Marlin/src/feature/mmu2/mmu2.h b/Marlin/src/feature/mmu2/mmu2.h index 970b0b4338ff..9e567bd21599 100644 --- a/Marlin/src/feature/mmu2/mmu2.h +++ b/Marlin/src/feature/mmu2/mmu2.h @@ -79,8 +79,17 @@ class MMU2 { #endif static void filament_runout(); + + #if ENABLED(PRUSA_MMU2_S_MODE) + static void check_filament(); + #endif static bool enabled, ready, mmu_print_saved; + + #if ENABLED(PRUSA_MMU2_S_MODE) + static bool mmu2s_triggered; + #endif + static uint8_t cmd, cmd_arg, last_cmd, extruder; static int8_t state; static volatile int8_t finda; diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 185f5c0b4dce..d26bb095656d 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2713,6 +2713,17 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #endif #endif +/** + * Prusa MMU2S requirements + */ +#if ENABLED(PRUSA_MMU2_S_MODE) + #if DISABLED(PRUSA_MMU2) + #error "PRUSA_MMU2_S_MODE requires PRUSA_MMU2." + #elif DISABLED(FILAMENT_RUNOUT_SENSOR) + #error "PRUSA_MMU2_S_MODE requires FILAMENT_RUNOUT_SENSOR." + #endif +#endif + /** * Advanced PRINTCOUNTER settings */ From d1992f6292cf3d13f69d2af232eae890e9cfbb28 Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Mon, 13 Apr 2020 17:04:01 +0200 Subject: [PATCH 02/22] fixed default settings --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0562df5b84e4..488ad19af394 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3156,7 +3156,7 @@ #define MMU2_SERIAL internalSerial // has MMU2S like sensor - #define PRUSA_MMU2_S_MODE + // #define PRUSA_MMU2_S_MODE // Use hardware reset for MMU if a pin is defined for it //#define MMU2_RST_PIN 23 From e5f1d32dee859d7f35b3580b708604b5c87a88f1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2020 14:22:47 -0500 Subject: [PATCH 03/22] Update mmu2.cpp --- Marlin/src/feature/mmu2/mmu2.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 05d53ec095f3..1d1d5d180d45 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -650,16 +650,12 @@ void MMU2::filament_runout() { #if ENABLED(PRUSA_MMU2_S_MODE) void MMU2::check_filament() { - const bool runout = (FIL_RUNOUT_INVERTING) ? !READ(FIL_RUNOUT_PIN) : READ(FIL_RUNOUT_PIN); + const bool runout = READ(FIL_RUNOUT_PIN) ^ (FIL_RUNOUT_INVERTING); if (runout && !mmu2s_triggered) { DEBUG_ECHOLNPGM("MMU <= 'A'"); - tx_str_P(PSTR("A\n")); - mmu2s_triggered = true; + tx_str_P(PSTR("A\n")); } - else if (!runout) { - if (mmu2s_triggered) - mmu2s_triggered = false; - } + mmu2s_triggered = runout; } #endif From 278ec217cdb586a1553dc432d20e0d853a13ab32 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2020 14:26:23 -0500 Subject: [PATCH 04/22] Update SanityCheck.h --- Marlin/src/inc/SanityCheck.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index d26bb095656d..c3ab7e058b20 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2708,22 +2708,13 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #error "PRUSA_MMU2 requires NOZZLE_PARK_FEATURE." #elif EXTRUDERS != 5 #error "PRUSA_MMU2 requires EXTRUDERS = 5." + #elif ENABLED(PRUSA_MMU2_S_MODE) && DISABLED(FILAMENT_RUNOUT_SENSOR) + #error "PRUSA_MMU2_S_MODE requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2."); #endif #endif -/** - * Prusa MMU2S requirements - */ -#if ENABLED(PRUSA_MMU2_S_MODE) - #if DISABLED(PRUSA_MMU2) - #error "PRUSA_MMU2_S_MODE requires PRUSA_MMU2." - #elif DISABLED(FILAMENT_RUNOUT_SENSOR) - #error "PRUSA_MMU2_S_MODE requires FILAMENT_RUNOUT_SENSOR." - #endif -#endif - /** * Advanced PRINTCOUNTER settings */ From 425badcc2172709334b691397e4337579a87ede0 Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Mon, 13 Apr 2020 23:05:46 +0200 Subject: [PATCH 05/22] added can_load function --- Marlin/Configuration_adv.h | 15 +++++++++++++ Marlin/src/feature/mmu2/mmu2.cpp | 38 ++++++++++++++++++++++++++++++++ Marlin/src/feature/mmu2/mmu2.h | 3 ++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 488ad19af394..216eefaa6eb8 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3192,7 +3192,22 @@ { 10.0, 700 }, \ { -10.0, 400 }, \ { -50.0, 2000 } + #if ENABLED(PRUSA_MMU2_S_MODE) + #define MMU2_CAN_LOAD_FEEDRATE 800 + #define MMU2_CAN_LOAD_SEQUENCE \ + { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ + { -52.0, MMU2_CAN_LOAD_FEEDRATE } + + #define MMU2_CAN_LOAD_RETRACT 6.0 // This value should be smaller than the difference of the MMU2_CAN_LOAD_SEQUENCE values + + // to reuse within mmu2 module + #define MMU2_CAN_LOAD_INCREMENT 0.2 + + #define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \ + { -MMU2_CAN_LOAD_INCREMENT, MMU2_CAN_LOAD_FEEDRATE } + + #endif #endif //#define MMU2_DEBUG // Write debug info to serial output diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 1d1d5d180d45..d943967dc938 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -112,6 +112,11 @@ char MMU2::rx_buffer[MMU_RX_SIZE], MMU2::tx_buffer[MMU_TX_SIZE]; static constexpr E_Step ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE }; static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE }; + #if ENABLED(PRUSA_MMU2_S_MODE) + static constexpr E_Step can_load_sequence[] PROGMEM = { MMU2_CAN_LOAD_SEQUENCE }; + static constexpr E_Step can_load_increment_sequence[] PROGMEM = { MMU2_CAN_LOAD_INCREMENT_SEQUENCE }; + #endif + #endif // MMU2_MENUS MMU2::MMU2() { @@ -657,6 +662,39 @@ void MMU2::filament_runout() { } mmu2s_triggered = runout; } + + bool MMU2::can_load() + { + execute_extruder_sequence((const E_Step *)can_load_sequence, COUNT(can_load_sequence)); + + int filament_detected count = 0; + const int steps = MMU2_CAN_LOAD_RETRACT / MMU2_CAN_LOAD_INCREMENT; + DEBUG_ECHOLNPGM("MMU can_load:")); + for(int i = 0; i < steps; ++i) + { + execute_extruder_sequence((const E_Step *)can_load_increment_sequence, COUNT(can_load_increment_sequence)); + if(mmu2s_triggered) + { + DEBUG_ECHOPGM("O"); + ++filament_detected_count; + } + else + { + DEBUG_ECHOPGM("o"); + } + } + if (filament_detected_count > steps - 4) //maybe the 4 should be a variable as well? + { + DEBUG_ECHOLNPGM(" succeeded."); + return true; + } + else + { + DEBUG_ECHOLNPGM(" failed."); + return false; + } + + } #endif #if HAS_LCD_MENU && ENABLED(MMU2_MENUS) diff --git a/Marlin/src/feature/mmu2/mmu2.h b/Marlin/src/feature/mmu2/mmu2.h index 9e567bd21599..30ad49fad240 100644 --- a/Marlin/src/feature/mmu2/mmu2.h +++ b/Marlin/src/feature/mmu2/mmu2.h @@ -82,6 +82,7 @@ class MMU2 { #if ENABLED(PRUSA_MMU2_S_MODE) static void check_filament(); + static bool can_load(); #endif static bool enabled, ready, mmu_print_saved; @@ -89,7 +90,7 @@ class MMU2 { #if ENABLED(PRUSA_MMU2_S_MODE) static bool mmu2s_triggered; #endif - + static uint8_t cmd, cmd_arg, last_cmd, extruder; static int8_t state; static volatile int8_t finda; From aeaf35f3b55f91013ddf6d7a40b0f7a14a0e0de5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2020 22:15:35 -0500 Subject: [PATCH 06/22] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 216eefaa6eb8..a2d865420251 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3155,9 +3155,6 @@ #define INTERNAL_SERIAL_PORT 2 #define MMU2_SERIAL internalSerial - // has MMU2S like sensor - // #define PRUSA_MMU2_S_MODE - // Use hardware reset for MMU if a pin is defined for it //#define MMU2_RST_PIN 23 @@ -3192,22 +3189,22 @@ { 10.0, 700 }, \ { -10.0, 400 }, \ { -50.0, 2000 } - #if ENABLED(PRUSA_MMU2_S_MODE) - #define MMU2_CAN_LOAD_FEEDRATE 800 - #define MMU2_CAN_LOAD_SEQUENCE \ + // Using a sensor like the MMU2S + //#define PRUSA_MMU2_S_MODE + #if ENABLED(PRUSA_MMU2_S_MODE) + #define MMU2_CAN_LOAD_FEEDRATE 800 // To reuse within MMU2 module + #define MMU2_CAN_LOAD_SEQUENCE \ { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ { -52.0, MMU2_CAN_LOAD_FEEDRATE } - #define MMU2_CAN_LOAD_RETRACT 6.0 // This value should be smaller than the difference of the MMU2_CAN_LOAD_SEQUENCE values + #define MMU2_CAN_LOAD_RETRACT 6.0 // Should be smaller than the difference between MMU2_CAN_LOAD_SEQUENCE values - // to reuse within mmu2 module - #define MMU2_CAN_LOAD_INCREMENT 0.2 + #define MMU2_CAN_LOAD_INCREMENT 0.2 // To reuse within MMU2 module - #define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \ + #define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \ { -MMU2_CAN_LOAD_INCREMENT, MMU2_CAN_LOAD_FEEDRATE } - #endif #endif //#define MMU2_DEBUG // Write debug info to serial output From 29d28fe750a640e01e01caf2e5ad8112777c20c1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2020 22:18:42 -0500 Subject: [PATCH 07/22] Update mmu2.cpp --- Marlin/src/feature/mmu2/mmu2.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index d943967dc938..d70455a1fc60 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -109,13 +109,14 @@ char MMU2::rx_buffer[MMU_RX_SIZE], MMU2::tx_buffer[MMU_TX_SIZE]; feedRate_t feedRate; //!< feed rate in mm/s }; - static constexpr E_Step ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE }; - static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE }; - - #if ENABLED(PRUSA_MMU2_S_MODE) - static constexpr E_Step can_load_sequence[] PROGMEM = { MMU2_CAN_LOAD_SEQUENCE }; - static constexpr E_Step can_load_increment_sequence[] PROGMEM = { MMU2_CAN_LOAD_INCREMENT_SEQUENCE }; - #endif + static constexpr E_Step + ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE } + , load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE } + #if ENABLED(PRUSA_MMU2_S_MODE) + , can_load_sequence[] PROGMEM = { MMU2_CAN_LOAD_SEQUENCE } + , can_load_increment_sequence[] PROGMEM = { MMU2_CAN_LOAD_INCREMENT_SEQUENCE } + #endif + ; #endif // MMU2_MENUS From 2946b915e3a33ab81ff385bcd4cd3b6a77fc9b14 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2020 22:23:25 -0500 Subject: [PATCH 08/22] Update mmu2.cpp --- Marlin/src/feature/mmu2/mmu2.cpp | 36 +++++++++++--------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index d70455a1fc60..68ca1a03065e 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -664,37 +664,25 @@ void MMU2::filament_runout() { mmu2s_triggered = runout; } - bool MMU2::can_load() - { + bool MMU2::can_load() { execute_extruder_sequence((const E_Step *)can_load_sequence, COUNT(can_load_sequence)); int filament_detected count = 0; const int steps = MMU2_CAN_LOAD_RETRACT / MMU2_CAN_LOAD_INCREMENT; DEBUG_ECHOLNPGM("MMU can_load:")); - for(int i = 0; i < steps; ++i) - { - execute_extruder_sequence((const E_Step *)can_load_increment_sequence, COUNT(can_load_increment_sequence)); - if(mmu2s_triggered) - { - DEBUG_ECHOPGM("O"); - ++filament_detected_count; - } - else - { - DEBUG_ECHOPGM("o"); - } - } - if (filament_detected_count > steps - 4) //maybe the 4 should be a variable as well? - { - DEBUG_ECHOLNPGM(" succeeded."); - return true; + LOOP_L_N(i, steps) { + execute_extruder_sequence((const E_Step *)can_load_increment_sequence, COUNT(can_load_increment_sequence)); + DEBUG_CHAR(mmu2s_triggered ? 'O' : 'o'); + if (mmu2s_triggered) ++filament_detected_count; } - else - { - DEBUG_ECHOLNPGM(" failed."); - return false; + + if (filament_detected_count <= steps - 4) { // maybe the 4 should be a variable as well? + DEBUG_ECHOLNPGM(" failed."); + return false; } - + + DEBUG_ECHOLNPGM(" succeeded."); + return true; } #endif From 22545f549630b735dfc50d1203cb40a97eaf7fd4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2020 22:26:14 -0500 Subject: [PATCH 09/22] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a2d865420251..dbf0e48c951e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3195,15 +3195,15 @@ #if ENABLED(PRUSA_MMU2_S_MODE) #define MMU2_CAN_LOAD_FEEDRATE 800 // To reuse within MMU2 module #define MMU2_CAN_LOAD_SEQUENCE \ - { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ - { -52.0, MMU2_CAN_LOAD_FEEDRATE } + { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ + { -52.0, MMU2_CAN_LOAD_FEEDRATE } #define MMU2_CAN_LOAD_RETRACT 6.0 // Should be smaller than the difference between MMU2_CAN_LOAD_SEQUENCE values #define MMU2_CAN_LOAD_INCREMENT 0.2 // To reuse within MMU2 module #define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \ - { -MMU2_CAN_LOAD_INCREMENT, MMU2_CAN_LOAD_FEEDRATE } + { -MMU2_CAN_LOAD_INCREMENT, MMU2_CAN_LOAD_FEEDRATE } #endif From 5f075f4f9867728f3278e57a71856b4fe63cba07 Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Tue, 14 Apr 2020 10:49:00 +0200 Subject: [PATCH 10/22] initial integration of can_load() and some more configuration variables --- Marlin/Configuration_adv.h | 4 ++ Marlin/src/feature/mmu2/mmu2.cpp | 71 +++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index dbf0e48c951e..1366e2832687 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3193,6 +3193,8 @@ // Using a sensor like the MMU2S //#define PRUSA_MMU2_S_MODE #if ENABLED(PRUSA_MMU2_S_MODE) + #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout x retry) + #define MMU2_CAN_LOAD_FEEDRATE 800 // To reuse within MMU2 module #define MMU2_CAN_LOAD_SEQUENCE \ { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ @@ -3200,6 +3202,8 @@ #define MMU2_CAN_LOAD_RETRACT 6.0 // Should be smaller than the difference between MMU2_CAN_LOAD_SEQUENCE values + #define MMU2_CAN_LOAD_DEVIATION 0.8 // Acceptable deviation + #define MMU2_CAN_LOAD_INCREMENT 0.2 // To reuse within MMU2 module #define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \ diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 68ca1a03065e..ea8a2cdd95a7 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -523,11 +523,43 @@ void MMU2::tool_change(const char* special) { command(MMU_CMD_T0 + index); manage_response(true, true); command(MMU_CMD_C0); + + #if ENABLED(PRUSA_MMU2_S_MODE) + // if Filament has not reached gears, continue loading + manage_response(true, true); + LOOP_L_N(i, MMU2_C0_RETRY) { + if(!mmu2s_triggered){ + command(MMU_CMD_C0); + manage_response(true, true); + check_filament(); + } + else + { + break; + } + + } + if (mmu2s_triggered) { + bool success = can_load(); + if (success && mmu2s_triggered) { + #endif + mmu_loop(); ENABLE_AXIS_E0(); extruder = index; active_extruder = 0; + #if ENABLED(PRUSA_MMU2_S_MODE) + } + } + LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); + BUZZ(100, 659); + BUZZ(200, 698); + BUZZ(100, 659); + BUZZ(300, 440); + BUZZ(100, 659); + + #endif } break; case 'c': { @@ -672,11 +704,12 @@ void MMU2::filament_runout() { DEBUG_ECHOLNPGM("MMU can_load:")); LOOP_L_N(i, steps) { execute_extruder_sequence((const E_Step *)can_load_increment_sequence, COUNT(can_load_increment_sequence)); + check_filament(); // Don't trust the idle function DEBUG_CHAR(mmu2s_triggered ? 'O' : 'o'); if (mmu2s_triggered) ++filament_detected_count; } - if (filament_detected_count <= steps - 4) { // maybe the 4 should be a variable as well? + if (filament_detected_count <= steps - (MMU2_CAN_LOAD_DEVIATION / MMU2_CAN_LOAD_INCREMENT)) { DEBUG_ECHOLNPGM(" failed."); return false; } @@ -714,8 +747,28 @@ void MMU2::filament_runout() { command(MMU_CMD_T0 + index); manage_response(true, true); command(MMU_CMD_C0); - mmu_loop(); + #if ENABLED(PRUSA_MMU2_S_MODE) + // if Filament has not reached gears, continue loading + manage_response(true, true); + LOOP_L_N(i, MMU2_C0_RETRY) { + if(!mmu2s_triggered){ + command(MMU_CMD_C0); + manage_response(true, true); + check_filament(); + } + else + { + break; + } + + } + if (mmu2s_triggered) { + bool success = can_load(); + if (success && mmu2s_triggered) { + #endif + + mmu_loop(); extruder = index; active_extruder = 0; @@ -723,6 +776,20 @@ void MMU2::filament_runout() { BUZZ(200, 404); return true; + + #if ENABLED(PRUSA_MMU2_S_MODE) + } + } + LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); + BUZZ(100, 659); + BUZZ(200, 698); + BUZZ(100, 659); + BUZZ(300, 440); + BUZZ(100, 659); + return false; + + + #endif } } From 463153a880930f5ad0ff08f875dda55083507e47 Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Tue, 14 Apr 2020 10:53:29 +0200 Subject: [PATCH 11/22] add missing #endig --- Marlin/Configuration_adv.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 1366e2832687..d06b37c72e9a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3189,6 +3189,7 @@ { 10.0, 700 }, \ { -10.0, 400 }, \ { -50.0, 2000 } + #endif // Using a sensor like the MMU2S //#define PRUSA_MMU2_S_MODE From 3d444fa9cb933ed5b26229cc6becec4462cabe6b Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Tue, 14 Apr 2020 11:24:06 +0200 Subject: [PATCH 12/22] missed a _ in variable --- Marlin/src/feature/mmu2/mmu2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index ea8a2cdd95a7..4b9eaf95aa13 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -699,7 +699,7 @@ void MMU2::filament_runout() { bool MMU2::can_load() { execute_extruder_sequence((const E_Step *)can_load_sequence, COUNT(can_load_sequence)); - int filament_detected count = 0; + int filament_detected_count = 0; const int steps = MMU2_CAN_LOAD_RETRACT / MMU2_CAN_LOAD_INCREMENT; DEBUG_ECHOLNPGM("MMU can_load:")); LOOP_L_N(i, steps) { From 5546eac22dd9a33111fc77d8f476bdf8191a318a Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Tue, 14 Apr 2020 11:29:09 +0200 Subject: [PATCH 13/22] removed additional ) --- Marlin/src/feature/mmu2/mmu2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 4b9eaf95aa13..9da05e2fea65 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -701,7 +701,7 @@ void MMU2::filament_runout() { int filament_detected_count = 0; const int steps = MMU2_CAN_LOAD_RETRACT / MMU2_CAN_LOAD_INCREMENT; - DEBUG_ECHOLNPGM("MMU can_load:")); + DEBUG_ECHOLNPGM("MMU can_load:"); LOOP_L_N(i, steps) { execute_extruder_sequence((const E_Step *)can_load_increment_sequence, COUNT(can_load_increment_sequence)); check_filament(); // Don't trust the idle function From 8f797b3f868fae07146048247be8f8b8adb9b67d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Apr 2020 16:35:12 -0500 Subject: [PATCH 14/22] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d06b37c72e9a..ef135cbe38e6 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3201,12 +3201,10 @@ { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ { -52.0, MMU2_CAN_LOAD_FEEDRATE } - #define MMU2_CAN_LOAD_RETRACT 6.0 // Should be smaller than the difference between MMU2_CAN_LOAD_SEQUENCE values - - #define MMU2_CAN_LOAD_DEVIATION 0.8 // Acceptable deviation - - #define MMU2_CAN_LOAD_INCREMENT 0.2 // To reuse within MMU2 module + #define MMU2_CAN_LOAD_RETRACT 6.0 // (mm) Keep under the distance between Load Sequence values + #define MMU2_CAN_LOAD_DEVIATION 0.8 // (mm) Acceptable deviation + #define MMU2_CAN_LOAD_INCREMENT 0.2 // (mm) To reuse within MMU2 module #define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \ { -MMU2_CAN_LOAD_INCREMENT, MMU2_CAN_LOAD_FEEDRATE } From 9f105314a6a5d8052dcd5691b601191417330725 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Apr 2020 17:01:02 -0500 Subject: [PATCH 15/22] Add test for PRUSA_MMU2_S_MODE --- buildroot/share/tests/mega2560-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/tests/mega2560-tests b/buildroot/share/tests/mega2560-tests index 884ea8be4ab2..4353544e3628 100755 --- a/buildroot/share/tests/mega2560-tests +++ b/buildroot/share/tests/mega2560-tests @@ -71,7 +71,7 @@ opt_set NUM_SERVOS 1 opt_enable ZONESTAR_LCD Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE BOOT_MARLIN_LOGO_ANIMATED \ AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \ NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \ - PRUSA_MMU2 MMU2_MENUS NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING + PRUSA_MMU2 MMU2_MENUS PRUSA_MMU2_S_MODE NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING exec_test $1 $2 "RAMPS | ZONESTAR_LCD | MMU2 | Servo Probe | ABL 3-Pt | Debug Leveling | EEPROM | G38 ..." # From 8b99923376190fe97f2767123177726f57804e30 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Apr 2020 17:08:40 -0500 Subject: [PATCH 16/22] Add "MMU" to some MMU strings --- Marlin/src/lcd/language/language_en.h | 18 +++++++++--------- Marlin/src/lcd/language/language_zh_TW.h | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index f2be60c72dd6..938eaa29041b 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -517,21 +517,21 @@ namespace Language_en { PROGMEM Language_Str MSG_MMU2_MENU = _UxGT("MMU"); PROGMEM Language_Str MSG_MMU2_WRONG_FIRMWARE = _UxGT("Update MMU Firmware!"); PROGMEM Language_Str MSG_MMU2_NOT_RESPONDING = _UxGT("MMU Needs Attention."); - PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("Resume Print"); - PROGMEM Language_Str MSG_MMU2_RESUMING = _UxGT("Resuming..."); - PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("Load Filament"); - PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("Load All"); - PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("Load to Nozzle"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("Eject Filament"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Eject Filament ~"); - PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("Unload Filament"); + PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("MMU Resume"); + PROGMEM Language_Str MSG_MMU2_RESUMING = _UxGT("MMU Resuming..."); + PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("MMU Load"); + PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("MMU Load All"); + PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Load to Nozzle"); + PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("MMU Eject"); + PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("MMU Eject ~"); + PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("MMU Unload"); PROGMEM Language_Str MSG_MMU2_LOADING_FILAMENT = _UxGT("Loading Fil. %i..."); PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("Ejecting Fil. ..."); PROGMEM Language_Str MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Unloading Fil...."); PROGMEM Language_Str MSG_MMU2_ALL = _UxGT("All"); PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("Filament ~"); PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("Reset MMU"); - PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("Resetting MMU..."); + PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("MMU Resetting..."); PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Remove, click"); PROGMEM Language_Str MSG_MIX = _UxGT("Mix"); diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 53e40bbab8d0..33a43a39d323 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -504,21 +504,21 @@ namespace Language_zh_TW { PROGMEM Language_Str MSG_MMU2_MENU = _UxGT("MMU"); PROGMEM Language_Str MSG_MMU2_WRONG_FIRMWARE = _UxGT("Update MMU Firmware!"); PROGMEM Language_Str MSG_MMU2_NOT_RESPONDING = _UxGT("MMU Needs Attention."); - PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("Resume Print"); - PROGMEM Language_Str MSG_MMU2_RESUMING = _UxGT("Resuming..."); - PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("Load Filament"); - PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("Load All"); - PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("Load to Nozzle"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("Eject Filament"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Eject Filament ~"); - PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("Unload Filament"); + PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("MMU Resume"); + PROGMEM Language_Str MSG_MMU2_RESUMING = _UxGT("MMU Resuming..."); + PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("MMU Load"); + PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("MMU Load All"); + PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Load to Nozzle"); + PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("MMU Eject"); + PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("MMU Eject ~"); + PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("MMU Unload"); PROGMEM Language_Str MSG_MMU2_LOADING_FILAMENT = _UxGT("Loading Fil. %i..."); PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("Ejecting Fil. ..."); PROGMEM Language_Str MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Unloading Fil...."); PROGMEM Language_Str MSG_MMU2_ALL = _UxGT("All"); PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("Filament ~"); PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("Reset MMU"); - PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("Resetting MMU..."); + PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("MMU Resetting..."); PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Remove, click"); PROGMEM Language_Str MSG_MIX = _UxGT("Mix"); From 23dc87f0c10599f1cd6f552e39dd1bd052954bd2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Apr 2020 17:09:31 -0500 Subject: [PATCH 17/22] Update test --- buildroot/share/tests/mega2560-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/tests/mega2560-tests b/buildroot/share/tests/mega2560-tests index 4353544e3628..15c2aa98acd2 100755 --- a/buildroot/share/tests/mega2560-tests +++ b/buildroot/share/tests/mega2560-tests @@ -71,7 +71,7 @@ opt_set NUM_SERVOS 1 opt_enable ZONESTAR_LCD Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE BOOT_MARLIN_LOGO_ANIMATED \ AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \ NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \ - PRUSA_MMU2 MMU2_MENUS PRUSA_MMU2_S_MODE NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING + PRUSA_MMU2 MMU2_MENUS PRUSA_MMU2_S_MODE FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING exec_test $1 $2 "RAMPS | ZONESTAR_LCD | MMU2 | Servo Probe | ABL 3-Pt | Debug Leveling | EEPROM | G38 ..." # From c8f5515cbb1a493b63ba1f4d2c3f8a283937166e Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Fri, 17 Apr 2020 12:25:21 +0200 Subject: [PATCH 18/22] forgot to add during tool change --- Marlin/src/feature/mmu2/mmu2.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 9da05e2fea65..fad0b43f9236 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -478,6 +478,25 @@ void MMU2::tool_change(uint8_t index) { manage_response(true, true); command(MMU_CMD_C0); + #if ENABLED(PRUSA_MMU2_S_MODE) + // if Filament has not reached gears, continue loading + manage_response(true, true); + LOOP_L_N(i, MMU2_C0_RETRY) { + if(!mmu2s_triggered){ + command(MMU_CMD_C0); + manage_response(true, true); + check_filament(); + } + else + { + break; + } + + } + if (mmu2s_triggered) { + bool success = can_load(); + if (success && mmu2s_triggered) { + #endif extruder = index; //filament change is finished active_extruder = 0; @@ -487,6 +506,18 @@ void MMU2::tool_change(uint8_t index) { SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder)); ui.reset_status(); + + #if ENABLED(PRUSA_MMU2_S_MODE) + } + } + LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); + BUZZ(100, 659); + BUZZ(200, 698); + BUZZ(100, 659); + BUZZ(300, 440); + BUZZ(100, 659); + + #endif } set_runout_valid(true); From b3f279459fab6d359a00a7ea631c9ffa321fcfd0 Mon Sep 17 00:00:00 2001 From: Toni Hoang Date: Fri, 17 Apr 2020 17:24:07 +0200 Subject: [PATCH 19/22] hotfix initial sequence for toolchange and fixed missing else clause --- Marlin/Configuration_adv.h | 3 ++- Marlin/src/feature/mmu2/mmu2.cpp | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index ef135cbe38e6..ae291e6f1e6d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3196,8 +3196,9 @@ #if ENABLED(PRUSA_MMU2_S_MODE) #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout x retry) - #define MMU2_CAN_LOAD_FEEDRATE 800 // To reuse within MMU2 module + #define MMU2_CAN_LOAD_FEEDRATE 800 // To reuse within MMU2 module, added hotfix initial Sequence #define MMU2_CAN_LOAD_SEQUENCE \ + { 0.1, MMU2_CAN_LOAD_FEEDRATE }, \ { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ { -52.0, MMU2_CAN_LOAD_FEEDRATE } diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index fad0b43f9236..6e4529ee5ed7 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -509,13 +509,18 @@ void MMU2::tool_change(uint8_t index) { #if ENABLED(PRUSA_MMU2_S_MODE) } + else { + LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); + BUZZ(100, 659); + BUZZ(200, 698); + BUZZ(100, 659); + BUZZ(300, 440); + BUZZ(100, 659); + } + + } - LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); - BUZZ(100, 659); - BUZZ(200, 698); - BUZZ(100, 659); - BUZZ(300, 440); - BUZZ(100, 659); + #endif } From b7ef58befedb842fcbabc15f07ba370af0d7a8fc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Apr 2020 23:40:22 -0500 Subject: [PATCH 20/22] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index ae291e6f1e6d..e56c5045402e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3194,9 +3194,9 @@ // Using a sensor like the MMU2S //#define PRUSA_MMU2_S_MODE #if ENABLED(PRUSA_MMU2_S_MODE) - #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout x retry) + #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries) - #define MMU2_CAN_LOAD_FEEDRATE 800 // To reuse within MMU2 module, added hotfix initial Sequence + #define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/m) #define MMU2_CAN_LOAD_SEQUENCE \ { 0.1, MMU2_CAN_LOAD_FEEDRATE }, \ { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ From 5020b4ff7884b2f46f0efcd4b5f63ad2f35b6c4d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Apr 2020 23:50:23 -0500 Subject: [PATCH 21/22] Clean up MMU2::tool_change --- Marlin/src/feature/mmu2/mmu2.cpp | 191 ++++++++----------------------- Marlin/src/feature/mmu2/mmu2.h | 10 +- 2 files changed, 55 insertions(+), 146 deletions(-) diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 6e4529ee5ed7..ae71b63638d8 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -236,10 +236,8 @@ void MMU2::mmu_loop() { DEBUG_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED"); enabled = true; - #if ENABLED(PRUSA_MMU2_S_MODE) - mmu2s_triggered = false; - #endif state = 1; + TERN_(PRUSA_MMU2_S_MODE, mmu2s_triggered = false); } break; @@ -304,9 +302,7 @@ void MMU2::mmu_loop() { state = 2; // wait for response } - #if ENABLED(PRUSA_MMU2_S_MODE) - check_filament(); - #endif + TERN_(PRUSA_MMU2_S_MODE, check_filament()); break; case 2: // response to command P0 @@ -325,9 +321,7 @@ void MMU2::mmu_loop() { else if (ELAPSED(millis(), last_request + MMU_P0_TIMEOUT)) // Resend request after timeout (3s) state = 1; - #if ENABLED(PRUSA_MMU2_S_MODE) - check_filament(); - #endif + TERN_(PRUSA_MMU2_S_MODE, check_filament()); break; case 3: // response to mmu commands @@ -346,9 +340,7 @@ void MMU2::mmu_loop() { } state = 1; } - #if ENABLED(PRUSA_MMU2_S_MODE) - check_filament(); - #endif + TERN_(PRUSA_MMU2_S_MODE, check_filament()); break; } } @@ -459,6 +451,33 @@ void MMU2::check_version() { } } +static bool mmu2_not_responding() { + LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); + BUZZ(100, 659); + BUZZ(200, 698); + BUZZ(100, 659); + BUZZ(300, 440); + BUZZ(100, 659); +} + +#if ENABLED(PRUSA_MMU2_S_MODE) + + bool MMU2::load_to_gears() { + command(MMU_CMD_C0); + manage_response(true, true); + LOOP_L_N(i, MMU2_C0_RETRY) { // Keep loading until filament reaches gears + if (mmu2s_triggered) break; + command(MMU_CMD_C0); + manage_response(true, true); + check_filament(); + } + const bool success = mmu2s_triggered && can_load(); + if (!success) mmu2_not_responding(); + return success; + } + +#endif + /** * Handle tool change */ @@ -474,55 +493,16 @@ void MMU2::tool_change(uint8_t index) { ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); command(MMU_CMD_T0 + index); - manage_response(true, true); - command(MMU_CMD_C0); - #if ENABLED(PRUSA_MMU2_S_MODE) - // if Filament has not reached gears, continue loading - manage_response(true, true); - LOOP_L_N(i, MMU2_C0_RETRY) { - if(!mmu2s_triggered){ - command(MMU_CMD_C0); - manage_response(true, true); - check_filament(); - } - else - { - break; - } - - } - if (mmu2s_triggered) { - bool success = can_load(); - if (success && mmu2s_triggered) { - #endif - extruder = index; //filament change is finished - active_extruder = 0; - - ENABLE_AXIS_E0(); - - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder)); - + if (load_to_gears()) { + extruder = index; // filament change is finished + active_extruder = 0; + ENABLE_AXIS_E0(); + SERIAL_ECHO_START(); + SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder)); + } ui.reset_status(); - - #if ENABLED(PRUSA_MMU2_S_MODE) - } - else { - LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); - BUZZ(100, 659); - BUZZ(200, 698); - BUZZ(100, 659); - BUZZ(300, 440); - BUZZ(100, 659); - } - - - } - - - #endif } set_runout_valid(true); @@ -558,44 +538,13 @@ void MMU2::tool_change(const char* special) { DISABLE_AXIS_E0(); command(MMU_CMD_T0 + index); manage_response(true, true); - command(MMU_CMD_C0); - - #if ENABLED(PRUSA_MMU2_S_MODE) - // if Filament has not reached gears, continue loading - manage_response(true, true); - LOOP_L_N(i, MMU2_C0_RETRY) { - if(!mmu2s_triggered){ - command(MMU_CMD_C0); - manage_response(true, true); - check_filament(); - } - else - { - break; - } - - } - if (mmu2s_triggered) { - bool success = can_load(); - if (success && mmu2s_triggered) { - #endif - mmu_loop(); - - ENABLE_AXIS_E0(); - extruder = index; - active_extruder = 0; - #if ENABLED(PRUSA_MMU2_S_MODE) - } - } - LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); - BUZZ(100, 659); - BUZZ(200, 698); - BUZZ(100, 659); - BUZZ(300, 440); - BUZZ(100, 659); - - #endif + if (load_to_gears()) { + mmu_loop(); + ENABLE_AXIS_E0(); + extruder = index; + active_extruder = 0; + } } break; case 'c': { @@ -669,12 +618,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { if (turn_off_nozzle) thermalManager.setTargetHotend(0, active_extruder); - LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); - BUZZ(100, 659); - BUZZ(200, 698); - BUZZ(100, 659); - BUZZ(300, 440); - BUZZ(100, 659); + mmu2_not_responding(); } } else if (mmu_print_saved) { @@ -779,54 +723,19 @@ void MMU2::filament_runout() { LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); return false; } - else { - command(MMU_CMD_T0 + index); - manage_response(true, true); - command(MMU_CMD_C0); - #if ENABLED(PRUSA_MMU2_S_MODE) - // if Filament has not reached gears, continue loading - manage_response(true, true); - LOOP_L_N(i, MMU2_C0_RETRY) { - if(!mmu2s_triggered){ - command(MMU_CMD_C0); - manage_response(true, true); - check_filament(); - } - else - { - break; - } - - } - if (mmu2s_triggered) { - bool success = can_load(); - if (success && mmu2s_triggered) { - #endif + command(MMU_CMD_T0 + index); + manage_response(true, true); + const bool success = load_to_gears(); + if (success) { mmu_loop(); extruder = index; active_extruder = 0; - load_to_nozzle(); - BUZZ(200, 404); - return true; - - #if ENABLED(PRUSA_MMU2_S_MODE) - } - } - LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); - BUZZ(100, 659); - BUZZ(200, 698); - BUZZ(100, 659); - BUZZ(300, 440); - BUZZ(100, 659); - return false; - - - #endif } + return success; } /** diff --git a/Marlin/src/feature/mmu2/mmu2.h b/Marlin/src/feature/mmu2/mmu2.h index 30ad49fad240..4a14ddb596eb 100644 --- a/Marlin/src/feature/mmu2/mmu2.h +++ b/Marlin/src/feature/mmu2/mmu2.h @@ -79,18 +79,18 @@ class MMU2 { #endif static void filament_runout(); - + #if ENABLED(PRUSA_MMU2_S_MODE) + static bool mmu2s_triggered; static void check_filament(); static bool can_load(); + static bool load_to_gears(); + #else + FORCE_INLINE static bool load_to_gears() { return true; } #endif static bool enabled, ready, mmu_print_saved; - #if ENABLED(PRUSA_MMU2_S_MODE) - static bool mmu2s_triggered; - #endif - static uint8_t cmd, cmd_arg, last_cmd, extruder; static int8_t state; static volatile int8_t finda; From 471f54145d413ab7b38f66d2e5ff6e0cec322c9a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 19 Apr 2020 02:21:54 -0500 Subject: [PATCH 22/22] Remove untranslated --- Marlin/src/lcd/language/language_zh_TW.h | 76 +----------------------- 1 file changed, 1 insertion(+), 75 deletions(-) diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 33a43a39d323..e192e208d299 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -379,21 +379,7 @@ namespace Language_zh_TW { PROGMEM Language_Str MSG_BLTOUCH_RESET = _UxGT("重置BLTouch"); // "Reset BLTouch" PROGMEM Language_Str MSG_BLTOUCH_STOW = _UxGT("裝載BLTouch"); // "Stow BLTouch" PROGMEM Language_Str MSG_BLTOUCH_DEPLOY = _UxGT("部署BLTouch"); // "Deploy BLTouch" - PROGMEM Language_Str MSG_BLTOUCH_SW_MODE = _UxGT("Cmd: SW-Mode"); - PROGMEM Language_Str MSG_BLTOUCH_5V_MODE = _UxGT("Cmd: 5V-Mode"); - PROGMEM Language_Str MSG_BLTOUCH_OD_MODE = _UxGT("Cmd: OD-Mode"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE = _UxGT("Cmd: Mode-Store"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_5V = _UxGT("Set BLTouch to 5V"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_OD = _UxGT("Set BLTouch to OD"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_ECHO = _UxGT("Report Drain"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_CHANGE = _UxGT("DANGER: Bad settings can cause damage! Proceed anyway?"); - PROGMEM Language_Str MSG_TOUCHMI_PROBE = _UxGT("TouchMI"); - PROGMEM Language_Str MSG_TOUCHMI_INIT = _UxGT("Init TouchMI"); - PROGMEM Language_Str MSG_TOUCHMI_ZTEST = _UxGT("Z Offset Test"); - PROGMEM Language_Str MSG_TOUCHMI_SAVE = _UxGT("Save"); - PROGMEM Language_Str MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Deploy TouchMI"); - PROGMEM Language_Str MSG_MANUAL_DEPLOY = _UxGT("Deploy Z-Probe"); - PROGMEM Language_Str MSG_MANUAL_STOW = _UxGT("Stow Z-Probe"); + PROGMEM Language_Str MSG_HOME_FIRST = _UxGT("歸位 %s%s%s 先"); //"Home ... first" PROGMEM Language_Str MSG_ZPROBE_OFFSETS = _UxGT("探針偏移"); //Probe Offsets PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("探針X偏移量"); //Probe X Offset @@ -500,52 +486,6 @@ namespace Language_zh_TW { PROGMEM Language_Str MSG_LCD_PROBING_FAILED = _UxGT("探針探測失敗"); // "Probing failed" PROGMEM Language_Str MSG_M600_TOO_COLD = _UxGT("M600: 太冷"); // "M600: Too cold" - PROGMEM Language_Str MSG_MMU2_CHOOSE_FILAMENT_HEADER = _UxGT("CHOOSE FILAMENT"); - PROGMEM Language_Str MSG_MMU2_MENU = _UxGT("MMU"); - PROGMEM Language_Str MSG_MMU2_WRONG_FIRMWARE = _UxGT("Update MMU Firmware!"); - PROGMEM Language_Str MSG_MMU2_NOT_RESPONDING = _UxGT("MMU Needs Attention."); - PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("MMU Resume"); - PROGMEM Language_Str MSG_MMU2_RESUMING = _UxGT("MMU Resuming..."); - PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("MMU Load"); - PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("MMU Load All"); - PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Load to Nozzle"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("MMU Eject"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("MMU Eject ~"); - PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("MMU Unload"); - PROGMEM Language_Str MSG_MMU2_LOADING_FILAMENT = _UxGT("Loading Fil. %i..."); - PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("Ejecting Fil. ..."); - PROGMEM Language_Str MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Unloading Fil...."); - PROGMEM Language_Str MSG_MMU2_ALL = _UxGT("All"); - PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("Filament ~"); - PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("Reset MMU"); - PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("MMU Resetting..."); - PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Remove, click"); - - PROGMEM Language_Str MSG_MIX = _UxGT("Mix"); - PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Component ="); - PROGMEM Language_Str MSG_MIXER = _UxGT("Mixer"); - PROGMEM Language_Str MSG_GRADIENT = _UxGT("Gradient"); - PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Full Gradient"); - PROGMEM Language_Str MSG_TOGGLE_MIX = _UxGT("Toggle Mix"); - PROGMEM Language_Str MSG_CYCLE_MIX = _UxGT("Cycle Mix"); - PROGMEM Language_Str MSG_GRADIENT_MIX = _UxGT("Gradient Mix"); - PROGMEM Language_Str MSG_REVERSE_GRADIENT = _UxGT("Reverse Gradient"); - PROGMEM Language_Str MSG_ACTIVE_VTOOL = _UxGT("Active V-tool"); - PROGMEM Language_Str MSG_START_VTOOL = _UxGT("Start V-tool"); - PROGMEM Language_Str MSG_END_VTOOL = _UxGT(" End V-tool"); - PROGMEM Language_Str MSG_GRADIENT_ALIAS = _UxGT("Alias V-tool"); - PROGMEM Language_Str MSG_RESET_VTOOLS = _UxGT("Reset V-tools"); - PROGMEM Language_Str MSG_COMMIT_VTOOL = _UxGT("Commit V-tool Mix"); - PROGMEM Language_Str MSG_VTOOLS_RESET = _UxGT("V-tools Were Reset"); - PROGMEM Language_Str MSG_START_Z = _UxGT("Start Z:"); - PROGMEM Language_Str MSG_END_Z = _UxGT(" End Z:"); - - PROGMEM Language_Str MSG_GAMES = _UxGT("Games"); - PROGMEM Language_Str MSG_BRICKOUT = _UxGT("Brickout"); - PROGMEM Language_Str MSG_INVADERS = _UxGT("Invaders"); - PROGMEM Language_Str MSG_SNAKE = _UxGT("Sn4k3"); - PROGMEM Language_Str MSG_MAZE = _UxGT("Maze"); - // // Filament Change screens show up to 3 lines on a 4-line display // ...or up to 2 lines on a 3-line display @@ -576,20 +516,6 @@ namespace Language_zh_TW { PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_1_LINE("恢復中 ...")); //"Resuming..." #endif // LCD_HEIGHT < 4 - PROGMEM Language_Str MSG_TMC_DRIVERS = _UxGT("TMC Drivers"); - PROGMEM Language_Str MSG_TMC_CURRENT = _UxGT("Driver Current"); - PROGMEM Language_Str MSG_TMC_HYBRID_THRS = _UxGT("Hybrid Threshold"); - PROGMEM Language_Str MSG_TMC_HOMING_THRS = _UxGT("Sensorless Homing"); - PROGMEM Language_Str MSG_TMC_STEPPING_MODE = _UxGT("Stepping Mode"); - PROGMEM Language_Str MSG_TMC_STEALTH_ENABLED = _UxGT("StealthChop Enabled"); - PROGMEM Language_Str MSG_SERVICE_RESET = _UxGT("Reset"); - PROGMEM Language_Str MSG_SERVICE_IN = _UxGT(" in:"); - PROGMEM Language_Str MSG_BACKLASH = _UxGT("Backlash"); - PROGMEM Language_Str MSG_BACKLASH_A = LCD_STR_A; - PROGMEM Language_Str MSG_BACKLASH_B = LCD_STR_B; - PROGMEM Language_Str MSG_BACKLASH_C = LCD_STR_C; - PROGMEM Language_Str MSG_BACKLASH_CORRECTION = _UxGT("Correction"); - PROGMEM Language_Str MSG_BACKLASH_SMOOTHING = _UxGT("Smoothing"); } #if FAN_COUNT == 1