Add a bed check: warn about bumps and flatness, pause PRINT_START on a failure
BED_SCAN_CHECK levels, scans and warns, without heating or touching the bed. extras/mesh_check.py fits a smooth surface to the mesh and reports areas more than 0.03 mm from it, and a range over 0.30 mm. In PRINT_START a failed check pauses before the nozzle heats. Resume sets the print file back to the PRINT_START line (M26), so it runs again as normal file G-code. BED_CHECK_IGNORE lets the next failed check only warn. Tested on saved scans and rendered macros only, not yet on the printer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e540e40cf7
commit
99b7109b5b
7 files changed
+358
-5
No files matched your search
@@ -0,0 +1,137 @@
|
||||
# Bed check: scan the bed and warn about bumps, dips or too much height range
|
||||
# (needs extras/mesh_check.py, which explains the method and the limits)
|
||||
#
|
||||
# BED_SCAN_CHECK [BUMP=0.03] [RANGE=0.30]
|
||||
# Scan now and report. Warns only, for use between prints. No heating and
|
||||
# no contact: X and Y home if needed, Z homes with the Beacon's proximity
|
||||
# mode. Replaces the active mesh, like any scan.
|
||||
#
|
||||
# BED_MESH_CHECK [BUMP=0.03] [RANGE=0.30] (extras/mesh_check.py)
|
||||
# Only check the mesh that is loaded now.
|
||||
#
|
||||
# In PRINT_START a failed check pauses the print before the nozzle heats up:
|
||||
# the toolhead goes up and out of the way so the plate can be cleaned.
|
||||
# Resume levels, homes and scans again, and checks again
|
||||
# BED_CHECK_IGNORE then Resume: the next failed check only warns
|
||||
# Cancel works as usual.
|
||||
#
|
||||
# How the retry works: a PAUSE in a macro only stops the print file, the rest
|
||||
# of the macro still runs, so everything after the check sits in
|
||||
# _PRINT_START_FINISH and is only called when the check allows it. While a
|
||||
# line of the file runs, virtual_sdcard.file_position is the start of that
|
||||
# line. Resume sets the file back there (M26) and resumes, so the file runs
|
||||
# PRINT_START again, as normal print file G-code: an error stops the print as
|
||||
# it always does, which an error in a delayed_gcode would not (the file would
|
||||
# carry on with the first layer).
|
||||
#
|
||||
# The pause goes through PAUSE, so through AFC_PAUSE: AFC_RESUME always restores
|
||||
# AFC's saved position after a pause. Without saving it here, that could be a
|
||||
# stale position from an earlier print, or X0 Y0 (seen after HEAT_SOAK).
|
||||
# RESET_FAILURE first, because AFC does not save over a position it still holds.
|
||||
# PAUSE sees _BED_CHECK_STATE.pending and only pauses: no retract, no park at
|
||||
# the bucket, and RESUME skips _RESUME_PRINT and its purge (the filament is not
|
||||
# loaded yet at this point).
|
||||
|
||||
[mesh_check]
|
||||
bump_limit: 0.03
|
||||
range_limit: 0.30
|
||||
|
||||
[gcode_macro _BED_CHECK_STATE]
|
||||
description: Variables of the print start bed check
|
||||
variable_pending: False # paused by the check, the next RESUME retries
|
||||
variable_ignore: False # BED_CHECK_IGNORE: the next failed check only warns
|
||||
variable_file_position: 0 # start of the PRINT_START line in the print file
|
||||
variable_park_z: 100 # room to reach the plate; free of the bucket above Z10
|
||||
gcode:
|
||||
|
||||
[gcode_macro _BED_CHECK_RESET]
|
||||
description: Forget a pending bed check (start and end of a print)
|
||||
gcode:
|
||||
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=pending VALUE=False
|
||||
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=ignore VALUE=False
|
||||
|
||||
[gcode_macro BED_SCAN_CHECK]
|
||||
description: Scan the bed and warn about bumps, dips or too much height range (not during a print)
|
||||
gcode:
|
||||
{% set state = printer.print_stats.state %}
|
||||
{% if state in ('printing', 'paused') %}
|
||||
_ERROR MSG="BED_SCAN_CHECK: not during a print ({state})" DISPLAY="Bed scan: not during a print"
|
||||
{% else %}
|
||||
SAVE_GCODE_STATE NAME=_bed_scan_check
|
||||
G90
|
||||
{% if 'xy' not in printer.toolhead.homed_axes %}
|
||||
_GUARD_ON PHASE=bed_check_home_xy
|
||||
G28 X Y
|
||||
_GUARD_OFF
|
||||
{% endif %}
|
||||
{% if 'z' not in printer.toolhead.homed_axes %}
|
||||
_GUARD_ON PHASE=bed_check_home_z
|
||||
G28 Z METHOD=PROXIMITY
|
||||
_GUARD_OFF
|
||||
{% endif %}
|
||||
_GUARD_ON PHASE=bed_check_qgl
|
||||
QUAD_GANTRY_LEVEL
|
||||
_GUARD_ON PHASE=bed_check_z
|
||||
G28 Z METHOD=PROXIMITY
|
||||
_GUARD_ON PHASE=bed_check_mesh
|
||||
BED_MESH_CALIBRATE RUNS=2
|
||||
G1 Z10 F1200
|
||||
_GUARD_OFF
|
||||
RESTORE_GCODE_STATE NAME=_bed_scan_check
|
||||
BED_MESH_CHECK {rawparams}
|
||||
_BED_SCAN_CHECK_REPORT
|
||||
{% endif %}
|
||||
|
||||
# Separate macro: rendered after BED_MESH_CHECK has run
|
||||
[gcode_macro _BED_SCAN_CHECK_REPORT]
|
||||
description: Helper for BED_SCAN_CHECK: warn when the check failed
|
||||
gcode:
|
||||
{% set check = printer.mesh_check %}
|
||||
{% if check.result == 'fail' %}
|
||||
_WARN MSG="Bed check: {check.summary}. A bump usually means something on the plate: clean it and scan again." DISPLAY="Bed check failed, see console"
|
||||
{% elif check.result == 'none' %}
|
||||
_WARN MSG="Bed check not done: {check.summary}" DISPLAY="Bed check not done"
|
||||
{% else %}
|
||||
M117 Bed check OK
|
||||
{% endif %}
|
||||
|
||||
[gcode_macro BED_CHECK_IGNORE]
|
||||
description: After the print start bed check paused the print: the next failed check only warns (press Resume after this)
|
||||
gcode:
|
||||
{% if printer["gcode_macro _BED_CHECK_STATE"].pending %}
|
||||
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=ignore VALUE=True
|
||||
RESPOND MSG="Bed check: press Resume. It scans once more and continues even if the check still fails."
|
||||
{% else %}
|
||||
RESPOND MSG="Bed check: the print is not paused by the check, nothing to ignore"
|
||||
{% endif %}
|
||||
|
||||
# Called by _PRINT_START_GATE. FILE_POS: start of the PRINT_START line.
|
||||
[gcode_macro _BED_CHECK_PAUSE]
|
||||
description: Helper for PRINT_START: move away from the plate and pause, RESUME scans again
|
||||
gcode:
|
||||
{% set cfg = printer["gcode_macro _BED_CHECK_STATE"] %}
|
||||
{% set summary = printer.mesh_check.summary %}
|
||||
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=pending VALUE=True
|
||||
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=file_position VALUE={params.FILE_POS|int}
|
||||
G90
|
||||
_GUARD_ON PHASE=bed_check_park
|
||||
G1 Z{[cfg.park_z, printer.toolhead.axis_maximum.z - 5]|min} F1200
|
||||
G1 X175 Y340 F6000
|
||||
_GUARD_OFF
|
||||
RESET_FAILURE
|
||||
PAUSE
|
||||
_STATUS STATE=paused
|
||||
_WARN MSG="Bed check failed, print paused: {summary}. Clean the plate and press Resume to scan again. To print anyway: BED_CHECK_IGNORE, then Resume." DISPLAY="Bed check failed: clean plate, Resume"
|
||||
|
||||
# Called by RESUME instead of its normal chain while a check is pending.
|
||||
# AFC_RESUME then restores the position that AFC_PAUSE saved in _BED_CHECK_PAUSE.
|
||||
[gcode_macro _BED_CHECK_RETRY]
|
||||
description: Helper for RESUME: go back to the PRINT_START line of the print file and resume
|
||||
gcode:
|
||||
{% set cfg = printer["gcode_macro _BED_CHECK_STATE"] %}
|
||||
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=pending VALUE=False
|
||||
# Clear the pause reason from the display
|
||||
M117
|
||||
RESPOND MSG="Bed check: levelling and scanning again"
|
||||
M26 S{cfg.file_position|int}
|
||||
RESUME_BASE
|
||||
@@ -54,3 +54,4 @@
|
||||
|
||||
# Calibration
|
||||
[include calibration/twist_check.cfg] # TWIST_CALIBRATE: axis twist compensation, with windows in Mainsail (runs scripts/twist_check.py)
|
||||
[include calibration/bed_scan_check.cfg] # BED_SCAN_CHECK, BED_MESH_CHECK: bumps and flatness; PRINT_START pauses on a failed check (needs extras/mesh_check.py)
|
||||
@@ -16,6 +16,9 @@
|
||||
# (the lane AFC was loading when a tool change failed, otherwise the loaded
|
||||
# lane), and RESUME stops with an error when another lane (or none) is loaded.
|
||||
# RESUME LANE_CHECK=0 resumes anyway (e.g. after remapping with SET_MAP).
|
||||
# A failed bed check in PRINT_START (calibration/bed_scan_check.cfg) pauses with
|
||||
# _BED_CHECK_STATE.pending set: PAUSE then only pauses, and RESUME runs
|
||||
# PRINT_START again instead of this chain's purge and lane check.
|
||||
|
||||
# https://klipperscreen.readthedocs.io/en/latest/macros/#recommended
|
||||
[gcode_macro PAUSE]
|
||||
@@ -25,7 +28,9 @@ variable_saved_fan_speed: 0.0
|
||||
variable_parked: False # set by PAUSE, used by _RESUME_PRINT
|
||||
variable_expected_lane: '' # AFC lane the print needs after RESUME ('' = no check)
|
||||
gcode:
|
||||
{% if not printer.pause_resume.is_paused %}
|
||||
{% if printer["gcode_macro _BED_CHECK_STATE"].pending %}
|
||||
PAUSE_BASE
|
||||
{% elif not printer.pause_resume.is_paused %}
|
||||
# AFC sets next_lane during a tool change and still has it when a failed
|
||||
# change pauses the print; it clears it once CHANGE_TOOL returns
|
||||
{% if 'AFC' in printer %}
|
||||
@@ -54,7 +59,11 @@ gcode:
|
||||
description: Resume the print (while HEAT_SOAK runs: skip the soak phase)
|
||||
rename_existing: RESUME_BASE
|
||||
gcode:
|
||||
HEAT_SOAK_RESUME ON_RESUME=_RESUME_PRINT {rawparams}
|
||||
{% if printer["gcode_macro _BED_CHECK_STATE"].pending %}
|
||||
_BED_CHECK_RETRY
|
||||
{% else %}
|
||||
HEAT_SOAK_RESUME ON_RESUME=_RESUME_PRINT {rawparams}
|
||||
{% endif %}
|
||||
|
||||
[gcode_macro _RESUME_PRINT]
|
||||
description: Resume after PAUSE: purge and check (or unretract), restore the part fan, continue the print
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
# PRINT_START runs on a soaked bed:
|
||||
# PRINT_WARMUP bed heats while the nozzle cools and the printer homes,
|
||||
# wait for the bed, HEAT_SOAK
|
||||
# PRINT_START QGL, Z, contact Z calibration, mesh, load the initial tool,
|
||||
# PA for all lanes, XY reference
|
||||
# PRINT_START QGL, Z, contact Z calibration, mesh, bed check (a failed
|
||||
# check pauses, RESUME runs PRINT_START again, see
|
||||
# calibration/bed_scan_check.cfg), then _PRINT_START_FINISH:
|
||||
# load the initial tool, PA for all lanes, XY reference
|
||||
# The filament is loaded after the Z calibration, so the contact always
|
||||
# touches a clean nozzle that has not been oozing at 150C for minutes.
|
||||
# Chamber prints are the exception: PRINT_WARMUP loads and purges the first
|
||||
@@ -26,6 +28,7 @@ gcode:
|
||||
|
||||
RESET_FAILURE
|
||||
CLEAR_PAUSE
|
||||
_BED_CHECK_RESET
|
||||
# Clear what an earlier print or error left on the display
|
||||
M117
|
||||
|
||||
@@ -193,10 +196,14 @@ gcode:
|
||||
RESUME_BASE
|
||||
|
||||
[gcode_macro PRINT_START]
|
||||
description: Print start after HEAT_SOAK: QGL, Z calibration, mesh, load the initial tool, PA
|
||||
description: Print start after HEAT_SOAK: QGL, Z calibration, mesh, bed check, then _PRINT_START_FINISH
|
||||
gcode:
|
||||
{% set target_extruder = params.EXTRUDER|int %}
|
||||
{% set initial_tool = params.TOOL|default("0")|int %}
|
||||
# Rendered while this line of the print file runs: the start of the line,
|
||||
# where a retry after a failed bed check goes back to. -1: not from a file.
|
||||
{% set sd = printer.virtual_sdcard %}
|
||||
{% set file_pos = sd.file_position if sd.is_active else -1 %}
|
||||
|
||||
RESPOND MSG="print start macro continued"
|
||||
_LIGHTS_ON
|
||||
@@ -235,6 +242,35 @@ gcode:
|
||||
# From here on the nozzle extrudes and AFC cuts and loads: guard off
|
||||
_GUARD_OFF
|
||||
|
||||
BED_MESH_CHECK
|
||||
_PRINT_START_GATE EXTRUDER={target_extruder} TOOL={initial_tool} FILE_POS={file_pos}
|
||||
|
||||
# Separate macro: rendered after BED_MESH_CHECK has run. Pausing does not stop
|
||||
# a running macro, so what follows the check must not be in PRINT_START itself.
|
||||
[gcode_macro _PRINT_START_GATE]
|
||||
description: Helper for PRINT_START: pause when the bed check failed, else go on with _PRINT_START_FINISH
|
||||
gcode:
|
||||
{% set check = printer.mesh_check %}
|
||||
{% set ignore = printer["gcode_macro _BED_CHECK_STATE"].ignore %}
|
||||
{% set file_pos = params.FILE_POS|int %}
|
||||
{% if check.result == 'fail' and not ignore and file_pos >= 0 %}
|
||||
_BED_CHECK_PAUSE FILE_POS={file_pos}
|
||||
{% else %}
|
||||
{% if check.result == 'fail' %}
|
||||
_WARN MSG="Bed check failed, continuing: {check.summary}" DISPLAY="Bed check failed, continuing"
|
||||
{% elif check.result != 'ok' %}
|
||||
_WARN MSG="Bed check not done, continuing: {check.summary}" DISPLAY="Bed check not done"
|
||||
{% endif %}
|
||||
_BED_CHECK_RESET
|
||||
_PRINT_START_FINISH EXTRUDER={params.EXTRUDER} TOOL={params.TOOL}
|
||||
{% endif %}
|
||||
|
||||
[gcode_macro _PRINT_START_FINISH]
|
||||
description: Helper for PRINT_START after the bed check: load the initial tool, PA, XY reference
|
||||
gcode:
|
||||
{% set target_extruder = params.EXTRUDER|int %}
|
||||
{% set initial_tool = params.TOOL|default("0")|int %}
|
||||
|
||||
# Heat over the bucket, then undo the retracts of the previous PRINT_END
|
||||
_STATUS STATE=heating_extruder
|
||||
BLOBIFIER_PARK
|
||||
@@ -310,6 +346,7 @@ gcode:
|
||||
description: Heaters (incl. chamber heater) and part fan off, flow back to 100%, bdwidth off, mesh and skew cleared, nozzle guard off
|
||||
gcode:
|
||||
_GUARD_OFF ; a print start that failed while it was armed
|
||||
_BED_CHECK_RESET ; cancelled while the bed check had it paused
|
||||
TURN_OFF_HEATERS
|
||||
iHEATER_OFF ; stops the chamber heater control loop too
|
||||
M107
|
||||
|
||||
Reference in new issue
Block a user