From 7ae399db86c8f2e13d8ac99a2d1f47119b3a23ba Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 26 Aug 2019 14:01:24 -0400 Subject: [PATCH 1/5] Initial Commit --- Marlin/src/Marlin.cpp | 10 ++++++++++ Marlin/src/gcode/control/M108_M112_M410.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index a548fc43a2ac..094261b043a5 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -747,6 +747,11 @@ void idle( */ void kill(PGM_P const lcd_msg/*=nullptr*/) { thermalManager.disable_all_heaters(); + stepper.quick_stop(); + disable_all_steppers(); + queue.stop(); + print_job_timer.stop(); + queue.clear(); SERIAL_ERROR_MSG(MSG_ERR_KILLED); @@ -774,6 +779,11 @@ void minkill() { for (int i = 1000; i--;) DELAY_US(250); thermalManager.disable_all_heaters(); // turn off heaters again + stepper.quick_stop(); + disable_all_steppers(); + queue.stop(); + print_job_timer.stop(); + queue.clear(); #if HAS_POWER_SWITCH PSU_OFF(); diff --git a/Marlin/src/gcode/control/M108_M112_M410.cpp b/Marlin/src/gcode/control/M108_M112_M410.cpp index 242aac1c0674..4796ca218ae7 100644 --- a/Marlin/src/gcode/control/M108_M112_M410.cpp +++ b/Marlin/src/gcode/control/M108_M112_M410.cpp @@ -41,7 +41,7 @@ void GcodeSuite::M108() { * M112: Emergency Stop */ void GcodeSuite::M112() { - kill(); + kill(PSTR("M112 Estop")); } /** From d439e6fdced33ef4b7d6f2d625d3425eb44ad69a Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 26 Aug 2019 16:54:19 -0400 Subject: [PATCH 2/5] Change Estop to Full Shutdown Reference to show minimal code changes, but documentation needs updating. --- Marlin/src/gcode/control/M108_M112_M410.cpp | 4 ++-- Marlin/src/gcode/control/M80_M81.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/module/planner.h | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/src/gcode/control/M108_M112_M410.cpp b/Marlin/src/gcode/control/M108_M112_M410.cpp index 4796ca218ae7..4668c6904ed4 100644 --- a/Marlin/src/gcode/control/M108_M112_M410.cpp +++ b/Marlin/src/gcode/control/M108_M112_M410.cpp @@ -38,10 +38,10 @@ void GcodeSuite::M108() { } /** - * M112: Emergency Stop + * M112: Full Shutdown */ void GcodeSuite::M112() { - kill(PSTR("M112 Estop")); + kill(PSTR("M112 Shutdown")); } /** diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index efb749501769..03f73fe87787 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -86,7 +86,7 @@ /** * M81: Turn off Power, including Power Supply, if there is one. * - * This code should ALWAYS be available for EMERGENCY SHUTDOWN! + * This code should ALWAYS be available for FULL SHUTDOWN! */ void GcodeSuite::M81() { thermalManager.disable_all_heaters(); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 91282d0ab5f2..49503b9b5cf9 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -407,7 +407,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #if DISABLED(EMERGENCY_PARSER) case 108: M108(); break; // M108: Cancel Waiting - case 112: M112(); break; // M112: Emergency Stop + case 112: M112(); break; // M112: Full Shutdown case 410: M410(); break; // M410: Quickstop - Abort all the planned moves. #if ENABLED(HOST_PROMPT_SUPPORT) case 876: M876(); break; // M876: Handle Host prompt responses diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index c12d5bde842c..c9b0cec2af33 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -132,7 +132,7 @@ * If AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F * M110 - Set the current line number. (Used by host printing) * M111 - Set debug flags: "M111 S". See flag bits defined in enum.h. - * M112 - Emergency stop. + * M112 - Full Shutdown. * M113 - Get or set the timeout interval for Host Keepalive "busy" messages. (Requires HOST_KEEPALIVE_FEATURE) * M114 - Report current position. * M115 - Report capabilities. (Extended capabilities requires EXTENDED_CAPABILITIES_REPORT) diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 38884cffa910..5afa3011b473 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -715,8 +715,8 @@ class Planner { FORCE_INLINE static float get_axis_position_degrees(const AxisEnum axis) { return get_axis_position_mm(axis); } #endif - // Called to force a quick stop of the machine (for example, when an emergency - // stop is required, or when endstops are hit) + // Called to force a quick stop of the machine (for example, when a Full Shutdown + // is required, or when endstops are hit) static void quick_stop(); // Called when an endstop is triggered. Causes the machine to stop inmediately From 484699f941719a39ec64a6e3e38765b9134ad09d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 26 Aug 2019 17:02:30 -0500 Subject: [PATCH 3/5] Update Marlin.cpp --- Marlin/src/Marlin.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 094261b043a5..20f86304eaa9 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -741,17 +741,21 @@ void idle( #endif } +// Kill heaters, job timer, and queue +void kill_activity() { + thermalManager.disable_all_heaters(); + stepper.quick_stop(); + //queue.stop(); + //print_job_timer.stop(); + //queue.clear(); +} + /** * Kill all activity and lock the machine. * After this the machine will need to be reset. */ void kill(PGM_P const lcd_msg/*=nullptr*/) { - thermalManager.disable_all_heaters(); - stepper.quick_stop(); - disable_all_steppers(); - queue.stop(); - print_job_timer.stop(); - queue.clear(); + kill_activity(); SERIAL_ERROR_MSG(MSG_ERR_KILLED); @@ -778,12 +782,7 @@ void minkill() { // Wait to ensure all interrupts stopped for (int i = 1000; i--;) DELAY_US(250); - thermalManager.disable_all_heaters(); // turn off heaters again - stepper.quick_stop(); - disable_all_steppers(); - queue.stop(); - print_job_timer.stop(); - queue.clear(); + kill_activity(); #if HAS_POWER_SWITCH PSU_OFF(); From c91acad711be957631d33468e4c8f772d8b38950 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Aug 2019 22:21:46 -0500 Subject: [PATCH 4/5] Update planner.h --- Marlin/src/module/planner.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 5afa3011b473..77cde6e2bf9e 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -715,8 +715,8 @@ class Planner { FORCE_INLINE static float get_axis_position_degrees(const AxisEnum axis) { return get_axis_position_mm(axis); } #endif - // Called to force a quick stop of the machine (for example, when a Full Shutdown - // is required, or when endstops are hit) + // Called to force a quick stop of the machine (for example, when + // a Full Shutdown is required, or when endstops are hit) static void quick_stop(); // Called when an endstop is triggered. Causes the machine to stop inmediately From 27e1e7ffb747641168ac2dcf69305ea26cd90701 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Aug 2019 22:33:43 -0500 Subject: [PATCH 5/5] M112 kills steppers in all cases --- Marlin/src/Marlin.cpp | 23 ++++++++------------- Marlin/src/Marlin.h | 4 ++-- Marlin/src/gcode/control/M108_M112_M410.cpp | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 20f86304eaa9..68f37d2a7253 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -741,21 +741,12 @@ void idle( #endif } -// Kill heaters, job timer, and queue -void kill_activity() { - thermalManager.disable_all_heaters(); - stepper.quick_stop(); - //queue.stop(); - //print_job_timer.stop(); - //queue.clear(); -} - /** * Kill all activity and lock the machine. * After this the machine will need to be reset. */ -void kill(PGM_P const lcd_msg/*=nullptr*/) { - kill_activity(); +void kill(PGM_P const lcd_msg/*=nullptr*/, const bool steppers_off/*=false*/) { + thermalManager.disable_all_heaters(); SERIAL_ERROR_MSG(MSG_ERR_KILLED); @@ -769,10 +760,10 @@ void kill(PGM_P const lcd_msg/*=nullptr*/) { host_action_kill(); #endif - minkill(); + minkill(steppers_off); } -void minkill() { +void minkill(const bool steppers_off/*=false*/) { // Wait a short time (allows messages to get out before shutting down. for (int i = 1000; i--;) DELAY_US(600); @@ -782,7 +773,11 @@ void minkill() { // Wait to ensure all interrupts stopped for (int i = 1000; i--;) DELAY_US(250); - kill_activity(); + // Reiterate heaters off + thermalManager.disable_all_heaters(); + + // Power off all steppers (for M112) or just the E steppers + steppers_off ? disable_all_steppers() : disable_e_steppers(); #if HAS_POWER_SWITCH PSU_OFF(); diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index db24382bc8d2..1a9acc007582 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -322,8 +322,8 @@ void disable_e_stepper(const uint8_t e); void disable_e_steppers(); void disable_all_steppers(); -void kill(PGM_P const lcd_msg=nullptr); -void minkill(); +void kill(PGM_P const lcd_msg=nullptr, const bool steppers_off=false); +void minkill(const bool steppers_off=false); void quickstop_stepper(); diff --git a/Marlin/src/gcode/control/M108_M112_M410.cpp b/Marlin/src/gcode/control/M108_M112_M410.cpp index 4668c6904ed4..9b6193bd9309 100644 --- a/Marlin/src/gcode/control/M108_M112_M410.cpp +++ b/Marlin/src/gcode/control/M108_M112_M410.cpp @@ -41,7 +41,7 @@ void GcodeSuite::M108() { * M112: Full Shutdown */ void GcodeSuite::M112() { - kill(PSTR("M112 Shutdown")); + kill(PSTR("M112 Shutdown"), true); } /**