From 810280c2e49e53b4c7f534308a8dee5b7a0bfc93 Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Tue, 14 Jan 2025 07:07:54 +0100 Subject: [PATCH] fix kill: stop cutter after steppers, fix LASER_SPINDLE_POWERUP_DELAY --- Marlin/src/MarlinCore.cpp | 7 +++---- Marlin/src/feature/spindle_laser.h | 16 ++++++++++++++-- Marlin/src/inc/Conditionals-4-adv.h | 9 +++++++++ Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/tool_change.cpp | 4 ---- buildroot/tests/BTT_SKR_PRO | 3 ++- buildroot/tests/I3DBEEZ9_V1 | 3 ++- buildroot/tests/mega1280 | 1 + 8 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 140423f25c76..8224b10e8047 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -895,8 +895,6 @@ void idle(const bool no_stepper_sleep/*=false*/) { void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { thermalManager.disable_all_heaters(); - TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control - // Echo the LCD message to serial for extra context if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLN(lcd_error); } @@ -916,6 +914,7 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp #endif minkill(steppers_off); + TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control } void minkill(const bool steppers_off/*=false*/) { @@ -931,11 +930,11 @@ void minkill(const bool steppers_off/*=false*/) { // Reiterate heaters off thermalManager.disable_all_heaters(); - TERN_(HAS_CUTTER, cutter.kill()); // Reiterate cutter shutdown - // Power off all steppers (for M112) or just the E steppers steppers_off ? stepper.disable_all_steppers() : stepper.disable_e_steppers(); + TERN_(HAS_CUTTER, cutter.kill()); // Cutter shutdown + TERN_(PSU_CONTROL, powerManager.power_off()); TERN_(HAS_SUICIDE, suicide()); diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 956e0b8ab9e0..bf5ca17e6ec6 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -231,14 +231,26 @@ class SpindleLaser { #if PIN_EXISTS(SPINDLE_LASER_ENA) WRITE(SPINDLE_LASER_ENA_PIN, enable ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); #endif - enable_state = enable; + if (enable_state != enable) { + power_delay(enable); + enable_state = enable; + } } static void disable() { isReadyForUI = false; set_enabled(false); } // Wait for spindle/laser to startup or shutdown static void power_delay(const bool on) { - safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); + #if ENABLED(SPINDLE_FEATURE) + if (active_tool_type == TYPE_SPINDLE) { + safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); + } + #endif + #if ENABLED(LASER_FEATURE) + if (active_tool_type == TYPE_LASER) { + safe_delay(on ? LASER_POWERUP_DELAY : LASER_POWERDOWN_DELAY); + } + #endif } #if ENABLED(SPINDLE_CHANGE_DIR) diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index bebbbb5ba6a7..74aaf1d544bf 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -1091,6 +1091,15 @@ #define CUTTER_UNIT_IS(V) (_CUTTER_POWER(CUTTER_POWER_UNIT) == _CUTTER_POWER(V)) #endif +#if ENABLED(LASER_FEATURE) + #ifndef LASER_POWERUP_DELAY + #define LASER_POWERUP_DELAY SPINDLE_LASER_POWERUP_DELAY + #endif + #ifndef LASER_POWERDOWN_DELAY + #define LASER_POWERDOWN_DELAY SPINDLE_LASER_POWERDOWN_DELAY + #endif +#endif + #if !defined(__AVR__) || !defined(USBCON) // Define constants and variables for buffering serial data. // Use only 0 or powers of 2 greater than 1 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 217405eae645..6d9848326c16 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2361,7 +2361,7 @@ void Temperature::task() { if (cooler.check_flow_too_low()) { TERN_(HAS_DISPLAY, if (cutter.enabled()) ui.flow_fault()); cutter.disable(); - cutter.cutter_mode = CUTTER_MODE_ERROR; // Immediately kill stepper inline power output + cutter.cutter_mode = CUTTER_MODE_ERROR; // Immediately kill inline power output of cutter } #endif #endif diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index e937c36a4e13..58a84051103c 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1264,7 +1264,6 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { cutter.inline_power(cutter.power); #endif cutter.set_enabled(false); - TERN_(SPINDLE_FEATURE, safe_delay(1000)); #endif #if ENABLED(COOLANT_MIST) @@ -1474,9 +1473,6 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { } #endif cutter.set_enabled(true); - if (TERN0(SPINDLE_FEATURE, cutter.active_tool_type = TYPE_SPINDLE)) { - safe_delay(1000); - } } #endif diff --git a/buildroot/tests/BTT_SKR_PRO b/buildroot/tests/BTT_SKR_PRO index ff8aae080f35..c35a68129981 100755 --- a/buildroot/tests/BTT_SKR_PRO +++ b/buildroot/tests/BTT_SKR_PRO @@ -25,6 +25,7 @@ restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ CUTTER_POWER_UNIT PERCENT \ LASER_PWM_PIN HEATER_1_PIN LASER_ENA_PIN HEATER_2_PIN \ - TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 + TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 \ + LASER_POWERUP_DELAY 50 LASER_POWERDOWN_DELAY 50 opt_enable LASER_FEATURE LASER_SAFETY_TIMEOUT_MS REPRAP_DISCOUNT_SMART_CONTROLLER exec_test $1 $2 "BigTreeTech SKR Pro | HD44780 | Laser (Percent) | Cooling | LCD" "$3" diff --git a/buildroot/tests/I3DBEEZ9_V1 b/buildroot/tests/I3DBEEZ9_V1 index 71122ca8ce8d..d51b79a21c90 100755 --- a/buildroot/tests/I3DBEEZ9_V1 +++ b/buildroot/tests/I3DBEEZ9_V1 @@ -25,6 +25,7 @@ restore_configs opt_set MOTHERBOARD BOARD_I3DBEEZ9_V1 SERIAL_PORT -1 \ CUTTER_POWER_UNIT PERCENT \ LASER_PWM_PIN HEATER_1_PIN LASER_ENA_PIN HEATER_2_PIN \ - TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 + TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 \ + LASER_POWERUP_DELAY 50 LASER_POWERDOWN_DELAY 50 opt_enable LASER_FEATURE LASER_SAFETY_TIMEOUT_MS REPRAP_DISCOUNT_SMART_CONTROLLER exec_test $1 $2 "I3DBEE Z9 Board | HD44780 | Laser (Percent) | Cooling | LCD" "$3" diff --git a/buildroot/tests/mega1280 b/buildroot/tests/mega1280 index 1b1a8f86b786..f13c723ad502 100755 --- a/buildroot/tests/mega1280 +++ b/buildroot/tests/mega1280 @@ -19,6 +19,7 @@ restore_configs opt_set LCD_LANGUAGE an \ POWER_MONITOR_CURRENT_PIN 14 POWER_MONITOR_VOLTAGE_PIN 15 \ CLOSED_LOOP_ENABLE_PIN 44 CLOSED_LOOP_MOVE_COMPLETE_PIN 45 + SPINDLE_LASER_POWERUP_DELAY 1000 SPINDLE_LASER_POWERDOWN_DELAY 1000 opt_enable SPINDLE_FEATURE ULTIMAKERCONTROLLER LCD_BED_LEVELING EDITABLE_HOMING_FEEDRATE \ EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ SENSORLESS_BACKOFF_MM HOMING_BACKOFF_POST_MM HOME_Y_BEFORE_X CODEPENDENT_XY_HOMING \