Move bd_pressure.cfg and TEST_SPEED into the repo

All macros now come from this repo. bd_pressure.cfg ([bdpressure bd_pa]
and the vendor PA_CALIBRATE macros) and Macros/TEST_SPEED.cfg were loose
files in ~/printer_data/config.

PA_CALIBRATE no longer sets Z back to z_current at the end: it was read
before the test ran, so a Z hop in the G28 XY (Beacon home_z_hop) would
leave Klipper believing the nozzle is lower than it is. Z is never switched
off or moved by the test, so it keeps its position without that line.
The ACC_WALL bug (read from ACCEL_TO_DECEL, always 4000) is documented,
not fixed: the cached PA values were measured at 4000.

printer.cfg must drop [include bd_pressure.cfg] and Macros/macros.cfg its
TEST_SPEED include, else the old copies (included later) still win.

Reference values from the load-check-afc branch and from the guard and
Z check tests added to CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-18 23:11:02 +02:00
1 parent 8eef0ee298
commit a16b57a0a9
5 files changed
+303 -1

No files matched your search

+2
View File
@@ -24,6 +24,7 @@
[include print/homing.cfg]
[include print/idle_timeout.cfg]
[include print/print_start_end.cfg]
[include print/test_speed.cfg] # TEST_SPEED: skipped-steps test
# Heating
[include heating/bed_fans.cfg]
@@ -39,6 +40,7 @@
[include afc/purge_until_empty.cfg]
# Pressure advance per lane/spool (bd_pressure + Spoolman)
[include pressure_advance/bd_pressure.cfg] # [bdpressure bd_pa] and the vendor PA_CALIBRATE macros
[include pressure_advance/bd_pa_spoolman.cfg]
# Spoolman
+164
View File
@@ -0,0 +1,164 @@
# bd_pressure (strain gauge on the nozzle): sensor and the vendor's PA
# calibration macros, from the bd_pressure repo (klipper/bd_pressure.cfg),
# moved here from ~/printer_data/config/bd_pressure.cfg.
#
# Connected over I2C (software I2C on the Nitehawk). Its endstop output is
# not wired; Beacon does the Z probing. Used by: LANE_CALIBRATE_PA
# (bd_pa_spoolman.cfg), the purge check (bdpressure_check.py) and the
# nozzle guard (bdp_guard.py).
#
# PA_CALIBRATE: SET_BDPRESSURE START switches the X and Y drivers off, so
# the X/Y moves of the test only happen on paper (the nozzle stays where
# LANE_CALIBRATE_PA put it) and X/Y are homed again at the end.
# Known: ACC_WALL is read from the ACCEL_TO_DECEL parameter (vendor bug), so
# the test always runs at 4000 mm/s^2; the cached PA values were measured
# like that. The acceleration and square corner velocity it sets are not
# restored (the slicer sets them again per feature).
[bdpressure bd_pa]
port: i2c
i2c_mcu: nhk
i2c_software_scl_pin: nhk:PB3
i2c_software_sda_pin: nhk:PB4
thrhold: 5 # probe trigger value, recommended 3 to 10; bdp_guard and the load check read it as THRHOLD_Z
[gcode_macro PA_RESET]
gcode:
M400
G4 P200
SET_BDPRESSURE NAME=bd_pa COMMAND=RESET_PROBE
G4 P200
[gcode_macro PA_STATE]
gcode:
{% set status = printer["bdpressure bd_pa"].state %}
{ action_respond_info("status:%s %d"%(status,params.T|int)) }
[gcode_macro PA_E]
gcode:
{% set status = printer["bdpressure bd_pa"].state %}
{% set i = params.I|int %}
#{ action_respond_info("status:%f %d"%(params.STEP|float,i)) }
{% if status=='START' %}
{% set pressure_ad = 0 + i*(params.STEP|float) %}
SET_PRESSURE_ADVANCE ADVANCE={pressure_ad}
{% set y_step =38.75 + i*3.5 %}
G1 X78 Y{y_step} F{params.T_SPEED|int}
G1 F{params.L_SPEED|int}
G1 X98 Y{y_step} E.92643
G1 F{params.H_SPEED|int}
G1 X138 Y{y_step} E1.85285
G1 F{params.L_SPEED|int}
G1 X158 Y{y_step} E.92643
M400
SET_BDPRESSURE NAME=bd_pa COMMAND=READ VALUE={pressure_ad}
{% endif %}
[gcode_macro PA_CALIBRATE]
gcode:
# PA_CALIBRATE NOZZLE_TEMP=[first_layer_temperature] MAX_VOLUMETRIC=[filament_max_volumetric_speed] ACC_WALL=[outer_wall_acceleration]
# TRAVEL_SPEED=[travel_speed] ACC_TO_DECEL_FACTOR=[accel_to_decel_factor]
### temperature=210,ACCEL_TO_DECEL=10000,ACCEL=8000,SQUARE_CORNER_VELOCITY=5
{% set NOZZLE_TEMP = 210 %}
{% if params.NOZZLE_TEMP %}
{ action_respond_info("nozzle TEMPERATURE %s "%params.NOZZLE_TEMP) }
{% set NOZZLE_TEMP = params.NOZZLE_TEMP|default(210)|float %}
{% endif %}
{% set ACC_WALL = 4000 %}
{% if params.ACC_WALL %}
{ action_respond_info("ACC_out_WALL %s "%params.ACC_WALL) }
{% set ACC_WALL = params.ACCEL_TO_DECEL|default(4000)|float %}
{% endif %}
{% set SQUARE_CORNER_SPEED = 9 %}
{% if params.SQUARE_CORNER_VELOCITY %}
{ action_respond_info("SQUARE_CORNER_VELOCITY %s "%params.SQUARE_CORNER_VELOCITY) }
{% set SQUARE_CORNER_SPEED = params.SQUARE_CORNER_VELOCITY|default(9)|float %}
{% endif %}
### travel_speed=400, max_volumetric_speed = [filament_max_volumetric_speed]
## low_speed = (1020/20)*max_volumetric_speed
## high_speed = (10740/20)*max_volumetric_speed
{% set ACC_TO_DECEL_FAC = 0.5 %}
{% set MIN_CRUISE = 0.5 %}
{% if params.ACC_TO_DECEL_FACTOR %}
{ action_respond_info("accel_to_decel_factor %s "%params.ACC_TO_DECEL_FACTOR) }
{% set ACC_TO_DECEL_FAC = params.ACC_TO_DECEL_FACTOR.replace("%", "").strip() | float / 100 %}
{% set MIN_CRUISE = 1-ACC_TO_DECEL_FAC|float %}
{ action_respond_info("ACC_TO_DECEL_FACTOR %s "%ACC_TO_DECEL_FAC) }
{% endif %}
{% if params.MINIMUM_CRUISE_RATIO %}
{% set MIN_CRUISE = params.MINIMUM_CRUISE_RATIO|default(0.5)|float %}
{% endif %}
{ action_respond_info("MIN_CRUISE %s "%MIN_CRUISE) }
{% set ACC_TO_DEC = ACC_TO_DECEL_FAC*ACC_WALL %}
{% set TRAVEL_SPEED = 400 %}
{% if params.TRAVEL_SPEED %}
{% set TRAVEL_SPEED = params.TRAVEL_SPEED|default(400)|float * 60 %}
{ action_respond_info("travel_speed %s/60 "%TRAVEL_SPEED) }
{% endif %}
{% set MAX_VOLUMETRIC = 20 %}
{% if params.MAX_VOLUMETRIC %}
{ action_respond_info("filament_max_volumetric_speed %s "%params.MAX_VOLUMETRIC) }
{% set MAX_VOLUMETRIC = params.MAX_VOLUMETRIC|default(20)|float %}
{% endif %}
{% set low_speed = 51*MAX_VOLUMETRIC %}
{ action_respond_info("low_speed %f "%low_speed) }
{% set high_speed = 537*MAX_VOLUMETRIC %}
{ action_respond_info("high_speed %f "%high_speed) }
# volum=[filament_max_volumetric_speed]
# travel=[travel_speed] [accel_to_decel_factor] acc=[outer_wall_acceleration] temper=[first_layer_temperature]
G90
G21
M83
M109 S{NOZZLE_TEMP}
G1 E4
SET_PRESSURE_ADVANCE ADVANCE=0.04; Override pressure advance value
SET_VELOCITY_LIMIT ACCEL={ACC_WALL} ACCEL_TO_DECEL={ACC_TO_DEC}
SET_VELOCITY_LIMIT ACCEL={ACC_WALL} MINIMUM_CRUISE_RATIO={MIN_CRUISE}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={SQUARE_CORNER_SPEED}
SET_STEPPER_ENABLE STEPPER=stepper_x ENABLE=1
SET_STEPPER_ENABLE STEPPER=stepper_y ENABLE=1
SET_BDPRESSURE NAME=bd_pa COMMAND=START
M400
G4 P1000
{% set y_step = 38.75 %}
{% set pressure_ad = 0 %}
{% set pressure_step = 0.002 %}
G1 F{high_speed}
G1 X78 Y{y_step} E9.92204
M400
G4 P4000
G1 F{low_speed}
G1 X98 Y{y_step} E.92643
G1 X138 Y{y_step} E1.85285
G1 X158 Y{y_step} E.92643
G1 X78 Y{y_step} F{TRAVEL_SPEED}
######
M400
{% for i in range(50) %}
PA_E STEP={pressure_step} T_SPEED={TRAVEL_SPEED} H_SPEED={high_speed} L_SPEED={low_speed} I={i}
{% endfor %}
M400
SET_BDPRESSURE NAME=bd_pa COMMAND=STOP
G4 P500
SET_BDPRESSURE NAME=bd_pa COMMAND=RESET_PROBE
G4 P500
SET_KINEMATIC_POSITION X=0 Y=0
G28 XY
# Z was not switched off and not moved: it keeps its position. The
# vendor macro set Z back to z_current, read before any of this ran:
# a Z hop in G28 XY (Beacon home_z_hop) would then leave Klipper
# believing the nozzle is lower than it is.
G4 P200
#G28 Z
+127
View File
@@ -0,0 +1,127 @@
# TEST_SPEED: skipped-steps test for speed and acceleration (common Voron
# macro, moved here from ~/printer_data/config/Macros/TEST_SPEED.cfg)
[gcode_macro TEST_SPEED]
# Home, get position, throw around toolhead, home again.
# If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured.
# We only measure to a full step to accomodate for endstop variance.
# Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10, ZHEIGHT=20
description: Test for max speed and acceleration parameters for the printer. Procedure: Home -> ReadPositionFromMCU -> MovesToolhead@Vel&Accel -> Home -> ReadPositionfromMCU
gcode:
# Speed
{% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
# Iterations
{% set iterations = params.ITERATIONS|default(5)|int %}
# Acceleration
{% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
# Minimum Cruise Ratio
{% set min_cruise_ratio = params.MIN_CRUISE_RATIO|default(0.5)|float %}
# Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions)
{% set bound = params.BOUND|default(20)|int %}
{% set zHeight = params.ZHEIGHT|default(20)|int %}
# Size for small pattern box
{% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %}
# Large pattern
# Max positions, inset by BOUND
{% set x_min = printer.toolhead.axis_minimum.x + bound %}
{% set x_max = printer.toolhead.axis_maximum.x - bound %}
{% set y_min = printer.toolhead.axis_minimum.y + bound %}
{% set y_max = printer.toolhead.axis_maximum.y - bound %}
# Small pattern at center
# Find X/Y center point
{% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %}
{% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %}
# Set small pattern box around center point
{% set x_center_min = x_center - (smallpatternsize/2) %}
{% set x_center_max = x_center + (smallpatternsize/2) %}
{% set y_center_min = y_center - (smallpatternsize/2) %}
{% set y_center_max = y_center + (smallpatternsize/2) %}
# Save current gcode state (absolute/relative, etc)
SAVE_GCODE_STATE NAME=TEST_SPEED
# Output parameters to g-code terminal
{ action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) }
# Home and get position for comparison later:
M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
G28
# QGL if not already QGLd (only if QGL section exists in config)
{% if printer.configfile.settings.quad_gantry_level %}
{% if printer.quad_gantry_level.applied == False %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% endif %}
# Move 50mm away from max position and home again (to help with hall effect endstop accuracy - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/24)
G90
G1 X{printer.toolhead.axis_maximum.x-50} Y{printer.toolhead.axis_maximum.y-50} F{30*60}
M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
G28 X Y
G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Go to starting position
G0 X{x_min} Y{y_min} Z{zHeight + 10} F{speed*60}
# Set new limits
{% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MINIMUM_CRUISE_RATIO={min_cruise_ratio}
{% else %}
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
{% endif %}
{% for i in range(iterations) %}
# Large pattern diagonals
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_max} Y{y_max} F{speed*60}
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
G0 X{x_min} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
# Large pattern box
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_min} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
# Small pattern diagonals
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60}
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
# Small pattern box
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
{% endfor %}
# Restore max speed/accel/accel_to_decel to their configured values
{% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} MINIMUM_CRUISE_RATIO={printer.configfile.settings.printer.minimum_cruise_ratio}
{% else %}
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
{% endif %}
# Re-home and get position again for comparison:
M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
G28 # This is a full G28 to fix an issue with CoreXZ - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/12
# Go to XY home positions (in case your homing override leaves it elsewhere)
G90
G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED