From 6abba7bfe9cd566e5f5d7c085547e05d990d47e1 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Fri, 22 Dec 2017 20:14:26 +0100 Subject: [PATCH 1/3] filament autoload - better detection algorithm, autoload in M600 from menu unload menu always visible --- Firmware/Marlin_main.cpp | 15 ++++++++++++--- Firmware/fsensor.cpp | 30 ++++++++++++++++-------------- Firmware/ultralcd.cpp | 2 +- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 2acdba49..9d829e40 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5600,15 +5600,21 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp //load_filament_time = millis(); KEEPALIVE_STATE(PAUSED_FOR_USER); #ifdef PAT9125 - if (filament_autoload_enabled && fsensor_M600) fsensor_autoload_check_start(); + if (filament_autoload_enabled && (old_fsensor_enabled || fsensor_M600)) fsensor_autoload_check_start(); #endif //PAT9125 +// printf_P(PSTR("M600 PAT9125 filament_autoload_enabled=%d, old_fsensor_enabled=%d, fsensor_M600=%d"), filament_autoload_enabled, old_fsensor_enabled, fsensor_M600); while(!lcd_clicked()) { manage_heater(); manage_inactivity(true); #ifdef PAT9125 - if (filament_autoload_enabled && fsensor_M600 && fsensor_check_autoload()) + if (filament_autoload_enabled && (old_fsensor_enabled || fsensor_M600) && fsensor_check_autoload()) + { + tone(BEEPER, 1000); + delay_keep_alive(50); + noTone(BEEPER); break; + } #endif //PAT9125 /*#ifdef SNMM target[E_AXIS] += 0.002; @@ -5618,7 +5624,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp } #ifdef PAT9125 - if (filament_autoload_enabled && fsensor_M600) fsensor_autoload_check_stop(); + if (filament_autoload_enabled && (old_fsensor_enabled || fsensor_M600)) fsensor_autoload_check_stop(); #endif //PAT9125 //WRITE(BEEPER, LOW); KEEPALIVE_STATE(IN_HANDLER); @@ -6400,6 +6406,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s if (fsensor_check_autoload()) { fsensor_autoload_check_stop(); + tone(BEEPER, 1000); + delay_keep_alive(50); + noTone(BEEPER); enquecommand_front_P((PSTR("M701"))); } } diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 64ac1a0b..457f45f8 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -46,6 +46,7 @@ bool fsensor_autoload_enabled = false; uint16_t fsensor_autoload_y = 0; uint8_t fsensor_autoload_c = 0; uint32_t fsensor_autoload_last_millis = 0; +uint8_t fsensor_autoload_sum = 0; void fsensor_block() { @@ -108,6 +109,7 @@ void fsensor_autoload_check_start(void) pat9125_update_y(); //update sensor fsensor_autoload_y = pat9125_y; //save current y value fsensor_autoload_c = 0; //reset number of changes counter + fsensor_autoload_sum = 0; fsensor_autoload_last_millis = millis(); fsensor_autoload_enabled = true; fsensor_err_cnt = 0; @@ -116,36 +118,36 @@ void fsensor_autoload_check_start(void) void fsensor_autoload_check_stop(void) { puts_P(PSTR("fsensor_autoload_check_stop\n")); + fsensor_autoload_sum = 0; fsensor_autoload_enabled = false; fsensor_err_cnt = 0; } bool fsensor_check_autoload(void) { - if ((millis() - fsensor_autoload_last_millis) < 50) return false; + uint8_t fsensor_autoload_c_old = fsensor_autoload_c; + if ((millis() - fsensor_autoload_last_millis) < 25) return false; fsensor_autoload_last_millis = millis(); pat9125_update_y(); //update sensor - uint16_t dy = fsensor_autoload_y - pat9125_y; + int16_t dy = fsensor_autoload_y - pat9125_y; if (dy) //? y value is different { - if (dy > 0) //? delta-y value is positive (inserting) + if (dy < 0) //? delta-y value is positive (inserting) { - fsensor_autoload_c+=3; //increment change counter -// printf_P(PSTR("fsensor_check_autoload dy=%d c=%d\n"), dy, fsensor_autoload_c); - } - else if (fsensor_autoload_c > 0) - { - fsensor_autoload_c--; -// printf_P(PSTR("fsensor_check_autoload dy=%d c=%d\n"), dy, fsensor_autoload_c); + fsensor_autoload_sum -= dy; + fsensor_autoload_c += 3; //increment change counter by 3 } + else if (fsensor_autoload_c > 1) + fsensor_autoload_c -= 2; //decrement change counter by 2 fsensor_autoload_y = pat9125_y; //save current value - if (fsensor_autoload_c > 10) return true; //number of positive changes > 10, start loading } else if (fsensor_autoload_c > 0) - { fsensor_autoload_c--; -// printf_P(PSTR("fsensor_check_autoload dy=%d c=%d\n"), dy, fsensor_autoload_c); - } + if (fsensor_autoload_c == 0) fsensor_autoload_sum = 0; +// if (fsensor_autoload_c != fsensor_autoload_c_old) +// printf_P(PSTR("fsensor_check_autoload dy=%d c=%d sum=%d\n"), dy, fsensor_autoload_c, fsensor_autoload_sum); + if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30)) + return true; return false; } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index bf864e3b..daf45a8a 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5027,8 +5027,8 @@ static void lcd_main_menu() if (!filament_autoload_enabled) { MENU_ITEM(function, MSG_LOAD_FILAMENT, lcd_LoadFilament); - MENU_ITEM(function, MSG_UNLOAD_FILAMENT, lcd_unLoadFilament); } + MENU_ITEM(function, MSG_UNLOAD_FILAMENT, lcd_unLoadFilament); #endif #ifdef SNMM MENU_ITEM(submenu, MSG_LOAD_FILAMENT, fil_load_menu); From 7f05b9fd443359f7ebef8093cd5b087f441b926b Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Fri, 22 Dec 2017 20:31:45 +0100 Subject: [PATCH 2/3] changed menu order (PFW 91) --- Firmware/ultralcd.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index daf45a8a..3dfeafc7 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5043,12 +5043,13 @@ static void lcd_main_menu() { MENU_ITEM(submenu, MSG_STATISTICS, lcd_menu_statistics); } - MENU_ITEM(submenu, MSG_SUPPORT, lcd_support_menu); MENU_ITEM(submenu, PSTR("Fail stats"), lcd_menu_fails_stats); MENU_ITEM(submenu, PSTR("Debug"), lcd_menu_debug); + MENU_ITEM(submenu, MSG_SUPPORT, lcd_support_menu); + END_MENU(); } From c4b045083cc9590d58ba50026ebc4f94a5e21311 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Fri, 22 Dec 2017 20:34:24 +0100 Subject: [PATCH 3/3] Extrude mintemp increased to 190C --- Firmware/Configuration_prusa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index e2c70b8a..2827a944 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -225,7 +225,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif // Extrude mintemp -#define EXTRUDE_MINTEMP 130 +#define EXTRUDE_MINTEMP 190 // Extruder cooling fans #define EXTRUDER_0_AUTO_FAN_PIN 8