Skip to content

Commit

Permalink
start_end: Speed up START_PRINT
Browse files Browse the repository at this point in the history
* Skip parking, etc. when heaters are already at target.
* Added parameter to skip Z rehoming when bed hits temp.
  • Loading branch information
jschuh committed Feb 2, 2023
1 parent 1c6e547 commit 28da2a9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
2 changes: 2 additions & 0 deletions globals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ variable_start_bed_heat_delay: 2000
variable_start_bed_heat_overshoot: 2.0
# Set to level bed in PRINT_START after stabilizing at temp; set 0 to disable.
variable_start_level_bed_at_temp: True
# Set to rehome the Z in PRINT_START after the bed temperature stabilizes.
variable_start_home_z_at_temp: True
# Set to clear adjustments (e.g. feedrate, extrusion, heater) at end of print.
variable_start_clear_adjustments_at_end: True
# Length of filament (in millimeters) to purge at print start.
Expand Down
41 changes: 36 additions & 5 deletions start_end.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ gcode:
{% set NOZZLE_SIZE = params.NOZZLE_SIZE|default(settings.NOZZLE_SIZE)|
default(printer.configfile.settings.extruder.nozzle_diameter)|float %}
{% set km = printer["gcode_macro _km_globals"] %}
{% set bed_overshoot = (BED + (km.start_bed_heat_overshoot if BED else 0.0),
{% set bed_at_target = (BED - printer.heater_bed.temperature)|abs < 0.3 %}
{% set bed_overshoot = (BED + (km.start_bed_heat_overshoot if
(BED and not bed_at_target) else 0.0),
printer.configfile.settings.heater_bed.max_temp ) | min %}

INIT_LAYER_GCODE LAYERS="{LAYERS}"
Expand All @@ -39,25 +41,30 @@ gcode:
# home all axes
G28
G90
PARK
{% if BED > 0.0 %}
# Skip this if the bed was already at target when START_PRINT was called.
{% if BED > 0.0 and not bed_at_target %}
PARK
# Overshoot the target a bit.
M190 S{bed_overshoot}
G4 P{km.start_bed_heat_delay / 2}
M190 R{BED} # Settle down after the overshoot.
G4 P{km.start_bed_heat_delay / 2}
{% endif %}
{% if CHAMBER > 0.0 %}
_KM_PARK_IF_NEEDED HEATER="chamber" RANGE=ABOVE
M191 S{CHAMBER}
{% endif %}
{% if km.start_level_bed_at_temp %}
M104 S{EXTRUDER} # set the final extruder target temperature
G28 Z # Re-home only the Z axis now that the bed has stabilized.
{% if km.start_home_z_at_temp and not bed_at_target %}
G28 Z # Re-home only the Z axis now that the bed has stabilized.
{% endif %}
BED_MESH_CALIBRATE_FAST{% if MESH_MIN %} MESH_MIN={MESH_MIN}{% endif
%}{% if MESH_MAX %} MESH_MAX={MESH_MAX}{% endif %}
PARK
G4
{% endif %}
# Wait for extruder to reach temperature
_KM_PARK_IF_NEEDED HEATER={printer.toolhead.extruder} RANGE=ABOVE
M109 S{EXTRUDER}
# apply Z offset for bed surface (just in case it was reset).
_APPLY_BED_SURFACE_OFFSET
Expand All @@ -67,6 +74,30 @@ gcode:
%}{% if MESH_MAX %} PRINT_MAX={MESH_MAX}{% endif %}
{% endif %}

[gcode_macro _km_park_if_needed]
description: Parks the extruder if the current temperature of the supplied
heater is not within the specified target range.
Usage: _KM_PARK_IF_NEEDED HEATER=<heater> RANGE=[<percentage>|ABOVE|BELOW]
gcode:
# This needs to get called as its own macro to get the current temp evaluated.
{% set HEATER = params.HEATER %}
{% set RANGE = (params.RANGE|default(1))|string|upper %}

{% if printer[HEATER].target %}
{% if RANGE == "ABOVE" %}
{% if printer[HEATER].temperature < printer[HEATER].target %}
PARK
{% endif %}
{% elif RANGE == "BELOW" %}
{% if printer[HEATER].temperature > printer[HEATER].target %}
PARK
{% endif %}
{% elif (printer[HEATER].temperature - printer[HEATER].target)|abs >
(printer[HEATER].target * RANGE|float * 0.01)|abs %}
PARK
{% endif %}
{% endif %}

[gcode_macro print_start_set]
description: Inserted by slicer to set values used by PRINT_START.
Usage: PRINT_START_SET <VARIABLE>=<value>
Expand Down

0 comments on commit 28da2a9

Please sign in to comment.