Marlin icon indicating copy to clipboard operation
Marlin copied to clipboard

Adds ramp acceleration to FREEZE_FEATURE

Open Switchleg1 opened this issue 1 year ago • 3 comments

Simply removes the FREEZE_FEATURE instant halt code and adds a linear ramp of deceleration when pin is triggered and acceleration back to full speed on deactivation. Acceleration values are based on the current planner blocks and final jerk is set within the configuration file.

This is achieved by intercepting the calculated step_rate during Step::block_phase_isr() on each planner block stages (init/accel/decel/cruise) by tracking the time accumulated since triggering the freeze pin.

For example here is the deceleration implementation:

#if ENABLED(FREEZE_FEATURE) if(frozen_time) check_frozen_time(step_rate); #endif

// step_rate to timer interval and steps per stepper isr interval = calc_multistep_timer_interval(step_rate << oversampling_factor); deceleration_time += interval;

#if ENABLED(FREEZE_FEATURE) check_frozen_pin(1, interval); #endif

-->

Requirements

Should work on all boards, has been tested on mega2560.

Benefits

Prevents skipped steps when trying to pause a machine.

Configurations

Configuration_Adv.h

#define FREEZE_FEATURE #if ENABLED(FREEZE_FEATURE) #define FREEZE_PIN 5 // Override the default (KILL) pin here #define FREEZE_JERK 2 // Completely halt when motion has decelerated below this value #define FREEZE_STATE LOW // State of pin indicating freeze #endif

adds FREEZE_JERK as in the example above

Switchleg1 avatar Dec 16 '24 20:12 Switchleg1

I apologize for the multiple updates. Copying over from another branch it appears I missed a few lines.

Switchleg1 avatar Dec 16 '24 21:12 Switchleg1

This wording will also need to be adjusted (or options/defaults changed) since it will no longer be "instant": https://github.com/MarlinFirmware/Marlin/blob/4eb8a871930ef152e4fa73fc1782e2ed22348c85/Marlin/Configuration_adv.h#L4292

thisiskeithb avatar Dec 18 '24 06:12 thisiskeithb

Great addition. This comment is here to remind me that I will have to revise the cutter stop logic of the freeze feature if a combination of laser and spindle should be allowed in the future (https://github.com/MarlinFirmware/Marlin/pull/27614).

DerAndere1 avatar Jun 04 '25 20:06 DerAndere1