From 6c8d9c6fb4b03543e355efffb0a2c4f8360acb38 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 5 Feb 2019 18:25:11 +0100 Subject: [PATCH] Retry filament load on MMU load failure once. --- Firmware/mmu.cpp | 70 +++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 36dd5a360..833d1fde2 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1362,46 +1362,60 @@ void mmu_eject_filament(uint8_t filament, bool recover) } } +static void load_more() +{ + for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) + { + if (PIN_GET(IR_SENSOR_PIN) == 0) return; +#ifdef MMU_DEBUG + 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); + } +} + void mmu_continue_loading() { + if (ir_sensor_detected) + { + load_more(); - if (ir_sensor_detected) { - for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { - if (PIN_GET(IR_SENSOR_PIN) == 0) return; -#ifdef MMU_DEBUG - 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(IR_SENSOR_PIN) != 0) { 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); - //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(); + mmu_command(MMU_CMD_T0 + tmp_extruder); + manage_response(true, true, MMU_TCODE_MOVE); + load_more(); - //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(); + if (PIN_GET(IR_SENSOR_PIN) != 0) + { + //pause print, show error message and then repeat last T-code + stop_and_save_print_to_ram(0, 0); - mmu_command(MMU_CMD_U0); - manage_response(false, true, MMU_UNLOAD_MOVE); + //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(); - setAllTargetHotends(0); - 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 - isPrintPaused = true; + //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(); + + mmu_command(MMU_CMD_U0); + manage_response(false, true, MMU_UNLOAD_MOVE); + + setAllTargetHotends(0); + 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 + isPrintPaused = true; + } } } else { //mmu_ir_sensor_detected == false