From c1425aece32d853f7887dc44cfc4016c060a2e31 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 13 Jun 2018 16:22:06 +0200 Subject: [PATCH 1/4] gcode: set safety timer period --- Firmware/Marlin_main.cpp | 13 ++++++++++++- Firmware/Timer.cpp | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index ab1ce505..658c7f27 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -194,6 +194,7 @@ // M84 - Disable steppers until next move, // or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout. // M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) +// M86 - Set safety timer expiration time with parameter S; M86 S0 will disable safety timer // M92 - Set axis_steps_per_unit - same syntax as G92 // M104 - Set extruder target temp // M105 - Read current temp @@ -492,6 +493,7 @@ const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42 static unsigned long previous_millis_cmd = 0; unsigned long max_inactive_time = 0; static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l; +static unsigned long safetytimer_inactive_time = DEFAULT_SAFETYTIMER_TIME_MINS*60*1000ul; unsigned long starttime=0; unsigned long stoptime=0; @@ -5434,6 +5436,15 @@ Sigma_Exit: max_inactive_time = code_value() * 1000; } break; +#ifdef SAFETYTIMER + case 86: // M86 - set safety timer expiration time in seconds; M86 S0 will disable safety timer + //when safety timer expires heatbed and nozzle target temperatures are set to zero + if (code_seen('S')) { + safetytimer_inactive_time = code_value() * 1000; + safetyTimer.start(); + } + break; +#endif case 92: // M92 for(int8_t i=0; i < NUM_AXIS; i++) { @@ -7436,7 +7447,7 @@ static void handleSafetyTimer() { safetyTimer.start(); } - else if (safetyTimer.expired(1800000ul)) //30 min + else if (safetyTimer.expired(safetytimer_inactive_time)) //30 min { setTargetBed(0); setTargetHotend(0, 0); diff --git a/Firmware/Timer.cpp b/Firmware/Timer.cpp index ecf9b9b9..792c2ca8 100644 --- a/Firmware/Timer.cpp +++ b/Firmware/Timer.cpp @@ -43,7 +43,7 @@ void Timer::start() template bool Timer::expired(T msPeriod) { - if (!m_isRunning) return false; + if ((!m_isRunning) || (!msPeriod)) return false; bool expired = false; const T now = millis(); if (m_started <= m_started + msPeriod) From 75c6f0b937406987a702b1c2766397ea48499e31 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 13 Jun 2018 16:27:11 +0200 Subject: [PATCH 2/4] variant files updated --- Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h | 4 ++++ Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h | 4 ++++ Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h | 1 + Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h | 1 + Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 1 + 5 files changed, 11 insertions(+) diff --git a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h index d366d429..c7e9e59e 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h @@ -422,6 +422,10 @@ THERMISTORS SETTINGS #define END_FILE_SECTION 10000 //number of bytes from end of file used for checking if file is complete +// Safety timer +#define SAFETYTIMER +#define DEFAULT_SAFETYTIMER_TIME_MINS 30 + #define M600_TIMEOUT 600 //seconds #ifndef SNMM diff --git a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h index df676383..022c3293 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h @@ -422,6 +422,10 @@ THERMISTORS SETTINGS #define END_FILE_SECTION 10000 //number of bytes from end of file used for checking if file is complete +// Safety timer +#define SAFETYTIMER +#define DEFAULT_SAFETYTIMER_TIME_MINS 30 + #define M600_TIMEOUT 600 //seconds #ifndef SNMM diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index c7e1421b..d07ab986 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -106,6 +106,7 @@ // Safety timer #define SAFETYTIMER +#define DEFAULT_SAFETYTIMER_TIME_MINS 30 // Filament sensor #define PAT9125 diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index a8f07916..d019c758 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -106,6 +106,7 @@ // Safety timer #define SAFETYTIMER +#define DEFAULT_SAFETYTIMER_TIME_MINS 30 // Filament sensor #define PAT9125 diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index d78a737c..2cf61d55 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -130,6 +130,7 @@ // Safety timer #define SAFETYTIMER +#define DEFAULT_SAFETYTIMER_TIME_MINS 30 // Filament sensor #define PAT9125 From 2026e7fe4d599c2bd01cc875bc8b37606ff5885d Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 14 Jun 2018 13:14:14 +0200 Subject: [PATCH 3/4] Revert changes in Timer class; disable safety timer in handleSafetyTimer function if safetytimer inactive time was set to zero --- Firmware/Marlin_main.cpp | 2 +- Firmware/Timer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 254b526f..d953811d 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7439,7 +7439,7 @@ static void handleSafetyTimer() #if (EXTRUDERS > 1) #error Implemented only for one extruder. #endif //(EXTRUDERS > 1) - if ((PRINTER_ACTIVE) || (!degTargetBed() && !degTargetHotend(0))) + if ((PRINTER_ACTIVE) || (!degTargetBed() && !degTargetHotend(0)) || (!safetytimer_inactive_time)) { safetyTimer.stop(); } diff --git a/Firmware/Timer.cpp b/Firmware/Timer.cpp index 792c2ca8..ecf9b9b9 100644 --- a/Firmware/Timer.cpp +++ b/Firmware/Timer.cpp @@ -43,7 +43,7 @@ void Timer::start() template bool Timer::expired(T msPeriod) { - if ((!m_isRunning) || (!msPeriod)) return false; + if (!m_isRunning) return false; bool expired = false; const T now = millis(); if (m_started <= m_started + msPeriod) From ed2f87f4f5e1a86690c2e7299fa50e23125f12e8 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 14 Jun 2018 17:29:40 +0200 Subject: [PATCH 4/4] documentation updated --- Firmware/Marlin_main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d953811d..58e8cec8 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7428,11 +7428,13 @@ void handle_status_leds(void) { #ifdef SAFETYTIMER /** - * @brief Turn off heating after 30 minutes of inactivity + * @brief Turn off heating after safetytimer_inactive_time milliseconds of inactivity * * Full screen blocking notification message is shown after heater turning off. * Paused print is not considered inactivity, as nozzle is cooled anyway and bed cooling would * damage print. + * + * If safetytimer_inactive_time is zero, feature is disabled (heating is never turned off because of inactivity) */ static void handleSafetyTimer() { @@ -7447,7 +7449,7 @@ static void handleSafetyTimer() { safetyTimer.start(); } - else if (safetyTimer.expired(safetytimer_inactive_time)) //30 min + else if (safetyTimer.expired(safetytimer_inactive_time)) { setTargetBed(0); setTargetHotend(0, 0);