Crash detection stops and waits for user if it fails multiple times in short time frame

This commit is contained in:
PavelSindler 2018-06-08 16:08:07 +02:00
parent 42cfcb2601
commit 332a23bef5
5 changed files with 48 additions and 10 deletions

5
.gitignore vendored
View file

@ -4,3 +4,8 @@
Debug Debug
Firmware/Configuration_prusa.h Firmware/Configuration_prusa.h
Firmware/Doc Firmware/Doc
/Firmware/__vm
/Firmware/Firmware.sln
/Firmware/Firmware.vcxproj
/Firmware/Firmware.vcxproj.filters
/Firmware/.vs/Firmware/v14

View file

@ -322,6 +322,7 @@ unsigned long pause_time = 0;
unsigned long start_pause_print = millis(); unsigned long start_pause_print = millis();
unsigned long t_fan_rising_edge = millis(); unsigned long t_fan_rising_edge = millis();
static LongTimer safetyTimer; static LongTimer safetyTimer;
static LongTimer crashDetTimer;
//unsigned long load_filament_time; //unsigned long load_filament_time;
@ -678,6 +679,25 @@ void crashdet_detected(uint8_t mask)
cmdqueue_pop_front(); cmdqueue_pop_front();
}*/ }*/
st_synchronize(); st_synchronize();
static uint8_t crashDet_counter = 0;
bool automatic_recovery_after_crash = true;
bool yesno;
if (crashDet_counter++ == 0) {
crashDetTimer.start();
}
else if (crashDetTimer.expired(CRASHDET_TIMER * 1000ul)){
crashDetTimer.stop();
crashDet_counter = 0;
}
else if(crashDet_counter == CRASHDET_COUNTER_MAX){
automatic_recovery_after_crash = false;
crashDetTimer.stop();
crashDet_counter = 0;
}
else {
crashDetTimer.start();
}
lcd_update_enable(true); lcd_update_enable(true);
lcd_implementation_clear(); lcd_implementation_clear();
@ -694,17 +714,21 @@ void crashdet_detected(uint8_t mask)
eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) + 1); eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) + 1);
} }
#ifdef AUTOMATIC_RECOVERY_AFTER_CRASH
bool yesno = true;
#else
bool yesno = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_CRASH_DETECTED), false);
#endif
lcd_update_enable(true); lcd_update_enable(true);
lcd_update(2); lcd_update(2);
lcd_setstatuspgm(_T(MSG_CRASH_DETECTED)); lcd_setstatuspgm(_T(MSG_CRASH_DETECTED));
gcode_G28(true, true, false, false); //home X and Y
st_synchronize();
if(automatic_recovery_after_crash)
yesno = true;
else
yesno = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Crash detected. Resume print?"), false);
lcd_update_enable(true);
if (yesno) if (yesno)
{ {
enquecommand_P(PSTR("G28 X Y"));
enquecommand_P(PSTR("CRASH_RECOVER")); enquecommand_P(PSTR("CRASH_RECOVER"));
} }
else else
@ -721,10 +745,15 @@ void crashdet_recover()
void crashdet_cancel() void crashdet_cancel()
{ {
card.sdprinting = false;
card.closefile();
tmc2130_sg_stop_on_crash = true; tmc2130_sg_stop_on_crash = true;
if (saved_printing_type == PRINTING_TYPE_SD) {
lcd_print_stop();
}else if(saved_printing_type == PRINTING_TYPE_USB){
SERIAL_ECHOLNPGM("// action:cancel"); //for Octoprint: works the same as clicking "Abort" button in Octoprint GUI
SERIAL_PROTOCOLLNRPGM(_T(MSG_OK));
} }
}
#endif //TMC2130 #endif //TMC2130
void failstats_reset_print() void failstats_reset_print()

View file

@ -141,6 +141,7 @@
//#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line //#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line
//#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message. //#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message.
//#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. //#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display.
//#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
#endif /* DEBUG_BUILD */ #endif /* DEBUG_BUILD */

View file

@ -141,6 +141,7 @@
//#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line //#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line
//#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message. //#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message.
//#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. //#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display.
//#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
#endif /* DEBUG_BUILD */ #endif /* DEBUG_BUILD */

View file

@ -112,8 +112,9 @@
#define Z_AXIS_ALWAYS_ON 1 #define Z_AXIS_ALWAYS_ON 1
// Automatic recovery after crash is detected //Crash detection
#define AUTOMATIC_RECOVERY_AFTER_CRASH #define CRASHDET_TIMER 45 //seconds
#define CRASHDET_COUNTER_MAX 3
// New XYZ calibration // New XYZ calibration
#define NEW_XYZCAL #define NEW_XYZCAL
@ -177,6 +178,7 @@
#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line #define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line
#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message. #define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message.
#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. #define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display.
#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
#endif /* DEBUG_BUILD */ #endif /* DEBUG_BUILD */
//#define EXPERIMENTAL_FEATURES //#define EXPERIMENTAL_FEATURES