From 35378769fdaed53d13e8f2cf2133318259aa1437 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Thu, 6 Dec 2018 19:19:50 +0100 Subject: [PATCH 01/31] MMU - idler sensor --- Firmware/mmu.cpp | 25 +++++++++++++++++++ .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 1 + 2 files changed, 26 insertions(+) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index b0c1bedaf..bbde47f7a 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -13,6 +13,7 @@ #include "sound.h" #include "printers.h" #include +#include "io_atmega2560.h" #ifdef TMC2130 #include "tmc2130.h" @@ -37,6 +38,10 @@ static int8_t mmu_state = 0; uint8_t mmu_cmd = 0; +#ifdef MMU_IDLER_SENSOR_PIN +uint8_t mmu_idl_sens = 0; +#endif //MMU_IDLER_SENSOR_PIN + uint8_t mmu_extruder = 0; //! This variable probably has no meaning and is planed to be removed @@ -106,6 +111,10 @@ void mmu_init(void) _delay_ms(10); //wait 10ms for sure mmu_reset(); //reset mmu (HW or SW), do not wait for response mmu_state = -1; +#ifdef MMU_IDLER_SENSOR_PIN + PIN_INP(MMU_IDLER_SENSOR_PIN); //input mode + PIN_SET(MMU_IDLER_SENSOR_PIN); //pullup +#endif //MMU_IDLER_SENSOR_PIN } //mmu main loop - state machine processing @@ -208,6 +217,9 @@ void mmu_loop(void) #endif //MMU_DEBUG mmu_printf_P(PSTR("T%d\n"), filament); mmu_state = 3; // wait for response +#ifdef MMU_IDLER_SENSOR_PIN + mmu_idl_sens = 1; //enable idler sensor +#endif //MMU_IDLER_SENSOR_PIN } else if ((mmu_cmd >= MMU_CMD_L0) && (mmu_cmd <= MMU_CMD_L4)) { @@ -286,6 +298,19 @@ void mmu_loop(void) } return; case 3: //response to mmu commands +#ifdef MMU_IDLER_SENSOR_PIN + if (mmu_idl_sens) + { + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) + { + mmu_puts_P(PSTR("A\n")); //send 'abort' request + mmu_idl_sens = 0; + //printf_P(PSTR("MMU IDLER_SENSOR = 0 - ABORT\n")); + } + //else + //printf_P(PSTR("MMU IDLER_SENSOR = 1 - WAIT\n")); + } +#endif //MMU_IDLER_SENSOR_PIN if (mmu_rx_ok() > 0) { #ifdef MMU_DEBUG diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 4655107c0..8ec5a47a5 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -614,5 +614,6 @@ #define MMU_REQUIRED_FW_BUILDNR 83 #define MMU_HWRESET //#define MMU_DEBUG //print communication between MMU2 and printer on serial +#define MMU_IDLER_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) #endif //__CONFIGURATION_PRUSA_H From e52e53d1eb688888c33877a5ab9255e3592947e6 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 12 Dec 2018 13:54:17 +0100 Subject: [PATCH 02/31] send continue loading commands periodically if initial load fails --- Firmware/Marlin_main.cpp | 13 +++++++++++-- Firmware/mmu.cpp | 6 ++++++ Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 25c005c59..da381e147 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -129,6 +129,7 @@ #include "sound.h" #include "cmdqueue.h" +#include "io_atmega2560.h" // Macros for bit masks #define BIT(b) (1<<(b)) @@ -6911,8 +6912,16 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) mmu_command(MMU_CMD_T0 + tmp_extruder); manage_response(true, true); - mmu_command(MMU_CMD_C0); - mmu_extruder = tmp_extruder; //filament change is finished +#ifdef MMU_IDLER_SENSOR_PIN + for (int i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) break; + mmu_command(MMU_CMD_C0); + manage_response(true, true); + } +#else + mmu_command(MMU_CMD_C0); +#endif //MMU_IDLER_SENSOR_PIN + mmu_extruder = tmp_extruder; //filament change is finished if (load_to_nozzle)// for single material usage with mmu { diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index bbde47f7a..2de413eab 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -237,6 +237,9 @@ void mmu_loop(void) #endif //MMU_DEBUG mmu_puts_P(PSTR("C0\n")); //send 'continue loading' mmu_state = 3; +#ifdef MMU_IDLER_SENSOR_PIN + mmu_idl_sens = 1; //enable idler sensor +#endif //MMU_IDLER_SENSOR_PIN } else if (mmu_cmd == MMU_CMD_U0) { @@ -303,6 +306,9 @@ void mmu_loop(void) { if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) { +#ifdef MMU_DEBUG + printf_P(PSTR("MMU <= 'A'\n"), mmu_finda); +#endif //MMU_DEBUG mmu_puts_P(PSTR("A\n")); //send 'abort' request mmu_idl_sens = 0; //printf_P(PSTR("MMU IDLER_SENSOR = 0 - ABORT\n")); diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 8ec5a47a5..e8425dd15 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -615,5 +615,6 @@ #define MMU_HWRESET //#define MMU_DEBUG //print communication between MMU2 and printer on serial #define MMU_IDLER_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 4 //max. number of attempts to load filament if first load failed #endif //__CONFIGURATION_PRUSA_H From c256af0a1c260c0bb70ca2ef6e6989d44ad11814 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 12 Dec 2018 14:50:55 +0100 Subject: [PATCH 03/31] unknown filament added; the same T-code will be not executed twice in a row; continue loading --- Firmware/Marlin_main.cpp | 20 ++++++++++---------- Firmware/mmu.cpp | 29 +++++++++++++++++++++++------ Firmware/mmu.h | 2 ++ Firmware/ultralcd.cpp | 11 ++++++++--- 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index da381e147..0f17c6b16 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6875,6 +6875,10 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) if (mmu_enabled) { tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT)); + if (tmp_extruder == mmu_extruder) { + printf_P(PSTR("Duplicit T-code ignored.\n")); + return; //dont execute the same T-code twice in a row + } st_synchronize(); mmu_command(MMU_CMD_T0 + tmp_extruder); manage_response(true, true); @@ -6884,7 +6888,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) if (mmu_enabled) { st_synchronize(); - mmu_command(MMU_CMD_C0); + mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished mmu_load_to_nozzle(); } @@ -6909,18 +6913,14 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) if (mmu_enabled) { + if (tmp_extruder == mmu_extruder) { + printf_P(PSTR("Duplicit T-code ignored.\n")); + return; //dont execute the same T-code twice in a row + } mmu_command(MMU_CMD_T0 + tmp_extruder); manage_response(true, true); -#ifdef MMU_IDLER_SENSOR_PIN - for (int i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) break; - mmu_command(MMU_CMD_C0); - manage_response(true, true); - } -#else - mmu_command(MMU_CMD_C0); -#endif //MMU_IDLER_SENSOR_PIN + mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished if (load_to_nozzle)// for single material usage with mmu diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 2de413eab..ef94f083d 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -42,10 +42,10 @@ uint8_t mmu_cmd = 0; uint8_t mmu_idl_sens = 0; #endif //MMU_IDLER_SENSOR_PIN -uint8_t mmu_extruder = 0; +uint8_t mmu_extruder = MMU_FILAMENT_UNKNOWN; //! This variable probably has no meaning and is planed to be removed -uint8_t tmp_extruder = 0; +uint8_t tmp_extruder = MMU_FILAMENT_UNKNOWN; int8_t mmu_finda = -1; @@ -307,7 +307,7 @@ void mmu_loop(void) if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) { #ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'A'\n"), mmu_finda); + printf_P(PSTR("MMU <= 'A'\n")); #endif //MMU_DEBUG mmu_puts_P(PSTR("A\n")); //send 'abort' request mmu_idl_sens = 0; @@ -619,7 +619,7 @@ void mmu_M600_load_filament(bool automatic) mmu_command(MMU_CMD_T0 + tmp_extruder); manage_response(false, true); - mmu_command(MMU_CMD_C0); + mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished mmu_load_to_nozzle(); load_filament_final_feed(); @@ -822,7 +822,8 @@ void extr_unload() lcd_clear(); lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); lcd_print(" "); - lcd_print(mmu_extruder + 1); + if (mmu_extruder == MMU_FILAMENT_UNKNOWN) lcd_print("?"); + else lcd_print(mmu_extruder + 1); filament_ramming(); @@ -1125,7 +1126,7 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr) lcd_print(tmp_extruder + 1); mmu_command(MMU_CMD_T0 + tmp_extruder); manage_response(true, true); - mmu_command(MMU_CMD_C0); + mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished mmu_load_to_nozzle(); load_filament_final_feed(); @@ -1181,3 +1182,19 @@ void mmu_eject_filament(uint8_t filament, bool recover) puts_P(PSTR("Filament nr out of range!")); } } + +void mmu_continue_loading() +{ +#ifdef MMU_IDLER_SENSOR_PIN + for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { +#ifdef MMU_DEBUG + printf_P(PSTR("Additional load attempt nr. %d\n"), i); +#endif // MMU_DEBUG + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) break; + mmu_command(MMU_CMD_C0); + manage_response(true, true); + } +#else + mmu_command(MMU_CMD_C0); +#endif //MMU_IDLER_SENSOR_PIN +} diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 2071891ea..d8a6269aa 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -14,6 +14,7 @@ extern int8_t mmu_finda; extern int16_t mmu_version; extern int16_t mmu_buildnr; +#define MMU_FILAMENT_UNKNOWN 255 #define MMU_CMD_NONE 0 #define MMU_CMD_T0 0x10 @@ -103,3 +104,4 @@ extern void mmu_eject_fil_1(); extern void mmu_eject_fil_2(); extern void mmu_eject_fil_3(); extern void mmu_eject_fil_4(); +extern void mmu_continue_loading(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f2a91f02b..53453a3a8 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -537,10 +537,15 @@ void lcdui_print_percent_done(void) void lcdui_print_extruder(void) { int chars = 0; - if (mmu_extruder == tmp_extruder) - chars = lcd_printf_P(_N(" F%u"), mmu_extruder+1); + if (mmu_extruder == tmp_extruder) { + if (mmu_extruder == MMU_FILAMENT_UNKNOWN) chars = lcd_printf_P(_N(" F?")); + else chars = lcd_printf_P(_N(" F%u"), mmu_extruder + 1); + } else - chars = lcd_printf_P(_N(" %u>%u"), mmu_extruder+1, tmp_extruder+1); + { + if (mmu_extruder == MMU_FILAMENT_UNKNOWN) chars = lcd_printf_P(_N(" ?>%u"), tmp_extruder + 1); + else chars = lcd_printf_P(_N(" %u>%u"), mmu_extruder + 1, tmp_extruder + 1); + } lcd_space(5 - chars); } From 29ecd4ec7a886f6c43fc965e1f782bc4030fb099 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 12 Dec 2018 22:32:47 +0100 Subject: [PATCH 04/31] duplicit T-codes execution improved, E-stepper movements when waiting for ok from mmu, continue loading function improved, eeprom: fail stats for mmu --- Firmware/Marlin_main.cpp | 8 +-- Firmware/eeprom.h | 6 ++ Firmware/mmu.cpp | 72 +++++++++++++++---- Firmware/mmu.h | 12 +++- Firmware/ultralcd.cpp | 37 ++++++++++ .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 +- 6 files changed, 118 insertions(+), 19 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 0f17c6b16..b3d2af721 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6875,13 +6875,13 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) if (mmu_enabled) { tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT)); - if (tmp_extruder == mmu_extruder) { + if ((tmp_extruder == mmu_extruder) && mmu_fil_loaded) { printf_P(PSTR("Duplicit T-code ignored.\n")); return; //dont execute the same T-code twice in a row } st_synchronize(); mmu_command(MMU_CMD_T0 + tmp_extruder); - manage_response(true, true); + manage_response(true, true, MMU_TCODE_MOVE); } } else if (*(strchr_pointer + index) == 'c') { //load to from bondtech gears to nozzle (nozzle should be preheated) @@ -6913,13 +6913,13 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) if (mmu_enabled) { - if (tmp_extruder == mmu_extruder) { + if ((tmp_extruder == mmu_extruder) && mmu_fil_loaded) { printf_P(PSTR("Duplicit T-code ignored.\n")); return; //dont execute the same T-code twice in a row } mmu_command(MMU_CMD_T0 + tmp_extruder); - manage_response(true, true); + manage_response(true, true, MMU_TCODE_MOVE); mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index da003990f..9f878796e 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -148,6 +148,12 @@ #define EEPROM_FSENS_OQ_MEASS_ENABLED (EEPROM_AUTO_DEPLETE - 1) //bool +#define EEPROM_MMU_FAIL_TOT (EEPROM_FSENS_OQ_MEASS_ENABLED - 2) //uint16_t +#define EEPROM_MMU_FAIL (EEPROM_MMU_FAIL_TOT - 1) //uint8_t + +#define EEPROM_MMU_LOAD_FAIL_TOT (EEPROM_MMU_FAIL - 2) //uint16_t +#define EEPROM_MMU_LOAD_FAIL (EEPROM_MMU_LOAD_FAIL_TOT - 1) //uint8_t + // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index ef94f083d..c79e84662 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -31,8 +31,8 @@ #endif //MMU_HWRESET bool mmu_enabled = false; - bool mmu_ready = false; +bool mmu_fil_loaded = false; //if true: blocks execution of duplicit T-codes static int8_t mmu_state = 0; @@ -217,6 +217,7 @@ void mmu_loop(void) #endif //MMU_DEBUG mmu_printf_P(PSTR("T%d\n"), filament); mmu_state = 3; // wait for response + mmu_fil_loaded = true; #ifdef MMU_IDLER_SENSOR_PIN mmu_idl_sens = 1; //enable idler sensor #endif //MMU_IDLER_SENSOR_PIN @@ -247,6 +248,7 @@ void mmu_loop(void) printf_P(PSTR("MMU <= 'U0'\n")); #endif //MMU_DEBUG mmu_puts_P(PSTR("U0\n")); //send 'unload current filament' + mmu_fil_loaded = false; mmu_state = 3; } else if ((mmu_cmd >= MMU_CMD_E0) && (mmu_cmd <= MMU_CMD_E4)) @@ -256,6 +258,7 @@ void mmu_loop(void) printf_P(PSTR("MMU <= 'E%d'\n"), filament); #endif //MMU_DEBUG mmu_printf_P(PSTR("E%d\n"), filament); //send eject filament + mmu_fil_loaded = false; mmu_state = 3; // wait for response } else if (mmu_cmd == MMU_CMD_R0) @@ -369,21 +372,52 @@ void mmu_command(uint8_t cmd) mmu_ready = false; } -bool mmu_get_response(void) +void mmu_load_step() { + current_position[E_AXIS] = current_position[E_AXIS] + MMU_LOAD_FEEDRATE * 0.1; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); +} + +void mmu_unload_step() { + current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * 0.1; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); +} + +bool mmu_get_response(uint8_t move) { -// printf_P(PSTR("mmu_get_response - begin\n")); + printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); KEEPALIVE_STATE(IN_PROCESS); while (mmu_cmd != 0) { // mmu_loop(); delay_keep_alive(100); } + while (!mmu_ready) { // mmu_loop(); + if (mmu_state != 3) break; - delay_keep_alive(100); + + switch (move) { + case MMU_LOAD_MOVE: + mmu_load_step(); + break; + case MMU_UNLOAD_MOVE: + mmu_unload_step(); + break; + case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading + current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); + move = MMU_LOAD_MOVE; + break; + default: + delay_keep_alive(100); + break; + } } bool ret = mmu_ready; mmu_ready = false; @@ -411,7 +445,7 @@ bool mmu_get_response(void) } -void manage_response(bool move_axes, bool turn_off_nozzle) +void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) { bool response = false; mmu_print_saved = false; @@ -423,7 +457,7 @@ void manage_response(bool move_axes, bool turn_off_nozzle) uint8_t screen = 0; //used for showing multiscreen messages while(!response) { - response = mmu_get_response(); //wait for "ok" from mmu + response = mmu_get_response(move); //wait for "ok" from mmu if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater if (lcd_update_enabled) { @@ -618,9 +652,10 @@ void mmu_M600_load_filament(bool automatic) // mmu_printf_P(PSTR("T%d\n"), tmp_extruder); mmu_command(MMU_CMD_T0 + tmp_extruder); - manage_response(false, true); + manage_response(false, true, MMU_LOAD_MOVE); mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished + mmu_load_to_nozzle(); load_filament_final_feed(); st_synchronize(); @@ -829,7 +864,7 @@ void extr_unload() mmu_command(MMU_CMD_U0); // get response - manage_response(false, true); + manage_response(false, true, MMU_UNLOAD_MOVE); lcd_update_enable(true); #else //SNMM @@ -1125,7 +1160,7 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr) lcd_print(" "); lcd_print(tmp_extruder + 1); mmu_command(MMU_CMD_T0 + tmp_extruder); - manage_response(true, true); + manage_response(true, true, MMU_TCODE_MOVE); mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished mmu_load_to_nozzle(); @@ -1162,7 +1197,7 @@ void mmu_eject_filament(uint8_t filament, bool recover) plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); st_synchronize(); mmu_command(MMU_CMD_E0 + filament); - manage_response(false, false); + manage_response(false, false, MMU_UNLOAD_MOVE); if (recover) { lcd_show_fullscreen_message_and_wait_P(_i("Please remove filament and then press the knob.")); @@ -1187,12 +1222,25 @@ void mmu_continue_loading() { #ifdef MMU_IDLER_SENSOR_PIN for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { + + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) return; #ifdef MMU_DEBUG printf_P(PSTR("Additional load attempt nr. %d\n"), i); #endif // MMU_DEBUG - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) break; mmu_command(MMU_CMD_C0); - manage_response(true, true); + manage_response(true, true, MMU_LOAD_MOVE); + } + if (PIN_GET(MMU_IDLER_SENSOR_PIN) != 0) { + //pause print, show error message and then repeat last T-code + if (card.sdprinting) { + lcd_pause_print(); + } + else + { + setTargetHotend0(0); + SERIAL_ECHOLNPGM("// action:pause"); //for octoprint + } + LCD_ALERTMESSAGEPGM("MMU Load Error"); } #else mmu_command(MMU_CMD_C0); diff --git a/Firmware/mmu.h b/Firmware/mmu.h index d8a6269aa..f19cbdbf9 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -4,6 +4,7 @@ extern bool mmu_enabled; +extern bool mmu_fil_loaded; extern uint8_t mmu_extruder; @@ -16,6 +17,13 @@ extern int16_t mmu_buildnr; #define MMU_FILAMENT_UNKNOWN 255 +#define MMU_UNLOAD_MOVE 1 +#define MMU_LOAD_MOVE 2 +#define MMU_TCODE_MOVE 3 + +#define MMU_LOAD_FEEDRATE 19.02f //mm/s +#define MMU_LOAD_TIME 1 //1000ms is load time for shortest allowed PTFE tubing and maximum loading speed + #define MMU_CMD_NONE 0 #define MMU_CMD_T0 0x10 #define MMU_CMD_T1 0x11 @@ -55,9 +63,9 @@ extern int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament); extern void mmu_command(uint8_t cmd); -extern bool mmu_get_response(void); +extern bool mmu_get_response(uint8_t move = 0); -extern void manage_response(bool move_axes, bool turn_off_nozzle); +extern void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move = 0); extern void mmu_load_to_nozzle(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 53453a3a8..ef5bef04b 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1955,6 +1955,43 @@ static void lcd_menu_fails_stats_print() lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Last print failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY); menu_back_if_clicked_fb(); } +/* +static void lcd_menu_fails_stats_mmu_print() +{ +//01234567890123456789 +//Last print failures +// Power failures 000 +// Filam. runouts 000 +// Crash X 000 Y 000 +////////////////////// + lcd_timeoutToStatus.stop(); //infinite timeout + uint8_t power = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); + uint8_t filam = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT); + uint8_t crashX = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X); + uint8_t crashY = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y); +// lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); + lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Last print failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY); + menu_back_if_clicked_fb(); +} + +static void lcd_menu_fails_stats_mmu_total() +{ +//01234567890123456789 +//Total failures +// Power failures 000 +// Filam. runouts 000 +// Crash X 000 Y 000 +////////////////////// + lcd_timeoutToStatus.stop(); //infinite timeout + uint16_t power = eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT); + uint16_t filam = eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT); + uint16_t crashX = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT); + uint16_t crashY = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT); +// lcd_printf_P(PSTR(ESC_H(0,0) "Total failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); + lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Total failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY); + menu_back_if_clicked_fb(); +} +*/ /** * @brief Open fail statistics menu * diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index e8425dd15..1e79a89d9 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -615,6 +615,6 @@ #define MMU_HWRESET //#define MMU_DEBUG //print communication between MMU2 and printer on serial #define MMU_IDLER_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) -#define MMU_IDLER_SENSOR_ATTEMPTS_NR 4 //max. number of attempts to load filament if first load failed +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning #endif //__CONFIGURATION_PRUSA_H From 665f1d7ffefe2513a27935fe44c3a0ebd4aec7a3 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 12 Dec 2018 23:36:50 +0100 Subject: [PATCH 05/31] pause print after N continue loading attempts and wait for user, then start print and repeat last T-code --- Firmware/mmu.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index c79e84662..7e34f69c0 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -857,7 +857,7 @@ void extr_unload() lcd_clear(); lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); lcd_print(" "); - if (mmu_extruder == MMU_FILAMENT_UNKNOWN) lcd_print("?"); + if (mmu_extruder == MMU_FILAMENT_UNKNOWN) lcd_print(" "); else lcd_print(mmu_extruder + 1); filament_ramming(); @@ -1231,16 +1231,26 @@ void mmu_continue_loading() manage_response(true, true, MMU_LOAD_MOVE); } if (PIN_GET(MMU_IDLER_SENSOR_PIN) != 0) { + char cmd[3]; //pause print, show error message and then repeat last T-code - if (card.sdprinting) { - lcd_pause_print(); - } - else - { - setTargetHotend0(0); - SERIAL_ECHOLNPGM("// action:pause"); //for octoprint - } - LCD_ALERTMESSAGEPGM("MMU Load Error"); + stop_and_save_print_to_ram(0, 0); + + //lift z + current_position[Z_AXIS] += Z_PAUSE_LIFT; + if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder); + st_synchronize(); + + //Move XY to side + current_position[X_AXIS] = X_PAUSE_POS; + current_position[Y_AXIS] = Y_PAUSE_POS; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); + st_synchronize(); + //set nozzle target temperature to 0 + setAllTargetHotends(0); + lcd_show_fullscreen_message_and_wait_P(_i("MMU load failed, fix the issue and pres the knob.")); + mmu_fil_loaded = false; //so we can retry same T-code again + restore_print_from_ram_and_continue(0); } #else mmu_command(MMU_CMD_C0); From a9829b6a1a1442b5350797ccb8b2d27b5aac2d06 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 13 Dec 2018 00:12:00 +0100 Subject: [PATCH 06/31] add statistics and idler sensor state --- Firmware/Marlin_main.cpp | 17 +++++++++++ Firmware/mmu.cpp | 4 +++ Firmware/ultralcd.cpp | 63 ++++++++++++++++++++++++++++++---------- 3 files changed, 68 insertions(+), 16 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b3d2af721..9d4e55f16 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -688,6 +688,12 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); + + lcd_menu_statistics(); break; @@ -714,6 +720,11 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); + #ifdef FILAMENT_SENSOR fsensor_enable(); fsensor_autoload_set(true); @@ -1388,6 +1399,12 @@ void setup() if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, 0); if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, 0); if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, 0); + + if (eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); + if (eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); + if (eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); + if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); + #ifdef SNMM if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM int _z = BOWDEN_LENGTH; diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 7e34f69c0..0aba47695 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -459,6 +459,8 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) { response = mmu_get_response(move); //wait for "ok" from mmu if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit + eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) + 1); + eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) + 1); if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater if (lcd_update_enabled) { lcd_update_was_enabled = true; @@ -1231,6 +1233,8 @@ void mmu_continue_loading() manage_response(true, true, MMU_LOAD_MOVE); } if (PIN_GET(MMU_IDLER_SENSOR_PIN) != 0) { + eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) + 1); + eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) + 1); char cmd[3]; //pause print, show error message and then repeat last T-code stop_and_save_print_to_ram(0, 0); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ef5bef04b..5c279734c 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -38,7 +38,7 @@ #include "mmu.h" #include "static_assert.h" - +#include "io_atmega2560.h" extern bool fans_check_enabled; @@ -1955,7 +1955,7 @@ static void lcd_menu_fails_stats_print() lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Last print failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY); menu_back_if_clicked_fb(); } -/* + static void lcd_menu_fails_stats_mmu_print() { //01234567890123456789 @@ -1965,33 +1965,30 @@ static void lcd_menu_fails_stats_mmu_print() // Crash X 000 Y 000 ////////////////////// lcd_timeoutToStatus.stop(); //infinite timeout - uint8_t power = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); - uint8_t filam = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT); - uint8_t crashX = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X); - uint8_t crashY = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y); + uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL); + uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL); // lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); - lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Last print failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY); + lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Last print failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails); menu_back_if_clicked_fb(); } static void lcd_menu_fails_stats_mmu_total() { //01234567890123456789 -//Total failures +//Last print failures // Power failures 000 // Filam. runouts 000 // Crash X 000 Y 000 ////////////////////// lcd_timeoutToStatus.stop(); //infinite timeout - uint16_t power = eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT); - uint16_t filam = eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT); - uint16_t crashX = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT); - uint16_t crashY = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT); -// lcd_printf_P(PSTR(ESC_H(0,0) "Total failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); - lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Total failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY); + uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL_TOT); + uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL_TOT); +// lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); + lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Total failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails); menu_back_if_clicked_fb(); } -*/ + + /** * @brief Open fail statistics menu * @@ -2007,6 +2004,16 @@ static void lcd_menu_fails_stats() MENU_ITEM_SUBMENU_P(_i("Total"), lcd_menu_fails_stats_total); MENU_END(); } + +static void lcd_menu_fails_stats_mmu() +{ + MENU_BEGIN(); + MENU_ITEM_BACK_P(_T(MSG_MAIN)); + MENU_ITEM_SUBMENU_P(_i("Last print"), lcd_menu_fails_stats_mmu_print); + MENU_ITEM_SUBMENU_P(_i("Total"), lcd_menu_fails_stats_mmu_total); + MENU_END(); +} + #elif defined(FILAMENT_SENSOR) /** * @brief Print last print and total filament run outs @@ -3634,6 +3641,27 @@ if(LCD_CLICKED) } #endif // defined TMC2130 +#ifdef TMC2130 +static void lcd_show_idler_state() +{ +lcd_set_cursor(0, 0); +lcd_puts_P((PSTR("Idler state"))); +lcd_set_cursor(0, 2); +lcd_puts_P((PIN_GET(MMU_IDLER_SENSOR_PIN) == 0)?(PSTR("ON")):(PSTR("OFF"))); // !!! both strings must have same length (due to dynamic refreshing) +} + +static void lcd_menu_show_idler_state() +{ +lcd_timeoutToStatus.stop(); +lcd_show_idler_state(); +if(LCD_CLICKED) + { + lcd_timeoutToStatus.start(); + menu_back(); + } +} +#endif // defined TMC2130 + void prusa_statistics(int _message, uint8_t _fil_nr) { @@ -5900,7 +5928,10 @@ static void lcd_main_menu() #if defined(TMC2130) || defined(FILAMENT_SENSOR) MENU_ITEM_SUBMENU_P(_i("Fail stats"), lcd_menu_fails_stats); #endif - + if (mmu_enabled) { + MENU_ITEM_SUBMENU_P(_i("Fail stats MMU"), lcd_menu_fails_stats_mmu); + MENU_ITEM_SUBMENU_P(_i("Show idler state"), lcd_menu_show_idler_state); + } MENU_ITEM_SUBMENU_P(_i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0 #ifdef LCD_TEST MENU_ITEM_SUBMENU_P(_i("W25x20CL init"), lcd_test_menu);////MSG_SUPPORT c=0 r=0 From df71398066db6ba486e646ed38b9e6b215d62c07 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 13 Dec 2018 00:43:27 +0100 Subject: [PATCH 07/31] statistics fix --- Firmware/Marlin_main.cpp | 2 ++ Firmware/mmu.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 9d4e55f16..9843ef971 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -642,6 +642,8 @@ void failstats_reset_print() eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0); eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); } diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 0aba47695..0faf3fa8c 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1233,8 +1233,8 @@ void mmu_continue_loading() manage_response(true, true, MMU_LOAD_MOVE); } if (PIN_GET(MMU_IDLER_SENSOR_PIN) != 0) { - eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) + 1); - eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) + 1); + eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) + 1); + eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) + 1); char cmd[3]; //pause print, show error message and then repeat last T-code stop_and_save_print_to_ram(0, 0); From 9c4f086addd21f64c933641ca3b3b9c686828ef3 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 13 Dec 2018 01:09:21 +0100 Subject: [PATCH 08/31] fixed statistics for MMU_FAIL --- Firmware/mmu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 0faf3fa8c..914164856 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -459,9 +459,9 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) { response = mmu_get_response(move); //wait for "ok" from mmu if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit - eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) + 1); - eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) + 1); if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater + eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) + 1); + eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) + 1); if (lcd_update_enabled) { lcd_update_was_enabled = true; lcd_update_enable(false); From 24ef6deeed2d870710bc5bc853216d68e72c956d Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 13 Dec 2018 16:43:40 +0100 Subject: [PATCH 09/31] typo fixed --- Firmware/mmu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 914164856..948113821 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1252,7 +1252,7 @@ void mmu_continue_loading() st_synchronize(); //set nozzle target temperature to 0 setAllTargetHotends(0); - lcd_show_fullscreen_message_and_wait_P(_i("MMU load failed, fix the issue and pres the knob.")); + lcd_show_fullscreen_message_and_wait_P(_i("MMU load failed, fix the issue and press the knob.")); mmu_fil_loaded = false; //so we can retry same T-code again restore_print_from_ram_and_continue(0); } From bbba27c15f932dd1e23148a11972e395fdf177c1 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 13 Dec 2018 16:53:59 +0100 Subject: [PATCH 10/31] idler state menu --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5c279734c..b62059f97 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3647,7 +3647,7 @@ static void lcd_show_idler_state() lcd_set_cursor(0, 0); lcd_puts_P((PSTR("Idler state"))); lcd_set_cursor(0, 2); -lcd_puts_P((PIN_GET(MMU_IDLER_SENSOR_PIN) == 0)?(PSTR("ON")):(PSTR("OFF"))); // !!! both strings must have same length (due to dynamic refreshing) +lcd_puts_P((PIN_GET(MMU_IDLER_SENSOR_PIN) == 0)?(PSTR("ON ")):(PSTR("OFF"))); // !!! both strings must have same length (due to dynamic refreshing) } static void lcd_menu_show_idler_state() From e0bed71801a78347991746929b824ed3d1093d86 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 13 Dec 2018 17:01:45 +0100 Subject: [PATCH 11/31] comments update --- Firmware/ultralcd.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b62059f97..60ad56b87 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1960,9 +1960,9 @@ static void lcd_menu_fails_stats_mmu_print() { //01234567890123456789 //Last print failures -// Power failures 000 -// Filam. runouts 000 -// Crash X 000 Y 000 +// MMU fails 000 +// MMU load fails 000 +// ////////////////////// lcd_timeoutToStatus.stop(); //infinite timeout uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL); @@ -1976,9 +1976,9 @@ static void lcd_menu_fails_stats_mmu_total() { //01234567890123456789 //Last print failures -// Power failures 000 -// Filam. runouts 000 -// Crash X 000 Y 000 +// MMU fails 000 +// MMU load fails 000 +// ////////////////////// lcd_timeoutToStatus.stop(); //infinite timeout uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL_TOT); From cb1f6d2a0ea0591fa7b9b508c56d4523bc5e507e Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 14 Dec 2018 19:43:26 +0100 Subject: [PATCH 12/31] show sensor states in calibration menu --- Firmware/ultralcd.cpp | 85 +++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 60ad56b87..4599ee3a3 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -195,6 +195,9 @@ static void menu_action_sddirectory(const char* filename); #define ENCODER_FEEDRATE_DEADZONE 10 +#define STATE_NA 255 +#define STATE_OFF 0 +#define STATE_ON 1 /* #define MENU_ITEM(type, label, args...) do { \ @@ -3620,49 +3623,60 @@ void lcd_diag_show_end_stops() lcd_return_to_status(); } -#ifdef TMC2130 -static void lcd_show_pinda_state() +static void lcd_print_state(uint8_t state) { -lcd_set_cursor(0, 0); -lcd_puts_P((PSTR("P.I.N.D.A. state"))); -lcd_set_cursor(0, 2); -lcd_puts_P(READ(Z_MIN_PIN)?(PSTR("Z1 (LED off)")):(PSTR("Z0 (LED on) "))); // !!! both strings must have same length (due to dynamic refreshing) + switch (state) { + case STATE_ON: + lcd_puts_P(_T(MSG_ON)); + break; + case STATE_OFF: + lcd_puts_P(_T(MSG_OFF)); + break; + default: + lcd_puts_P(_i("N/A")); + break; + } } -static void menu_show_pinda_state() +static void lcd_show_sensors_state() { -lcd_timeoutToStatus.stop(); -lcd_show_pinda_state(); -if(LCD_CLICKED) - { - lcd_timeoutToStatus.start(); - menu_back(); - } -} -#endif // defined TMC2130 + //0: N/A; 1: OFF; 2: ON + uint8_t chars = 0; + uint8_t pinda_state = STATE_NA; + uint8_t finda_state = STATE_NA; + uint8_t idler_state = STATE_NA; -#ifdef TMC2130 -static void lcd_show_idler_state() -{ -lcd_set_cursor(0, 0); -lcd_puts_P((PSTR("Idler state"))); -lcd_set_cursor(0, 2); -lcd_puts_P((PIN_GET(MMU_IDLER_SENSOR_PIN) == 0)?(PSTR("ON ")):(PSTR("OFF"))); // !!! both strings must have same length (due to dynamic refreshing) + pinda_state = READ(Z_MIN_PIN); + if (mmu_enabled) { + finda_state = mmu_finda; + } +#ifdef MMU_IDLER_SENSOR_PIN + idler_state = !PIN_GET(MMU_IDLER_SENSOR_PIN); +#endif + lcd_puts_at_P(0, 0, _i("Sensors state")); + lcd_puts_at_P(1, 1, _i("PINDA:")); + lcd_set_cursor(LCD_WIDTH - 4, 1); + lcd_print_state(pinda_state); + + lcd_puts_at_P(1, 2, _i("FINDA:")); + lcd_set_cursor(LCD_WIDTH - 4, 2); + lcd_print_state(finda_state); + + lcd_puts_at_P(1, 3, _i("IR:")); + lcd_set_cursor(LCD_WIDTH - 4, 3); + lcd_print_state(idler_state); } -static void lcd_menu_show_idler_state() +static void lcd_menu_show_sensors_state() { -lcd_timeoutToStatus.stop(); -lcd_show_idler_state(); -if(LCD_CLICKED) - { - lcd_timeoutToStatus.start(); - menu_back(); - } + lcd_timeoutToStatus.stop(); + lcd_show_sensors_state(); + if(LCD_CLICKED) + { + lcd_timeoutToStatus.start(); + menu_back(); + } } -#endif // defined TMC2130 - - void prusa_statistics(int _message, uint8_t _fil_nr) { #ifdef DEBUG_DISABLE_PRUSA_STATISTICS @@ -5020,7 +5034,7 @@ static void lcd_calibration_menu() MENU_ITEM_SUBMENU_P(_i("Bed level correct"), lcd_adjust_bed);////MSG_BED_CORRECTION_MENU c=0 r=0 MENU_ITEM_SUBMENU_P(_i("PID calibration"), pid_extruder);////MSG_PID_EXTRUDER c=17 r=1 #ifdef TMC2130 - MENU_ITEM_SUBMENU_P(_i("Show pinda state"), menu_show_pinda_state); + MENU_ITEM_SUBMENU_P(_i("Show sensors"), lcd_menu_show_sensors_state); #else MENU_ITEM_SUBMENU_P(_i("Show end stops"), menu_show_end_stops);////MSG_SHOW_END_STOPS c=17 r=1 #endif @@ -5930,7 +5944,6 @@ static void lcd_main_menu() #endif if (mmu_enabled) { MENU_ITEM_SUBMENU_P(_i("Fail stats MMU"), lcd_menu_fails_stats_mmu); - MENU_ITEM_SUBMENU_P(_i("Show idler state"), lcd_menu_show_idler_state); } MENU_ITEM_SUBMENU_P(_i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0 #ifdef LCD_TEST From 27c861236016ccbc449ad54e3a280b8fe3297bd5 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 17 Dec 2018 21:25:07 +0100 Subject: [PATCH 13/31] use just short movement for unloading filament --- Firmware/mmu.cpp | 14 ++++++-------- Firmware/mmu.h | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 948113821..2be8b1d2a 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -377,13 +377,6 @@ void mmu_load_step() { plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); st_synchronize(); } - -void mmu_unload_step() { - current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * 0.1; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); - st_synchronize(); -} - bool mmu_get_response(uint8_t move) { printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); @@ -406,7 +399,11 @@ bool mmu_get_response(uint8_t move) mmu_load_step(); break; case MMU_UNLOAD_MOVE: - mmu_unload_step(); + current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); + disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary + move = MMU_NO_MOVE; break; case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME; @@ -414,6 +411,7 @@ bool mmu_get_response(uint8_t move) st_synchronize(); move = MMU_LOAD_MOVE; break; + case MMU_NO_MOVE: default: delay_keep_alive(100); break; diff --git a/Firmware/mmu.h b/Firmware/mmu.h index f19cbdbf9..88ba047a8 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -17,6 +17,7 @@ extern int16_t mmu_buildnr; #define MMU_FILAMENT_UNKNOWN 255 +#define MMU_NO_MOVE 0 #define MMU_UNLOAD_MOVE 1 #define MMU_LOAD_MOVE 2 #define MMU_TCODE_MOVE 3 From 7703125b2e0fba43239da6db800b1690d1fa54c3 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 18 Dec 2018 16:08:29 +0100 Subject: [PATCH 14/31] retry unload movements (T-codes, M702 C) if filament detected by idler sensor, then turn off stepper and wait, MMU_LOAD_TIME prolonged --- Firmware/mmu.cpp | 38 ++++++++++++++++++++++++++++---------- Firmware/mmu.h | 2 +- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 2be8b1d2a..875c195be 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -399,17 +399,35 @@ bool mmu_get_response(uint8_t move) mmu_load_step(); break; case MMU_UNLOAD_MOVE: - current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); - st_synchronize(); - disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary - move = MMU_NO_MOVE; + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading + { + printf_P(PSTR("Unload 1\n")); + current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); + } + else //filament was unloaded from idler, no additional movements needed + { + printf_P(PSTR("Unloading finished 1\n")); + disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary + move = MMU_NO_MOVE; + } break; - case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading - current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); - st_synchronize(); - move = MMU_LOAD_MOVE; + case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first + { + printf_P(PSTR("Unload 2\n")); + current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); + } + else //delay to allow mmu unit to pull out filament from bondtech gears and then start with infinite loading + { + printf_P(PSTR("Unloading finished 2\n")); + disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary + delay_keep_alive(MMU_LOAD_TIME_MS); + move = MMU_LOAD_MOVE; + } break; case MMU_NO_MOVE: default: diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 88ba047a8..8d88304c6 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -23,7 +23,7 @@ extern int16_t mmu_buildnr; #define MMU_TCODE_MOVE 3 #define MMU_LOAD_FEEDRATE 19.02f //mm/s -#define MMU_LOAD_TIME 1 //1000ms is load time for shortest allowed PTFE tubing and maximum loading speed +#define MMU_LOAD_TIME_MS 2000 //1000ms is load time for shortest allowed PTFE tubing and maximum loading speed #define MMU_CMD_NONE 0 #define MMU_CMD_T0 0x10 From c782373f2d87e7894b192fa370176242edd47287 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 18 Dec 2018 16:09:10 +0100 Subject: [PATCH 15/31] comment --- Firmware/mmu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 8d88304c6..b6fbaaa6a 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -23,7 +23,7 @@ extern int16_t mmu_buildnr; #define MMU_TCODE_MOVE 3 #define MMU_LOAD_FEEDRATE 19.02f //mm/s -#define MMU_LOAD_TIME_MS 2000 //1000ms is load time for shortest allowed PTFE tubing and maximum loading speed +#define MMU_LOAD_TIME_MS 2000 //should be fine tuned to load time for shortest allowed PTFE tubing and maximum loading speed #define MMU_CMD_NONE 0 #define MMU_CMD_T0 0x10 From fc33affbdaa775e8c38cb6abc23a034bc3476319 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 18 Dec 2018 17:24:29 +0100 Subject: [PATCH 16/31] temporary change --- Firmware/mmu.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 875c195be..bf4469c19 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -379,6 +379,11 @@ void mmu_load_step() { } bool mmu_get_response(uint8_t move) { + bool sensor_pin = false; + #ifdef MMU_IDLER_SENSOR_PIN + sensor_pin = true; + #endif //MMU_IDLER_SENSOR_PIN + printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); KEEPALIVE_STATE(IN_PROCESS); while (mmu_cmd != 0) @@ -399,7 +404,7 @@ bool mmu_get_response(uint8_t move) mmu_load_step(); break; case MMU_UNLOAD_MOVE: - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0 && sensor_pin) //filament is still detected by idler sensor, printer helps with unlading { printf_P(PSTR("Unload 1\n")); current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; @@ -414,7 +419,7 @@ bool mmu_get_response(uint8_t move) } break; case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0 && sensor_pin) //filament detected by idler sensor, we must unload first { printf_P(PSTR("Unload 2\n")); current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; From 4543949cac32867ce88ad3639fa66e673608eb37 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 18 Dec 2018 17:29:44 +0100 Subject: [PATCH 17/31] build without MMU_IDLER_SENSOR_PIN defined --- Firmware/mmu.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index bf4469c19..a73416556 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -379,11 +379,6 @@ void mmu_load_step() { } bool mmu_get_response(uint8_t move) { - bool sensor_pin = false; - #ifdef MMU_IDLER_SENSOR_PIN - sensor_pin = true; - #endif //MMU_IDLER_SENSOR_PIN - printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); KEEPALIVE_STATE(IN_PROCESS); while (mmu_cmd != 0) @@ -404,7 +399,8 @@ bool mmu_get_response(uint8_t move) mmu_load_step(); break; case MMU_UNLOAD_MOVE: - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0 && sensor_pin) //filament is still detected by idler sensor, printer helps with unlading +#ifdef MMU_IDLER_SENSOR_PIN + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading { printf_P(PSTR("Unload 1\n")); current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; @@ -412,14 +408,17 @@ bool mmu_get_response(uint8_t move) st_synchronize(); } else //filament was unloaded from idler, no additional movements needed +#endif //MMU_IDLER_SENSOR_PIN { printf_P(PSTR("Unloading finished 1\n")); disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary move = MMU_NO_MOVE; } + break; case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0 && sensor_pin) //filament detected by idler sensor, we must unload first +#ifdef MMU_IDLER_SENSOR_PIN + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first { printf_P(PSTR("Unload 2\n")); current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; @@ -427,6 +426,7 @@ bool mmu_get_response(uint8_t move) st_synchronize(); } else //delay to allow mmu unit to pull out filament from bondtech gears and then start with infinite loading +#endif //MMU_IDLER_SENSOR_PIN { printf_P(PSTR("Unloading finished 2\n")); disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary From 11ab5dfd36bedcc74df79c1cd414a548eb3c03eb Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 18 Dec 2018 17:33:27 +0100 Subject: [PATCH 18/31] fail stats menu for mmu defined for MK2.5 version --- Firmware/ultralcd.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4599ee3a3..12e47ea9a 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1922,6 +1922,15 @@ static void lcd_menu_extruder_info() menu_back_if_clicked(); } +static void lcd_menu_fails_stats_mmu() +{ + MENU_BEGIN(); + MENU_ITEM_BACK_P(_T(MSG_MAIN)); + MENU_ITEM_SUBMENU_P(_i("Last print"), lcd_menu_fails_stats_mmu_print); + MENU_ITEM_SUBMENU_P(_i("Total"), lcd_menu_fails_stats_mmu_total); + MENU_END(); +} + #if defined(TMC2130) && defined(FILAMENT_SENSOR) static void lcd_menu_fails_stats_total() { @@ -2008,15 +2017,6 @@ static void lcd_menu_fails_stats() MENU_END(); } -static void lcd_menu_fails_stats_mmu() -{ - MENU_BEGIN(); - MENU_ITEM_BACK_P(_T(MSG_MAIN)); - MENU_ITEM_SUBMENU_P(_i("Last print"), lcd_menu_fails_stats_mmu_print); - MENU_ITEM_SUBMENU_P(_i("Total"), lcd_menu_fails_stats_mmu_total); - MENU_END(); -} - #elif defined(FILAMENT_SENSOR) /** * @brief Print last print and total filament run outs From fc5d7e35efba2053c66ce7baecda6fc8e47288b4 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 18 Dec 2018 17:35:41 +0100 Subject: [PATCH 19/31] fail stats mmu function definitions --- Firmware/ultralcd.cpp | 65 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 12e47ea9a..856d0cc36 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1931,6 +1931,38 @@ static void lcd_menu_fails_stats_mmu() MENU_END(); } +static void lcd_menu_fails_stats_mmu_print() +{ +//01234567890123456789 +//Last print failures +// MMU fails 000 +// MMU load fails 000 +// +////////////////////// + lcd_timeoutToStatus.stop(); //infinite timeout + uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL); + uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL); +// lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); + lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Last print failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails); + menu_back_if_clicked_fb(); +} + +static void lcd_menu_fails_stats_mmu_total() +{ +//01234567890123456789 +//Last print failures +// MMU fails 000 +// MMU load fails 000 +// +////////////////////// + lcd_timeoutToStatus.stop(); //infinite timeout + uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL_TOT); + uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL_TOT); +// lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); + lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Total failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails); + menu_back_if_clicked_fb(); +} + #if defined(TMC2130) && defined(FILAMENT_SENSOR) static void lcd_menu_fails_stats_total() { @@ -1968,39 +2000,6 @@ static void lcd_menu_fails_stats_print() menu_back_if_clicked_fb(); } -static void lcd_menu_fails_stats_mmu_print() -{ -//01234567890123456789 -//Last print failures -// MMU fails 000 -// MMU load fails 000 -// -////////////////////// - lcd_timeoutToStatus.stop(); //infinite timeout - uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL); - uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL); -// lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); - lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Last print failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails); - menu_back_if_clicked_fb(); -} - -static void lcd_menu_fails_stats_mmu_total() -{ -//01234567890123456789 -//Last print failures -// MMU fails 000 -// MMU load fails 000 -// -////////////////////// - lcd_timeoutToStatus.stop(); //infinite timeout - uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL_TOT); - uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL_TOT); -// lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); - lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Total failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails); - menu_back_if_clicked_fb(); -} - - /** * @brief Open fail statistics menu * From 880163dbcbd8d2bd38cdba2fd5c62501f1aed371 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 18 Dec 2018 17:38:24 +0100 Subject: [PATCH 20/31] missing prototypes --- Firmware/ultralcd.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 856d0cc36..72f344592 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -136,6 +136,10 @@ static void lcd_menu_extruder_info(); static void lcd_menu_xyz_y_min(); static void lcd_menu_xyz_skew(); static void lcd_menu_xyz_offset(); +static void lcd_menu_fails_stats_mmu(); +static void lcd_menu_fails_stats_mmu_print(); +static void lcd_menu_fails_stats_mmu_total(); + #if defined(TMC2130) || defined(FILAMENT_SENSOR) static void lcd_menu_fails_stats(); #endif //TMC2130 or FILAMENT_SENSOR From 3c64bad1cbce97d661ce2352f3da74ebe7b77370 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Dec 2018 17:12:16 +0100 Subject: [PATCH 21/31] initial version which works on old and new hw, initial version of idler sensor detection --- Firmware/mmu.cpp | 150 ++++++++++-------- Firmware/mmu.h | 2 + Firmware/pins_Einsy_1_0.h | 1 + Firmware/pins_Rambo_1_0.h | 2 +- Firmware/pins_Rambo_1_3.h | 2 +- Firmware/ultralcd.cpp | 6 +- .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 +- 7 files changed, 91 insertions(+), 74 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index a73416556..f1cc840b6 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -38,9 +38,10 @@ static int8_t mmu_state = 0; uint8_t mmu_cmd = 0; -#ifdef MMU_IDLER_SENSOR_PIN +//idler ir sensor uint8_t mmu_idl_sens = 0; -#endif //MMU_IDLER_SENSOR_PIN +bool mmu_idler_sensor_detected = false; + uint8_t mmu_extruder = MMU_FILAMENT_UNKNOWN; @@ -111,10 +112,25 @@ void mmu_init(void) _delay_ms(10); //wait 10ms for sure mmu_reset(); //reset mmu (HW or SW), do not wait for response mmu_state = -1; -#ifdef MMU_IDLER_SENSOR_PIN PIN_INP(MMU_IDLER_SENSOR_PIN); //input mode PIN_SET(MMU_IDLER_SENSOR_PIN); //pullup -#endif //MMU_IDLER_SENSOR_PIN +} + +//returns true if idler IR sensor was detected, otherwise returns false +bool check_for_idler_sensor() +{ + bool detected = false; + //if MMU_IDLER_SENSOR_PIN input is low and pat9125sensor is not present we detected idler sensor + if ((PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) && fsensor_not_responding) + { + detected = true; + //printf_P(PSTR("Idler IR sensor detected\n")); + } + else + { + //printf_P(PSTR("Idler IR sensor not detected\n")); + } + return detected; } //mmu main loop - state machine processing @@ -167,9 +183,9 @@ void mmu_loop(void) if ((PRINTER_TYPE == PRINTER_MK3) || (PRINTER_TYPE == PRINTER_MK3_SNMM)) { -#ifdef MMU_DEBUG +#if defined MMU_DEBUG && defined MMU_FINDA_DEBUG puts_P(PSTR("MMU <= 'P0'")); -#endif //MMU_DEBUG +#endif //MMU_DEBUG && MMU_FINDA_DEBUG mmu_puts_P(PSTR("P0\n")); //send 'read finda' request mmu_state = -4; } @@ -187,9 +203,9 @@ void mmu_loop(void) case -5: if (mmu_rx_ok() > 0) { -#ifdef MMU_DEBUG +#if defined MMU_DEBUG && defined MMU_FINDA_DEBUG puts_P(PSTR("MMU <= 'P0'")); -#endif //MMU_DEBUG +#endif //MMU_DEBUG && MMU_FINDA_DEBUG mmu_puts_P(PSTR("P0\n")); //send 'read finda' request mmu_state = -4; } @@ -198,11 +214,13 @@ void mmu_loop(void) if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer -#ifdef MMU_DEBUG +#if defined MMU_DEBUG && defined MMU_FINDA_DEBUG printf_P(PSTR("MMU => '%dok'\n"), mmu_finda); -#endif //MMU_DEBUG +#endif //MMU_DEBUG && MMU_FINDA_DEBUG puts_P(PSTR("MMU - ENABLED")); mmu_enabled = true; + //if we have filament loaded into the nozzle, we can decide if printer has idler sensor right now; otherwise we will will wait till start of T-code so it will be detected on beginning of second T-code + if(check_for_idler_sensor()) mmu_idler_sensor_detected = true; mmu_state = 1; } return; @@ -218,9 +236,7 @@ void mmu_loop(void) mmu_printf_P(PSTR("T%d\n"), filament); mmu_state = 3; // wait for response mmu_fil_loaded = true; -#ifdef MMU_IDLER_SENSOR_PIN - mmu_idl_sens = 1; //enable idler sensor -#endif //MMU_IDLER_SENSOR_PIN + if(mmu_idler_sensor_detected) mmu_idl_sens = 1; //if idler sensor detected, use it for T-code } else if ((mmu_cmd >= MMU_CMD_L0) && (mmu_cmd <= MMU_CMD_L4)) { @@ -238,9 +254,7 @@ void mmu_loop(void) #endif //MMU_DEBUG mmu_puts_P(PSTR("C0\n")); //send 'continue loading' mmu_state = 3; -#ifdef MMU_IDLER_SENSOR_PIN - mmu_idl_sens = 1; //enable idler sensor -#endif //MMU_IDLER_SENSOR_PIN + if(mmu_idler_sensor_detected) mmu_idl_sens = 1; //if idler sensor detected use it for C0 code } else if (mmu_cmd == MMU_CMD_U0) { @@ -273,9 +287,10 @@ void mmu_loop(void) } else if ((mmu_last_response + 300) < millis()) //request every 300ms { -#ifdef MMU_DEBUG + if(check_for_idler_sensor()) mmu_idler_sensor_detected = true; +#if defined MMU_DEBUG && defined MMU_FINDA_DEBUG puts_P(PSTR("MMU <= 'P0'")); -#endif //MMU_DEBUG +#endif //MMU_DEBUG && MMU_FINDA_DEBUG mmu_puts_P(PSTR("P0\n")); //send 'read finda' request mmu_state = 2; } @@ -284,9 +299,9 @@ void mmu_loop(void) if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer -#ifdef MMU_DEBUG +#if defined MMU_DEBUG && MMU_FINDA_DEBUG printf_P(PSTR("MMU => '%dok'\n"), mmu_finda); -#endif //MMU_DEBUG +#endif //MMU_DEBUG && MMU_FINDA_DEBUG //printf_P(PSTR("Eact: %d\n"), int(e_active())); if (!mmu_finda && CHECK_FINDA && fsensor_enabled) { fsensor_stop_and_save_print(); @@ -304,22 +319,22 @@ void mmu_loop(void) } return; case 3: //response to mmu commands -#ifdef MMU_IDLER_SENSOR_PIN - if (mmu_idl_sens) - { - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) + if (mmu_idler_sensor_detected) { + if (mmu_idl_sens) { + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) + { #ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'A'\n")); + printf_P(PSTR("MMU <= 'A'\n")); #endif //MMU_DEBUG - mmu_puts_P(PSTR("A\n")); //send 'abort' request - mmu_idl_sens = 0; - //printf_P(PSTR("MMU IDLER_SENSOR = 0 - ABORT\n")); + mmu_puts_P(PSTR("A\n")); //send 'abort' request + mmu_idl_sens = 0; + //printf_P(PSTR("MMU IDLER_SENSOR = 0 - ABORT\n")); + } + //else + //printf_P(PSTR("MMU IDLER_SENSOR = 1 - WAIT\n")); } - //else - //printf_P(PSTR("MMU IDLER_SENSOR = 1 - WAIT\n")); } -#endif //MMU_IDLER_SENSOR_PIN if (mmu_rx_ok() > 0) { #ifdef MMU_DEBUG @@ -379,6 +394,8 @@ void mmu_load_step() { } bool mmu_get_response(uint8_t move) { + if (!mmu_idler_sensor_detected) move = MMU_NO_MOVE; + printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); KEEPALIVE_STATE(IN_PROCESS); while (mmu_cmd != 0) @@ -399,7 +416,6 @@ bool mmu_get_response(uint8_t move) mmu_load_step(); break; case MMU_UNLOAD_MOVE: -#ifdef MMU_IDLER_SENSOR_PIN if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading { printf_P(PSTR("Unload 1\n")); @@ -408,7 +424,6 @@ bool mmu_get_response(uint8_t move) st_synchronize(); } else //filament was unloaded from idler, no additional movements needed -#endif //MMU_IDLER_SENSOR_PIN { printf_P(PSTR("Unloading finished 1\n")); disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary @@ -417,7 +432,6 @@ bool mmu_get_response(uint8_t move) break; case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements -#ifdef MMU_IDLER_SENSOR_PIN if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first { printf_P(PSTR("Unload 2\n")); @@ -426,7 +440,6 @@ bool mmu_get_response(uint8_t move) st_synchronize(); } else //delay to allow mmu unit to pull out filament from bondtech gears and then start with infinite loading -#endif //MMU_IDLER_SENSOR_PIN { printf_P(PSTR("Unloading finished 2\n")); disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary @@ -1243,41 +1256,42 @@ void mmu_eject_filament(uint8_t filament, bool recover) void mmu_continue_loading() { -#ifdef MMU_IDLER_SENSOR_PIN - for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) return; + if (mmu_idler_sensor_detected) { + for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) return; #ifdef MMU_DEBUG - printf_P(PSTR("Additional load attempt nr. %d\n"), i); + printf_P(PSTR("Additional load attempt nr. %d\n"), i); #endif // MMU_DEBUG - mmu_command(MMU_CMD_C0); - manage_response(true, true, MMU_LOAD_MOVE); - } - if (PIN_GET(MMU_IDLER_SENSOR_PIN) != 0) { - eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) + 1); - eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) + 1); - char cmd[3]; - //pause print, show error message and then repeat last T-code - stop_and_save_print_to_ram(0, 0); + mmu_command(MMU_CMD_C0); + manage_response(true, true, MMU_LOAD_MOVE); + } + if (PIN_GET(MMU_IDLER_SENSOR_PIN) != 0) { + eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) + 1); + eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) + 1); + char cmd[3]; + //pause print, show error message and then repeat last T-code + stop_and_save_print_to_ram(0, 0); - //lift z - current_position[Z_AXIS] += Z_PAUSE_LIFT; - if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder); - st_synchronize(); - - //Move XY to side - current_position[X_AXIS] = X_PAUSE_POS; - current_position[Y_AXIS] = Y_PAUSE_POS; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); - st_synchronize(); - //set nozzle target temperature to 0 - setAllTargetHotends(0); - lcd_show_fullscreen_message_and_wait_P(_i("MMU load failed, fix the issue and press the knob.")); - mmu_fil_loaded = false; //so we can retry same T-code again - restore_print_from_ram_and_continue(0); - } -#else - mmu_command(MMU_CMD_C0); -#endif //MMU_IDLER_SENSOR_PIN + //lift z + current_position[Z_AXIS] += Z_PAUSE_LIFT; + if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder); + st_synchronize(); + + //Move XY to side + current_position[X_AXIS] = X_PAUSE_POS; + current_position[Y_AXIS] = Y_PAUSE_POS; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); + st_synchronize(); + //set nozzle target temperature to 0 + setAllTargetHotends(0); + lcd_show_fullscreen_message_and_wait_P(_i("MMU load failed, fix the issue and press the knob.")); + mmu_fil_loaded = false; //so we can retry same T-code again + restore_print_from_ram_and_continue(0); + } + } + else { //mmu_idler_sensor_detected == false + mmu_command(MMU_CMD_C0); + } } diff --git a/Firmware/mmu.h b/Firmware/mmu.h index b6fbaaa6a..c3416cbc6 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -11,6 +11,7 @@ extern uint8_t mmu_extruder; extern uint8_t tmp_extruder; extern int8_t mmu_finda; +extern bool mmu_idler_sensor_detected; extern int16_t mmu_version; extern int16_t mmu_buildnr; @@ -52,6 +53,7 @@ extern int mmu_printf_P(const char* format, ...); extern int8_t mmu_rx_ok(void); +extern bool check_for_idler_sensor(); extern void mmu_init(void); diff --git a/Firmware/pins_Einsy_1_0.h b/Firmware/pins_Einsy_1_0.h index eabdb4abb..4ef8f9ba8 100644 --- a/Firmware/pins_Einsy_1_0.h +++ b/Firmware/pins_Einsy_1_0.h @@ -121,6 +121,7 @@ #define TACH_0 79 // !!! changed from 81 (EINY03) #define TACH_1 80 +#define MMU_IDLER_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) // Support for an 8 bit logic analyzer, for example the Saleae. // Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop. diff --git a/Firmware/pins_Rambo_1_0.h b/Firmware/pins_Rambo_1_0.h index 1e3a142c9..b37ab641d 100644 --- a/Firmware/pins_Rambo_1_0.h +++ b/Firmware/pins_Rambo_1_0.h @@ -102,7 +102,7 @@ #define SDCARDDETECT 72 - +#define MMU_IDLER_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) // Support for an 8 bit logic analyzer, for example the Saleae. // Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop. diff --git a/Firmware/pins_Rambo_1_3.h b/Firmware/pins_Rambo_1_3.h index a9a6b390d..297735c18 100644 --- a/Firmware/pins_Rambo_1_3.h +++ b/Firmware/pins_Rambo_1_3.h @@ -102,7 +102,7 @@ #define SDCARDDETECT 15 - +#define MMU_IDLER_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) // Support for an 8 bit logic analyzer, for example the Saleae. // Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop. diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 72f344592..cff7a1f17 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3653,9 +3653,9 @@ static void lcd_show_sensors_state() if (mmu_enabled) { finda_state = mmu_finda; } -#ifdef MMU_IDLER_SENSOR_PIN - idler_state = !PIN_GET(MMU_IDLER_SENSOR_PIN); -#endif + if (mmu_idler_sensor_detected) { + idler_state = !PIN_GET(MMU_IDLER_SENSOR_PIN); + } lcd_puts_at_P(0, 0, _i("Sensors state")); lcd_puts_at_P(1, 1, _i("PINDA:")); lcd_set_cursor(LCD_WIDTH - 4, 1); diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 1e79a89d9..eaa9fc24f 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -614,7 +614,7 @@ #define MMU_REQUIRED_FW_BUILDNR 83 #define MMU_HWRESET //#define MMU_DEBUG //print communication between MMU2 and printer on serial -#define MMU_IDLER_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) + #define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning #endif //__CONFIGURATION_PRUSA_H From d292e877df4f36f104a140105b7047ae9f4a7013 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Dec 2018 18:51:13 +0100 Subject: [PATCH 22/31] load to nozzle shortened, sensor menu moved to support --- Firmware/mmu.cpp | 9 ++++++++- Firmware/ultralcd.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index f1cc840b6..82468241d 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -608,7 +608,14 @@ void mmu_load_to_nozzle() bool saved_e_relative_mode = axis_relative_modes[E_AXIS]; if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true; - current_position[E_AXIS] += 7.2f; + if (mmu_idler_sensor_detected) + { + current_position[E_AXIS] += 3f; + } + else + { + current_position[E_AXIS] + 7.2f; + } float feedrate = 562; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder); st_synchronize(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index cff7a1f17..093ddb746 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -139,6 +139,7 @@ static void lcd_menu_xyz_offset(); static void lcd_menu_fails_stats_mmu(); static void lcd_menu_fails_stats_mmu_print(); static void lcd_menu_fails_stats_mmu_total(); +static void lcd_menu_show_sensors_state(); #if defined(TMC2130) || defined(FILAMENT_SENSOR) static void lcd_menu_fails_stats(); @@ -2235,16 +2236,17 @@ static void lcd_support_menu() #ifndef MK1BP MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_SUBMENU_P(_i("XYZ cal. details"), lcd_menu_xyz_y_min);////MSG_XYZ_DETAILS c=19 r=1 - MENU_ITEM_SUBMENU_P(_i("Extruder info"), lcd_menu_extruder_info);////MSG_INFO_EXTRUDER c=15 r=1 + MENU_ITEM_SUBMENU_P(_i("Extruder info"), lcd_menu_extruder_info);////MSG_INFO_EXTRUDER c=18 r=1 + MENU_ITEM_SUBMENU_P(_i("Show sensors"), lcd_menu_show_sensors_state);////MSG_INFO_SENSORS c=18 r=1 #ifdef TMC2130 - MENU_ITEM_SUBMENU_P(_i("Belt status"), lcd_menu_belt_status);////MSG_MENU_BELT_STATUS c=15 r=1 + MENU_ITEM_SUBMENU_P(_i("Belt status"), lcd_menu_belt_status);////MSG_MENU_BELT_STATUS c=18 r=1 #endif //TMC2130 - MENU_ITEM_SUBMENU_P(_i("Temperatures"), lcd_menu_temperatures);////MSG_MENU_TEMPERATURES c=15 r=1 + MENU_ITEM_SUBMENU_P(_i("Temperatures"), lcd_menu_temperatures);////MSG_MENU_TEMPERATURES c=18 r=1 #if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) - MENU_ITEM_SUBMENU_P(_i("Voltages"), lcd_menu_voltages);////MSG_MENU_VOLTAGES c=15 r=1 + MENU_ITEM_SUBMENU_P(_i("Voltages"), lcd_menu_voltages);////MSG_MENU_VOLTAGES c=18 r=1 #endif //defined VOLT_BED_PIN || defined VOLT_PWR_PIN #ifdef DEBUG_BUILD @@ -3656,7 +3658,7 @@ static void lcd_show_sensors_state() if (mmu_idler_sensor_detected) { idler_state = !PIN_GET(MMU_IDLER_SENSOR_PIN); } - lcd_puts_at_P(0, 0, _i("Sensors state")); + lcd_puts_at_P(0, 0, _i("Sensor state")); lcd_puts_at_P(1, 1, _i("PINDA:")); lcd_set_cursor(LCD_WIDTH - 4, 1); lcd_print_state(pinda_state); @@ -5036,9 +5038,7 @@ static void lcd_calibration_menu() MENU_ITEM_SUBMENU_P(_i("Bed level correct"), lcd_adjust_bed);////MSG_BED_CORRECTION_MENU c=0 r=0 MENU_ITEM_SUBMENU_P(_i("PID calibration"), pid_extruder);////MSG_PID_EXTRUDER c=17 r=1 -#ifdef TMC2130 - MENU_ITEM_SUBMENU_P(_i("Show sensors"), lcd_menu_show_sensors_state); -#else +#ifndef TMC2130 MENU_ITEM_SUBMENU_P(_i("Show end stops"), menu_show_end_stops);////MSG_SHOW_END_STOPS c=17 r=1 #endif #ifndef MK1BP From 5462d451e16debfc47b7af4be698b57f1f52a937 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Dec 2018 20:56:45 +0100 Subject: [PATCH 23/31] show power failures in fail stats menu, shorter load to nozzle if idler sensor detected --- Firmware/mmu.cpp | 23 +++++++++++++++++++++-- Firmware/mmu.h | 4 +++- Firmware/ultralcd.cpp | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 82468241d..1c41284ca 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -57,6 +57,8 @@ int16_t mmu_buildnr = -1; uint32_t mmu_last_request = 0; uint32_t mmu_last_response = 0; +uint16_t mmu_power_failures = 0; + //clear rx buffer void mmu_clr_rx_buf(void) @@ -283,6 +285,14 @@ void mmu_loop(void) mmu_puts_P(PSTR("R0\n")); //send recover after eject mmu_state = 3; // wait for response } + else if (mmu_cmd == MMU_CMD_S3) + { +#ifdef MMU_DEBUG + printf_P(PSTR("MMU <= 'S3'\n")); +#endif //MMU_DEBUG + mmu_puts_P(PSTR("S3\n")); //send power failures request + mmu_state = 4; // power failures response + } mmu_cmd = 0; } else if ((mmu_last_response + 300) < millis()) //request every 300ms @@ -348,6 +358,15 @@ void mmu_loop(void) mmu_state = 1; } return; + case 4: + if (mmu_rx_ok() > 0) + { + fscanf_P(uart2io, PSTR("%d"), &mmu_power_failures); //scan finda from buffer + } + else if ((mmu_last_request + MMU_CMD_TIMEOUT) < millis()) + { //resend request after timeout (5 min) + mmu_state = 1; + } } } @@ -610,11 +629,11 @@ void mmu_load_to_nozzle() if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true; if (mmu_idler_sensor_detected) { - current_position[E_AXIS] += 3f; + current_position[E_AXIS] += 3.0f; } else { - current_position[E_AXIS] + 7.2f; + current_position[E_AXIS] += 7.2f; } float feedrate = 562; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder); diff --git a/Firmware/mmu.h b/Firmware/mmu.h index c3416cbc6..a4b3d4587 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -16,6 +16,8 @@ extern bool mmu_idler_sensor_detected; extern int16_t mmu_version; extern int16_t mmu_buildnr; +extern uint16_t mmu_power_failures; + #define MMU_FILAMENT_UNKNOWN 255 #define MMU_NO_MOVE 0 @@ -45,7 +47,7 @@ extern int16_t mmu_buildnr; #define MMU_CMD_E3 0x53 #define MMU_CMD_E4 0x54 #define MMU_CMD_R0 0x60 - +#define MMU_CMD_S3 0x73 extern int mmu_puts_P(const char* str); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 093ddb746..6501ca244 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1960,11 +1960,12 @@ static void lcd_menu_fails_stats_mmu_total() // MMU load fails 000 // ////////////////////// + mmu_command(MMU_CMD_S3); lcd_timeoutToStatus.stop(); //infinite timeout uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL_TOT); uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL_TOT); // lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY); - lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Total failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails); + lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S %-3d"), _i("Total failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails, _i("MMU power fails"), mmu_power_failures); menu_back_if_clicked_fb(); } From 688d4a8a823778bba8528628b2f79b6a6dbc14c8 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Dec 2018 21:05:54 +0100 Subject: [PATCH 24/31] missing defines in variant files --- Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h | 2 ++ Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h | 2 ++ Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h | 2 ++ Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h | 2 ++ 4 files changed, 8 insertions(+) diff --git a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h index f237e79a6..7bceb096f 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h @@ -432,4 +432,6 @@ THERMISTORS SETTINGS //#define SUPPORT_VERBOSITY #endif +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning + #endif //__CONFIGURATION_PRUSA_H diff --git a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h index e09178bbc..14fbd865b 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h @@ -432,4 +432,6 @@ THERMISTORS SETTINGS //#define SUPPORT_VERBOSITY #endif +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning + #endif //__CONFIGURATION_PRUSA_H diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index f3a5285dd..0472a1082 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -487,4 +487,6 @@ #define MMU_REQUIRED_FW_BUILDNR 132 //#define MMU_DEBUG //print communication between MMU2 and printer on serial +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning + #endif //__CONFIGURATION_PRUSA_H diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index 2aff81e0c..615d34826 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -488,4 +488,6 @@ #define MMU_REQUIRED_FW_BUILDNR 132 //#define MMU_DEBUG //print communication between MMU2 and printer on serial +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning + #endif //__CONFIGURATION_PRUSA_H From e36e58f385932bd46a10a29154b26c3b7532a0bf Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Dec 2018 21:28:57 +0100 Subject: [PATCH 25/31] show sensor on/off temporarily changed to unlocalized strings --- Firmware/ultralcd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0a59e006f..937ccd5a1 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3633,10 +3633,10 @@ static void lcd_print_state(uint8_t state) { switch (state) { case STATE_ON: - lcd_puts_P(_T(MSG_ON)); + lcd_puts_P(_i("On ")); break; case STATE_OFF: - lcd_puts_P(_T(MSG_OFF)); + lcd_puts_P(_i("Off")); break; default: lcd_puts_P(_i("N/A")); From 6ba86acebc036a2df006a55405d037057c0a7a63 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Dec 2018 22:33:01 +0100 Subject: [PATCH 26/31] send A (abort) command to mmu only when loading phase of T-code --- Firmware/mmu.cpp | 6 ++++-- Firmware/mmu.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index af8f6676e..5a3f6edb2 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -41,7 +41,7 @@ uint8_t mmu_cmd = 0; //idler ir sensor uint8_t mmu_idl_sens = 0; bool mmu_idler_sensor_detected = false; - +bool mmu_loading_flag = false; uint8_t mmu_extruder = MMU_FILAMENT_UNKNOWN; @@ -334,7 +334,7 @@ void mmu_loop(void) if (mmu_idler_sensor_detected) { if (mmu_idl_sens) { - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0 && mmu_loading_flag) { #ifdef MMU_DEBUG printf_P(PSTR("MMU <= 'A'\n")); @@ -424,6 +424,7 @@ void mmu_load_step() { } bool mmu_get_response(uint8_t move) { + mmu_loading_flag = false; if (!mmu_idler_sensor_detected) move = MMU_NO_MOVE; printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); @@ -443,6 +444,7 @@ bool mmu_get_response(uint8_t move) switch (move) { case MMU_LOAD_MOVE: + mmu_loading_flag = true; mmu_load_step(); break; case MMU_UNLOAD_MOVE: diff --git a/Firmware/mmu.h b/Firmware/mmu.h index a4b3d4587..30f35599f 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -12,6 +12,7 @@ extern uint8_t tmp_extruder; extern int8_t mmu_finda; extern bool mmu_idler_sensor_detected; +extern bool mmu_loading_flag; extern int16_t mmu_version; extern int16_t mmu_buildnr; From 88441f7f2f930a47e61f95534d0b4c115945cb08 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Dec 2018 23:07:39 +0100 Subject: [PATCH 27/31] scan power failures fix --- Firmware/mmu.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 5a3f6edb2..532a3128e 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -373,6 +373,12 @@ void mmu_loop(void) if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%d"), &mmu_power_failures); //scan finda from buffer +#ifdef MMU_DEBUG + printf_P(PSTR("MMU => 'ok'\n")); +#endif //MMU_DEBUG + mmu_last_cmd = 0; + mmu_ready = true; + mmu_state = 1; } else if ((mmu_last_request + MMU_CMD_TIMEOUT) < millis()) { //resend request after timeout (5 min) From 3ab1daf722329c2c73de92a8ccc44067d93691cb Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Dec 2018 23:17:32 +0100 Subject: [PATCH 28/31] MMU_DEBUG temporarily enabled --- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index eaa9fc24f..31d8277ac 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -613,7 +613,7 @@ #define MMU_REQUIRED_FW_BUILDNR 83 #define MMU_HWRESET -//#define MMU_DEBUG //print communication between MMU2 and printer on serial +#define MMU_DEBUG //print communication between MMU2 and printer on serial #define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning From b7b7e9387f2e6d21b3ffbfa3b0586633c7702117 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 4 Jan 2019 21:07:52 +0100 Subject: [PATCH 29/31] do resend attempts before pausing print (mmu needs attention state) so the print would not be paused if T-code is not received correctly by mmu; prevent infinite loading --- Firmware/mmu.cpp | 59 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 532a3128e..4832c16ee 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -23,8 +23,9 @@ #define MMU_TODELAY 100 #define MMU_TIMEOUT 10 -#define MMU_CMD_TIMEOUT 300000ul //5min timeout for mmu commands (except P0) +#define MMU_CMD_TIMEOUT 45000ul //5min timeout for mmu commands (except P0) #define MMU_P0_TIMEOUT 3000ul //timeout for P0 command: 3seconds +#define MMU_MAX_RESEND_ATTEMPTS 2 #ifdef MMU_HWRESET #define MMU_RST_PIN 76 @@ -139,6 +140,7 @@ bool check_for_idler_sensor() //mmu main loop - state machine processing void mmu_loop(void) { + static uint8_t mmu_attempt_nr = 0; int filament = 0; // printf_P(PSTR("MMU loop, state=%d\n"), mmu_state); switch (mmu_state) @@ -352,6 +354,7 @@ void mmu_loop(void) #ifdef MMU_DEBUG printf_P(PSTR("MMU => 'ok'\n")); #endif //MMU_DEBUG + mmu_attempt_nr = 0; mmu_last_cmd = 0; mmu_ready = true; mmu_state = 1; @@ -360,11 +363,17 @@ void mmu_loop(void) { //resend request after timeout (5 min) if (mmu_last_cmd) { + if (mmu_attempt_nr++ < MMU_MAX_RESEND_ATTEMPTS) { #ifdef MMU_DEBUG - printf_P(PSTR("MMU retry\n")); + printf_P(PSTR("MMU retry attempt nr. %d\n"), mmu_attempt_nr - 1); #endif //MMU_DEBUG - mmu_cmd = mmu_last_cmd; -// mmu_last_cmd = 0; //resend just once + mmu_cmd = mmu_last_cmd; + } + else { + mmu_cmd = 0; + mmu_last_cmd = 0; //check + mmu_attempt_nr = 0; + } } mmu_state = 1; } @@ -372,7 +381,7 @@ void mmu_loop(void) case 4: if (mmu_rx_ok() > 0) { - fscanf_P(uart2io, PSTR("%d"), &mmu_power_failures); //scan finda from buffer + fscanf_P(uart2io, PSTR("%d"), &mmu_power_failures); //scan power failures #ifdef MMU_DEBUG printf_P(PSTR("MMU => 'ok'\n")); #endif //MMU_DEBUG @@ -424,10 +433,11 @@ void mmu_command(uint8_t cmd) } void mmu_load_step() { - current_position[E_AXIS] = current_position[E_AXIS] + MMU_LOAD_FEEDRATE * 0.1; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); - st_synchronize(); + current_position[E_AXIS] = current_position[E_AXIS] + MMU_LOAD_FEEDRATE * 0.1; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); } + bool mmu_get_response(uint8_t move) { mmu_loading_flag = false; @@ -445,13 +455,23 @@ bool mmu_get_response(uint8_t move) { // mmu_loop(); - if (mmu_state != 3) + if ((mmu_state != 3) && (mmu_last_cmd == 0)) break; + //Do load steps only if temperature is higher then min. temp for safe extrusion. + //Otherwise "cold extrusion prevented" would be send to serial line periodically + if (degHotend(active_extruder) < EXTRUDE_MINTEMP) { + disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary + delay_keep_alive(100); + continue; + } + switch (move) { case MMU_LOAD_MOVE: mmu_loading_flag = true; mmu_load_step(); + //don't rely on "ok" signal from mmu unit; if filament detected by idler sensor during loading stop loading movements to prevent infinite loading + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) move = MMU_NO_MOVE; break; case MMU_UNLOAD_MOVE: if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading @@ -467,7 +487,6 @@ bool mmu_get_response(uint8_t move) disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary move = MMU_NO_MOVE; } - break; case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first @@ -491,6 +510,7 @@ bool mmu_get_response(uint8_t move) break; } } + printf_P(PSTR("mmu_get_response() returning: %d\n"), mmu_ready); bool ret = mmu_ready; mmu_ready = false; // printf_P(PSTR("mmu_get_response - end %d\n"), ret?1:0); @@ -527,6 +547,7 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) float x_position_bckp = current_position[X_AXIS]; float y_position_bckp = current_position[Y_AXIS]; uint8_t screen = 0; //used for showing multiscreen messages + while(!response) { response = mmu_get_response(move); //wait for "ok" from mmu @@ -563,6 +584,7 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) //set nozzle target temperature to 0 setAllTargetHotends(0); } + disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary } //first three lines are used for printing multiscreen message; last line contains measured and target nozzle temperature @@ -577,19 +599,21 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) } lcd_set_degree(); - lcd_set_cursor(0, 4); //line 4 - //Print the hotend temperature (9 chars total) and fill rest of the line with space - int chars = lcd_printf_P(_N("%c%3d/%d%c"), LCD_STR_THERMOMETER[0],(int)(degHotend(active_extruder) + 0.5), (int)(degTargetHotend(active_extruder) + 0.5), LCD_STR_DEGREE[0]); - lcd_space(9 - chars); //5 seconds delay - for (uint8_t i = 0; i < 50; i++) { + for (uint8_t i = 0; i < 5; i++) { if (lcd_clicked()) { setTargetHotend(hotend_temp_bckp, active_extruder); + /// mmu_cmd = mmu_last_cmd; break; - } - delay_keep_alive(100); + } + + //Print the hotend temperature (9 chars total) and fill rest of the line with space + lcd_set_cursor(0, 4); //line 4 + int chars = lcd_printf_P(_N("%c%3d/%d%c"), LCD_STR_THERMOMETER[0],(int)(degHotend(active_extruder) + 0.5), (int)(degTargetHotend(active_extruder) + 0.5), LCD_STR_DEGREE[0]); + lcd_space(9 - chars); + delay_keep_alive(1000); } } else if (mmu_print_saved) { @@ -1332,6 +1356,7 @@ void mmu_continue_loading() //set nozzle target temperature to 0 setAllTargetHotends(0); lcd_show_fullscreen_message_and_wait_P(_i("MMU load failed, fix the issue and press the knob.")); + mmu_fil_loaded = false; //so we can retry same T-code again restore_print_from_ram_and_continue(0); } From 02262ff7ca3ada6523ce934a797a034e165178f5 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 4 Jan 2019 21:37:19 +0100 Subject: [PATCH 30/31] mmu load fail: possibility to unload/eject filament from menu --- Firmware/mmu.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 4832c16ee..709da16ce 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1355,10 +1355,8 @@ void mmu_continue_loading() st_synchronize(); //set nozzle target temperature to 0 setAllTargetHotends(0); - lcd_show_fullscreen_message_and_wait_P(_i("MMU load failed, fix the issue and press the knob.")); - + lcd_setstatuspgm(_i("MMU load failed "));////MSG_RECOVERING_PRINT c=20 r=1 mmu_fil_loaded = false; //so we can retry same T-code again - restore_print_from_ram_and_continue(0); } } else { //mmu_idler_sensor_detected == false From 7946cd725084a5db683bd14fab67673380d45439 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 4 Jan 2019 22:23:11 +0100 Subject: [PATCH 31/31] eeprom write nr. limitation --- Firmware/mmu.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 709da16ce..6433eafb5 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -553,8 +553,12 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) response = mmu_get_response(move); //wait for "ok" from mmu if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater - eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) + 1); - eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) + 1); + + uint8_t mmu_fail = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL); + uint16_t mmu_fail_tot = eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT); + if(mmu_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, mmu_fail + 1); + if(mmu_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, mmu_fail_tot + 1); + if (lcd_update_enabled) { lcd_update_was_enabled = true; lcd_update_enable(false); @@ -1336,8 +1340,10 @@ void mmu_continue_loading() manage_response(true, true, MMU_LOAD_MOVE); } if (PIN_GET(MMU_IDLER_SENSOR_PIN) != 0) { - eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) + 1); - eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) + 1); + uint8_t mmu_load_fail = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL); + uint16_t mmu_load_fail_tot = eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT); + if(mmu_load_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, mmu_load_fail + 1); + if(mmu_load_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, mmu_load_fail_tot + 1); char cmd[3]; //pause print, show error message and then repeat last T-code stop_and_save_print_to_ram(0, 0);