From 326c061d8c0018e8be5b8c434998d5ecdc887cb9 Mon Sep 17 00:00:00 2001 From: DRracer Date: Mon, 27 May 2019 18:27:24 +0200 Subject: [PATCH 1/5] testing pin 5 --- Firmware/pins_Einsy_1_0.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 Firmware/pins_Einsy_1_0.h diff --git a/Firmware/pins_Einsy_1_0.h b/Firmware/pins_Einsy_1_0.h old mode 100644 new mode 100755 index 33363388a..2e05d3263 --- a/Firmware/pins_Einsy_1_0.h +++ b/Firmware/pins_Einsy_1_0.h @@ -99,7 +99,8 @@ //#define KILL_PIN 32 -//#define LCD_BL_PIN 5 //backlight control pin +// LCD backlight pin may interfere with something, this is yet to be found out correctly +#define LCD_BL_PIN 5 //backlight control pin #define BEEPER 84 // Beeper on AUX-4 #define LCD_PINS_RS 82 #define LCD_PINS_ENABLE 61 // !!! changed from 18 (EINY03) From 675579177887beb40d2084278e68a90b01f5f690 Mon Sep 17 00:00:00 2001 From: DRracer Date: Fri, 31 May 2019 11:29:11 +0200 Subject: [PATCH 2/5] Fix repeated fan error checking --- Firmware/Marlin_main.cpp | 6 ++- Firmware/temperature.cpp | 82 ++++++++++++++++++++++++++++++---------- Firmware/temperature.h | 3 +- 3 files changed, 67 insertions(+), 24 deletions(-) mode change 100644 => 100755 Firmware/Marlin_main.cpp diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp old mode 100644 new mode 100755 index 557ca34ad..fd1d34ebb --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3391,8 +3391,10 @@ void process_commands() { #ifdef FANCHECK if (fan_check_error){ - fan_check_error = false; - lcd_pause_print(); + if( fan_check_error == EFCE_DETECTED ){ + fan_check_error = EFCE_REPORTED; + lcd_pause_print(); + } // otherwise it has already been reported, so just ignore further processing return; } #endif diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index b245b23ba..1b60a0230 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -95,7 +95,7 @@ float current_temperature_bed = 0.0; #endif #ifdef FANCHECK - volatile bool fan_check_error = false; + volatile uint8_t fan_check_error = EFCE_OK; #endif unsigned char soft_pwm_bed; @@ -489,6 +489,38 @@ void countFanSpeed() fan_edge_counter[1] = 0; } +//#define SIMULATE_FAN_ERRORS +#ifdef SIMULATE_FAN_ERRORS +struct FanSpeedErrorSimulator { + unsigned long lastMillis = 0; + bool state = false; // zatim mam 0 - klid, 1 reportuju chybu + //! @return pocet simulovanych chyb + inline uint8_t step(){ + unsigned long ms = _millis(); + switch(state){ + case false: + if( (ms - lastMillis) > 120000UL ){ // funkcni ventilator chci 2 minuty + state = true; + lastMillis = ms; + SERIAL_ECHOLNPGM("SIM Fan error"); + } + break; + case true: + if( (ms - lastMillis) > 20000UL ){ // vypadek ventilatoru chci uz 20s, + //abych stihl udelat pokusnej resume print, kdyz jeste jsou rozbity vetraky + state = false; + lastMillis = ms; + SERIAL_ECHOLNPGM("SIM Fan ok"); + } + break; + } + return state ? 20 : 0; + } +}; + +static FanSpeedErrorSimulator fanSpeedErrorSimulator; +#endif + void checkFanSpeed() { uint8_t max_print_fan_errors = 0; @@ -512,6 +544,16 @@ void checkFanSpeed() else fan_speed_errors[1] = 0; #endif +#ifdef SIMULATE_FAN_ERRORS + fan_speed_errors[0] = fanSpeedErrorSimulator.step(); +#endif + + // drop the fan_check_error flag when both fans are ok + if( fan_speed_errors[0] == 0 && fan_speed_errors[1] == 0 && fan_check_error == EFCE_REPORTED){ + // we may even send some info to the LCD from here + fan_check_error = EFCE_OK; + } + if ((fan_speed_errors[0] > max_extruder_fan_errors) && fans_check_enabled) { fan_speed_errors[0] = 0; fanSpeedError(0); //extruder fan @@ -522,6 +564,19 @@ void checkFanSpeed() } } +void fanSpeedErrorBeep(const char *serialMsg, const char *lcdMsg){ + SERIAL_ECHOLNRPGM(serialMsg); + if (get_message_level() == 0) { + if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT)){ + WRITE(BEEPER, HIGH); + delayMicroseconds(200); + WRITE(BEEPER, LOW); + delayMicroseconds(100); // what is this wait for? + } + LCD_ALERTMESSAGERPGM(lcdMsg); + } +} + void fanSpeedError(unsigned char _fan) { if (get_message_level() != 0 && isPrintPaused) return; //to ensure that target temp. is not set to zero in case taht we are resuming print @@ -530,7 +585,8 @@ void fanSpeedError(unsigned char _fan) { lcd_print_stop(); } else { - fan_check_error = true; + fan_check_error = EFCE_DETECTED; + } } else { @@ -538,27 +594,11 @@ void fanSpeedError(unsigned char _fan) { SERIAL_ECHOLNPGM("// action:pause"); //for octoprint } switch (_fan) { - case 0: - SERIAL_ECHOLNPGM("Extruder fan speed is lower then expected"); - if (get_message_level() == 0) { -if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT)) - WRITE(BEEPER, HIGH); - delayMicroseconds(200); - WRITE(BEEPER, LOW); - delayMicroseconds(100); - LCD_ALERTMESSAGEPGM("Err: EXTR. FAN ERROR"); - } + case 0: // extracting the same code from case 0 and case 1 into a function saves 72B + fanSpeedErrorBeep(PSTR("Extruder fan speed is lower than expected"), PSTR("Err: EXTR. FAN ERROR") ); break; case 1: - SERIAL_ECHOLNPGM("Print fan speed is lower then expected"); - if (get_message_level() == 0) { -if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT)) - WRITE(BEEPER, HIGH); - delayMicroseconds(200); - WRITE(BEEPER, LOW); - delayMicroseconds(100); - LCD_ALERTMESSAGEPGM("Err: PRINT FAN ERROR"); - } + fanSpeedErrorBeep(PSTR("Print fan speed is lower than expected"), PSTR("Err: PRINT FAN ERROR") ); break; } } diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 31ab8d9f5..5b22e3a5a 100644 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -238,7 +238,8 @@ void checkExtruderAutoFans(); #if (defined(FANCHECK) && defined(TACH_0) && (TACH_0 > -1)) -extern volatile bool fan_check_error; +enum { EFCE_OK = 0, EFCE_DETECTED, EFCE_REPORTED }; +extern volatile uint8_t fan_check_error; void countFanSpeed(); void checkFanSpeed(); From 09fee4e64de07bcb1b785afc3e0fd4a6d8f92286 Mon Sep 17 00:00:00 2001 From: DRracer Date: Fri, 31 May 2019 11:30:30 +0200 Subject: [PATCH 3/5] remove fan error simulation automaton --- Firmware/temperature.cpp | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 1b60a0230..08ff40dbe 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -489,38 +489,6 @@ void countFanSpeed() fan_edge_counter[1] = 0; } -//#define SIMULATE_FAN_ERRORS -#ifdef SIMULATE_FAN_ERRORS -struct FanSpeedErrorSimulator { - unsigned long lastMillis = 0; - bool state = false; // zatim mam 0 - klid, 1 reportuju chybu - //! @return pocet simulovanych chyb - inline uint8_t step(){ - unsigned long ms = _millis(); - switch(state){ - case false: - if( (ms - lastMillis) > 120000UL ){ // funkcni ventilator chci 2 minuty - state = true; - lastMillis = ms; - SERIAL_ECHOLNPGM("SIM Fan error"); - } - break; - case true: - if( (ms - lastMillis) > 20000UL ){ // vypadek ventilatoru chci uz 20s, - //abych stihl udelat pokusnej resume print, kdyz jeste jsou rozbity vetraky - state = false; - lastMillis = ms; - SERIAL_ECHOLNPGM("SIM Fan ok"); - } - break; - } - return state ? 20 : 0; - } -}; - -static FanSpeedErrorSimulator fanSpeedErrorSimulator; -#endif - void checkFanSpeed() { uint8_t max_print_fan_errors = 0; @@ -544,10 +512,6 @@ void checkFanSpeed() else fan_speed_errors[1] = 0; #endif -#ifdef SIMULATE_FAN_ERRORS - fan_speed_errors[0] = fanSpeedErrorSimulator.step(); -#endif - // drop the fan_check_error flag when both fans are ok if( fan_speed_errors[0] == 0 && fan_speed_errors[1] == 0 && fan_check_error == EFCE_REPORTED){ // we may even send some info to the LCD from here From 5985c0608ef0778be6856042a36f17807d2e0cab Mon Sep 17 00:00:00 2001 From: DRracer Date: Mon, 3 Jun 2019 09:02:27 +0200 Subject: [PATCH 4/5] Revert changes to pins_Einsy_1_0.h not related to the fan check error fix --- Firmware/pins_Einsy_1_0.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Firmware/pins_Einsy_1_0.h b/Firmware/pins_Einsy_1_0.h index 2e05d3263..33363388a 100755 --- a/Firmware/pins_Einsy_1_0.h +++ b/Firmware/pins_Einsy_1_0.h @@ -99,8 +99,7 @@ //#define KILL_PIN 32 -// LCD backlight pin may interfere with something, this is yet to be found out correctly -#define LCD_BL_PIN 5 //backlight control pin +//#define LCD_BL_PIN 5 //backlight control pin #define BEEPER 84 // Beeper on AUX-4 #define LCD_PINS_RS 82 #define LCD_PINS_ENABLE 61 // !!! changed from 18 (EINY03) From 83578c3389352a9ef7b7358b00b75be4213d257e Mon Sep 17 00:00:00 2001 From: DRracer Date: Thu, 6 Jun 2019 15:50:13 +0200 Subject: [PATCH 5/5] documentation + minor code cleanup based on code review --- Firmware/temperature.cpp | 6 +++++- Firmware/temperature.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) mode change 100644 => 100755 Firmware/temperature.h diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 08ff40dbe..9c49cf79c 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -528,7 +528,11 @@ void checkFanSpeed() } } -void fanSpeedErrorBeep(const char *serialMsg, const char *lcdMsg){ +//! Prints serialMsg to serial port, displays lcdMsg onto the LCD and beeps. +//! Extracted from fanSpeedError to save some space. +//! @param serialMsg pointer into PROGMEM, this text will be printed to the serial port +//! @param lcdMsg pointer into PROGMEM, this text will be printed onto the LCD +static void fanSpeedErrorBeep(const char *serialMsg, const char *lcdMsg){ SERIAL_ECHOLNRPGM(serialMsg); if (get_message_level() == 0) { if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT)){ diff --git a/Firmware/temperature.h b/Firmware/temperature.h old mode 100644 new mode 100755 index 5b22e3a5a..27a7e713d --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -238,7 +238,11 @@ void checkExtruderAutoFans(); #if (defined(FANCHECK) && defined(TACH_0) && (TACH_0 > -1)) -enum { EFCE_OK = 0, EFCE_DETECTED, EFCE_REPORTED }; +enum { + EFCE_OK = 0, //!< normal operation, both fans are ok + EFCE_DETECTED, //!< fan error detected, but not reported yet + EFCE_REPORTED //!< fan error detected and reported to LCD and serial +}; extern volatile uint8_t fan_check_error; void countFanSpeed();