action_raise_error aborts while the macro renders, so an M117 in the same macro never ran and errors such as the RESUME lane check only reached the console. messages.cfg adds _ERROR (M117, then raise in a separate macro) and _WARN (RESPOND TYPE=error + M117); all errors and warnings use them. PAUSE shows AFC's error as the pause reason; RESUME, CANCEL_PRINT and PRINT_WARMUP clear the display. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.8 KiB
INI
70 lines
2.8 KiB
INI
# AFC_XY_SAFETY_CHECK: lost-step check around tool changes (needs extras/xy_drift.py)
|
|
|
|
#####################################################################
|
|
## XY lost-step check (needs xy_drift.py + [xy_drift])
|
|
#####################################################################
|
|
# Homing resets the toolhead position, so the position after G28 cannot
|
|
# show lost steps. [xy_drift] compares the stepper step counts at the X and
|
|
# Y endstop triggers instead: every lost step shows up as drift.
|
|
# _AFC_STORE_HOME_REFERENCE (PRINT_START) stores the reference, every
|
|
# AFC_XY_SAFETY_CHECK compares against it and then stores a new reference,
|
|
# so each check reports the drift since the previous one.
|
|
|
|
[xy_drift]
|
|
|
|
[gcode_macro _AFC_STORE_HOME_REFERENCE]
|
|
gcode:
|
|
G28 X Y
|
|
M400
|
|
XY_DRIFT_STORE
|
|
|
|
[gcode_macro AFC_XY_SAFETY_CHECK]
|
|
description: Re-home XY and report steps lost since the last check
|
|
variable_allowed_mm: 0.1 # one motor skipping one cycle (0.4 mm) shows as 0.2 mm in X and Y; endstop noise ~0.02
|
|
variable_soft_fail: 1 # 1 = PAUSE on drift, 0 = M112
|
|
gcode:
|
|
{% set th = printer.toolhead %}
|
|
M117 AFC XY check...
|
|
SAVE_GCODE_STATE NAME=_AFC_XY_CHECK
|
|
G90
|
|
G1 Z{[th.position.z + 10, th.axis_maximum.z]|min} F3000
|
|
G28 X Y
|
|
M400
|
|
_AFC_CHECK_CAPTURE
|
|
RESTORE_GCODE_STATE NAME=_AFC_XY_CHECK
|
|
|
|
[gcode_macro _AFC_CHECK_CAPTURE]
|
|
gcode:
|
|
{% set d = printer.xy_drift %}
|
|
{% set cfg = printer["gcode_macro AFC_XY_SAFETY_CHECK"] %}
|
|
{% set th = printer.toolhead %}
|
|
{% set lim = cfg.allowed_mm|float %}
|
|
{% set drift = d.ref_set and (d.x|abs > lim or d.y|abs > lim) %}
|
|
{% if not d.ref_set %}
|
|
RESPOND PREFIX="AFC" MSG="XY check: no reference yet (Klipper restarted?), storing one now"
|
|
{% else %}
|
|
RESPOND PREFIX="AFC" MSG="XY drift since last check: X={'%.3f' % d.x} Y={'%.3f' % d.y} mm (limit {lim})"
|
|
{% endif %}
|
|
# New reference from this homing, so the next check reports only new drift
|
|
XY_DRIFT_STORE
|
|
{% if not drift %}
|
|
{% if d.ref_set %}
|
|
RESPOND PREFIX="AFC" MSG="Position OK"
|
|
{% endif %}
|
|
G1 X{th.axis_maximum.x - 10} Y{th.axis_maximum.y - 10} F5000
|
|
{% elif cfg.soft_fail|int == 1 %}
|
|
_WARN MSG="AFC: XY drift detected! X={'%.3f' % d.x} Y={'%.3f' % d.y} mm. Axes are re-homed, print PAUSED. Run AFC_XY_RESUME to continue, or CANCEL_PRINT." DISPLAY="AFC: XY drift! See console. Paused."
|
|
PAUSE
|
|
{% else %}
|
|
_WARN MSG="AFC: XY drift X={'%.3f' % d.x} Y={'%.3f' % d.y} mm -> M112"
|
|
M112
|
|
{% endif %}
|
|
|
|
[gcode_macro AFC_XY_RESUME]
|
|
description: Acknowledge XY drift warning and resume print
|
|
gcode:
|
|
RESPOND PREFIX="AFC" MSG="User acknowledged drift, resuming."
|
|
# Axes were re-homed by the check, so AFC's resume returns to the
|
|
# correct print position.
|
|
RESUME
|