Crashdetection

This commit is contained in:
Robert Pelnar 2017-09-22 23:06:52 +02:00
parent 4805713b8d
commit d2ff47dac8
6 changed files with 77 additions and 23 deletions

View File

@ -142,8 +142,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define TMC2130_SG_HOMING 1 // stallguard homing #define TMC2130_SG_HOMING 1 // stallguard homing
//#define TMC2130_SG_HOMING_SW_XY 1 // stallguard "software" homing for XY axes //#define TMC2130_SG_HOMING_SW_XY 1 // stallguard "software" homing for XY axes
#define TMC2130_SG_HOMING_SW_Z 1 // stallguard "software" homing for Z axis #define TMC2130_SG_HOMING_SW_Z 1 // stallguard "software" homing for Z axis
#define TMC2130_SG_THRS_X 5 // stallguard sensitivity for X axis #define TMC2130_SG_THRS_X 6 // stallguard sensitivity for X axis
#define TMC2130_SG_THRS_Y 5 // stallguard sensitivity for Y axis #define TMC2130_SG_THRS_Y 6 // stallguard sensitivity for Y axis
#define TMC2130_SG_THRS_Z 3 // stallguard sensitivity for Z axis #define TMC2130_SG_THRS_Z 3 // stallguard sensitivity for Z axis
#define TMC2130_SG_DELTA 128 // stallguard delta [usteps] (minimum usteps before stallguard readed - SW homing) #define TMC2130_SG_DELTA 128 // stallguard delta [usteps] (minimum usteps before stallguard readed - SW homing)

View File

@ -569,6 +569,27 @@ void stop_and_save_print_to_ram(float z_move, float e_move);
void restore_print_from_ram_and_continue(float e_move); void restore_print_from_ram_and_continue(float e_move);
void crashdet_enable()
{
tmc2130_sg_stop_on_crash = true;
}
void crashdet_disable()
{
tmc2130_sg_stop_on_crash = false;
}
void crashdet_stop_and_save_print()
{
stop_and_save_print_to_ram(10, 0); //XY - no change, Z 10mm up, E - no change
}
void crashdet_restore_print_and_continue()
{
restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change
}
#ifdef PAT9125 #ifdef PAT9125
void fsensor_stop_and_save_print() void fsensor_stop_and_save_print()
@ -1206,6 +1227,12 @@ void loop()
#endif //PAT9125 #endif //PAT9125
#ifdef TMC2130 #ifdef TMC2130
tmc2130_check_overtemp(); tmc2130_check_overtemp();
if (tmc2130_sg_crash)
{
tmc2130_sg_crash = false;
crashdet_stop_and_save_print();
enquecommand_P((PSTR("D999")));
}
#endif //TMC2130 #endif //TMC2130
} }
@ -5659,6 +5686,45 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
MYSERIAL.print("selectedSerialPort = "); MYSERIAL.print("selectedSerialPort = ");
MYSERIAL.println(selectedSerialPort, DEC); MYSERIAL.println(selectedSerialPort, DEC);
break; break;
case 999:
{
MYSERIAL.println("D999 - crash");
/* while (!is_buffer_empty())
{
process_commands();
cmdqueue_pop_front();
}*/
st_synchronize();
lcd_update_enable(true);
lcd_implementation_clear();
lcd_update(2);
bool yesno = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_CRASH_DETECTED, false);
lcd_update_enable(true);
lcd_update(2);
lcd_setstatuspgm(WELCOME_MSG);
if (yesno)
{
enquecommand_P(PSTR("G28 X"));
enquecommand_P(PSTR("G28 Y"));
enquecommand_P(PSTR("D1000"));
}
else
{
enquecommand_P(PSTR("D1001"));
}
}
break;
case 1000:
crashdet_restore_print_and_continue();
tmc2130_sg_stop_on_crash = true;
break;
case 1001:
card.sdprinting = false;
card.closefile();
tmc2130_sg_stop_on_crash = true;
break;
/* case 4: /* case 4:
{ {
MYSERIAL.println("D4 - Test"); MYSERIAL.println("D4 - Test");
@ -6964,26 +7030,6 @@ void restore_print_from_eeprom() {
//extern uint32_t sdpos_atomic; //extern uint32_t sdpos_atomic;
void crashdet_enable()
{
tmc2130_sg_stop_on_crash = true;
}
void crashdet_disable()
{
tmc2130_sg_stop_on_crash = false;
}
void crashdet_stop_and_save_print()
{
stop_and_save_print_to_ram(10, 0); //XY - no change, Z 10mm up, E - no change
}
void crashdet_restore_print_and_continue()
{
restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change
}
bool saved_printing = false; bool saved_printing = false;
uint32_t saved_sdpos = 0; uint32_t saved_sdpos = 0;
float saved_pos[4] = {0, 0, 0, 0}; float saved_pos[4] = {0, 0, 0, 0};

View File

@ -1030,6 +1030,11 @@ const char * const MSG_RECOVER_PRINT_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_RECOVER_PRINT_EN MSG_RECOVER_PRINT_EN
}; };
const char MSG_CRASH_DETECTED_EN[] PROGMEM = "Crash detected. Continue printing?";
const char * const MSG_CRASH_DETECTED_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_CRASH_DETECTED_EN
};
const char MSG_RECTRACT_EN[] PROGMEM = "Rectract"; const char MSG_RECTRACT_EN[] PROGMEM = "Rectract";
const char * const MSG_RECTRACT_LANG_TABLE[LANG_NUM] PROGMEM = { const char * const MSG_RECTRACT_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_RECTRACT_EN MSG_RECTRACT_EN

View File

@ -433,6 +433,8 @@ extern const char* const MSG_RECOVERING_PRINT_LANG_TABLE[1];
#define MSG_RECOVERING_PRINT LANG_TABLE_SELECT_EXPLICIT(MSG_RECOVERING_PRINT_LANG_TABLE, 0) #define MSG_RECOVERING_PRINT LANG_TABLE_SELECT_EXPLICIT(MSG_RECOVERING_PRINT_LANG_TABLE, 0)
extern const char* const MSG_RECOVER_PRINT_LANG_TABLE[1]; extern const char* const MSG_RECOVER_PRINT_LANG_TABLE[1];
#define MSG_RECOVER_PRINT LANG_TABLE_SELECT_EXPLICIT(MSG_RECOVER_PRINT_LANG_TABLE, 0) #define MSG_RECOVER_PRINT LANG_TABLE_SELECT_EXPLICIT(MSG_RECOVER_PRINT_LANG_TABLE, 0)
extern const char* const MSG_CRASH_DETECTED_LANG_TABLE[1];
#define MSG_CRASH_DETECTED LANG_TABLE_SELECT_EXPLICIT(MSG_CRASH_DETECTED_LANG_TABLE, 0)
extern const char* const MSG_RECTRACT_LANG_TABLE[1]; extern const char* const MSG_RECTRACT_LANG_TABLE[1];
#define MSG_RECTRACT LANG_TABLE_SELECT_EXPLICIT(MSG_RECTRACT_LANG_TABLE, 0) #define MSG_RECTRACT LANG_TABLE_SELECT_EXPLICIT(MSG_RECTRACT_LANG_TABLE, 0)
extern const char* const MSG_REFRESH_LANG_TABLE[1]; extern const char* const MSG_REFRESH_LANG_TABLE[1];

View File

@ -306,6 +306,7 @@
#define(length=17, lines=1) MSG_EXTRUDER_4 "Extruder 4" #define(length=17, lines=1) MSG_EXTRUDER_4 "Extruder 4"
#define(length=20, lines=2) MSG_RECOVER_PRINT "Blackout occurred. Recover print?" #define(length=20, lines=2) MSG_RECOVER_PRINT "Blackout occurred. Recover print?"
#define(length=20, lines=1) MSG_RECOVERING_PRINT "Recovering print " #define(length=20, lines=1) MSG_RECOVERING_PRINT "Recovering print "
#define(length=20, lines=2) MSG_CRASH_DETECTED "Crash detected. Continue printing?"
#define(length=15, lines=1) MSG_INFO_EXTRUDER "Extruder info" #define(length=15, lines=1) MSG_INFO_EXTRUDER "Extruder info"

View File

@ -195,7 +195,7 @@ void tmc2130_st_isr(uint8_t last_step_mask)
if (tmc2130_sg_stop_on_crash && error) if (tmc2130_sg_stop_on_crash && error)
{ {
tmc2130_sg_crash = true; tmc2130_sg_crash = true;
crashdet_stop_and_save_print(); tmc2130_sg_stop_on_crash = false;
} }
} }