Skip to content

Commit

Permalink
Implement nozzle reheating on timeout via display
Browse files Browse the repository at this point in the history
- Raise nozzle timeout to 10 minutes
- Use continue button as reheat trigger
- Manage nozzle_timed_out variable via display
- Add PausedByNozzleTimeout flag to enter correct routine on display
- Bump version to 1.4.3
  • Loading branch information
davidramiro committed Mar 8, 2019
1 parent cea5472 commit 1a5804f
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 26 deletions.
61 changes: 48 additions & 13 deletions Marlin/AnycubicTFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void AnycubicTFTClass::KillTFT()

void AnycubicTFTClass::StartPrint(){
if (TFTstate==ANYCUBIC_TFT_STATE_SDPAUSE) { // resuming from SD pause
if((!PausedByRunout) && (!PausedByFilamentChange)) // was that a regular pause?
if((!PausedByRunout) && (!PausedByFilamentChange) && (!PausedByNozzleTimeout)) // was that a regular pause?
{
enqueue_and_echo_commands_P(PSTR("G91")); // relative mode
enqueue_and_echo_commands_P(PSTR("G1 Z-10 F240")); // lower nozzle again
Expand All @@ -148,11 +148,11 @@ void AnycubicTFTClass::StartPrint(){
}
starttime=millis();
#ifdef SDSUPPORT
if((!PausedByRunout) && (!PausedByFilamentChange)) // was that a regular pause?
if((!PausedByRunout) && (!PausedByFilamentChange) && (!PausedByNozzleTimeout)) // was that a regular pause?
{
card.startFileprint(); // start or resume regularly
}
else if((PausedByRunout) && (!PausedByFilamentChange)) // resuming from a pause that was caused by filament runout
else if((PausedByRunout) && (!PausedByFilamentChange) && (!PausedByNozzleTimeout)) // resuming from a pause that was caused by filament runout
{
enqueue_and_echo_commands_P(PSTR("M24")); // unpark nozzle and resume
#ifdef ANYCUBIC_TFT_DEBUG
Expand All @@ -163,19 +163,30 @@ void AnycubicTFTClass::StartPrint(){
SERIAL_ECHOLNPGM("DEBUG: Filament Pause Flag cleared");
#endif
}
else if((!PausedByRunout) && (PausedByFilamentChange)) // was M600 called?
else if((!PausedByRunout) && (PausedByFilamentChange) && (!PausedByNozzleTimeout)) // was M600 called and the nozzle is not timed out?
{
FilamentChangeResume(); // enter M108 routine
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Start M108 routine");
#endif
PausedByFilamentChange=false; // clear flag
FilamentChangeResume(); // enter M108 routine
PausedByFilamentChange=false; // clear flag
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Filament Change Flag cleared");
#endif
}
#endif
TFTstate=ANYCUBIC_TFT_STATE_SDPRINT;
if (!PausedByNozzleTimeout) {
TFTstate=ANYCUBIC_TFT_STATE_SDPRINT;
} else {
TFTstate=ANYCUBIC_TFT_STATE_SDPAUSE_REQ;
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Set Pause again because of timeout");
#endif
PausedByNozzleTimeout=false;
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Nozzle timeout flag cleared");
#endif
}
}

void AnycubicTFTClass::PausePrint(){
Expand All @@ -192,7 +203,7 @@ void AnycubicTFTClass::PausePrint(){
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Filament Runout Pause");
#endif
enqueue_and_echo_commands_P(PSTR("M25")); // pause print and park nozzle
enqueue_and_echo_commands_P(PSTR("M25")); // pause print and park nozzle
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: M25 sent, parking nozzle");
#endif
Expand Down Expand Up @@ -251,16 +262,19 @@ void AnycubicTFTClass::StopPrint(){
for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
#endif
TFTstate=ANYCUBIC_TFT_STATE_SDSTOP_REQ;
enqueue_and_echo_commands_P(PSTR("M27")); // force report of SD status
}

void AnycubicTFTClass::FilamentChangeResume(){
enqueue_and_echo_commands_P(PSTR("M108")); // call M108 to break out of M600 pause
HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e); // resume heating if timed out
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: M108 called");
#endif
wait_for_heatup = false;
wait_for_user = false; // remove waiting flags
card.startFileprint(); // resume with proper progress state
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: M108 Resume called");
SERIAL_ECHOLNPGM("DEBUG: M108 Resume done");
#endif
}

Expand All @@ -273,6 +287,24 @@ void AnycubicTFTClass::FilamentChangePause(){
#endif
}

void AnycubicTFTClass::ReheatNozzle(){
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Send reheat M108");
#endif
enqueue_and_echo_commands_P(PSTR("M108"));
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Resume heating");
#endif
HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e); // resume heating if timed out
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Clear flags");
#endif
nozzle_timed_out = false;
wait_for_user = false;
wait_for_heatup = false;
TFTstate=ANYCUBIC_TFT_STATE_SDPAUSE_REQ;
}


float AnycubicTFTClass::CodeValue()
{
Expand Down Expand Up @@ -538,7 +570,7 @@ void AnycubicTFTClass::StateHandler()
#ifdef SDSUPPORT
if((!card.sdprinting) && (!planner.movesplanned())) {
// We have to wait until the sd card printing has been settled
if((!PausedByRunout) && (!PausedByFilamentChange))
if((!PausedByRunout) && (!PausedByFilamentChange) && (!PausedByNozzleTimeout))
{
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Regular Pause requested");
Expand Down Expand Up @@ -602,7 +634,7 @@ void AnycubicTFTClass::FilamentRunout()
// something changed! save current timestamp.
const millis_t fil_ms = millis();
static millis_t fil_delay;

// since this is inside a loop, only set delay time once
if (FilamentSetMillis){
#ifdef ANYCUBIC_TFT_DEBUG
Expand Down Expand Up @@ -814,7 +846,10 @@ void AnycubicTFTClass::GetCommandFromTFT()
SERIAL_ECHOLNPGM("TFT Serial Debug: SD print started... J04");
#endif
}
#endif
if (nozzle_timed_out) {
ReheatNozzle();
}
#endif
break;
case 11: // A11 STOP SD PRINT
#ifdef SDSUPPORT
Expand Down
2 changes: 2 additions & 0 deletions Marlin/AnycubicTFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class AnycubicTFTClass {
char TFTstate=ANYCUBIC_TFT_STATE_IDLE;
bool PausedByRunout=false;
bool PausedByFilamentChange=false;
bool PausedByNozzleTimeout=false;

private:
char TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE];
Expand Down Expand Up @@ -100,6 +101,7 @@ class AnycubicTFTClass {
void HandleSpecialMenu();
void FilamentChangePause();
void FilamentChangeResume();
void ReheatNozzle();

char SelectedDirectory[30];
uint8_t SpecialMenu=false;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@
#define FILAMENT_UNLOAD_DELAY 5000 // (ms) Delay for the filament to cool after retract.
#define FILAMENT_UNLOAD_PURGE_LENGTH 8 // (mm) An unretract is done, then this length is purged.

#define PAUSE_PARK_NOZZLE_TIMEOUT 300 // (seconds) Time limit before the nozzle is turned off for safety.
#define PAUSE_PARK_NOZZLE_TIMEOUT 600 // (seconds) Time limit before the nozzle is turned off for safety.
#define FILAMENT_CHANGE_ALERT_BEEPS 10 // Number of alert beeps to play when a response is needed.
#define PAUSE_PARK_NO_STEPPER_TIMEOUT // Enable for XYZ steppers to stay powered on during filament change.

Expand Down
3 changes: 3 additions & 0 deletions Marlin/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) ==

extern volatile bool wait_for_heatup;

// Making sure this flag can be cleared by the Anycubic display
extern volatile bool nozzle_timed_out;

#if HAS_RESUME_CONTINUE
extern volatile bool wait_for_user;
#endif
Expand Down
26 changes: 24 additions & 2 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ static bool relative_mode; // = false;
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
volatile bool wait_for_heatup = true;

// Making sure this flag can be cleared by the Anycubic display
volatile bool nozzle_timed_out = false;

// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
#if HAS_RESUME_CONTINUE
volatile bool wait_for_user; // = false;
Expand Down Expand Up @@ -7213,7 +7216,11 @@ inline void gcode_M17() {
* Used by M125 and M600
*/
static void wait_for_filament_reload(const int8_t max_beep_count=0) {
bool nozzle_timed_out = false;
nozzle_timed_out = false;
nozzle_timed_out = false;
#ifdef ANYCUBIC_TFT_MODEL
AnycubicTFT.PausedByNozzleTimeout = false;
#endif

#if ENABLED(ULTIPANEL)
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT);
Expand Down Expand Up @@ -7246,6 +7253,14 @@ inline void gcode_M17() {
nozzle_timed_out |= thermalManager.is_heater_idle(e);

if (nozzle_timed_out) {

#ifdef ANYCUBIC_TFT_MODEL
AnycubicTFT.PausedByNozzleTimeout=true;
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Nozzle timeout flag set");
#endif
#endif

#if ENABLED(ULTIPANEL)
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
#endif
Expand Down Expand Up @@ -7287,6 +7302,9 @@ inline void gcode_M17() {

wait_for_user = true; // Wait for user to load filament
nozzle_timed_out = false;
#ifdef ANYCUBIC_TFT_DEBUG
AnycubicTFT.PausedByNozzleTimeout = false;
#endif

#if HAS_BUZZER
filament_change_beep(max_beep_count, true);
Expand Down Expand Up @@ -7320,7 +7338,11 @@ inline void gcode_M17() {
if (!did_pause_print) return;

// Re-enable the heaters if they timed out
bool nozzle_timed_out = false;
nozzle_timed_out = false;
#ifdef ANYCUBIC_TFT_MODEL
AnycubicTFT.PausedByNozzleTimeout = false;
#endif

HOTEND_LOOP() {
nozzle_timed_out |= thermalManager.is_heater_idle(e);
thermalManager.reset_heater_idle_timer(e);
Expand Down
4 changes: 2 additions & 2 deletions Marlin/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* Defines the version of the Marlin-AI3M build. Not to be confused with
* Marlin's own build number, e.g. 1.1.9.
*/
#define CUSTOM_BUILD_VERSION "v1.4.2"
#define CUSTOM_BUILD_VERSION "v1.4.3"

/**
* Verbose version identifier which should contain a reference to the location
Expand All @@ -54,7 +54,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
#define STRING_DISTRIBUTION_DATE "2019-02-24"
#define STRING_DISTRIBUTION_DATE "2019-03-06"

/**
* Required minimum Configuration.h and Configuration_adv.h file versions.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
#define MSG_INVALID_EXTRUDER "Invalid extruder"
#define MSG_INVALID_SOLENOID "Invalid solenoid"
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature"
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID " MARLIN-AI3M_VERSION:" CUSTOM_BUILD_VERSION
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " MARLIN-AI3M_VERSION:" CUSTOM_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID
#define MSG_MARLIN_AI3M "Marlin-AI3M"
#define MSG_COUNT_X " Count X:"
#define MSG_COUNT_A " Count A:"
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ Feel free to discuss issues and work with me further optimizing this firmware!
I am running this version on an i3 Mega Ultrabase V3 (for distinction of the different versions, check [this Thingiverse thread](https://www.thingiverse.com/groups/anycubic-i3-mega/forums/general/topic:27064)).
Basically, this should work on every Ultrabase version that has two Z-axis endstops.

The new **Mega-S** should work too, but you will need to enter those two commands to make the new extruder work:
```
M92 E384
M500
```
Afterwards, calibration is highly recommended as per the instructions on the [Wiki](https://github.com/davidramiro/Marlin-AI3M/wiki/Calibration/).
The new **Mega-S** should work too, but you will need to enter two additional commands after flashing the firmware, mentioned in the instructions below.

Looking for a **BLtouch firmware**? Head [this way](https://github.com/MNieddu91/Marlin-AI3M-BLTouch)! Mounting and configuration instructions are included.

Expand All @@ -26,7 +21,7 @@ A German translation of the instructions can be found [here](https://kore.cc/i3m

## Known issues:

- **Cura users: Please turn off jerk and acceleration control in your print settings (not visible by default, select advanced visibility to unlock them). Cura's high default jerk and acceleration might cause shifted layers if you use TMC2208.**
- Power outage support is not included
- Estimated print times from your slicer might be slightly off.
- Special characters on any file or folders name on the SD card will cause the file menu to freeze. Simply replace or remove every special character (Chinese, Arabic, Russian, accents, German & Scandinavian umlauts, ...) from the name. Symbols like dashes or underscores are no problem.
**Important note: On the SD card that comes with the printer there is a folder with Chinese characters in it by default. Please rename or remove it.**
Expand Down Expand Up @@ -78,6 +73,11 @@ I provided three different precompiled hex files: One for no modifications on th
- `M502` - load hard coded default values
- `M500` - save them to EEPROM

**If you are using this on a Mega-S, those two additional commands are necessary:**
- `M92 E384` - set correct steps for the new extruder
- `M500` - save them
- I highly recommend calibrating the extruder.

#### Calibration and other instructions have been moved to the [Wiki](https://github.com/davidramiro/Marlin-AI3M/wiki/Calibration).


Expand Down Expand Up @@ -182,6 +182,9 @@ G26 C H200 P25 R25
- Place `M600` in your GCode at the desired layer or send it via terminal
- Alternatively: Use `FilamentChange Pause` in the Special Menu
- The nozzle will park and your printer will beep
- For safety reasons, the printer will turn off the hotend after 10 minutes. If you see the temperature being under the target:
- SD printing: Click `CONTINUE` **(only once!)** on the screen and wait for the hotend to heat up again.
- USB printing: Send `M108` and wait for the hotend to heat up again.
- Remove the filament from the bowden tube
- Insert the new filament right up to the nozzle, just until a bit of plastic oozes out
- Remove the excess filament from the nozzle with tweezers
Expand All @@ -199,6 +202,9 @@ G26 C H200 P25 R25
- Alternatively: Use `FilamentChange Pause` in the Special Menu
- The nozzle will park
- The printer will remove the filament right up to the extruder and beep when finished
- For safety reasons, the printer will turn off the hotend after 10 minutes. If you see the temperature being under the target:
- SD printing: Click `CONTINUE` **(only once!)** on the screen and wait for the hotend to heat up again.
- USB printing: Send `M108` and wait for the hotend to heat up again.
- Insert the new filament just up to the end of the bowden fitting, as shown here:

![Load Filament][m600 load]
Expand Down

0 comments on commit 1a5804f

Please sign in to comment.