Skip to content

Commit

Permalink
fix kill: stop cutter after steppers, fix LASER_SPINDLE_POWERUP_DELAY
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndere1 committed Jan 16, 2025
1 parent 171d441 commit 810280c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
7 changes: 3 additions & 4 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand All @@ -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*/) {
Expand All @@ -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());
Expand Down
16 changes: 14 additions & 2 deletions Marlin/src/feature/spindle_laser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions Marlin/src/inc/Conditionals-4-adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion buildroot/tests/BTT_SKR_PRO
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion buildroot/tests/I3DBEEZ9_V1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions buildroot/tests/mega1280
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 810280c

Please sign in to comment.