From 93f00c87a70d9537ce076407bacb10e86806df13 Mon Sep 17 00:00:00 2001 From: MangaValk Date: Mon, 12 Oct 2026 18:18:40 +0200 Subject: [PATCH] Stop using bdwidth while printing, work without it bdwidth's motion reading stays at 0, its per-reading width compensation made the flow jump between 77 and 119%, and a USB dropout shut down Klipper. PRINT_START no longer enables it. _PRINT_CLEANUP, BLOBIFIER_CHECKED and PURGE_UNTIL_EMPTY only send bdwidth commands when [bdwidth fila_width_0] exists, and bdwidth_status reports present: False with neutral values when it is not configured, so the section can be removed from printer.cfg. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 8 ++++---- README.md | 4 ++-- extras/bdwidth_status.py | 14 +++++++++++++- macros/afc/purge_check.cfg | 5 +++-- macros/afc/purge_until_empty.cfg | 2 +- macros/print/print_start_end.cfg | 9 +++++---- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 161478f..ae3e987 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -11,10 +11,10 @@ Voron 2.4 350, Klipper + Moonraker + Mainsail on a Raspberry Pi 4 5 lanes, Blobifier purge bucket, Beacon (Z homing and probing), Nitehawk-SB toolboard (USB), Leviathan mainboard as USB-CAN bridge, bd_pressure (load-check firmware, branch `load-check-extension` in -`D:\Claude\bd_pressure-load-check\bd_pressure`), bdwidth (measures width and -motion optically with a CCD; its motion reading stays at 0, so it runs width -only (`ENABLE_WIDTH` in PRINT_START) and the purge check runs with -`motion_check: False`; clogs and breaks are caught by AFC's buffer fault +`D:\Claude\bd_pressure-load-check\bd_pressure`), bdwidth (CCD width/motion sensor on USB; switched off: its motion reading +stays at 0, its width compensation made the flow jump 77-119% and a USB +dropout once shut down Klipper. The macros work with or without +`[bdwidth fila_width_0]`; clogs and breaks are caught by AFC's buffer fault detection, `filament_error_sensitivity`), iHeater chamber heater. ## Working with the printer diff --git a/README.md b/README.md index cf939ee..74d9f61 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ everything below, grouped by topic. Comment out what you do not use there. | `blobifier.cfg` | `BLOBIFIER`, `BLOBIFIER_CLEAN`, `BLOBIFIER_PARK`, `BLOBIFIER_SHAKE_BUCKET`, ...: purge bucket and nozzle brush for AFC (Turtleblobifier, heavily modified) | Blobifier hardware, AFC | | `blobifier_hw.cfg` | servo and bucket switch pins | — | | **print/** | | | -| `print_start_end.cfg` | `PRINT_WARMUP`, `PRINT_START`, `PRINT_END` | Beacon, AFC, Blobifier, `HEAT_SOAK`, iHeater, bdwidth, bd_pressure PA macros | +| `print_start_end.cfg` | `PRINT_WARMUP`, `PRINT_START`, `PRINT_END` | Beacon, AFC, Blobifier, `HEAT_SOAK`, iHeater, bd_pressure PA macros (bdwidth is no longer enabled while printing) | | `pause_resume.cfg` | `PAUSE`, `RESUME`, `CANCEL_PRINT`, `M600` (RESUME also handles a running `HEAT_SOAK`, and after a PAUSE purges 40 mm with `BLOBIFIER_CHECKED` first: a failed check keeps the print paused, `RESUME PURGE=0` skips the purge; CANCEL_PRINT runs the same cleanup as `PRINT_END`) | `heating/heat_soak.cfg`, `leds/`, `blobifier/`, `afc/purge_check.cfg` | | `filament.cfg` | `LOAD_FILAMENT`, `UNLOAD_FILAMENT` | — | | `homing.cfg` | `HOME` | — | @@ -50,7 +50,7 @@ everything below, grouped by topic. Comment out what you do not use there. | File | For | |---|---| | `xy_drift.py` | `AFC_XY_SAFETY_CHECK`: measures lost XY steps from the stepper step counts at the endstop triggers (CoreXY). The toolhead position after homing cannot show lost steps. | -| `bdwidth_status.py` | exposes bdwidth's motion counter and width to macros, and keeps a USB dropout of bdwidth (port: usb) from shutting down Klipper: the read is retried every 10 s and the port reopened | +| `bdwidth_status.py` | exposes bdwidth's motion counter and width to macros (`present: False` with neutral values when no bdwidth is configured, so the macros also work without it), and keeps a USB dropout of bdwidth (port: usb) from shutting down Klipper: the read is retried every 10 s and the port reopened | | `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. | ### Scripts (`scripts/`) diff --git a/extras/bdwidth_status.py b/extras/bdwidth_status.py index fb596b7..9b108cd 100644 --- a/extras/bdwidth_status.py +++ b/extras/bdwidth_status.py @@ -26,6 +26,9 @@ # only starts reading on the first SET_BDWIDTH ... ENABLE # linear_motion - counts per mm (motion_linear_coefficient) # sample_time - seconds between sensor reads +# present - False when no [bdwidth ] is configured; the +# other fields then hold neutral defaults, so macros keep +# working with bdwidth removed from the config # usb_ok - False while the USB connection is down (port: usb) # usb_errors - USB read errors since Klipper start # @@ -54,7 +57,10 @@ class BDWidthStatus: self._handle_connect) def _handle_connect(self): - self.sensor = self.printer.lookup_object(self.sensor_name) + self.sensor = self.printer.lookup_object(self.sensor_name, None) + if self.sensor is None: + logging.info("bdwidth_status: no [%s] configured", self.sensor_name) + return if (getattr(self.sensor, 'port', None) == 'usb' and callable(getattr(self.sensor, 'Read_bdwidth', None)) and getattr(self.sensor, 'usb', None) is not None): @@ -96,6 +102,11 @@ class BDWidthStatus: def get_status(self, eventtime): s = self.sensor + if s is None: + return {'name': self.name, 'present': False, 'reading': False, + 'enabled': False, 'total_move': 0, 'last_motion': 0, + 'diameter': 0., 'active': 'disable', 'linear_motion': 42.8, + 'sample_time': 1., 'usb_ok': True, 'usb_errors': 0} # bdwidth's own get_status() is the runout helper's, which carries # the SET_FILAMENT_SENSOR enable flag try: @@ -110,6 +121,7 @@ class BDWidthStatus: and 'disable' not in str(getattr(s, 'is_active', 'disable'))) return { 'name': self.name, + 'present': True, 'reading': reading, 'enabled': enabled, 'total_move': getattr(s, 'actual_total_move', 0), diff --git a/macros/afc/purge_check.cfg b/macros/afc/purge_check.cfg index 687e8ed..69a9dae 100644 --- a/macros/afc/purge_check.cfg +++ b/macros/afc/purge_check.cfg @@ -65,13 +65,14 @@ gcode: # pause the printer (the check reports it instead). Afterwards the # runout response is restored; bdwidth itself is only switched off # again outside a print, so a print never loses it. - {% set bdw_on = cfg.motion_check and not printer.bdwidth_status.reading|default(false) %} + {% set has_bdw = printer.bdwidth_status.present|default(true) %} + {% set bdw_on = has_bdw and cfg.motion_check and not printer.bdwidth_status.reading|default(false) %} {% set bdw_off = bdw_on and printer.print_stats.state not in ["printing", "paused"] %} {% set runout_was = 1 if printer.bdwidth_status.enabled else 0 %} # Without the motion check, bdwidth's own runout response is off during # the purge too, so a bdwidth that does not see the movement cannot # pause the printer here; the pressure check judges the purge. - {% set runout_off = bdw_on or not cfg.motion_check %} + {% set runout_off = has_bdw and (bdw_on or not cfg.motion_check) %} {% if cfg.mode == "off" %} BLOBIFIER {rawparams} {% else %} diff --git a/macros/afc/purge_until_empty.cfg b/macros/afc/purge_until_empty.cfg index 2fd4b41..4ff8d4b 100644 --- a/macros/afc/purge_until_empty.cfg +++ b/macros/afc/purge_until_empty.cfg @@ -73,7 +73,7 @@ gcode: RESPOND MSG="PURGE_UNTIL_EMPTY: unsyncing {printer.AFC.current_load} from the extruder (UNSET_LANE_LOADED)" UNSET_LANE_LOADED {% endif %} - {% set bdw = printer.bdwidth_status.name if 'bdwidth_status' in printer else '' %} + {% set bdw = printer.bdwidth_status.name if 'bdwidth_status' in printer and printer.bdwidth_status.present|default(true) else '' %} {% set runout_was = 1 if bdw and printer.bdwidth_status.enabled else 0 %} {% if runout_was %} RESPOND MSG="PURGE_UNTIL_EMPTY: bdwidth runout response off during the purges" diff --git a/macros/print/print_start_end.cfg b/macros/print/print_start_end.cfg index 72daf8d..858e78c 100644 --- a/macros/print/print_start_end.cfg +++ b/macros/print/print_start_end.cfg @@ -203,10 +203,9 @@ gcode: _AFC_STORE_HOME_REFERENCE - # Width only (flow compensation and runout when no filament is measured). - # The CCD motion reading stays at 0 (actual_total_move:0), so motion mode - # (ENABLE_MOTION / ENABLE_ALL) only gives false "Rounout" messages. - SET_BDWIDTH NAME=fila_width_0 COMMAND=ENABLE_WIDTH + # bdwidth is not used while printing: its motion reading stays at 0 and its + # per-reading width compensation made the flow jump between 77 and 119%. + # To use it again: SET_BDWIDTH NAME=fila_width_0 COMMAND=ENABLE_WIDTH _status_printing @@ -252,7 +251,9 @@ gcode: TURN_OFF_HEATERS iHEATER_OFF ; stops the chamber heater control loop too M107 + {% if 'bdwidth fila_width_0' in printer %} SET_BDWIDTH NAME=fila_width_0 COMMAND=DISABLE ; also sets M221 S100 + {% endif %} M221 S100 BED_MESH_CLEAR SET_SKEW CLEAR=1