diff --git a/CLAUDE.md b/CLAUDE.md index d7eb724..a108c07 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -63,6 +63,9 @@ detection, `filament_error_sensitivity`), iHeater chamber heater. 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`. +- PA values are saved per nozzle and spool (`pa_value_0_4_spool_`), the fitted + size in `pa_nozzle` (`SET_NOZZLE`). The slicer's `NOZZLE=` on `PRINT_WARMUP` must + match, or the print stops. A new size needs an entry in `_PA_CFG.nozzle_test`. - `PRINT_END` and `CANCEL_PRINT` share `_PRINT_CLEANUP` (heaters including `iHEATER_OFF`, fan, `M221 S100`, bdwidth off). Anything that must happen at the end of every print goes there. `RESTORE_GCODE_STATE` restores the diff --git a/README.md b/README.md index 2bc1755..d2c6298 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ everything below, grouped by topic. Comment out what you do not use there. | `purge_until_empty.cfg` | `PURGE_UNTIL_EMPTY`: purges a snapped filament out until there is no more nozzle pressure | same as `purge_check.cfg` | | **pressure_advance/** | | | | `bd_pressure.cfg` | `[bdpressure bd_pa]` (I2C on the Nitehawk) and the vendor macros `PA_CALIBRATE`, `PA_E`, `PA_RESET`, `PA_STATE`; `PA_CALIBRATE` no longer sets Z back to a value read before the test (wrong after a Z hop in `G28 XY`) | `bdpressure.py` from the bd_pressure repo | -| `bd_pa_spoolman.cfg` + `bd_pa_*.sh` | `LANE_CALIBRATE_PA`, `PA_CALIBRATE_ALL_LANES`, `LANE_RECAL_PA`, `SET_SPOOL_ID`, `PA_STATUS`: pressure advance per lane/spool, cached locally and in Spoolman; before a calibration the lane's spool is assigned again so a temperature just changed in Spoolman is used; flexible materials (TPU/TPE) calibrate at a lower flow (8 mm³/s) and over a wider PA range (0–0.196 in 0.004 steps instead of 0–0.098); a calibration with no result, a pause during the test or too few/stuck sensor readings is rejected and not saved | bd_pressure, AFC, Spoolman, `gcode_shell_command` | +| `bd_pa_spoolman.cfg` | `LANE_CALIBRATE_PA`, `PA_CALIBRATE_ALL_LANES`, `LANE_RECAL_PA`, `SET_SPOOL_ID`, `PA_STATUS`, `SET_NOZZLE`: pressure advance per nozzle and spool, saved on the printer; run `SET_NOZZLE SIZE=0.2` after a swap (a print start stops if the slicer profile has another size); each nozzle has its own test flow and PA range (0.4: 25 mm³/s, 0–0.098, about 2 min a lane; 0.2: 5 mm³/s, 0–0.196, about 9 min, not measured yet); before a calibration the lane's spool is assigned again so a temperature just changed in Spoolman is used; flexible materials (TPU/TPE) calibrate at a lower flow (8 mm³/s) and over a wider PA range (0–0.196 in 0.004 steps instead of 0–0.098); a calibration with no result, a pause during the test or too few/stuck sensor readings is rejected and not saved | bd_pressure, AFC, Spoolman through AFC | | **spoolman/** | | | | `active_spool.cfg` | `SET_ACTIVE_SPOOL`, `CLEAR_ACTIVE_SPOOL` | Spoolman in Moonraker | | **leds/** | | | @@ -143,7 +143,7 @@ These are the settings of one printer. Before using a file, check: - **Settings at the top of a file** (`variable_...`): `afc/purge_check.cfg` (`mode: "enforce"`, `motion_check: False` because this printer's bdwidth motion reading is unreliable), `pressure_advance/bd_pa_spoolman.cfg` - (`spoolman_url`), `heating/bed_fans.cfg`, `heating/filament_drying.cfg`. + (`nozzle_test`), `heating/bed_fans.cfg`, `heating/filament_drying.cfg`. - `xy_drift.py` is for CoreXY only. Comment out files you do not need in `klipper-macros.cfg`. diff --git a/macros/pressure_advance/bd_pa_create_spoolman_field.sh b/macros/pressure_advance/bd_pa_create_spoolman_field.sh deleted file mode 100755 index ce107bb..0000000 --- a/macros/pressure_advance/bd_pa_create_spoolman_field.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -BASE_URL=$1 -FIELD=$2 -curl -sf -X POST "${BASE_URL}/api/v1/field/spool/${FIELD}" \ - -H "Content-Type: application/json" \ - -d "{\"name\": \"Pressure Advance\", \"field_type\": \"float\", \"default_value\": \"0\"}" \ - > /tmp/pa_setup_result 2>&1 diff --git a/macros/pressure_advance/bd_pa_spoolman.cfg b/macros/pressure_advance/bd_pa_spoolman.cfg index 1bbf8b2..b1152f8 100644 --- a/macros/pressure_advance/bd_pa_spoolman.cfg +++ b/macros/pressure_advance/bd_pa_spoolman.cfg @@ -171,6 +171,9 @@ # To see what's cached, and which lanes are missing a tracked # spool_id: # PA_STATUS +# +# After fitting another nozzle (values are saved per nozzle): +# SET_NOZZLE SIZE=0.2 ######################################################################## # [save_variables] is defined once in ../save_variables.cfg (shared with Blobifier) @@ -190,18 +193,24 @@ variable_lane_names: "lane1,lane2,lane3,lane4,lane5" variable_fallback_nozzle_temp: 260 # bd_pressure PA_CALIBRATE parameters -- tune to your printer/filament. # See https://pandapi3d.cn/bdpressure/home for guidance on these values. -variable_max_volumetric: 25 +# Per nozzle, and only these sizes are accepted by SET_NOZZLE: +# max_volumetric: test flow (mm3/s). The test time follows it: about 2 min a +# lane at 25, 9 min at 5. +# pa_step: PA_CALIBRATE tests 50 values, 0..49 x step (0.002: 0-0.098, +# 0.004: 0-0.196). +# The 0.2 values are starting estimates, not measured yet. +variable_nozzle_test: {"0.4": {"max_volumetric": 25, "pa_step": 0.002}, "0.2": {"max_volumetric": 5, "pa_step": 0.004}} # Lower test flow (mm3/s) for materials that cannot extrude max_volumetric: # soft TPU buckles or slips in the extruder at 25. A key contained in the -# lane's material (any case) applies; with several matches the lowest wins. +# lane's material (any case) applies; the lowest of these and the nozzle's +# flow wins. variable_material_max_volumetric: {"tpu": 8, "tpe": 8, "flex": 8} variable_acc_wall: 5000 variable_travel_speed: 300 variable_acc_to_decel_factor: 50 # Minimum PA delta before we bother re-saving the cached value variable_write_threshold: 0.002 -# A calibration is rejected (nothing cached or written to Spoolman, the -# previous PA is kept) when: +# A calibration is rejected (nothing saved, the previous PA is kept) when: # - its result is the last PA_CALIBRATE test value: bdpressure.py found no # result and left the extruder at the end of its scan (0..49 x the PA # step: 0.098 at the default step, 0.196 for flexibles), @@ -209,94 +218,74 @@ variable_write_threshold: 0.002 # - bd_pressure gave fewer than min_points readings or fewer than # min_distinct different ones (sensor silent or hung; needs # bdpressure_check.py, otherwise this check is skipped). -variable_pa_step: 0.002 # PA_CALIBRATE tests 50 values: 0..49 x step # Wider range for materials whose PA can be above 0.098 (soft TPU measured # 0.094): same 50 lines and test time, coarser steps. Key contained in the -# lane's material (any case); with several matches the largest step wins. +# lane's material (any case); the largest of these and the nozzle's step wins. variable_material_pa_step: {"tpu": 0.004, "tpe": 0.004, "flex": 0.004} variable_min_points: 10 variable_min_distinct: 8 # PA applied when a rejected lane has no earlier cached value variable_fallback_pa: 0.04 -# Spoolman URL and the custom "extra" field name used to push calibrated -# PA values back to the spool record (so the value travels with the -# spool, not just with this printer's local save_variables cache). -# Create the field once with: _PA_SETUP_SPOOLMAN_FIELD (see below). -variable_spoolman_url: "http://localhost:7912" -variable_spoolman_field: "pa_value" gcode: # intentionally empty -- variables only # --------------------------------------------------------------------------- -# Spoolman write-back: push a calibrated PA value to a spool's "extra" -# field, so the value travels with the spool (e.g. if you move it to a -# different printer, or reinstall save_variables from scratch). -# -# Requires the custom field to exist once -- run _PA_SETUP_SPOOLMAN_FIELD -# (below) a single time, or create it manually: -# curl -X POST http://:7912/api/v1/field/spool/pa_value -H "Content-Type: application/json" -d '{"name": "Pressure Advance", "field_type": "float", "default_value": "0"}' -# -# UNVERIFIED -- needs live testing the same way everything else in this -# file has needed it. In particular: confirm curl and python3 are both -# available in the shell shell_command runs in (they're standard on -# MainsailOS/FluiddOS, but worth confirming), and confirm the merge-write -# below doesn't clobber any other custom Spoolman fields you may have. +# Fitted nozzle. A PA value only holds for the nozzle it was measured with, so +# values are saved per nozzle and spool: pa_value_0_4_spool_15. The size is the +# saved variable pa_nozzle, set by SET_NOZZLE after a swap. The slicer sends the +# size of its profile to PRINT_WARMUP, and a mismatch stops the print before +# anything heats. G-code without a size uses the saved one. # --------------------------------------------------------------------------- -[gcode_shell_command _pa_write_spoolman] -# HISTORICAL NOTE ON ARGUMENT OFFSET (no longer applicable here, kept -# for context): an earlier version of this command ran the script -# inline via `bash -c '