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
+357
-4
No files matched your search
@@ -57,6 +57,11 @@ detection, `filament_error_sensitivity`), iHeater chamber heater.
|
|||||||
After a PAUSE, `_RESUME_PRINT` first purges with `BLOBIFIER_CHECKED`
|
After a PAUSE, `_RESUME_PRINT` first purges with `BLOBIFIER_CHECKED`
|
||||||
(`_RESUME_PURGE`); a failed check raises an error, which aborts the whole
|
(`_RESUME_PURGE`); a failed check raises an error, which aborts the whole
|
||||||
chain (AFC_RESUME's restore too), so the printer stays paused.
|
chain (AFC_RESUME's restore too), so the printer stays paused.
|
||||||
|
- 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`
|
||||||
|
calls `_BED_CHECK_RETRY`, which sets the print file back to the `PRINT_START`
|
||||||
|
line (`M26`) and resumes. Everything after the check belongs in
|
||||||
|
`_PRINT_START_FINISH`: a pause does not stop a running macro.
|
||||||
- Only one `[save_variables]`, in `macros/save_variables.cfg`.
|
- Only one `[save_variables]`, in `macros/save_variables.cfg`.
|
||||||
- `PRINT_END` and `CANCEL_PRINT` share `_PRINT_CLEANUP` (heaters including
|
- `PRINT_END` and `CANCEL_PRINT` share `_PRINT_CLEANUP` (heaters including
|
||||||
`iHEATER_OFF`, fan, `M221 S100`, bdwidth off). Anything that must happen
|
`iHEATER_OFF`, fan, `M221 S100`, bdwidth off). Anything that must happen
|
||||||
@@ -106,6 +111,9 @@ detection, `filament_error_sensitivity`), iHeater chamber heater.
|
|||||||
in log mode); a light finger push on the cold nozzle gives 41
|
in log mode); a light finger push on the cold nozzle gives 41
|
||||||
(threshold 30).
|
(threshold 30).
|
||||||
- Z check after a contact homing: Beacon vs Klipper Z about 0.06 mm.
|
- Z check after a contact homing: Beacon vs Klipper Z about 0.06 mm.
|
||||||
|
- Bed check (mesh_check, limits 0.03 and 0.30 mm): clean plate, worst deviation
|
||||||
|
0.016 mm cold and on a hot PLA print, range 0.12-0.17. Residue on the plate:
|
||||||
|
0.06-0.09 mm with the mesh ending at its edge, 0.30 mm with the mesh over it.
|
||||||
- XY drift check: endstop noise about 0.01-0.02 mm; limit 0.1 mm (one motor
|
- XY drift check: endstop noise about 0.01-0.02 mm; limit 0.1 mm (one motor
|
||||||
skipping one cycle = 0.4 mm shows as 0.2 mm in X and Y).
|
skipping one cycle = 0.4 mm shows as 0.2 mm in X and Y).
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ everything below, grouped by topic. Comment out what you do not use there.
|
|||||||
|
|
||||||
| **calibration/** | | |
|
| **calibration/** | | |
|
||||||
| `twist_check.cfg` + `scripts/twist_check.py` | `TWIST_CALIBRATE`: axis twist calibration from Mainsail with windows that explain each step. Measure (25 min) says whether new `[axis_twist_compensation]` values are needed, Verify (17 min) checks them with bd_pressure. Progress on the status line, result in a window, HTML report with charts in `config/twist_data/`. Never changes `printer.cfg`. `TWIST_STOP` stops a run. | Beacon, `[axis_twist_compensation]`, `gcode_shell_command`, Mainsail prompts; Verify also `bdp_touch.py` |
|
| `twist_check.cfg` + `scripts/twist_check.py` | `TWIST_CALIBRATE`: axis twist calibration from Mainsail with windows that explain each step. Measure (25 min) says whether new `[axis_twist_compensation]` values are needed, Verify (17 min) checks them with bd_pressure. Progress on the status line, result in a window, HTML report with charts in `config/twist_data/`. Never changes `printer.cfg`. `TWIST_STOP` stops a run. | Beacon, `[axis_twist_compensation]`, `gcode_shell_command`, Mainsail prompts; Verify also `bdp_touch.py` |
|
||||||
|
| `bed_scan_check.cfg` | `BED_SCAN_CHECK [BUMP=0.03] [RANGE=0.30]`: levels, scans and warns about bumps, dips or too much height range, without heating or touching the bed. In `PRINT_START` a failed check pauses before the nozzle heats and moves the toolhead away: clean the plate and Resume, which runs `PRINT_START` again from QGL with a new scan and check. `BED_CHECK_IGNORE`, then Resume: the next failed check only warns | `extras/mesh_check.py`, Beacon, AFC |
|
||||||
|
|
||||||
### Klipper modules (`extras/`)
|
### Klipper modules (`extras/`)
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ everything below, grouped by topic. Comment out what you do not use there.
|
|||||||
| `bdpressure_check.py` | bd_pressure load check (`BDP_CHECK_START/STOP/QUERY`). Needs the load-check firmware from the bd_pressure `load-check-extension` branch; on stock firmware it reports "not available" and does nothing. Also reports how many readings the last `PA_CALIBRATE` got (`pa_points`, `pa_distinct`), used to reject runs with a silent or stuck sensor. |
|
| `bdpressure_check.py` | bd_pressure load check (`BDP_CHECK_START/STOP/QUERY`). Needs the load-check firmware from the bd_pressure `load-check-extension` branch; on stock firmware it reports "not available" and does nothing. Also reports how many readings the last `PA_CALIBRATE` got (`pa_points`, `pa_distinct`), used to reject runs with a silent or stuck sensor. |
|
||||||
| `bdp_guard.py` | nozzle collision guard: while armed (`BDP_GUARD_ARM/DISARM/QUERY`) reads the bd_pressure force every 20 ms over I2C and, in stop mode, shuts Klipper down when it stays above the threshold. Reports reads, peak and errors per phase in the console and klippy.log. When it arms and finds the sensor still in PA mode (an emergency stop during `PA_CALIBRATE`; `FIRMWARE_RESTART` does not reset the sensor), it switches it to probe mode and takes a new zero first. Puts a lock on the sensor's I2C connection that `bdpressure.py` and `bdpressure_check.py` also go through (Klipper allows one I2C request at a time per device). Needs the load-check firmware. |
|
| `bdp_guard.py` | nozzle collision guard: while armed (`BDP_GUARD_ARM/DISARM/QUERY`) reads the bd_pressure force every 20 ms over I2C and, in stop mode, shuts Klipper down when it stays above the threshold. Reports reads, peak and errors per phase in the console and klippy.log. When it arms and finds the sensor still in PA mode (an emergency stop during `PA_CALIBRATE`; `FIRMWARE_RESTART` does not reset the sensor), it switches it to probe mode and takes a new zero first. Puts a lock on the sensor's I2C connection that `bdpressure.py` and `bdpressure_check.py` also go through (Klipper allows one I2C request at a time per device). Needs the load-check firmware. |
|
||||||
| `bdp_touch.py` | `BDP_TOUCH`: lowers the nozzle in one slow continuous move (drip mode, like a homing move) while reading the bd_pressure force as fast as I2C allows (its endstop output is not wired), stops at a force limit (default 60) or 0.5 mm below the start, then lifts back; it must be one quick press, because the sensor re-zeros itself while the force looks steady; reports the height where the force reaches the threshold and the zero-force height from a line fit, and logs the whole curve to klippy.log. `_TOUCH_COMPARE`: alternates that with Beacon's contact probe. Refuses while the bdp_guard is armed or the sensor is in PA mode. Needs the load-check firmware. |
|
| `bdp_touch.py` | `BDP_TOUCH`: lowers the nozzle in one slow continuous move (drip mode, like a homing move) while reading the bd_pressure force as fast as I2C allows (its endstop output is not wired), stops at a force limit (default 60) or 0.5 mm below the start, then lifts back; it must be one quick press, because the sensor re-zeros itself while the force looks steady; reports the height where the force reaches the threshold and the zero-force height from a line fit, and logs the whole curve to klippy.log. `_TOUCH_COMPARE`: alternates that with Beacon's contact probe. Refuses while the bdp_guard is armed or the sensor is in PA mode. Needs the load-check firmware. |
|
||||||
|
| `mesh_check.py` | `BED_MESH_CHECK`: fits a smooth surface to the loaded mesh and reports the height range and every area further from it than the limit, with its position. Only reads the mesh. Needs numpy (Beacon needs it too). |
|
||||||
|
|
||||||
### Scripts (`scripts/`)
|
### Scripts (`scripts/`)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
# Checks the loaded bed mesh for bumps, dips and too much height range.
|
||||||
|
#
|
||||||
|
# The bed is naturally bowl-shaped, so a height range alone cannot tell dirt
|
||||||
|
# from normal shape. This fits a smooth surface (polynomial, degree 4) to the
|
||||||
|
# probed points, leaving out outliers, and looks at how far each point is from
|
||||||
|
# it. Measured on this printer's Beacon scans (33x35 points):
|
||||||
|
# clean plate, cold or hot: worst deviation 0.016 mm
|
||||||
|
# residue on the plate, 2026-11: 0.07 (bed 60C), 0.09 (bed 100C, at the old
|
||||||
|
# mesh edge), 0.30 mm (cold, mesh over it)
|
||||||
|
# Only reads the mesh: it moves nothing and changes nothing.
|
||||||
|
#
|
||||||
|
# Install: copy to ~/klipper/klippy/extras/mesh_check.py (install.sh links it)
|
||||||
|
# and add
|
||||||
|
#
|
||||||
|
# [mesh_check]
|
||||||
|
# bump_limit: 0.03 # mm from the smooth surface that counts as a bump or dip
|
||||||
|
# range_limit: 0.30 # mm between the highest and lowest point
|
||||||
|
#
|
||||||
|
# Commands:
|
||||||
|
# BED_MESH_CHECK [BUMP=<mm>] [RANGE=<mm>]
|
||||||
|
#
|
||||||
|
# Status (printer.mesh_check): result ('ok', 'fail', 'none' = no mesh or the
|
||||||
|
# check failed, 'not run'), range, worst, areas (number of bumps and dips),
|
||||||
|
# summary (no double quotes, usable in a macro's MSG="...")
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
DEGREE = 4
|
||||||
|
MAX_AREAS = 5 # areas named in the report, biggest deviation first
|
||||||
|
MIN_POINTS = 40 # fewer points cannot carry a degree 4 surface reliably
|
||||||
|
|
||||||
|
|
||||||
|
def surface_residuals(z):
|
||||||
|
# Deviation of each point from a smooth surface. Refit without the points
|
||||||
|
# far from it, so a bump does not pull the surface towards itself.
|
||||||
|
ny, nx = z.shape
|
||||||
|
x, y = np.meshgrid(np.linspace(-1., 1., nx), np.linspace(-1., 1., ny))
|
||||||
|
terms = [x.ravel()**i * y.ravel()**j
|
||||||
|
for i in range(DEGREE + 1) for j in range(DEGREE + 1 - i)]
|
||||||
|
a = np.column_stack(terms)
|
||||||
|
values = z.ravel()
|
||||||
|
keep = np.ones(values.size, dtype=bool)
|
||||||
|
residuals = np.zeros(values.size)
|
||||||
|
for _ in range(5):
|
||||||
|
coeffs = np.linalg.lstsq(a[keep], values[keep], rcond=None)[0]
|
||||||
|
residuals = values - a.dot(coeffs)
|
||||||
|
spread = 1.4826 * np.median(
|
||||||
|
np.abs(residuals[keep] - np.median(residuals[keep])))
|
||||||
|
keep = np.abs(residuals) < max(3. * spread, 0.01)
|
||||||
|
return residuals.reshape(z.shape)
|
||||||
|
|
||||||
|
|
||||||
|
def find_areas(residuals, limit):
|
||||||
|
# Groups of touching points (diagonals too) beyond the limit, as
|
||||||
|
# (peak, row min, row max, column min, column max)
|
||||||
|
ny, nx = residuals.shape
|
||||||
|
over = np.abs(residuals) > limit
|
||||||
|
seen = np.zeros(over.shape, dtype=bool)
|
||||||
|
areas = []
|
||||||
|
for start in zip(*np.nonzero(over)):
|
||||||
|
if seen[start]:
|
||||||
|
continue
|
||||||
|
seen[start] = True
|
||||||
|
stack = [start]
|
||||||
|
points = []
|
||||||
|
while stack:
|
||||||
|
j, i = stack.pop()
|
||||||
|
points.append((j, i))
|
||||||
|
for dj in (-1, 0, 1):
|
||||||
|
for di in (-1, 0, 1):
|
||||||
|
nj, ni = j + dj, i + di
|
||||||
|
if (0 <= nj < ny and 0 <= ni < nx and over[nj, ni]
|
||||||
|
and not seen[nj, ni]):
|
||||||
|
seen[nj, ni] = True
|
||||||
|
stack.append((nj, ni))
|
||||||
|
peak = max((residuals[p] for p in points), key=abs)
|
||||||
|
rows = [p[0] for p in points]
|
||||||
|
cols = [p[1] for p in points]
|
||||||
|
areas.append((float(peak), min(rows), max(rows), min(cols), max(cols)))
|
||||||
|
areas.sort(key=lambda area: -abs(area[0]))
|
||||||
|
return areas
|
||||||
|
|
||||||
|
|
||||||
|
def analyse(matrix, mesh_min, mesh_max, bump_limit, range_limit):
|
||||||
|
# Returns the status dictionary. No Klipper objects, so it can be tested
|
||||||
|
# against saved scans.
|
||||||
|
z = np.array(matrix, dtype=float)
|
||||||
|
if z.ndim != 2 or z.size == 0:
|
||||||
|
return {'result': 'none', 'range': 0., 'worst': 0., 'areas': 0,
|
||||||
|
'summary': 'no bed mesh loaded'}
|
||||||
|
height_range = float(z.max() - z.min())
|
||||||
|
ny, nx = z.shape
|
||||||
|
if z.size < MIN_POINTS:
|
||||||
|
return {'result': 'none', 'range': height_range, 'worst': 0.,
|
||||||
|
'areas': 0,
|
||||||
|
'summary': 'mesh too small to check (%d points)' % (z.size,)}
|
||||||
|
residuals = surface_residuals(z)
|
||||||
|
worst = float(np.abs(residuals).max())
|
||||||
|
areas = find_areas(residuals, bump_limit)
|
||||||
|
step_x = (mesh_max[0] - mesh_min[0]) / float(nx - 1)
|
||||||
|
step_y = (mesh_max[1] - mesh_min[1]) / float(ny - 1)
|
||||||
|
problems = []
|
||||||
|
for peak, row0, row1, col0, col1 in areas[:MAX_AREAS]:
|
||||||
|
problems.append("%s %+.2f mm at X%.0f-%.0f Y%.0f-%.0f" % (
|
||||||
|
"bump" if peak > 0. else "dip", peak,
|
||||||
|
mesh_min[0] + col0 * step_x, mesh_min[0] + col1 * step_x,
|
||||||
|
mesh_min[1] + row0 * step_y, mesh_min[1] + row1 * step_y))
|
||||||
|
if len(areas) > MAX_AREAS:
|
||||||
|
problems.append("%d more" % (len(areas) - MAX_AREAS,))
|
||||||
|
too_wide = height_range > range_limit
|
||||||
|
if too_wide:
|
||||||
|
problems.append("range %.2f mm is over the limit of %.2f" % (
|
||||||
|
height_range, range_limit))
|
||||||
|
text = "range %.3f mm, worst deviation %.3f mm" % (height_range, worst)
|
||||||
|
if problems:
|
||||||
|
text = "%s: %s" % (text, ", ".join(problems))
|
||||||
|
return {'result': 'fail' if problems else 'ok', 'range': height_range,
|
||||||
|
'worst': worst, 'areas': len(areas), 'summary': text}
|
||||||
|
|
||||||
|
|
||||||
|
class MeshCheck:
|
||||||
|
def __init__(self, config):
|
||||||
|
self.printer = config.get_printer()
|
||||||
|
self.reactor = self.printer.get_reactor()
|
||||||
|
self.bump_limit = config.getfloat('bump_limit', 0.03, above=0.)
|
||||||
|
self.range_limit = config.getfloat('range_limit', 0.30, above=0.)
|
||||||
|
self.status = {'result': 'not run', 'range': 0., 'worst': 0.,
|
||||||
|
'areas': 0, 'summary': ''}
|
||||||
|
gcode = self.printer.lookup_object('gcode')
|
||||||
|
gcode.register_command('BED_MESH_CHECK', self.cmd_BED_MESH_CHECK,
|
||||||
|
desc="Check the loaded bed mesh for bumps, "
|
||||||
|
"dips and too much height range")
|
||||||
|
|
||||||
|
def cmd_BED_MESH_CHECK(self, gcmd):
|
||||||
|
bump = gcmd.get_float('BUMP', self.bump_limit, above=0.)
|
||||||
|
height_range = gcmd.get_float('RANGE', self.range_limit, above=0.)
|
||||||
|
# A failing analysis must not stop a print: it reports and goes on
|
||||||
|
try:
|
||||||
|
bed_mesh = self.printer.lookup_object('bed_mesh')
|
||||||
|
mesh = bed_mesh.get_status(self.reactor.monotonic())
|
||||||
|
self.status = analyse(mesh['probed_matrix'], mesh['mesh_min'],
|
||||||
|
mesh['mesh_max'], bump, height_range)
|
||||||
|
except Exception:
|
||||||
|
logging.exception("mesh_check: analysis failed")
|
||||||
|
self.status = {'result': 'none', 'range': 0., 'worst': 0.,
|
||||||
|
'areas': 0,
|
||||||
|
'summary': 'check failed, see klippy.log'}
|
||||||
|
msg = "Bed mesh check: %s" % (self.status['summary'],)
|
||||||
|
logging.info("mesh_check: %s (%s)", msg, self.status['result'])
|
||||||
|
gcmd.respond_info(msg)
|
||||||
|
|
||||||
|
def get_status(self, eventtime):
|
||||||
|
return dict(self.status)
|
||||||
|
|
||||||
|
|
||||||
|
def load_config(config):
|
||||||
|
return MeshCheck(config)
|
||||||
@@ -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
|
# Calibration
|
||||||
[include calibration/twist_check.cfg] # TWIST_CALIBRATE: axis twist compensation, with windows in Mainsail (runs scripts/twist_check.py)
|
[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
|
# (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.
|
# 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).
|
# 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
|
# https://klipperscreen.readthedocs.io/en/latest/macros/#recommended
|
||||||
[gcode_macro PAUSE]
|
[gcode_macro PAUSE]
|
||||||
@@ -25,7 +28,9 @@ variable_saved_fan_speed: 0.0
|
|||||||
variable_parked: False # set by PAUSE, used by _RESUME_PRINT
|
variable_parked: False # set by PAUSE, used by _RESUME_PRINT
|
||||||
variable_expected_lane: '' # AFC lane the print needs after RESUME ('' = no check)
|
variable_expected_lane: '' # AFC lane the print needs after RESUME ('' = no check)
|
||||||
gcode:
|
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
|
# 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
|
# change pauses the print; it clears it once CHANGE_TOOL returns
|
||||||
{% if 'AFC' in printer %}
|
{% if 'AFC' in printer %}
|
||||||
@@ -54,7 +59,11 @@ gcode:
|
|||||||
description: Resume the print (while HEAT_SOAK runs: skip the soak phase)
|
description: Resume the print (while HEAT_SOAK runs: skip the soak phase)
|
||||||
rename_existing: RESUME_BASE
|
rename_existing: RESUME_BASE
|
||||||
gcode:
|
gcode:
|
||||||
|
{% if printer["gcode_macro _BED_CHECK_STATE"].pending %}
|
||||||
|
_BED_CHECK_RETRY
|
||||||
|
{% else %}
|
||||||
HEAT_SOAK_RESUME ON_RESUME=_RESUME_PRINT {rawparams}
|
HEAT_SOAK_RESUME ON_RESUME=_RESUME_PRINT {rawparams}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[gcode_macro _RESUME_PRINT]
|
[gcode_macro _RESUME_PRINT]
|
||||||
description: Resume after PAUSE: purge and check (or unretract), restore the part fan, continue the 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_START runs on a soaked bed:
|
||||||
# PRINT_WARMUP bed heats while the nozzle cools and the printer homes,
|
# PRINT_WARMUP bed heats while the nozzle cools and the printer homes,
|
||||||
# wait for the bed, HEAT_SOAK
|
# wait for the bed, HEAT_SOAK
|
||||||
# PRINT_START QGL, Z, contact Z calibration, mesh, load the initial tool,
|
# PRINT_START QGL, Z, contact Z calibration, mesh, bed check (a failed
|
||||||
# PA for all lanes, XY reference
|
# 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
|
# 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.
|
# 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
|
# Chamber prints are the exception: PRINT_WARMUP loads and purges the first
|
||||||
@@ -26,6 +28,7 @@ gcode:
|
|||||||
|
|
||||||
RESET_FAILURE
|
RESET_FAILURE
|
||||||
CLEAR_PAUSE
|
CLEAR_PAUSE
|
||||||
|
_BED_CHECK_RESET
|
||||||
# Clear what an earlier print or error left on the display
|
# Clear what an earlier print or error left on the display
|
||||||
M117
|
M117
|
||||||
|
|
||||||
@@ -193,10 +196,14 @@ gcode:
|
|||||||
RESUME_BASE
|
RESUME_BASE
|
||||||
|
|
||||||
[gcode_macro PRINT_START]
|
[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:
|
gcode:
|
||||||
{% set target_extruder = params.EXTRUDER|int %}
|
{% set target_extruder = params.EXTRUDER|int %}
|
||||||
{% set initial_tool = params.TOOL|default("0")|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"
|
RESPOND MSG="print start macro continued"
|
||||||
_LIGHTS_ON
|
_LIGHTS_ON
|
||||||
@@ -235,6 +242,35 @@ gcode:
|
|||||||
# From here on the nozzle extrudes and AFC cuts and loads: guard off
|
# From here on the nozzle extrudes and AFC cuts and loads: guard off
|
||||||
_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
|
# Heat over the bucket, then undo the retracts of the previous PRINT_END
|
||||||
_STATUS STATE=heating_extruder
|
_STATUS STATE=heating_extruder
|
||||||
BLOBIFIER_PARK
|
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
|
description: Heaters (incl. chamber heater) and part fan off, flow back to 100%, bdwidth off, mesh and skew cleared, nozzle guard off
|
||||||
gcode:
|
gcode:
|
||||||
_GUARD_OFF ; a print start that failed while it was armed
|
_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
|
TURN_OFF_HEATERS
|
||||||
iHEATER_OFF ; stops the chamber heater control loop too
|
iHEATER_OFF ; stops the chamber heater control loop too
|
||||||
M107
|
M107
|
||||||
|
|||||||
Reference in new issue
Block a user