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 14, 2025
1 parent 171d441 commit 1e0750f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
9 changes: 4 additions & 5 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void startOrResumeJob() {

IF_DISABLED(SD_ABORT_NO_COOLDOWN, thermalManager.disable_all_heaters());

TERN(HAS_CUTTER, cutter.kill(), thermalManager.zero_fan_speeds()); // Full cutter shutdown including ISR control
TERN(HAS_CUTTER, cutter.kill_cutter(), thermalManager.zero_fan_speeds()); // Full cutter shutdown including ISR control

wait_for_heatup = false;

Expand Down 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_cutter()); // 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()); // 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
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

0 comments on commit 1e0750f

Please sign in to comment.