Files
klipper-macros/macros/pressure_advance/bd_pressure.cfg
T
mangavalkandClaude Opus 5.5 29604b2f1e PA calibration: wider PA range for TPU/TPE
PA_CALIBRATE takes PA_STEP (default 0.002, 0-0.098 over 50 lines).
_PA_CFG.material_pa_step uses 0.004 (0-0.196) for tpu/tpe/flex; soft TPU
measured 0.094, close to the old end. The "no result" rejection uses the
end of the range actually tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:29:02 +02:00

168 lines
6.5 KiB
INI

# 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 %}
# PA_STEP: PA increase per test line, 50 lines (0..49 x step); the
# vendor value 0.002 tests 0-0.098. bdpressure.py reports the VALUE
# sent with each reading, so a larger step widens the range.
{% set pressure_step = params.PA_STEP|default(0.002)|float %}
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