From 8bf0b496b97e3b1f8f390aa3fa97d7410eabf8ef Mon Sep 17 00:00:00 2001 From: Roxy-3D Date: Sat, 21 Jan 2017 16:10:57 -0700 Subject: [PATCH] Improve M600 with timeout, wait for heatup. --- Marlin/Configuration_adv.h | 6 +- Marlin/Marlin_main.cpp | 99 ++++++++++++++++++++++++--- Marlin/dogm_font_data_ISO10646_1_tr.h | 2 +- Marlin/endstops.cpp | 4 ++ Marlin/enum.h | 4 +- Marlin/language.h | 1 + Marlin/language_en.h | 21 +++++- Marlin/ultralcd.cpp | 73 +++++++++++++++++++- Marlin/ultralcd_impl_DOGM.h | 11 +++ Marlin/ultralcd_impl_HD44780.h | 8 +++ README.md | 1 + 11 files changed, 212 insertions(+), 18 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0e12ba18d..36b238716 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -721,12 +721,16 @@ #define FILAMENT_CHANGE_LOAD_LENGTH 0 // Load filament length over hotend in mm // Longer length for bowden printers to fast load filament into whole bowden tube over the hotend, // Short or zero length for printers without bowden where loading is not used - #define FILAMENT_CHANGE_LOAD_FEEDRATE 10 // Load filament feedrate in mm/s - filament loading into the bowden tube can be fast + #define FILAMENT_CHANGE_LOAD_FEEDRATE 6 // Load filament feedrate in mm/s - filament loading into the bowden tube can be fast #define FILAMENT_CHANGE_EXTRUDE_LENGTH 50 // Extrude filament length in mm after filament is load over the hotend, // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change #define FILAMENT_CHANGE_EXTRUDE_FEEDRATE 3 // Extrude filament feedrate in mm/s - must be slower than load feedrate + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet + #define STEPPER_MOTORS_DONT_TIMEOUT_DURING_FILAMENT_CHANGE // Enable to make stepper motors hold position during filament change even if it + // takes longer than DEFAULT_STEPPER_DEACTIVE_TIME #endif /******************************************************************************\ diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index e1cd4a4e6..2b72b1dc5 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -7290,6 +7290,28 @@ inline void gcode_M503() { #if ENABLED(FILAMENT_CHANGE_FEATURE) + millis_t next_buzz = 0; + unsigned long int runout_beep = 0; + + void filament_change_beep() { + millis_t ms = millis(); + if (ms >= next_buzz) { + if (runout_beep <= FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS ) { // Only beep as long as we are supposed to! + BUZZ(300, 2000); + next_buzz = ms + 2500; // Beep every 2.5s while waiting + runout_beep++; + } + else if (runout_beep > FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS && + runout_beep <= (FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS + 5)) { // End with a burst of short beeps + BUZZ(200, 2000); + next_buzz = ms + 400; // Beep + runout_beep++; + } + } + } + + bool busy_doing_M600 = false; + /** * M600: Pause for filament change * @@ -7310,6 +7332,8 @@ inline void gcode_M503() { return; } + busy_doing_M600 = true; // Stepper Motors can't timeout when this is set + // Show initial message and wait for synchronize steppers lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INIT); stepper.synchronize(); @@ -7367,6 +7391,7 @@ inline void gcode_M503() { stepper.synchronize(); lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_UNLOAD); + idle(); // Unload filament if (code_seen('L')) destination[E_AXIS] += code_value_axis_units(E_AXIS); @@ -7384,23 +7409,66 @@ inline void gcode_M503() { disable_e3(); delay(100); - #if HAS_BUZZER - millis_t next_buzz = 0; - #endif + millis_t nozzle_timeout = millis() + FILAMENT_CHANGE_NOZZLE_TIMEOUT*1000L; + bool nozzle_timed_out = false; + float temps[4]; + int iii; // Wait for filament insert by user and press button lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); - // LCD click or M108 will clear this - wait_for_user = true; + idle(); + + wait_for_user = true; // LCD click or M108 will clear this + next_buzz = 0; + runout_beep = 0; + for( iii=0; iii= next_buzz) { - BUZZ(300, 2000); - next_buzz = ms + 2500; // Beep every 2.5s while waiting + millis_t current_ms = millis(); + if (nozzle_timed_out == true) + lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE); + #if HAS_BUZZER + filament_change_beep(); + #endif //HAS_BUZZER + + if (current_ms >= nozzle_timeout) { + if (nozzle_timed_out == false ) { + nozzle_timed_out = true; // if the nozzle time out happens, remember we turned off the nozzles. + for( iii=0; iii 3 ) { + lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT); + goto KEEP_CHECKING_TEMPS; + } + } + + wait_for_user = true; // LCD click or M108 will clear this + next_buzz = 0; + runout_beep = 0; + while (wait_for_user) { + if (nozzle_timed_out == true) + lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); + else break; + #if HAS_BUZZER + filament_change_beep(); #endif idle(true); } @@ -7408,6 +7476,8 @@ inline void gcode_M503() { // Show load message lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD); + idle(); + // Load filament if (code_seen('L')) destination[E_AXIS] -= code_value_axis_units(E_AXIS); #if defined(FILAMENT_CHANGE_LOAD_LENGTH) && FILAMENT_CHANGE_LOAD_LENGTH > 0 @@ -7459,6 +7529,7 @@ inline void gcode_M503() { // Show status screen lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_STATUS); + busy_doing_M600 = false; // Allow Stepper Motors to be turned off during inactivity } #endif // FILAMENT_CHANGE_FEATURE @@ -10073,7 +10144,13 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { millis_t ms = millis(); if (max_inactive_time && ELAPSED(ms, previous_cmd_ms + max_inactive_time)) kill(PSTR(MSG_KILLED)); - + + #if ENABLED(FILAMENT_CHANGE_FEATURE) + #ifdef STEPPER_MOTORS_DONT_TIMEOUT_DURING_FILAMENT_CHANGE + if (busy_doing_M600 == false ) // We only allow the stepper motors to time out if + #endif // we are not in the middle of an M600 command. + #endif + if (stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time) && !ignore_stepper_queue && !planner.blocks_queued()) { #if ENABLED(DISABLE_INACTIVE_X) diff --git a/Marlin/dogm_font_data_ISO10646_1_tr.h b/Marlin/dogm_font_data_ISO10646_1_tr.h index 23d6ea88b..e32f59f95 100644 --- a/Marlin/dogm_font_data_ISO10646_1_tr.h +++ b/Marlin/dogm_font_data_ISO10646_1_tr.h @@ -31,7 +31,7 @@ X Font ascent = 7 descent=-1 Max Font ascent = 8 descent=-1 */ -#include "U8glib.h" +#include const u8g_fntpgm_uint8_t ISO10646_TR[2591] U8G_SECTION(".progmem.ISO10646_TR") = { 0,6,9,0,254,7,1,146,3,33,32,255,255,8,255,7, 255,0,0,0,6,0,0,1,7,7,6,2,0,128,128,128, diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index 659fc4052..545ca09c0 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -217,6 +217,10 @@ void Endstops::M119() { SERIAL_PROTOCOLPGM(MSG_Z_PROBE); SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); #endif + #if ENABLED(FILAMENT_RUNOUT_SENSOR) + SERIAL_PROTOCOLPGM(MSG_FILAMENT_RUNOUT_SENSOR); + SERIAL_PROTOCOLLN(((READ(FIL_RUNOUT_PIN)^FIL_RUNOUT_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif } // Endstops::M119 #if ENABLED(Z_DUAL_ENDSTOPS) diff --git a/Marlin/enum.h b/Marlin/enum.h index 23b1fd033..41b40063c 100644 --- a/Marlin/enum.h +++ b/Marlin/enum.h @@ -143,7 +143,9 @@ enum TempState { FILAMENT_CHANGE_MESSAGE_EXTRUDE, FILAMENT_CHANGE_MESSAGE_OPTION, FILAMENT_CHANGE_MESSAGE_RESUME, - FILAMENT_CHANGE_MESSAGE_STATUS + FILAMENT_CHANGE_MESSAGE_STATUS, + FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE, + FILAMENT_CHANGE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT }; #endif #endif diff --git a/Marlin/language.h b/Marlin/language.h index 4fda75a9e..914d1dd6b 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -152,6 +152,7 @@ #define MSG_Z2_MIN "z2_min: " #define MSG_Z2_MAX "z2_max: " #define MSG_Z_PROBE "z_probe: " +#define MSG_FILAMENT_RUNOUT_SENSOR "filament_Runout_Sensor: " #define MSG_ERR_MATERIAL_INDEX "M145 S out of range (0-1)" #define MSG_ERR_M355_NONE "No case light" #define MSG_ERR_M421_PARAMETERS "M421 required parameters missing" diff --git a/Marlin/language_en.h b/Marlin/language_en.h index bea641641..a4f4abdac 100644 --- a/Marlin/language_en.h +++ b/Marlin/language_en.h @@ -33,6 +33,9 @@ #ifndef WELCOME_MSG #define WELCOME_MSG MACHINE_NAME _UxGT(" ready.") #endif +#ifndef MSG_BACK + #define MSG_BACK _UxGT("Back") +#endif #ifndef MSG_SD_INSERTED #define MSG_SD_INSERTED _UxGT("Card inserted") #endif @@ -486,7 +489,6 @@ #ifndef MSG_DELTA_CALIBRATE_CENTER #define MSG_DELTA_CALIBRATE_CENTER _UxGT("Calibrate Center") #endif - #ifndef MSG_INFO_MENU #define MSG_INFO_MENU _UxGT("About Printer") #endif @@ -583,6 +585,12 @@ #ifndef MSG_FILAMENT_CHANGE_OPTION_RESUME #define MSG_FILAMENT_CHANGE_OPTION_RESUME _UxGT("Resume print") #endif +#ifndef MSG_FILAMENT_CHANGE_MINTEMP + #define MSG_FILAMENT_CHANGE_MINTEMP _UxGT("Minimum Temp is ") +#endif +#ifndef MSG_FILAMENT_CHANGE_NOZZLE + #define MSG_FILAMENT_CHANGE_NOZZLE _UxGT(" Nozzle: ") +#endif // // Filament Change screens show up to 3 lines on a 4-line display @@ -603,6 +611,14 @@ #define MSG_FILAMENT_CHANGE_INSERT_2 _UxGT("and press button") #define MSG_FILAMENT_CHANGE_INSERT_3 _UxGT("to continue...") #endif + #ifndef MSG_FILAMENT_CHANGE_HEAT_1 + #define MSG_FILAMENT_CHANGE_HEAT_1 _UxGT("Press button to") + #define MSG_FILAMENT_CHANGE_HEAT_2 _UxGT("heat nozzle.") + #endif + #ifndef MSG_FILAMENT_CHANGE_HEATING_1 + #define MSG_FILAMENT_CHANGE_HEATING_1 _UxGT("Heating nozzle") + #define MSG_FILAMENT_CHANGE_HEATING_2 _UxGT("Please wait...") + #endif #ifndef MSG_FILAMENT_CHANGE_LOAD_1 #define MSG_FILAMENT_CHANGE_LOAD_1 _UxGT("Wait for") #define MSG_FILAMENT_CHANGE_LOAD_2 _UxGT("filament load") @@ -625,6 +641,9 @@ #ifndef MSG_FILAMENT_CHANGE_INSERT_1 #define MSG_FILAMENT_CHANGE_INSERT_1 _UxGT("Insert and Click") #endif + #ifndef MSG_FILAMENT_CHANGE_HEATING_1 + #define MSG_FILAMENT_CHANGE_HEATING_1 _UxGT("Heating...") + #endif #ifndef MSG_FILAMENT_CHANGE_LOAD_1 #define MSG_FILAMENT_CHANGE_LOAD_1 _UxGT("Loading...") #endif diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 6b81fac83..0dd0a59d5 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -54,6 +54,7 @@ char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kan #if ENABLED(DOGLCD) #include "ultralcd_impl_DOGM.h" + #include #else #include "ultralcd_impl_HD44780.h" #endif @@ -151,6 +152,7 @@ uint16_t max_display_update_time = 0; void lcd_filament_change_unload_message(); void lcd_filament_change_insert_message(); void lcd_filament_change_load_message(); + void lcd_filament_change_heat_nozzle(); void lcd_filament_change_extrude_message(); void lcd_filament_change_resume_message(); #endif @@ -948,7 +950,8 @@ void kill_screen(const char* lcd_msg) { // Change filament // #if ENABLED(FILAMENT_CHANGE_FEATURE) - MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change); + if (!thermalManager.tooColdToExtrude(active_extruder)) + MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change); #endif END_MENU(); @@ -1384,11 +1387,13 @@ KeepDrawing: MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_material1_hotend0); MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_material2_hotend0); #endif + // // Change filament // #if ENABLED(FILAMENT_CHANGE_FEATURE) - MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change); + if (!thermalManager.tooColdToExtrude(active_extruder)) + MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change); #endif #endif @@ -2441,11 +2446,21 @@ KeepDrawing: } #endif // LCD_INFO_MENU + /** + * + * Filament Change Feature Screens + * + */ #if ENABLED(FILAMENT_CHANGE_FEATURE) + void lcd_filament_change_toocold_menu() { START_MENU(); STATIC_ITEM(MSG_HEATING_FAILED_LCD, true, true); - MENU_BACK(MSG_FILAMENTCHANGE); + STATIC_ITEM (MSG_FILAMENT_CHANGE_MINTEMP STRINGIFY(EXTRUDE_MINTEMP) ".", false, false); + MENU_BACK(MSG_BACK); + STATIC_ITEM (" "); + STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); + lcd_implementation_hotend_status(); END_MENU(); } @@ -2478,6 +2493,8 @@ KeepDrawing: #ifdef MSG_FILAMENT_CHANGE_INIT_3 STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_3); #endif + STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); + lcd_implementation_hotend_status(); END_SCREEN(); } @@ -2491,6 +2508,35 @@ KeepDrawing: #ifdef MSG_FILAMENT_CHANGE_UNLOAD_3 STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_3); #endif + STATIC_ITEM (" "); + STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); + lcd_implementation_hotend_status(); + END_SCREEN(); + } + + void lcd_filament_change_wait_for_nozzles_to_heat() { + START_SCREEN(); + STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, true, true); + STATIC_ITEM(MSG_FILAMENT_CHANGE_HEATING_1); + #ifdef MSG_FILAMENT_CHANGE_HEATING_2 + STATIC_ITEM(MSG_FILAMENT_CHANGE_HEATING_2); + #endif + STATIC_ITEM(" "); + STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); + lcd_implementation_hotend_status(); + END_SCREEN(); + } + + void lcd_filament_change_heat_nozzle() { + START_SCREEN(); + STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, true, true); + STATIC_ITEM(MSG_FILAMENT_CHANGE_HEAT_1); + #ifdef MSG_FILAMENT_CHANGE_INSERT_2 + STATIC_ITEM(MSG_FILAMENT_CHANGE_HEAT_2); + #endif + STATIC_ITEM(" "); + STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); + lcd_implementation_hotend_status(); END_SCREEN(); } @@ -2504,6 +2550,8 @@ KeepDrawing: #ifdef MSG_FILAMENT_CHANGE_INSERT_3 STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_3); #endif + STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); + lcd_implementation_hotend_status(); END_SCREEN(); } @@ -2517,6 +2565,9 @@ KeepDrawing: #ifdef MSG_FILAMENT_CHANGE_LOAD_3 STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_3); #endif + STATIC_ITEM(" "); + STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); + lcd_implementation_hotend_status(); END_SCREEN(); } @@ -2530,6 +2581,9 @@ KeepDrawing: #ifdef MSG_FILAMENT_CHANGE_EXTRUDE_3 STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_3); #endif + STATIC_ITEM(" "); + STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); + lcd_implementation_hotend_status(); END_SCREEN(); } @@ -2550,20 +2604,33 @@ KeepDrawing: switch (message) { case FILAMENT_CHANGE_MESSAGE_INIT: defer_return_to_status = true; + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_init_message); break; case FILAMENT_CHANGE_MESSAGE_UNLOAD: + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_unload_message); break; case FILAMENT_CHANGE_MESSAGE_INSERT: + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_insert_message); break; case FILAMENT_CHANGE_MESSAGE_LOAD: + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_load_message); break; case FILAMENT_CHANGE_MESSAGE_EXTRUDE: + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_extrude_message); break; + case FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE: + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; + lcd_goto_screen(lcd_filament_change_heat_nozzle); + break; + case FILAMENT_CHANGE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT: + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; + lcd_goto_screen(lcd_filament_change_wait_for_nozzles_to_heat); + break; case FILAMENT_CHANGE_MESSAGE_OPTION: filament_change_menu_response = FILAMENT_CHANGE_RESPONSE_WAIT_FOR; lcd_goto_screen(lcd_filament_change_option_menu); diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index 2b51ea79c..cc1b709e8 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -379,6 +379,17 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, //#define DOGM_SD_PERCENT + +static void lcd_implementation_hotend_status() { + u8g.setPrintPos(58, 60); + lcd_print( (char) '0'+active_extruder ); + lcd_print( ' ' ); + lcd_print( ' ' ); + lcd_print(itostr3(thermalManager.degHotend(active_extruder))); + lcd_print('/'); + lcd_print(itostr3(thermalManager.degTargetHotend(active_extruder))); +} + static void lcd_implementation_status_screen() { bool blink = lcd_blink(); diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index 38edbc747..f4fa4795d 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -592,6 +592,14 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, #endif // LCD_PROGRESS_BAR +static void lcd_implementation_hotend_status() { + lcd.setCursor(10,3); + lcd.print(LCD_STR_THERMOMETER[active_extruder]); + lcd.print(itostr3(thermalManager.degHotend(active_extruder))); + lcd.print('/'); + lcd.print(itostr3(thermalManager.degTargetHotend(active_extruder))); +} + /** Possible status screens: 16x2 |000/000 B000/000| diff --git a/README.md b/README.md index 42e5cfa96..ad259a238 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ The latest Release Candidate lives in the ["RC" branch](https://github.com/Marli ## Recent Changes - RCBugFix - Fixed broken MBL + - M600 heater timeout option - RC8 - 06 Dec 2016 - Major performance improvement for Graphical LCDs