New fail stats (global, last print), crashdetection X and Y separated

This commit is contained in:
Robert Pelnar 2018-01-30 13:10:36 +01:00
parent 39bd5c3a1d
commit 210b97d16d
6 changed files with 114 additions and 65 deletions

View File

@ -93,25 +93,28 @@
#define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1) #define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1)
#define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1) #define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1)
#define EEPROM_UVLO_MESH_BED_LEVELING (EEPROM_FAN_CHECK_ENABLED - 9*2) #define EEPROM_UVLO_MESH_BED_LEVELING (EEPROM_FAN_CHECK_ENABLED - 9*2)
#define EEPROM_UVLO_Z_MICROSTEPS (EEPROM_UVLO_MESH_BED_LEVELING - 2) #define EEPROM_UVLO_Z_MICROSTEPS (EEPROM_UVLO_MESH_BED_LEVELING - 2)
#define EEPROM_UVLO_E_ABS (EEPROM_UVLO_Z_MICROSTEPS - 1) #define EEPROM_UVLO_E_ABS (EEPROM_UVLO_Z_MICROSTEPS - 1)
#define EEPROM_UVLO_CURRENT_POSITION_E (EEPROM_UVLO_E_ABS - 4) //float for current position in E #define EEPROM_UVLO_CURRENT_POSITION_E (EEPROM_UVLO_E_ABS - 4) //float for current position in E
// Crash detection mode EEPROM setting // Crash detection mode EEPROM setting
#define EEPROM_CRASH_DET (EEPROM_UVLO_MESH_BED_LEVELING-12) #define EEPROM_CRASH_DET (EEPROM_UVLO_CURRENT_POSITION_E - 5) // float (orig EEPROM_UVLO_MESH_BED_LEVELING-12)
// Crash detection counter Y (last print)
#define EEPROM_CRASH_COUNT_Y (EEPROM_CRASH_DET - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15)
// Filament sensor on/off EEPROM setting // Filament sensor on/off EEPROM setting
#define EEPROM_FSENSOR (EEPROM_UVLO_MESH_BED_LEVELING-14) #define EEPROM_FSENSOR (EEPROM_CRASH_COUNT_Y - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-14)
// Crash detection counter // Crash detection counter X (last print)
#define EEPROM_CRASH_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-15) #define EEPROM_CRASH_COUNT_X (EEPROM_FSENSOR - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15)
// Filament runout/error coutner // Filament runout/error coutner (last print)
#define EEPROM_FERROR_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-16) #define EEPROM_FERROR_COUNT (EEPROM_CRASH_COUNT_X - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-16)
// Power loss errors // Power loss errors (last print)
#define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17) #define EEPROM_POWER_COUNT (EEPROM_FERROR_COUNT - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-17)
#define EEPROM_XYZ_CAL_SKEW (EEPROM_POWER_COUNT - 4) //float for skew backup #define EEPROM_XYZ_CAL_SKEW (EEPROM_POWER_COUNT - 4) // float for skew backup
#define EEPROM_WIZARD_ACTIVE (EEPROM_XYZ_CAL_SKEW - 1) #define EEPROM_WIZARD_ACTIVE (EEPROM_XYZ_CAL_SKEW - 1)
#define EEPROM_BELTSTATUS_X (EEPROM_WIZARD_ACTIVE - 2) //uint16 #define EEPROM_BELTSTATUS_X (EEPROM_WIZARD_ACTIVE - 2) // uint16
#define EEPROM_BELTSTATUS_Y (EEPROM_BELTSTATUS_X - 2) //uint16 #define EEPROM_BELTSTATUS_Y (EEPROM_BELTSTATUS_X - 2) // uint16
#define EEPROM_DIR_DEPTH (EEPROM_BELTSTATUS_Y-1) #define EEPROM_DIR_DEPTH (EEPROM_BELTSTATUS_Y-1)
#define EEPROM_DIRS (EEPROM_DIR_DEPTH-80) //8 chars for each dir name, max 10 levels #define EEPROM_DIRS (EEPROM_DIR_DEPTH-80) //8 chars for each dir name, max 10 levels
@ -120,6 +123,16 @@
#define EEPROM_FSENS_AUTOLOAD_ENABLED (EEPROM_SECOND_SERIAL_ACTIVE - 1) #define EEPROM_FSENS_AUTOLOAD_ENABLED (EEPROM_SECOND_SERIAL_ACTIVE - 1)
// Crash detection counter X (total)
#define EEPROM_CRASH_COUNT_X_TOT (EEPROM_FSENS_AUTOLOAD_ENABLED - 2) // uint16
// Crash detection counter Y (total)
#define EEPROM_CRASH_COUNT_Y_TOT (EEPROM_CRASH_COUNT_X_TOT - 2) // uint16
// Filament runout/error coutner (total)
#define EEPROM_FERROR_COUNT_TOT (EEPROM_CRASH_COUNT_Y_TOT - 2) // uint16
// Power loss errors (total)
#define EEPROM_POWER_COUNT_TOT (EEPROM_FERROR_COUNT_TOT - 2) // uint16
//TMC2130 configuration //TMC2130 configuration
#define EEPROM_TMC_AXIS_SIZE //axis configuration block size #define EEPROM_TMC_AXIS_SIZE //axis configuration block size
#define EEPROM_TMC_X (EEPROM_TMC + 0 * EEPROM_TMC_AXIS_SIZE) //X axis configuration blok #define EEPROM_TMC_X (EEPROM_TMC + 0 * EEPROM_TMC_AXIS_SIZE) //X axis configuration blok

View File

@ -449,7 +449,7 @@ void dcode_10()
void dcode_12() void dcode_12()
{//Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print ) {//Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print )
LOG("D12 - Reset failstat counters\n"); LOG("D12 - Reset failstat counters\n");
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, 0x00); eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0x00);
eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00); eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00);
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00); eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00);
} }

View File

@ -604,7 +604,7 @@ void crashdet_disable()
{ {
// MYSERIAL.println("crashdet_disable"); // MYSERIAL.println("crashdet_disable");
tmc2130_sg_stop_on_crash = false; tmc2130_sg_stop_on_crash = false;
tmc2130_sg_crash = false; tmc2130_sg_crash = 0;
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00); eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00);
CrashDetectMenu = 0; CrashDetectMenu = 0;
} }
@ -633,7 +633,7 @@ void crashdet_stop_and_save_print2()
sei(); sei();
} }
void crashdet_detected() void crashdet_detected(uint8_t mask)
{ {
// printf("CRASH_DETECTED"); // printf("CRASH_DETECTED");
/* while (!is_buffer_empty()) /* while (!is_buffer_empty())
@ -646,11 +646,17 @@ void crashdet_detected()
lcd_update_enable(true); lcd_update_enable(true);
lcd_implementation_clear(); lcd_implementation_clear();
lcd_update(2); lcd_update(2);
// Increment crash counter if (mask & X_AXIS_MASK)
uint8_t crash_count = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT); {
crash_count++; eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_X, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) + 1);
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, crash_count); eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) + 1);
}
if (mask & Y_AXIS_MASK)
{
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) + 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 #ifdef AUTOMATIC_RECOVERY_AFTER_CRASH
bool yesno = true; bool yesno = true;
@ -719,10 +725,16 @@ void factory_reset(char level, bool quiet)
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0);
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0);
eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0);
eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT, 0); 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_FERROR_COUNT, 0);
eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0);
eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0);
lcd_menu_statistics(); lcd_menu_statistics();
break; break;
@ -1093,8 +1105,8 @@ void setup()
card.initsd(); card.initsd();
if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff)
eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0); eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT) == 0xff) if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff)
eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT, 0); eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff)
eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0); eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0);
#ifdef SNMM #ifdef SNMM
@ -1473,9 +1485,15 @@ void loop()
tmc2130_check_overtemp(); tmc2130_check_overtemp();
if (tmc2130_sg_crash) if (tmc2130_sg_crash)
{ {
tmc2130_sg_crash = false; uint8_t crash = tmc2130_sg_crash;
tmc2130_sg_crash = 0;
// crashdet_stop_and_save_print(); // crashdet_stop_and_save_print();
enquecommand_P((PSTR("CRASH_DETECTED"))); switch (crash)
{
case 1: enquecommand_P((PSTR("CRASH_DETECTEDX"))); break;
case 2: enquecommand_P((PSTR("CRASH_DETECTEDY"))); break;
case 3: enquecommand_P((PSTR("CRASH_DETECTEDXY"))); break;
}
} }
#endif //TMC2130 #endif //TMC2130
@ -2276,7 +2294,12 @@ void process_commands()
} }
else if(code_seen("CRASH_DETECTED")) else if(code_seen("CRASH_DETECTED"))
crashdet_detected(); {
uint8_t mask = 0;
if (code_seen("X")) mask |= X_AXIS_MASK;
if (code_seen("Y")) mask |= Y_AXIS_MASK;
crashdet_detected(mask);
}
else if(code_seen("CRASH_RECOVER")) else if(code_seen("CRASH_RECOVER"))
crashdet_recover(); crashdet_recover();
else if(code_seen("CRASH_CANCEL")) else if(code_seen("CRASH_CANCEL"))

View File

@ -58,7 +58,7 @@ uint32_t tmc2130_sg_meassure_val = 0;
bool tmc2130_sg_stop_on_crash = true; bool tmc2130_sg_stop_on_crash = true;
uint8_t tmc2130_sg_diag_mask = 0x00; uint8_t tmc2130_sg_diag_mask = 0x00;
bool tmc2130_sg_crash = false; uint8_t tmc2130_sg_crash = 0;
uint16_t tmc2130_sg_err[4] = {0, 0, 0, 0}; uint16_t tmc2130_sg_err[4] = {0, 0, 0, 0};
uint16_t tmc2130_sg_cnt[4] = {0, 0, 0, 0}; uint16_t tmc2130_sg_cnt[4] = {0, 0, 0, 0};
bool tmc2130_sg_change = false; bool tmc2130_sg_change = false;
@ -234,7 +234,7 @@ extern bool is_usb_printing;
void tmc2130_st_isr(uint8_t last_step_mask) void tmc2130_st_isr(uint8_t last_step_mask)
{ {
if (tmc2130_mode == TMC2130_MODE_SILENT || tmc2130_sg_stop_on_crash == false) return; if (tmc2130_mode == TMC2130_MODE_SILENT || tmc2130_sg_stop_on_crash == false) return;
bool crash = false; uint8_t crash = 0;
uint8_t diag_mask = tmc2130_sample_diag(); uint8_t diag_mask = tmc2130_sample_diag();
// for (uint8_t axis = X_AXIS; axis <= E_AXIS; axis++) // for (uint8_t axis = X_AXIS; axis <= E_AXIS; axis++)
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++)
@ -252,7 +252,7 @@ void tmc2130_st_isr(uint8_t last_step_mask)
if (tmc2130_sg_err[axis] >= sg_thr) if (tmc2130_sg_err[axis] >= sg_thr)
{ {
tmc2130_sg_err[axis] = 0; tmc2130_sg_err[axis] = 0;
crash = true; crash |= mask;
} }
} }
} }
@ -267,7 +267,7 @@ void tmc2130_st_isr(uint8_t last_step_mask)
}*/ }*/
if (/*!is_usb_printing && */tmc2130_sg_stop_on_crash && crash) if (/*!is_usb_printing && */tmc2130_sg_stop_on_crash && crash)
{ {
tmc2130_sg_crash = true; tmc2130_sg_crash = crash;
tmc2130_sg_stop_on_crash = false; tmc2130_sg_stop_on_crash = false;
crashdet_stop_and_save_print(); crashdet_stop_and_save_print();
} }

View File

@ -13,7 +13,7 @@ extern uint8_t tmc2130_current_r[4];
extern uint8_t tmc2130_sg_thr[4]; extern uint8_t tmc2130_sg_thr[4];
extern bool tmc2130_sg_stop_on_crash; extern bool tmc2130_sg_stop_on_crash;
extern bool tmc2130_sg_crash; extern uint8_t tmc2130_sg_crash; //crash mask
extern uint8_t tmc2130_sg_meassure; extern uint8_t tmc2130_sg_meassure;
extern uint16_t tmc2130_sg_meassure_cnt; extern uint16_t tmc2130_sg_meassure_cnt;

View File

@ -1529,45 +1529,58 @@ static void lcd_menu_extruder_info()
} }
} }
static void lcd_menu_fails_stats() static void lcd_menu_fails_stats_total()
{ {
//01234567890123456789
// Display screen info //Total failures
// Power failures 000
lcd.setCursor(0, 0); // Filam. runouts 000
lcd.print("Failure stats "); // Crash X 000 Y 000
//////////////////////
// Display power failures uint16_t power = eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT);
uint8_t power_count = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); uint16_t filam = eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT);
lcd.setCursor(0, 1); uint16_t crashX = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT);
lcd.print(" Power failures: "); uint16_t crashY = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT);
lcd.setCursor(17, 1); fprintf_P(lcdout, 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.print(itostr3((int)power_count));
// Display Crash detected
uint8_t crash_count = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT);
lcd.setCursor(0, 2);
lcd.print(" Crash detected: ");
lcd.setCursor(17, 2);
lcd.print(itostr3((int)crash_count));
// Display filament failures
uint8_t ferror_count = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT);
lcd.setCursor(0, 3);
lcd.print(" Filament fails: ");
lcd.setCursor(17, 3);
lcd.print(itostr3((int)ferror_count));
if (lcd_clicked()) if (lcd_clicked())
{ {
lcd_quick_feedback(); lcd_quick_feedback();
lcd_return_to_status(); //lcd_return_to_status();
lcd_goto_menu(lcd_menu_fails_stats, 4);
} }
} }
static void lcd_menu_fails_stats_print()
{
//01234567890123456789
//Last print failures
// Power failures 000
// Filam. runouts 000
// Crash X 000 Y 000
//////////////////////
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);
fprintf_P(lcdout, 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);
if (lcd_clicked())
{
lcd_quick_feedback();
//lcd_return_to_status();
lcd_goto_menu(lcd_menu_fails_stats, 2);
}
}
static void lcd_menu_fails_stats()
{
START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(submenu, PSTR("Last print"), lcd_menu_fails_stats_print);
MENU_ITEM(submenu, PSTR("Total"), lcd_menu_fails_stats_total);
END_MENU();
}
#ifdef DEBUG_BUILD #ifdef DEBUG_BUILD
extern uint16_t SP_min; extern uint16_t SP_min;
extern char* __malloc_heap_start; extern char* __malloc_heap_start;