From 7882b3c9753a96ee78903fab0eb14ae0c3fb9737 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 3 Oct 2018 17:29:24 +0200 Subject: [PATCH 1/3] Update fsensor in Manage_inactivity instead of main loop. --- Firmware/Marlin_main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 80f21058..7d9cc2e4 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1964,10 +1964,6 @@ void loop() isPrintPaused ? manage_inactivity(true) : manage_inactivity(false); checkHitEndstops(); lcd_update(0); -#ifdef FILAMENT_SENSOR - if (mcode_in_progress != 600 && !mmu_enabled) //M600 not in progress - fsensor_update(); -#endif //FILAMENT_SENSOR #ifdef TMC2130 tmc2130_check_overtemp(); if (tmc2130_sg_crash) @@ -7368,7 +7364,10 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } else + { fsensor_autoload_check_stop(); + fsensor_update(); + } } } #endif //FILAMENT_SENSOR From f9d8c46802d53ea23e5eb3c5b2b1214b75891252 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Thu, 4 Oct 2018 15:48:28 +0200 Subject: [PATCH 2/3] Enable/disable optical quality meassurement in settings menu --- Firmware/eeprom.h | 2 ++ Firmware/fsensor.cpp | 27 +++++++++++++++++++++++---- Firmware/fsensor.h | 3 +++ Firmware/ultralcd.cpp | 10 ++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index d79bbd08..c3633a71 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -146,6 +146,8 @@ #define EEPROM_SOUND_MODE (EEPROM_UVLO_TINY_Z_MICROSTEPS-1) // uint8 #define EEPROM_AUTO_DEPLETE (EEPROM_SOUND_MODE-1) //bool +#define EEPROM_FSENS_OQ_MEASS_ENABLED (EEPROM_AUTO_DEPLETE - 1) //bool + // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index a46ef8c4..80702882 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -42,6 +42,8 @@ bool fsensor_enabled = true; bool fsensor_watch_runout = true; //not responding - is set if any communication error occured durring initialization or readout bool fsensor_not_responding = false; +//enable/disable quality meassurement +bool fsensor_oq_meassure_enabled = false; //number of errors, updated in ISR uint8_t fsensor_err_cnt = 0; @@ -114,6 +116,8 @@ void fsensor_init(void) printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125); uint8_t fsensor = eeprom_read_byte((uint8_t*)EEPROM_FSENSOR); fsensor_autoload_enabled=eeprom_read_byte((uint8_t*)EEPROM_FSENS_AUTOLOAD_ENABLED); + uint8_t oq_meassure_enabled = eeprom_read_byte((uint8_t*)EEPROM_FSENS_OQ_MEASS_ENABLED); + fsensor_oq_meassure_enabled = (oq_meassure_enabled == 1)?true:false; fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * axis_steps_per_unit[E_AXIS]); if (!pat9125) @@ -255,9 +259,16 @@ bool fsensor_check_autoload(void) return false; } +void fsensor_oq_meassure_set(bool State) +{ + fsensor_oq_meassure_enabled = State; + eeprom_update_byte((unsigned char *)EEPROM_FSENS_OQ_MEASS_ENABLED, fsensor_oq_meassure_enabled); +} + void fsensor_oq_meassure_start(uint8_t skip) { if (!fsensor_enabled) return; + if (!fsensor_oq_meassure_enabled) return; printf_P(PSTR("fsensor_oq_meassure_start\n")); fsensor_oq_skipchunk = skip; fsensor_oq_samples = 0; @@ -277,6 +288,7 @@ void fsensor_oq_meassure_start(uint8_t skip) void fsensor_oq_meassure_stop(void) { if (!fsensor_enabled) return; + if (!fsensor_oq_meassure_enabled) return; printf_P(PSTR("fsensor_oq_meassure_stop, %hhu samples\n"), fsensor_oq_samples); printf_P(_N(" st_sum=%u yd_sum=%u er_sum=%u er_max=%hhu\n"), fsensor_oq_st_sum, fsensor_oq_yd_sum, fsensor_oq_er_sum, fsensor_oq_er_max); printf_P(_N(" yd_min=%u yd_max=%u yd_avg=%u sh_avg=%u\n"), fsensor_oq_yd_min, fsensor_oq_yd_max, (uint16_t)((uint32_t)fsensor_oq_yd_sum * fsensor_chunk_len / fsensor_oq_st_sum), (uint16_t)(fsensor_oq_sh_sum / fsensor_oq_samples)); @@ -291,6 +303,7 @@ const char _NG[] PROGMEM = "NG!"; bool fsensor_oq_result(void) { if (!fsensor_enabled) return true; + if (!fsensor_oq_meassure_enabled) return true; printf_P(_N("fsensor_oq_result\n")); bool res_er_sum = (fsensor_oq_er_sum <= FSENSOR_OQ_MAX_ES); printf_P(_N(" er_sum = %u %S\n"), fsensor_oq_er_sum, (res_er_sum?_OK:_NG)); @@ -305,9 +318,10 @@ bool fsensor_oq_result(void) printf_P(_N(" yd_min = %u %S\n"), fsensor_oq_yd_min, (res_yd_min?_OK:_NG)); uint16_t yd_dev = (fsensor_oq_yd_max - yd_avg) + (yd_avg - fsensor_oq_yd_min); - uint16_t yd_qua = 10 * yd_avg / (yd_dev + 1); printf_P(_N(" yd_dev = %u\n"), yd_dev); - printf_P(_N(" yd_qua = %u\n"), yd_qua); + + uint16_t yd_qua = 10 * yd_avg / (yd_dev + 1); + printf_P(_N(" yd_qua = %u %S\n"), yd_qua, ((yd_qua >= 8)?_OK:_NG)); uint8_t sh_avg = (fsensor_oq_sh_sum / fsensor_oq_samples); bool res_sh_avg = (sh_avg <= FSENSOR_OQ_MAX_SH); @@ -467,9 +481,14 @@ void fsensor_update(void) fsensor_oq_meassure_stop(); bool err = false; - err |= (fsensor_oq_er_sum > 2); err |= (err_cnt > 1); - err |= (fsensor_oq_yd_sum < (4 * FSENSOR_OQ_MIN_YD)); +#ifdef FSENSOR_QUALITY + if (fsensor_oq_meassure_enabled) + { + err |= (fsensor_oq_er_sum > 2); + err |= (fsensor_oq_yd_sum < (4 * FSENSOR_OQ_MIN_YD)); + } +#endif //FSENSOR_QUALITY if (!err) { printf_P(PSTR("fsensor_err_cnt = 0\n")); diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index df58def2..411c9b46 100644 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -10,6 +10,8 @@ extern int16_t fsensor_chunk_len; extern bool fsensor_enabled; //not responding flag extern bool fsensor_not_responding; +//enable/disable quality meassurement +extern bool fsensor_oq_meassure_enabled; //save restore printing @@ -39,6 +41,7 @@ extern void fsensor_autoload_check_stop(void); extern bool fsensor_check_autoload(void); //optical quality meassurement support +extern void fsensor_oq_meassure_set(bool State); extern void fsensor_oq_meassure_start(uint8_t skip); extern void fsensor_oq_meassure_stop(void); extern bool fsensor_oq_result(void); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index fef61d72..2a4cf0f0 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2209,6 +2209,12 @@ void lcd_set_filament_autoload() { fsensor_autoload_set(!fsensor_autoload_enabled); } +void lcd_set_filament_oq_meass() +{ + fsensor_oq_meassure_set(!fsensor_oq_meassure_enabled); +} + + void lcd_unLoadFilament() { @@ -4594,6 +4600,10 @@ do\ MENU_ITEM_FUNCTION_P(_i("F. autoload [on]"), lcd_set_filament_autoload);/*////MSG_FSENS_AUTOLOAD_ON c=17 r=1*/\ else\ MENU_ITEM_FUNCTION_P(_i("F. autoload [off]"), lcd_set_filament_autoload);/*////MSG_FSENS_AUTOLOAD_OFF c=17 r=1*/\ + if (fsensor_oq_meassure_enabled)\ + MENU_ITEM_FUNCTION_P(_i("F. OQ meass. [on]"), lcd_set_filament_oq_meass);/*////MSG_FSENS_OQMEASS_ON c=17 r=1*/\ + else\ + MENU_ITEM_FUNCTION_P(_i("F. OQ meass.[off]"), lcd_set_filament_oq_meass);/*////MSG_FSENS_OQMEASS_OFF c=17 r=1*/\ }\ }\ }\ From 9960c80bf7217bc5f7443305c6eb4ba5039ace00 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Thu, 4 Oct 2018 16:12:41 +0200 Subject: [PATCH 3/3] Additional check always with enabled oq_meassure + variant files --- Firmware/fsensor.cpp | 16 ++++++++-------- .../variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h | 2 ++ .../variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h | 2 ++ .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 3 +++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 80702882..2891b770 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -446,6 +446,8 @@ void fsensor_update(void) { bool autoload_enabled_tmp = fsensor_autoload_enabled; fsensor_autoload_enabled = false; + bool oq_meassure_enabled_tmp = fsensor_oq_meassure_enabled; + fsensor_oq_meassure_enabled = true; fsensor_stop_and_save_print(); @@ -482,14 +484,11 @@ void fsensor_update(void) bool err = false; err |= (err_cnt > 1); -#ifdef FSENSOR_QUALITY - if (fsensor_oq_meassure_enabled) - { - err |= (fsensor_oq_er_sum > 2); - err |= (fsensor_oq_yd_sum < (4 * FSENSOR_OQ_MIN_YD)); - } -#endif //FSENSOR_QUALITY - if (!err) + + err |= (fsensor_oq_er_sum > 2); + err |= (fsensor_oq_yd_sum < (4 * FSENSOR_OQ_MIN_YD)); + + if (!err) { printf_P(PSTR("fsensor_err_cnt = 0\n")); fsensor_restore_print_and_continue(); @@ -504,6 +503,7 @@ void fsensor_update(void) fsensor_watch_runout = false; } fsensor_autoload_enabled = autoload_enabled_tmp; + fsensor_oq_meassure_enabled = oq_meassure_enabled_tmp; } } diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index 626c64e8..627e284a 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -145,6 +145,8 @@ //#define CMD_DIAGNOSTICS //Show cmd queue length on printer display #endif /* DEBUG_BUILD */ +#define FSENSOR_QUALITY + /*------------------------------------ EXTRUDER SETTINGS diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index cb13e8ad..7c76a8b3 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -146,6 +146,8 @@ //#define CMD_DIAGNOSTICS //Show cmd queue length on printer display #endif /* DEBUG_BUILD */ +#define FSENSOR_QUALITY + /*------------------------------------ EXTRUDER SETTINGS diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index ea1951f4..6f4729a6 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -183,6 +183,9 @@ #define CMD_DIAGNOSTICS //Show cmd queue length on printer display #endif /* DEBUG_BUILD */ +#define FSENSOR_QUALITY + + #define LINEARITY_CORRECTION #define TMC2130_LINEARITY_CORRECTION #define TMC2130_LINEARITY_CORRECTION_XYZ