From 39bd5c3a1d93b93657dd48a3526f44ac430e8960 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Thu, 25 Jan 2018 05:13:21 +0100 Subject: [PATCH 1/6] Extruder stealthChop and constant-off-time mode. Extruder different chopper frequency in spreadcycle. Dcodes (fix) --- Firmware/Configuration_prusa.h | 22 ++++++++++++++----- Firmware/Dcodes.cpp | 3 ++- Firmware/tmc2130.cpp | 39 ++++++++++++++++++++++++++++------ 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index cd5ddcbc..0934eab5 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -104,7 +104,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define MINTEMP_MINAMBIENT 25 #define MINTEMP_MINAMBIENT_RAW 978 - +//#define DEBUG_BUILD #ifdef DEBUG_BUILD //#define _NO_ASM #define DEBUG_DCODES //D codes @@ -119,7 +119,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o //#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored //#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored //#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored -//#define DEBUG_DISABLE_STARTMSGS //no startup messages +#define DEBUG_DISABLE_STARTMSGS //no startup messages //#define DEBUG_DISABLE_MINTEMP //mintemp error ignored //#define DEBUG_DISABLE_SWLIMITS //sw limits ignored //#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line @@ -159,16 +159,28 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define TMC2130_PWM_AUTO_Y 1 // PWMCONF #define TMC2130_PWM_FREQ_Y 2 // PWMCONF -/* //not used +#define TMC2130_PWM_GRAD_E 2 // PWMCONF +#define TMC2130_PWM_AMPL_E 235 // PWMCONF +#define TMC2130_PWM_AUTO_E 1 // PWMCONF +#define TMC2130_PWM_FREQ_E 2 // PWMCONF + #define TMC2130_PWM_GRAD_Z 4 // PWMCONF #define TMC2130_PWM_AMPL_Z 200 // PWMCONF #define TMC2130_PWM_AUTO_Z 1 // PWMCONF #define TMC2130_PWM_FREQ_Z 2 // PWMCONF + #define TMC2130_PWM_GRAD_E 4 // PWMCONF -#define TMC2130_PWM_AMPL_E 200 // PWMCONF +#define TMC2130_PWM_AMPL_E 240 // PWMCONF #define TMC2130_PWM_AUTO_E 1 // PWMCONF #define TMC2130_PWM_FREQ_E 2 // PWMCONF -*/ + +#define TMC2130_TOFF_XYZ 3 // CHOPCONF // fchop = 27.778kHz +#define TMC2130_TOFF_E 3 // CHOPCONF // fchop = 27.778kHz +//#define TMC2130_TOFF_E 4 // CHOPCONF // fchop = 21.429kHz +//#define TMC2130_TOFF_E 5 // CHOPCONF // fchop = 17.442kHz + +//#define TMC2130_STEALTH_E // Extruder stealthChop mode +//#define TMC2130_CNSTOFF_E // Extruder constant-off-time mode (similar to MK2) //#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410) #define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410) diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index 7937cc01..5c2b1750 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -491,7 +491,8 @@ void dcode_9125() LOG("D9125 - PAT9125\n"); if ((strchr_pointer[1+4] == '?') || (strchr_pointer[1+4] == 0)) { - printf("res_x=%d res_y=%d x=%d y=%d b=%d s=%d\n", pat9125_xres, pat9125_yres, pat9125_x, pat9125_y, pat9125_b, pat9125_s); +// printf("res_x=%d res_y=%d x=%d y=%d b=%d s=%d\n", pat9125_xres, pat9125_yres, pat9125_x, pat9125_y, pat9125_b, pat9125_s); + printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s); return; } if (strchr_pointer[1+4] == '!') diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 01713208..13e17414 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -34,13 +34,13 @@ uint8_t tmc2130_current_r_home[4] = {10, 10, 20, 10}; //pwm_ampl -uint8_t tmc2130_pwm_ampl[2] = {TMC2130_PWM_AMPL_X, TMC2130_PWM_AMPL_Y}; +uint8_t tmc2130_pwm_ampl[4] = {TMC2130_PWM_AMPL_X, TMC2130_PWM_AMPL_Y, TMC2130_PWM_AMPL_Z, TMC2130_PWM_AMPL_E}; //pwm_grad -uint8_t tmc2130_pwm_grad[2] = {TMC2130_PWM_GRAD_X, TMC2130_PWM_GRAD_Y}; +uint8_t tmc2130_pwm_grad[4] = {TMC2130_PWM_GRAD_X, TMC2130_PWM_GRAD_Y, TMC2130_PWM_GRAD_Z, TMC2130_PWM_GRAD_E}; //pwm_auto -uint8_t tmc2130_pwm_auto[2] = {TMC2130_PWM_AUTO_X, TMC2130_PWM_AUTO_Y}; +uint8_t tmc2130_pwm_auto[4] = {TMC2130_PWM_AUTO_X, TMC2130_PWM_AUTO_Y, TMC2130_PWM_AUTO_Z, TMC2130_PWM_AUTO_E}; //pwm_freq -uint8_t tmc2130_pwm_freq[2] = {TMC2130_PWM_FREQ_X, TMC2130_PWM_FREQ_Y}; +uint8_t tmc2130_pwm_freq[4] = {TMC2130_PWM_FREQ_X, TMC2130_PWM_FREQ_Y, TMC2130_PWM_FREQ_Z, TMC2130_PWM_FREQ_E}; uint8_t tmc2130_mres[4] = {0, 0, 0, 0}; //will be filed at begin of init @@ -198,7 +198,15 @@ void tmc2130_init() // tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[axis] & 0x1f) << 8) | (tmc2130_current_h[axis] & 0x1f)); tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_TPOWERDOWN, 0x00000000); +#ifndef TMC2130_STEALTH_E tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS); +#else //TMC2130_STEALTH_E + tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr[axis]) << 16)); + tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_TCOOLTHRS, 0); + tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_GCONF, TMC2130_GCONF_SILENT); + tmc2130_wr_PWMCONF(tmc2130_cs[axis], tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0); + tmc2130_wr_TPWMTHRS(tmc2130_cs[axis], TMC2130_TPWMTHRS); +#endif //TMC2130_STEALTH_E } tmc2130_sg_err[0] = 0; @@ -414,14 +422,33 @@ void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_ { uint8_t cs = tmc2130_cs[axis]; uint8_t intpol = 1; + uint8_t toff = TMC2130_TOFF_XYZ; // toff = 3 (fchop = 27.778kHz) + uint8_t hstrt = 5; //initial 4, modified to 5 + uint8_t hend = 1; + uint8_t fd3 = 0; + uint8_t rndtf = 0; //random off time + uint8_t chm = 0; //spreadCycle + uint8_t tbl = 2; //blanking time + if (axis == E_AXIS) + { +#ifdef TMC2130_CNSTOFF_E + // fd = 0 (slow decay only) + hstrt = 0; //fd0..2 + fd3 = 0; //fd3 + hend = 0; //sine wave offset + chm = 1; // constant off time mod +#endif //TMC2130_CNSTOFF_E + toff = TMC2130_TOFF_E; // toff = 3-5 +// rndtf = 1; + } if (current_r <= 31) { - tmc2130_wr_CHOPCONF(cs, 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, intpol, 0, 0); + tmc2130_wr_CHOPCONF(cs, toff, hstrt, hend, fd3, 0, rndtf, chm, tbl, 1, 0, 0, 0, mres, intpol, 0, 0); tmc2130_wr(cs, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((current_r & 0x1f) << 8) | (current_h & 0x1f)); } else { - tmc2130_wr_CHOPCONF(cs, 3, 5, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, mres, intpol, 0, 0); + tmc2130_wr_CHOPCONF(cs, toff, hstrt, hend, fd3, 0, 0, 0, tbl, 0, 0, 0, 0, mres, intpol, 0, 0); tmc2130_wr(cs, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | (((current_r >> 1) & 0x1f) << 8) | ((current_h >> 1) & 0x1f)); } } From 210b97d16d8643e242ddf0c770eda05f3e96c482 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Tue, 30 Jan 2018 13:10:36 +0100 Subject: [PATCH 2/6] New fail stats (global, last print), crashdetection X and Y separated --- Firmware/Configuration.h | 37 ++++++++++++------- Firmware/Dcodes.cpp | 2 +- Firmware/Marlin_main.cpp | 53 +++++++++++++++++++-------- Firmware/tmc2130.cpp | 8 ++--- Firmware/tmc2130.h | 2 +- Firmware/ultralcd.cpp | 77 +++++++++++++++++++++++----------------- 6 files changed, 114 insertions(+), 65 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 7db9a539..7898130e 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -93,25 +93,28 @@ #define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 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_Z_MICROSTEPS (EEPROM_UVLO_MESH_BED_LEVELING - 2) #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 -#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 -#define EEPROM_FSENSOR (EEPROM_UVLO_MESH_BED_LEVELING-14) -// Crash detection counter -#define EEPROM_CRASH_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-15) -// Filament runout/error coutner -#define EEPROM_FERROR_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-16) -// Power loss errors -#define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17) +#define EEPROM_FSENSOR (EEPROM_CRASH_COUNT_Y - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-14) +// Crash detection counter X (last print) +#define EEPROM_CRASH_COUNT_X (EEPROM_FSENSOR - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15) +// Filament runout/error coutner (last print) +#define EEPROM_FERROR_COUNT (EEPROM_CRASH_COUNT_X - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-16) +// Power loss errors (last print) +#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_BELTSTATUS_X (EEPROM_WIZARD_ACTIVE - 2) //uint16 -#define EEPROM_BELTSTATUS_Y (EEPROM_BELTSTATUS_X - 2) //uint16 +#define EEPROM_BELTSTATUS_X (EEPROM_WIZARD_ACTIVE - 2) // uint16 +#define EEPROM_BELTSTATUS_Y (EEPROM_BELTSTATUS_X - 2) // uint16 #define EEPROM_DIR_DEPTH (EEPROM_BELTSTATUS_Y-1) #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) +// 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 #define EEPROM_TMC_AXIS_SIZE //axis configuration block size #define EEPROM_TMC_X (EEPROM_TMC + 0 * EEPROM_TMC_AXIS_SIZE) //X axis configuration blok diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index 5c2b1750..46dd7673 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -449,7 +449,7 @@ void dcode_10() void dcode_12() {//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"); - 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_POWER_COUNT, 0x00); } diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 7a0abb71..68ee96a2 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -604,7 +604,7 @@ void crashdet_disable() { // MYSERIAL.println("crashdet_disable"); tmc2130_sg_stop_on_crash = false; - tmc2130_sg_crash = false; + tmc2130_sg_crash = 0; eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00); CrashDetectMenu = 0; } @@ -633,7 +633,7 @@ void crashdet_stop_and_save_print2() sei(); } -void crashdet_detected() +void crashdet_detected(uint8_t mask) { // printf("CRASH_DETECTED"); /* while (!is_buffer_empty()) @@ -646,11 +646,17 @@ void crashdet_detected() lcd_update_enable(true); lcd_implementation_clear(); lcd_update(2); - - // Increment crash counter - uint8_t crash_count = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT); - crash_count++; - eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, crash_count); + + if (mask & X_AXIS_MASK) + { + eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_X, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) + 1); + 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 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_FILAMENTUSED, 0); - eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT, 0); + eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 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_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(); break; @@ -1093,8 +1105,8 @@ void setup() card.initsd(); if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0); - if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT) == 0xff) - eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT, 0); + if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff) + eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0); if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0); #ifdef SNMM @@ -1473,9 +1485,15 @@ void loop() tmc2130_check_overtemp(); if (tmc2130_sg_crash) { - tmc2130_sg_crash = false; + uint8_t crash = tmc2130_sg_crash; + tmc2130_sg_crash = 0; // 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 @@ -2276,7 +2294,12 @@ void process_commands() } 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")) crashdet_recover(); else if(code_seen("CRASH_CANCEL")) diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 13e17414..70871c5e 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -58,7 +58,7 @@ uint32_t tmc2130_sg_meassure_val = 0; bool tmc2130_sg_stop_on_crash = true; 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_cnt[4] = {0, 0, 0, 0}; bool tmc2130_sg_change = false; @@ -234,7 +234,7 @@ extern bool is_usb_printing; void tmc2130_st_isr(uint8_t last_step_mask) { 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(); // for (uint8_t axis = X_AXIS; axis <= E_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) { 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) { - tmc2130_sg_crash = true; + tmc2130_sg_crash = crash; tmc2130_sg_stop_on_crash = false; crashdet_stop_and_save_print(); } diff --git a/Firmware/tmc2130.h b/Firmware/tmc2130.h index 373e0240..3c64aff7 100644 --- a/Firmware/tmc2130.h +++ b/Firmware/tmc2130.h @@ -13,7 +13,7 @@ extern uint8_t tmc2130_current_r[4]; extern uint8_t tmc2130_sg_thr[4]; 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 uint16_t tmc2130_sg_meassure_cnt; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 1d2d5f58..a8c5bd64 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1529,45 +1529,58 @@ static void lcd_menu_extruder_info() } } -static void lcd_menu_fails_stats() +static void lcd_menu_fails_stats_total() { - - // Display screen info - - lcd.setCursor(0, 0); - lcd.print("Failure stats "); - - // Display power failures - uint8_t power_count = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); - lcd.setCursor(0, 1); - lcd.print(" Power failures: "); - lcd.setCursor(17, 1); - 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)); - +//01234567890123456789 +//Total failures +// Power failures 000 +// Filam. runouts 000 +// Crash X 000 Y 000 +////////////////////// + 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); + 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); if (lcd_clicked()) { 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 extern uint16_t SP_min; extern char* __malloc_heap_start; From daaac2fb8849a2cd127afdbf488eda8a3f10f2e6 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Tue, 30 Jan 2018 19:49:40 +0100 Subject: [PATCH 3/6] fail stats --- Firmware/Marlin_main.cpp | 19 ++++++++++--------- Firmware/fsensor.cpp | 5 ++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 68ee96a2..2e3dc82a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1103,12 +1103,14 @@ void setup() // Force SD card update. Otherwise the SD card update is done from loop() on card.checkautostart(false), // but this times out if a blocking dialog is shown in setup(). card.initsd(); - if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) - eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0); - if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff) - eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0); - if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) - eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0); + if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0); + if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0); + if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, 0); + if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0); + if (eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_POWER_COUNT, 0); + if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X, 0); + if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y, 0); + if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT, 0); #ifdef SNMM if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM int _z = BOWDEN_LENGTH; @@ -7562,9 +7564,8 @@ void uvlo_() disable_z(); // Increment power failure counter - uint8_t power_count = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); - power_count++; - eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, power_count); + eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) + 1); + eeprom_update_word((uint16_t*)EEPROM_POWER_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) + 1); SERIAL_ECHOLNPGM("UVLO - end"); MYSERIAL.println(millis() - time_start); diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 2b53b710..c69e5d16 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -266,9 +266,8 @@ void fsensor_update() else*/ { fsensor_stop_and_save_print(); - uint8_t ferror_count = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT); - ferror_count++; - eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, ferror_count); + eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1); + eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1); enquecommand_front_P((PSTR("M600"))); fsensor_M600 = true; fsensor_enabled = false; From 4c5618c371be9e3dbbb55e0331c8faf5b576dda3 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 31 Jan 2018 15:09:36 +0100 Subject: [PATCH 4/6] failstats - reset "last print" counters card - new member variable "paused" (bool) --- Firmware/Marlin_main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 2e3dc82a..f541743f 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -690,6 +690,13 @@ void crashdet_cancel() tmc2130_sg_stop_on_crash = true; } +void failstats_reset_print() +{ + eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 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_POWER_COUNT, 0); +} #ifdef MESH_BED_LEVELING @@ -3993,6 +4000,8 @@ void process_commands() card.openFile(strchr_pointer + 4,true); break; case 24: //M24 - Start SD print + if (!card.paused) + failstats_reset_print(); card.startFileprint(); starttime=millis(); break; From 1a01282e339e7fa56e3cc2e5273b34ac40e40cba Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 31 Jan 2018 15:20:27 +0100 Subject: [PATCH 5/6] cardreader - new member "paused" tmc2130 - decreased crash sensitivity for Y --- Firmware/cardreader.cpp | 4 ++++ Firmware/cardreader.h | 1 + Firmware/tmc2130.cpp | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 4732d0a1..021ab269 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -25,6 +25,7 @@ CardReader::CardReader() sdpos = 0; sdprinting = false; cardOK = false; + paused = false; saving = false; logging = false; autostart_atmillis=0; @@ -240,6 +241,7 @@ void CardReader::startFileprint() if(cardOK) { sdprinting = true; + paused = false; #ifdef SDCARD_SORT_ALPHA //flush_presort(); #endif @@ -251,6 +253,7 @@ void CardReader::pauseSDPrint() if(sdprinting) { sdprinting = false; + paused = true; } } @@ -333,6 +336,7 @@ void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/) SERIAL_ECHOLN(name); } sdprinting = false; + paused = false; SdFile myDir; diff --git a/Firmware/cardreader.h b/Firmware/cardreader.h index 1315ff18..f9d30a76 100644 --- a/Firmware/cardreader.h +++ b/Firmware/cardreader.h @@ -75,6 +75,7 @@ public: bool logging; bool sdprinting ; bool cardOK ; + bool paused ; char filename[13]; uint16_t creationTime, creationDate; uint32_t cluster, position; diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 70871c5e..7b248b12 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -247,8 +247,8 @@ void tmc2130_st_isr(uint8_t last_step_mask) { tmc2130_sg_cnt[axis] = tmc2130_sg_err[axis]; tmc2130_sg_change = true; - uint8_t sg_thr = 48; - if (axis == Y_AXIS) sg_thr = 64; + uint8_t sg_thr = 64; +// if (axis == Y_AXIS) sg_thr = 64; if (tmc2130_sg_err[axis] >= sg_thr) { tmc2130_sg_err[axis] = 0; From adc69eda18850ce042df87cad18c6ba2b75018dd Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 31 Jan 2018 17:03:33 +0100 Subject: [PATCH 6/6] PINDA temp. calibration warning messages. --- Firmware/Marlin_main.cpp | 3 +++ Firmware/language_all.cpp | 5 +++++ Firmware/language_all.h | 2 ++ Firmware/language_en.h | 1 + 4 files changed, 11 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f541743f..6294cf86 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3140,6 +3140,9 @@ void process_commands() #ifdef PINDA_THERMISTOR if (true) { + lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CAL_WARNING); + bool result = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_STEEL_SHEET_CHECK, false, false); + if(result) lcd_show_fullscreen_message_and_wait_P(MSG_REMOVE_STEEL_SHEET); if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) { // We don't know where we are! HOME! // Push the commands to the front of the message queue in the reverse order! diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index 35bdf936..b5512551 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -2157,6 +2157,11 @@ const char * const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_TEMP_CALIBRATION_ON_CZ }; +const char MSG_TEMP_CAL_WARNING_EN[] PROGMEM = "Stable ambient temperature 21-26C is needed a rigid stand is required."; +const char * const MSG_TEMP_CAL_WARNING_LANG_TABLE[1] PROGMEM = { + MSG_TEMP_CAL_WARNING_EN +}; + const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_EN[] PROGMEM = "SD card [normal]"; const char * const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[1] PROGMEM = { MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_EN diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 1ca91ad0..dd2414a1 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -708,6 +708,8 @@ extern const char* const MSG_TEMP_CALIBRATION_OFF_LANG_TABLE[LANG_NUM]; #define MSG_TEMP_CALIBRATION_OFF LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_OFF_LANG_TABLE) extern const char* const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM]; #define MSG_TEMP_CALIBRATION_ON LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_ON_LANG_TABLE) +extern const char* const MSG_TEMP_CAL_WARNING_LANG_TABLE[1]; +#define MSG_TEMP_CAL_WARNING LANG_TABLE_SELECT_EXPLICIT(MSG_TEMP_CAL_WARNING_LANG_TABLE, 0) extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[1]; #define MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF LANG_TABLE_SELECT_EXPLICIT(MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE, 0) extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_ON_LANG_TABLE[1]; diff --git a/Firmware/language_en.h b/Firmware/language_en.h index d7a3a367..d21f1ed3 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -361,6 +361,7 @@ #define(length=20, lines=4) MSG_REMOVE_STEEL_SHEET "Please remove steel sheet from heatbed." #define(length=20, lines=2) MSG_CALIBRATE_Z_AUTO "Calibrating Z" #define(length=20, lines=2) MSG_STEEL_SHEET_CHECK "Is steel sheet on heatbed?" +#define(length=20, lines=4) MSG_TEMP_CAL_WARNING "Stable ambient temperature 21-26C is needed a rigid stand is required." #define MSG_SELFTEST_AXIS "Axis" #define MSG_SELFTEST_AXIS_LENGTH "Axis length"