Compare commits
17
Commits
7bee9a1ecd
..
main
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "external/aldis"]
|
||||||
|
path = external/aldis
|
||||||
|
url = https://github.com/mjonuschat/aldis.git
|
||||||
@@ -10,8 +10,10 @@ Voron 2.4 350, Klipper + Moonraker + Mainsail on a Raspberry Pi 4
|
|||||||
(`http://mainsailos.local`, Moonraker API on port 80). AFC Box Turtle with
|
(`http://mainsailos.local`, Moonraker API on port 80). AFC Box Turtle with
|
||||||
5 lanes, Blobifier purge bucket, Beacon (Z homing and probing), Nitehawk-SB
|
5 lanes, Blobifier purge bucket, Beacon (Z homing and probing), Nitehawk-SB
|
||||||
toolboard (USB), Leviathan mainboard as USB-CAN bridge, bd_pressure
|
toolboard (USB), Leviathan mainboard as USB-CAN bridge, bd_pressure
|
||||||
(load-check firmware, branch `load-check-extension` in
|
(load-check firmware; `bdpressure.py`, `bdpressure_check.py` and `bdp_guard.py`
|
||||||
`D:\Claude\bd_pressure-load-check\bd_pressure`), bdwidth (CCD width/motion sensor on USB; switched off: its motion reading
|
come from the fork `https://github.com/MangaValk/bd_pressure`, local clone
|
||||||
|
`D:\Claude\bd_pressure`, branch `main`, installed on the Pi in `~/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
|
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
|
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
|
`[bdwidth fila_width_0]`; clogs and breaks are caught by AFC's buffer fault
|
||||||
@@ -37,7 +39,11 @@ detection, `filament_error_sensitivity`), iHeater chamber heater.
|
|||||||
On the Pi, `macros/` is linked as `~/printer_data/config/klipper-macros/`
|
On the Pi, `macros/` is linked as `~/printer_data/config/klipper-macros/`
|
||||||
and `scripts/` as `~/printer_data/config/klipper-macros-scripts/`.
|
and `scripts/` as `~/printer_data/config/klipper-macros-scripts/`.
|
||||||
- `extras/*.py` are linked into `~/klipper/klippy/extras/`.
|
- `extras/*.py` are linked into `~/klipper/klippy/extras/`.
|
||||||
- `scripts/` MCU firmware update scripts (printer-specific IDs) and
|
- MCU firmware: aldis (`external/aldis`, git submodule pinned to the release in
|
||||||
|
use, v0.4.0; the Pi runs the released binary in `~/aldis`). Bump the
|
||||||
|
submodule when the Pi's aldis is updated.
|
||||||
|
- `scripts/` Katapult update script (printer-specific IDs), the archived Klipper
|
||||||
|
update script in `scripts/archive/`, and
|
||||||
`twist_check.py` (axis twist calibration, runs on the Pi and talks to
|
`twist_check.py` (axis twist calibration, runs on the Pi and talks to
|
||||||
Moonraker on localhost; started by `TWIST_CALIBRATE` in
|
Moonraker on localhost; started by `TWIST_CALIBRATE` in
|
||||||
`macros/calibration/twist_check.cfg`, results in `config/twist_data/`).
|
`macros/calibration/twist_check.cfg`, results in `config/twist_data/`).
|
||||||
@@ -57,7 +63,19 @@ detection, `filament_error_sensitivity`), iHeater chamber heater.
|
|||||||
After a PAUSE, `_RESUME_PRINT` first purges with `BLOBIFIER_CHECKED`
|
After a PAUSE, `_RESUME_PRINT` first purges with `BLOBIFIER_CHECKED`
|
||||||
(`_RESUME_PURGE`); a failed check raises an error, which aborts the whole
|
(`_RESUME_PURGE`); a failed check raises an error, which aborts the whole
|
||||||
chain (AFC_RESUME's restore too), so the printer stays paused.
|
chain (AFC_RESUME's restore too), so the printer stays paused.
|
||||||
|
- A failed bed check in `PRINT_START` (`calibration/bed_scan_check.cfg`) pauses
|
||||||
|
with `_BED_CHECK_STATE.pending` set: `PAUSE` then only pauses, and `RESUME`
|
||||||
|
calls `_BED_CHECK_RETRY`, which sets the print file back to the `PRINT_START`
|
||||||
|
line (`M26`) and resumes. Everything after the check belongs in
|
||||||
|
`_PRINT_START_FINISH`: a pause does not stop a running macro.
|
||||||
|
- An AFC infinite spool swap pauses and resumes the file without the PAUSE and
|
||||||
|
RESUME macros and only stops on AFC's own error state, so PAUSE cannot stop it.
|
||||||
|
During a swap `print_stats.state` is paused with `pause_resume.is_paused` False;
|
||||||
|
a failed purge check then raises an error (`_PURGE_CHECK_SWAP_STOP`).
|
||||||
- Only one `[save_variables]`, in `macros/save_variables.cfg`.
|
- Only one `[save_variables]`, in `macros/save_variables.cfg`.
|
||||||
|
- PA values are saved per nozzle and spool (`pa_value_0_4_spool_<id>`), 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
|
- `PRINT_END` and `CANCEL_PRINT` share `_PRINT_CLEANUP` (heaters including
|
||||||
`iHEATER_OFF`, fan, `M221 S100`, bdwidth off). Anything that must happen
|
`iHEATER_OFF`, fan, `M221 S100`, bdwidth off). Anything that must happen
|
||||||
at the end of every print goes there. `RESTORE_GCODE_STATE` restores the
|
at the end of every print goes there. `RESTORE_GCODE_STATE` restores the
|
||||||
@@ -73,7 +91,7 @@ detection, `filament_error_sensitivity`), iHeater chamber heater.
|
|||||||
not `action_raise_error` / `RESPOND TYPE=error`, so they also show on the
|
not `action_raise_error` / `RESPOND TYPE=error`, so they also show on the
|
||||||
display. `action_raise_error` aborts while rendering, so an `M117` in the
|
display. `action_raise_error` aborts while rendering, so an `M117` in the
|
||||||
same macro would never run. No double quotes in `MSG`/`DISPLAY`.
|
same macro would never run. No double quotes in `MSG`/`DISPLAY`.
|
||||||
- Nozzle guard (`print/nozzle_guard.cfg`, `extras/bdp_guard.py`): wrap only
|
- Nozzle guard (`print/nozzle_guard.cfg`, `bdp_guard.py` in the bd_pressure repo): wrap only
|
||||||
moves where nothing may touch the nozzle in `_GUARD_ON PHASE=x` /
|
moves where nothing may touch the nozzle in `_GUARD_ON PHASE=x` /
|
||||||
`_GUARD_OFF`. Never leave it on across contact homing, extrusion, purges,
|
`_GUARD_OFF`. Never leave it on across contact homing, extrusion, purges,
|
||||||
the Blobifier park or AFC cuts and loads: in `mode: stop` that is an
|
the Blobifier park or AFC cuts and loads: in `mode: stop` that is an
|
||||||
@@ -106,6 +124,9 @@ detection, `filament_error_sensitivity`), iHeater chamber heater.
|
|||||||
in log mode); a light finger push on the cold nozzle gives 41
|
in log mode); a light finger push on the cold nozzle gives 41
|
||||||
(threshold 30).
|
(threshold 30).
|
||||||
- Z check after a contact homing: Beacon vs Klipper Z about 0.06 mm.
|
- Z check after a contact homing: Beacon vs Klipper Z about 0.06 mm.
|
||||||
|
- Bed check (mesh_check, limits 0.03 and 0.30 mm): clean plate, worst deviation
|
||||||
|
0.016 mm cold and on a hot PLA print, range 0.12-0.17. Residue on the plate:
|
||||||
|
0.06-0.09 mm with the mesh ending at its edge, 0.30 mm with the mesh over it.
|
||||||
- XY drift check: endstop noise about 0.01-0.02 mm; limit 0.1 mm (one motor
|
- XY drift check: endstop noise about 0.01-0.02 mm; limit 0.1 mm (one motor
|
||||||
skipping one cycle = 0.4 mm shows as 0.2 mm in X and Y).
|
skipping one cycle = 0.4 mm shows as 0.2 mm in X and Y).
|
||||||
|
|
||||||
|
|||||||
@@ -25,24 +25,25 @@ everything below, grouped by topic. Comment out what you do not use there.
|
|||||||
| `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` |
|
| `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` | — |
|
| `filament.cfg` | `LOAD_FILAMENT`, `UNLOAD_FILAMENT` | — |
|
||||||
| `homing.cfg` | `HOME`: X/Y, then Z always with Beacon contact (also when already homed); `_Z_CHECK`: stops the print when Klipper's Z and the Beacon reading differ (run in `PRINT_START` after the soak) | Beacon |
|
| `homing.cfg` | `HOME`: X/Y, then Z always with Beacon contact (also when already homed); `_Z_CHECK`: stops the print when Klipper's Z and the Beacon reading differ (run in `PRINT_START` after the soak) | Beacon |
|
||||||
| `nozzle_guard.cfg` | `[bdp_guard]`, `_GUARD_ON PHASE=<name>`, `_GUARD_OFF`: bd_pressure watches the nozzle force during print-start moves where nothing should touch it (QGL, Z homing, mesh); `mode: stop` shuts Klipper down on a touch (the brush runs log-only), `mode: log` only reports the peak per phase | `extras/bdp_guard.py` + bd_pressure load-check firmware |
|
| `nozzle_guard.cfg` | `[bdp_guard]`, `_GUARD_ON PHASE=<name>`, `_GUARD_OFF`: bd_pressure watches the nozzle force during print-start moves where nothing should touch it (QGL, Z homing, mesh); `mode: stop` shuts Klipper down on a touch (the brush runs log-only), `mode: log` only reports the peak per phase | `bdp_guard.py` from the bd_pressure repo + its load-check firmware |
|
||||||
| `test_speed.cfg` | `TEST_SPEED`: skipped-steps test for speed and acceleration | — |
|
| `test_speed.cfg` | `TEST_SPEED`: skipped-steps test for speed and acceleration | — |
|
||||||
| `idle_timeout.cfg` | `[idle_timeout]`: heaters, chamber heater and motors off | iHeater macros |
|
| `idle_timeout.cfg` | `[idle_timeout]`: heaters, chamber heater and motors off | iHeater macros |
|
||||||
| **heating/** | | |
|
| **heating/** | | |
|
||||||
| `heat_soak.cfg` | `HEAT_SOAK`, `STOP_HEAT_SOAK`, `CANCEL_HEAT_SOAK`, `HEAT_SOAK_RESUME`, `RESUME` | — |
|
| `heat_soak.cfg` | `HEAT_SOAK`, `STOP_HEAT_SOAK`, `CANCEL_HEAT_SOAK`, `HEAT_SOAK_RESUME`, `RESUME` | — |
|
||||||
| `soak_my_bed.cfg` | `SOAK_MY_BED` (homes and levels first) | soak-my-bed |
|
| `soak_my_bed.cfg` | `SOAK_MY_BED` (homes and levels first) | soak-my-bed |
|
||||||
| `bed_fans.cfg` | Bed fans through `SET_HEATER_TEMPERATURE`/`M190`/`M140`/`TURN_OFF_HEATERS` overrides | `[fan_generic BedFans]` |
|
| `bed_fans.cfg` | Bed fans through `SET_HEATER_TEMPERATURE`/`M190`/`M140`/`TURN_OFF_HEATERS` overrides; off during a print without a heated chamber (`PRINT_WARMUP CHAMBER=` 30 or less), on during the cooldown after any print | `[fan_generic BedFans]` |
|
||||||
| `chamber_iheater.cfg` | iHeater MCU, heater and sensors, `M141`, `M191`, `iHEATER_ON`, `iHEATER_OFF` | iHeater chamber heater |
|
| `chamber_iheater.cfg` | iHeater MCU, heater and sensors, `M141`, `M191`, `iHEATER_ON`, `iHEATER_OFF` | iHeater chamber heater |
|
||||||
| `filament_drying.cfg` | `START_DRYING`, `STOP_DRYING`, `STATUS_DRYING` | bed fans, chamber heater (optional) |
|
| `filament_drying.cfg` | `START_DRYING`, `STOP_DRYING`, `STATUS_DRYING` | bed fans, chamber heater (optional) |
|
||||||
| **afc/** | | |
|
| **afc/** | | |
|
||||||
| `xy_safety_check.cfg` | `AFC_XY_SAFETY_CHECK`, `_AFC_STORE_HOME_REFERENCE`, `AFC_XY_RESUME`: lost-step check around tool changes | `extras/xy_drift.py` (CoreXY) |
|
| `xy_safety_check.cfg` | `AFC_XY_SAFETY_CHECK`, `_AFC_STORE_HOME_REFERENCE`, `AFC_XY_RESUME`: lost-step check around tool changes | `extras/xy_drift.py` (CoreXY) |
|
||||||
| `lane_tools.cfg` | `LANE_FEED_UNTIL_HUB_OPEN`, `LANE_FEED_ABORT` | AFC |
|
| `lane_tools.cfg` | `LANE_FEED_UNTIL_HUB_OPEN`, `LANE_FEED_ABORT` | AFC |
|
||||||
| `purge_check.cfg` | `BLOBIFIER_CHECKED`: checks every AFC purge with bd_pressure (and optionally bdwidth motion); a bd_pressure that does not answer fails the check, `PURGE_CHECK_IGNORE_SENSOR` lets the current print finish without it; when the previous filament (saved `nozzle_last_temp`) needs more than 10°C above the new one, the purge runs at the previous filament's temperature and the nozzle cools back afterwards, so its leftover melts out | Blobifier, AFC, `extras/bdpressure_check.py` + bd_pressure load-check firmware, `extras/bdwidth_status.py` |
|
| `purge_check.cfg` | `BLOBIFIER_CHECKED`: checks every AFC purge with bd_pressure (and optionally bdwidth motion); a bd_pressure that does not answer fails the check, `PURGE_CHECK_IGNORE_SENSOR` lets the current print finish without it; when the previous filament (saved `nozzle_last_temp`) needs more than 10°C above the new one, the purge runs at the previous filament's temperature and the nozzle cools back afterwards, so its leftover melts out | Blobifier, AFC, `bdpressure_check.py` from the bd_pressure repo + its load-check firmware, `extras/bdwidth_status.py` |
|
||||||
| `flex_lanes.cfg` | Lanes holding TPU/TPE (material from Spoolman) get slower long moves (50 mm/s, AFC's minimum) through the tube; back to the configured speed when the lane holds something else. Polls every 5 s, reapplies after a restart. The last stretch into the extruder (`tool_load_speed`) stays as configured | AFC |
|
| `flex_lanes.cfg` | Lanes holding TPU/TPE (material from Spoolman) get slower long moves (50 mm/s, AFC's minimum) through the tube; back to the configured speed when the lane holds something else. Polls every 5 s, reapplies after a restart. The last stretch into the extruder (`tool_load_speed`) stays as configured | AFC |
|
||||||
|
| `auto_resume.cfg` | After an AFC "NOT FEEDING" buffer fault pause during a print (not "CLOG DETECTED": usually a real blockage), runs `RESUME` by itself after 5 s, so the lane check and the purge check decide; a failed check keeps it paused. At most 2 per print and none within 10 min of printing after the previous one; not during `PRINT_START` or a PA test. Off: `enabled` in `_AUTO_RESUME_CFG` | `print/pause_resume.cfg`, `purge_check.cfg`, AFC |
|
||||||
| `purge_until_empty.cfg` | `PURGE_UNTIL_EMPTY`: purges a snapped filament out until there is no more nozzle pressure | same as `purge_check.cfg` |
|
| `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/** | | |
|
| **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_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/** | | |
|
| **spoolman/** | | |
|
||||||
| `active_spool.cfg` | `SET_ACTIVE_SPOOL`, `CLEAR_ACTIVE_SPOOL` | Spoolman in Moonraker |
|
| `active_spool.cfg` | `SET_ACTIVE_SPOOL`, `CLEAR_ACTIVE_SPOOL` | Spoolman in Moonraker |
|
||||||
| **leds/** | | |
|
| **leds/** | | |
|
||||||
@@ -53,6 +54,7 @@ everything below, grouped by topic. Comment out what you do not use there.
|
|||||||
|
|
||||||
| **calibration/** | | |
|
| **calibration/** | | |
|
||||||
| `twist_check.cfg` + `scripts/twist_check.py` | `TWIST_CALIBRATE`: axis twist calibration from Mainsail with windows that explain each step. Measure (25 min) says whether new `[axis_twist_compensation]` values are needed, Verify (17 min) checks them with bd_pressure. Progress on the status line, result in a window, HTML report with charts in `config/twist_data/`. Never changes `printer.cfg`. `TWIST_STOP` stops a run. | Beacon, `[axis_twist_compensation]`, `gcode_shell_command`, Mainsail prompts; Verify also `bdp_touch.py` |
|
| `twist_check.cfg` + `scripts/twist_check.py` | `TWIST_CALIBRATE`: axis twist calibration from Mainsail with windows that explain each step. Measure (25 min) says whether new `[axis_twist_compensation]` values are needed, Verify (17 min) checks them with bd_pressure. Progress on the status line, result in a window, HTML report with charts in `config/twist_data/`. Never changes `printer.cfg`. `TWIST_STOP` stops a run. | Beacon, `[axis_twist_compensation]`, `gcode_shell_command`, Mainsail prompts; Verify also `bdp_touch.py` |
|
||||||
|
| `bed_scan_check.cfg` | `BED_SCAN_CHECK [BUMP=0.03] [RANGE=0.30]`: levels, scans and warns about bumps, dips or too much height range, without heating or touching the bed. In `PRINT_START` a failed check pauses before the nozzle heats and moves the toolhead away: clean the plate and Resume, which runs `PRINT_START` again from QGL with a new scan and check. `BED_CHECK_IGNORE`, then Resume: the next failed check only warns | `extras/mesh_check.py`, Beacon, AFC |
|
||||||
|
|
||||||
### Klipper modules (`extras/`)
|
### Klipper modules (`extras/`)
|
||||||
|
|
||||||
@@ -60,15 +62,25 @@ everything below, grouped by topic. Comment out what you do not use there.
|
|||||||
|---|---|
|
|---|---|
|
||||||
| `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. |
|
| `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 (`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 |
|
| `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. Also reports how many readings the last `PA_CALIBRATE` got (`pa_points`, `pa_distinct`), used to reject runs with a silent or stuck sensor. |
|
|
||||||
| `bdp_guard.py` | nozzle collision guard: while armed (`BDP_GUARD_ARM/DISARM/QUERY`) reads the bd_pressure force every 20 ms over I2C and, in stop mode, shuts Klipper down when it stays above the threshold. Reports reads, peak and errors per phase in the console and klippy.log. When it arms and finds the sensor still in PA mode (an emergency stop during `PA_CALIBRATE`; `FIRMWARE_RESTART` does not reset the sensor), it switches it to probe mode and takes a new zero first. Puts a lock on the sensor's I2C connection that `bdpressure.py` and `bdpressure_check.py` also go through (Klipper allows one I2C request at a time per device). Needs the load-check firmware. |
|
|
||||||
| `bdp_touch.py` | `BDP_TOUCH`: lowers the nozzle in one slow continuous move (drip mode, like a homing move) while reading the bd_pressure force as fast as I2C allows (its endstop output is not wired), stops at a force limit (default 60) or 0.5 mm below the start, then lifts back; it must be one quick press, because the sensor re-zeros itself while the force looks steady; reports the height where the force reaches the threshold and the zero-force height from a line fit, and logs the whole curve to klippy.log. `_TOUCH_COMPARE`: alternates that with Beacon's contact probe. Refuses while the bdp_guard is armed or the sensor is in PA mode. Needs the load-check firmware. |
|
| `bdp_touch.py` | `BDP_TOUCH`: lowers the nozzle in one slow continuous move (drip mode, like a homing move) while reading the bd_pressure force as fast as I2C allows (its endstop output is not wired), stops at a force limit (default 60) or 0.5 mm below the start, then lifts back; it must be one quick press, because the sensor re-zeros itself while the force looks steady; reports the height where the force reaches the threshold and the zero-force height from a line fit, and logs the whole curve to klippy.log. `_TOUCH_COMPARE`: alternates that with Beacon's contact probe. Refuses while the bdp_guard is armed or the sensor is in PA mode. Needs the load-check firmware. |
|
||||||
|
| `mesh_check.py` | `BED_MESH_CHECK`: fits a smooth surface to the loaded mesh and reports the height range and every area further from it than the limit, with its position. Only reads the mesh. Needs numpy (Beacon needs it too). |
|
||||||
|
|
||||||
|
The bd_pressure load check (`bdpressure_check.py`: `BDP_CHECK_START/STOP/QUERY`,
|
||||||
|
`pa_points`/`pa_distinct`) and nozzle guard (`bdp_guard.py`: `BDP_GUARD_ARM/DISARM/QUERY`)
|
||||||
|
moved to the bd_pressure repo (`https://github.com/MangaValk/bd_pressure`, folder
|
||||||
|
`klipper/`, docs in `klipper/load_check/README.md`). Install that repo with its
|
||||||
|
`klipper/install.sh` and its own `[update_manager bd_pressure]` entry; the macros
|
||||||
|
here (`purge_check.cfg`, `nozzle_guard.cfg`, `bd_pa_spoolman.cfg`) still use them.
|
||||||
|
|
||||||
### Scripts (`scripts/`)
|
### Scripts (`scripts/`)
|
||||||
|
|
||||||
Firmware update scripts for all MCUs (Klipper and Katapult). They contain
|
MCU firmware: Klipper on the MCUs is updated with
|
||||||
this printer's CAN UUIDs and serial IDs: see [scripts/README.md](scripts/README.md)
|
[aldis](https://github.com/mjonuschat/aldis), included as a git submodule in
|
||||||
before using them on another printer. `twist_check.py` is the axis twist
|
`external/aldis` (pinned to the release in use; on the Pi run the released
|
||||||
|
program in `~/aldis`). Install and use: [scripts/README.md](scripts/README.md).
|
||||||
|
The old Klipper update script is in `scripts/archive/`; the Katapult script
|
||||||
|
(`update_katapult_all_mcus.sh`, this printer's CAN UUIDs and serial IDs) is
|
||||||
|
still used for the bootloaders. `twist_check.py` is the axis twist
|
||||||
calibration behind `TWIST_CALIBRATE`: see [scripts/twist_check.md](scripts/twist_check.md).
|
calibration behind `TWIST_CALIBRATE`: see [scripts/twist_check.md](scripts/twist_check.md).
|
||||||
|
|
||||||
### Tools (`tools/`)
|
### Tools (`tools/`)
|
||||||
@@ -141,7 +153,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`
|
- **Settings at the top of a file** (`variable_...`): `afc/purge_check.cfg`
|
||||||
(`mode: "enforce"`, `motion_check: False` because this printer's bdwidth
|
(`mode: "enforce"`, `motion_check: False` because this printer's bdwidth
|
||||||
motion reading is unreliable), `pressure_advance/bd_pa_spoolman.cfg`
|
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.
|
- `xy_drift.py` is for CoreXY only.
|
||||||
|
|
||||||
Comment out files you do not need in `klipper-macros.cfg`.
|
Comment out files you do not need in `klipper-macros.cfg`.
|
||||||
@@ -172,6 +184,7 @@ original licenses apply to those parts:
|
|||||||
| `pressure_advance/bd_pressure.cfg` | [bd_pressure](https://github.com/markniu/bd_pressure) `klipper/bd_pressure.cfg` |
|
| `pressure_advance/bd_pressure.cfg` | [bd_pressure](https://github.com/markniu/bd_pressure) `klipper/bd_pressure.cfg` |
|
||||||
| `print/test_speed.cfg` | [Ellis' TEST_SPEED](https://ellis3dp.com/Print-Tuning-Guide/articles/determining_max_speeds_accels.html) |
|
| `print/test_speed.cfg` | [Ellis' TEST_SPEED](https://ellis3dp.com/Print-Tuning-Guide/articles/determining_max_speeds_accels.html) |
|
||||||
| `print/pause_resume.cfg`, `print/filament.cfg` | [KlipperScreen recommended macros](https://klipperscreen.readthedocs.io/en/latest/macros/#recommended) |
|
| `print/pause_resume.cfg`, `print/filament.cfg` | [KlipperScreen recommended macros](https://klipperscreen.readthedocs.io/en/latest/macros/#recommended) |
|
||||||
|
| `external/aldis` | [aldis](https://github.com/mjonuschat/aldis) by mjonuschat, GPL-3.0 (git submodule, unchanged) |
|
||||||
| `scripts/` | [Voron docs: automating MCU updates](https://docs.vorondesign.com/community/howto/drachenkatze/automating_klipper_mcu_updates.html), [Esoterical's CANBus guide](https://canbus.esoterical.online/) |
|
| `scripts/` | [Voron docs: automating MCU updates](https://docs.vorondesign.com/community/howto/drachenkatze/automating_klipper_mcu_updates.html), [Esoterical's CANBus guide](https://canbus.esoterical.online/) |
|
||||||
|
|
||||||
Uses: [Klipper](https://github.com/Klipper3d/klipper),
|
Uses: [Klipper](https://github.com/Klipper3d/klipper),
|
||||||
|
|||||||
+1
Submodule external/aldis added at 607c8db1b0.
@@ -1,283 +0,0 @@
|
|||||||
# Nozzle collision guard with bd_pressure (load-check firmware extension).
|
|
||||||
#
|
|
||||||
# The bd_pressure strain gauge sees the force on the nozzle. The load-check
|
|
||||||
# firmware keeps the current force minus its baseline in register 64-65
|
|
||||||
# (chk_delta), also outside a load check; it is the same value the endstop
|
|
||||||
# output switches on (|delta| >= thrhold). While the guard is armed this
|
|
||||||
# module reads it every INTERVAL seconds. In stop mode, SAMPLES reads in a
|
|
||||||
# row at or above THRESHOLD shut Klipper down at once (like M112, without
|
|
||||||
# waiting for the running macro to finish).
|
|
||||||
#
|
|
||||||
# Every ARM (also a phase switch) first sets a new zero (register 52), so
|
|
||||||
# slow pressure changes before the guarded moves do not count (TPU in a
|
|
||||||
# nozzle that heats up keeps changing pressure for minutes).
|
|
||||||
#
|
|
||||||
# Arm it only around moves where the nozzle must not touch anything: not
|
|
||||||
# around contact homing, extrusion, purges or AFC cuts and loads, which
|
|
||||||
# press on the nozzle on purpose. ARM and DISARM act immediately, not in
|
|
||||||
# the move queue: put an M400 before them (the _GUARD_ON/_GUARD_OFF macros
|
|
||||||
# do this).
|
|
||||||
#
|
|
||||||
# Install: copy to ~/klipper/klippy/extras/bdp_guard.py and add
|
|
||||||
#
|
|
||||||
# [bdp_guard]
|
|
||||||
# sensor: bd_pa # name after "bdpressure" in [bdpressure bd_pa]
|
|
||||||
# mode: log # log: only measure; stop: shut down on a touch
|
|
||||||
# threshold: 30 # |delta| that counts as a touch
|
|
||||||
# samples: 3 # reads in a row at or above threshold
|
|
||||||
# interval: 0.02 # seconds between reads while armed
|
|
||||||
# timeout: 600 # disarm by itself when a phase runs this long
|
|
||||||
# # (a macro that failed before its DISARM)
|
|
||||||
#
|
|
||||||
# Commands:
|
|
||||||
# BDP_GUARD_ARM PHASE=<name> [MODE=log|stop] start (or switch phase)
|
|
||||||
# BDP_GUARD_DISARM stop and report the phase
|
|
||||||
# BDP_GUARD_QUERY report without stopping
|
|
||||||
#
|
|
||||||
# Each phase reports (console and klippy.log, "bdp_guard:") the reads, the
|
|
||||||
# peak |delta|, the longest run of reads at or above threshold and the
|
|
||||||
# read errors, so a log-mode print start shows what each phase normally
|
|
||||||
# measures before stop mode is switched on.
|
|
||||||
#
|
|
||||||
# Status (printer.bdp_guard): armed, mode, phase, threshold, samples, peak,
|
|
||||||
# longest_run, reads, errors, available
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
REG_MODE = 48 # status_clk: 7 = PA mode, 2 = probe (endstop) mode
|
|
||||||
REG_RESET_PROBE = 52 # set_normal: write 1 = take the current reading as zero
|
|
||||||
MODE_PA = 7
|
|
||||||
REG_EXT = 54 # extension marker 0xBD + version
|
|
||||||
REG_DELTA = 64 # chk_delta, int16 little-endian
|
|
||||||
EXT_MAGIC = 0xBD
|
|
||||||
MODES = ('log', 'stop')
|
|
||||||
|
|
||||||
|
|
||||||
# Klipper allows only one I2C request at a time per device: a second one
|
|
||||||
# while the first waits for its answer raises KeyError ('i2c_response', oid)
|
|
||||||
# and shuts Klipper down. The guard reads from a timer while G-code runs,
|
|
||||||
# and bdpressure.py writes the probe mode at every homing move (seen: G28
|
|
||||||
# during an armed guard), so all transfers of the sensor take this lock.
|
|
||||||
# The guard puts it on the sensor object at connect; bdpressure and
|
|
||||||
# bdpressure_check use sensor.i2c and so get it too.
|
|
||||||
class LockedI2C:
|
|
||||||
def __init__(self, i2c, mutex):
|
|
||||||
self._i2c = i2c
|
|
||||||
self._mutex = mutex
|
|
||||||
|
|
||||||
def i2c_read(self, *args, **kwargs):
|
|
||||||
with self._mutex:
|
|
||||||
return self._i2c.i2c_read(*args, **kwargs)
|
|
||||||
|
|
||||||
def i2c_write(self, *args, **kwargs):
|
|
||||||
with self._mutex:
|
|
||||||
return self._i2c.i2c_write(*args, **kwargs)
|
|
||||||
|
|
||||||
def i2c_write_wait_ack(self, *args, **kwargs):
|
|
||||||
with self._mutex:
|
|
||||||
return self._i2c.i2c_write_wait_ack(*args, **kwargs)
|
|
||||||
|
|
||||||
def i2c_transfer(self, *args, **kwargs):
|
|
||||||
with self._mutex:
|
|
||||||
return self._i2c.i2c_transfer(*args, **kwargs)
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
|
||||||
return getattr(self._i2c, name)
|
|
||||||
|
|
||||||
|
|
||||||
class BDPGuard:
|
|
||||||
def __init__(self, config):
|
|
||||||
self.printer = config.get_printer()
|
|
||||||
self.reactor = self.printer.get_reactor()
|
|
||||||
self.sensor_name = 'bdpressure ' + config.get('sensor', 'bd_pa')
|
|
||||||
self.mode = config.getchoice('mode', {m: m for m in MODES}, 'log')
|
|
||||||
self.threshold = config.getint('threshold', 30, minval=1)
|
|
||||||
self.samples = config.getint('samples', 3, minval=1)
|
|
||||||
self.interval = config.getfloat('interval', 0.02, minval=0.005)
|
|
||||||
self.timeout = config.getfloat('timeout', 600., minval=10.)
|
|
||||||
self.armed_until = 0.
|
|
||||||
self.sensor = self.i2c = None
|
|
||||||
self.available = False
|
|
||||||
self.timer = None
|
|
||||||
self.zeroing = False
|
|
||||||
self.phase_mode = self.mode
|
|
||||||
self._reset_phase('')
|
|
||||||
self.printer.register_event_handler('klippy:connect',
|
|
||||||
self._handle_connect)
|
|
||||||
self.printer.register_event_handler('klippy:shutdown',
|
|
||||||
self._handle_shutdown)
|
|
||||||
gcode = self.printer.lookup_object('gcode')
|
|
||||||
gcode.register_command('BDP_GUARD_ARM', self.cmd_ARM,
|
|
||||||
desc="Arm the bd_pressure nozzle collision guard")
|
|
||||||
gcode.register_command('BDP_GUARD_DISARM', self.cmd_DISARM,
|
|
||||||
desc="Disarm the bd_pressure nozzle collision guard")
|
|
||||||
gcode.register_command('BDP_GUARD_QUERY', self.cmd_QUERY,
|
|
||||||
desc="Report the bd_pressure guard values")
|
|
||||||
|
|
||||||
def _handle_connect(self):
|
|
||||||
self.sensor = self.printer.lookup_object(self.sensor_name, None)
|
|
||||||
i2c = getattr(self.sensor, 'i2c', None)
|
|
||||||
if i2c is not None and not isinstance(i2c, LockedI2C):
|
|
||||||
# Every user of the sensor (bdpressure, bdpressure_check, this
|
|
||||||
# guard) now goes through one lock, see LockedI2C
|
|
||||||
i2c = LockedI2C(i2c, self.reactor.mutex())
|
|
||||||
self.sensor.i2c = i2c
|
|
||||||
self.i2c = i2c
|
|
||||||
|
|
||||||
def _handle_shutdown(self):
|
|
||||||
self._stop_timer()
|
|
||||||
|
|
||||||
def _reset_phase(self, phase):
|
|
||||||
self.phase = phase
|
|
||||||
self.peak = self.longest_run = self.run = 0
|
|
||||||
self.reads = self.errors = 0
|
|
||||||
|
|
||||||
def _check_available(self):
|
|
||||||
if self.i2c is None:
|
|
||||||
return False
|
|
||||||
try:
|
|
||||||
data = bytearray(self.i2c.i2c_read([REG_EXT], 2)['response'])
|
|
||||||
except Exception:
|
|
||||||
logging.exception("bdp_guard: reading the extension marker failed")
|
|
||||||
return False
|
|
||||||
return len(data) == 2 and data[0] == EXT_MAGIC and data[1] >= 1
|
|
||||||
|
|
||||||
def _ensure_probe_mode(self, gcmd):
|
|
||||||
# An emergency stop during PA_CALIBRATE leaves the sensor in PA mode
|
|
||||||
# (FIRMWARE_RESTART does not reset it); bdpressure.py only switches
|
|
||||||
# it back at the next homing move, after the guard is armed. In PA
|
|
||||||
# mode the delta means nothing and could trip the guard. Register 48
|
|
||||||
# is the mode: 7 = PA, 2 = probe.
|
|
||||||
if getattr(self.sensor, 'last_state', 0):
|
|
||||||
return # a calibration runs, leave the sensor alone
|
|
||||||
try:
|
|
||||||
mode = bytearray(self.i2c.i2c_read([REG_MODE], 1)['response'])
|
|
||||||
if len(mode) != 1 or mode[0] != MODE_PA:
|
|
||||||
return
|
|
||||||
self.sensor.set_probe_mode()
|
|
||||||
# new samples at the probe sample rate, then a fresh baseline
|
|
||||||
self.reactor.pause(self.reactor.monotonic() + 0.5)
|
|
||||||
self.i2c.i2c_write([REG_RESET_PROBE, 1])
|
|
||||||
self.reactor.pause(self.reactor.monotonic() + 0.3)
|
|
||||||
except Exception:
|
|
||||||
logging.exception("bdp_guard: switching the sensor to probe mode failed")
|
|
||||||
return
|
|
||||||
msg = ("BDP_GUARD: bd_pressure was still in PA mode (stopped "
|
|
||||||
"calibration?), switched to probe mode")
|
|
||||||
logging.info(msg)
|
|
||||||
gcmd.respond_info(msg)
|
|
||||||
|
|
||||||
def _rezero(self):
|
|
||||||
# A fresh zero at every ARM: only force that appears during the
|
|
||||||
# guarded moves counts, not slow changes before them. Seen with TPU
|
|
||||||
# in a nozzle heating to 150C: the pressure kept rising (+43) or
|
|
||||||
# falling as it oozed (-56) for minutes, faster than the sensor's
|
|
||||||
# own baseline update (only when steady, about every 7 s), and
|
|
||||||
# stopped the printer at the start of a phase with the nozzle in
|
|
||||||
# the air. ARM comes after M400, with the nozzle clear of
|
|
||||||
# everything, so this does not hide a real touch.
|
|
||||||
self.zeroing = True
|
|
||||||
try:
|
|
||||||
self.i2c.i2c_write([REG_RESET_PROBE, 1])
|
|
||||||
self.reactor.pause(self.reactor.monotonic() + 0.2)
|
|
||||||
except Exception:
|
|
||||||
logging.exception("bdp_guard: setting a new zero failed")
|
|
||||||
self.zeroing = False
|
|
||||||
|
|
||||||
def _stop_timer(self):
|
|
||||||
if self.timer is not None:
|
|
||||||
self.reactor.unregister_timer(self.timer)
|
|
||||||
self.timer = None
|
|
||||||
|
|
||||||
def _poll(self, eventtime):
|
|
||||||
# Never raise here: an exception in a timer shuts Klipper down.
|
|
||||||
try:
|
|
||||||
if self.printer.is_shutdown():
|
|
||||||
return self.reactor.NEVER
|
|
||||||
if eventtime > self.armed_until:
|
|
||||||
logging.info("bdp_guard: %s armed longer than %.0f s, "
|
|
||||||
"disarmed (%d reads, peak %d)", self.phase,
|
|
||||||
self.timeout, self.reads, self.peak)
|
|
||||||
self._stop_timer()
|
|
||||||
self.phase = ''
|
|
||||||
return self.reactor.NEVER
|
|
||||||
# PA mode (SET_BDPRESSURE START): the delta means nothing then;
|
|
||||||
# while ARM sets a new zero the readings are in between
|
|
||||||
if self.zeroing or getattr(self.sensor, 'last_state', 0):
|
|
||||||
return eventtime + self.interval
|
|
||||||
data = bytearray(self.i2c.i2c_read([REG_DELTA], 2)['response'])
|
|
||||||
if len(data) != 2:
|
|
||||||
self.errors += 1
|
|
||||||
return eventtime + self.interval
|
|
||||||
delta = data[0] | (data[1] << 8)
|
|
||||||
if delta & 0x8000:
|
|
||||||
delta -= 0x10000
|
|
||||||
mag = abs(delta)
|
|
||||||
self.reads += 1
|
|
||||||
self.peak = max(self.peak, mag)
|
|
||||||
self.run = self.run + 1 if mag >= self.threshold else 0
|
|
||||||
self.longest_run = max(self.longest_run, self.run)
|
|
||||||
if self.run >= self.samples and self.phase_mode == 'stop':
|
|
||||||
# klippy:shutdown unregisters this timer
|
|
||||||
self.printer.invoke_shutdown(
|
|
||||||
"bd_pressure guard: nozzle touched something during %s "
|
|
||||||
"(delta %d, threshold %d)"
|
|
||||||
% (self.phase or 'an armed move', delta, self.threshold))
|
|
||||||
return self.reactor.NEVER
|
|
||||||
except Exception:
|
|
||||||
self.errors += 1
|
|
||||||
if self.errors == 1: # 50 reads/s: only the first per phase
|
|
||||||
logging.exception("bdp_guard: read failed")
|
|
||||||
return eventtime + self.interval
|
|
||||||
|
|
||||||
def _report(self, gcmd, prefix):
|
|
||||||
msg = ("%s %s (%s): %d reads, peak %d, longest run >= %d: %d reads, "
|
|
||||||
"%d errors" % (prefix, self.phase or '-', self.phase_mode,
|
|
||||||
self.reads, self.peak, self.threshold,
|
|
||||||
self.longest_run, self.errors))
|
|
||||||
logging.info("bdp_guard: %s", msg)
|
|
||||||
gcmd.respond_info(msg)
|
|
||||||
|
|
||||||
def cmd_ARM(self, gcmd):
|
|
||||||
phase = gcmd.get('PHASE', 'armed')
|
|
||||||
mode = gcmd.get('MODE', self.mode).lower()
|
|
||||||
if mode not in MODES:
|
|
||||||
raise gcmd.error("BDP_GUARD_ARM: MODE must be log or stop")
|
|
||||||
if self.timer is not None:
|
|
||||||
self._report(gcmd, "BDP_GUARD")
|
|
||||||
else:
|
|
||||||
self.available = self._check_available()
|
|
||||||
if not self.available:
|
|
||||||
gcmd.respond_info("BDP_GUARD_ARM: bd_pressure load-check "
|
|
||||||
"extension not found, guard not armed")
|
|
||||||
return
|
|
||||||
self._ensure_probe_mode(gcmd)
|
|
||||||
self._rezero()
|
|
||||||
self.phase_mode = mode
|
|
||||||
self._reset_phase(phase)
|
|
||||||
self.armed_until = self.reactor.monotonic() + self.timeout
|
|
||||||
if self.timer is None:
|
|
||||||
self.timer = self.reactor.register_timer(
|
|
||||||
self._poll, self.reactor.monotonic() + self.interval)
|
|
||||||
|
|
||||||
def cmd_DISARM(self, gcmd):
|
|
||||||
if self.timer is None:
|
|
||||||
return
|
|
||||||
self._stop_timer()
|
|
||||||
self._report(gcmd, "BDP_GUARD")
|
|
||||||
self.phase = ''
|
|
||||||
|
|
||||||
def cmd_QUERY(self, gcmd):
|
|
||||||
self._report(gcmd, "BDP_GUARD_QUERY" + (" armed" if self.timer
|
|
||||||
else " not armed"))
|
|
||||||
|
|
||||||
def get_status(self, eventtime):
|
|
||||||
return {'armed': self.timer is not None, 'mode': self.phase_mode,
|
|
||||||
'phase': self.phase, 'threshold': self.threshold,
|
|
||||||
'samples': self.samples, 'peak': self.peak,
|
|
||||||
'longest_run': self.longest_run, 'reads': self.reads,
|
|
||||||
'errors': self.errors, 'available': self.available}
|
|
||||||
|
|
||||||
|
|
||||||
def load_config(config):
|
|
||||||
return BDPGuard(config)
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
# Load check using the bd_pressure firmware extension (bdp_check_ext.patch).
|
|
||||||
#
|
|
||||||
# Uses the I2C connection the existing [bdpressure <name>] section already
|
|
||||||
# set up. Before writing anything it reads the extension marker (bytes
|
|
||||||
# 54-55 = 0xBD + version 1 or 2). On stock firmware the marker is missing and every
|
|
||||||
# command only reports "not available": nothing is written, because
|
|
||||||
# writing past the stock register table would land in the sensor's RAM.
|
|
||||||
#
|
|
||||||
# Install: copy to ~/klipper/klippy/extras/bdpressure_check.py
|
|
||||||
#
|
|
||||||
# Config:
|
|
||||||
# [bdpressure_check]
|
|
||||||
# sensor: bd_pa # name after "bdpressure" in [bdpressure bd_pa]
|
|
||||||
#
|
|
||||||
# Commands (run them after M400, they act immediately, not in the move queue):
|
|
||||||
# BDP_CHECK_START freeze the baseline and start measuring
|
|
||||||
# BDP_CHECK_STOP stop measuring and read the result
|
|
||||||
# BDP_CHECK_QUERY read the current values without stopping
|
|
||||||
#
|
|
||||||
# Status (printer.bdpressure_check), updated by the commands above:
|
|
||||||
# available, running, peak, above_ms, longest_ms, delta
|
|
||||||
# pa_points, pa_distinct - readings the [bdpressure] module collected in
|
|
||||||
# its last PA_CALIBRATE, and how many of them differ (read
|
|
||||||
# from that module, not from the sensor). A sensor that
|
|
||||||
# stops answering gives few points; one that hangs repeats
|
|
||||||
# the same reading. LANE_CALIBRATE_PA rejects such runs.
|
|
||||||
|
|
||||||
REG_EXT = 54 # first byte of the extension
|
|
||||||
REG_CTRL = 56
|
|
||||||
EXT_LEN = 12 # bytes 54-65, the same in version 1 and 2
|
|
||||||
EXT_MAGIC = 0xBD
|
|
||||||
# Version 2 (load-check firmware 20261015 and later) only adds diagnostics
|
|
||||||
# at 66-71. Accepting only version 1 made the purge check report the sensor
|
|
||||||
# as not answering after the firmware update.
|
|
||||||
EXT_VERSIONS = (1, 2)
|
|
||||||
|
|
||||||
|
|
||||||
class BDPressureCheck:
|
|
||||||
def __init__(self, config):
|
|
||||||
self.printer = config.get_printer()
|
|
||||||
self.sensor_name = 'bdpressure ' + config.get('sensor', 'bd_pa')
|
|
||||||
self.sensor = None
|
|
||||||
self.status = {'available': False, 'running': False, 'peak': 0,
|
|
||||||
'above_ms': 0, 'longest_ms': 0, 'delta': 0}
|
|
||||||
self.printer.register_event_handler('klippy:connect',
|
|
||||||
self._handle_connect)
|
|
||||||
gcode = self.printer.lookup_object('gcode')
|
|
||||||
gcode.register_command('BDP_CHECK_START', self.cmd_START,
|
|
||||||
desc="Start a bd_pressure load check")
|
|
||||||
gcode.register_command('BDP_CHECK_STOP', self.cmd_STOP,
|
|
||||||
desc="Stop the bd_pressure load check and read it")
|
|
||||||
gcode.register_command('BDP_CHECK_QUERY', self.cmd_QUERY,
|
|
||||||
desc="Read the bd_pressure load check values")
|
|
||||||
|
|
||||||
def _handle_connect(self):
|
|
||||||
self.sensor = self.printer.lookup_object(self.sensor_name)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def i2c(self):
|
|
||||||
# Looked up at every use: bdp_guard replaces the sensor's i2c with a
|
|
||||||
# locked wrapper at connect, possibly after this module's connect.
|
|
||||||
return getattr(self.sensor, 'i2c', None)
|
|
||||||
|
|
||||||
def _read(self):
|
|
||||||
if self.i2c is None:
|
|
||||||
self.status['available'] = False
|
|
||||||
return False
|
|
||||||
data = bytearray(self.i2c.i2c_read([REG_EXT], EXT_LEN)['response'])
|
|
||||||
if (len(data) < EXT_LEN or data[0] != EXT_MAGIC
|
|
||||||
or data[1] not in EXT_VERSIONS):
|
|
||||||
self.status['available'] = False
|
|
||||||
return False
|
|
||||||
u16 = lambda i: data[i] | (data[i + 1] << 8)
|
|
||||||
delta = u16(10)
|
|
||||||
self.status.update({
|
|
||||||
'available': True,
|
|
||||||
'running': bool(data[3] & 1),
|
|
||||||
'peak': u16(4),
|
|
||||||
'above_ms': u16(6),
|
|
||||||
'longest_ms': u16(8),
|
|
||||||
'delta': delta - 0x10000 if delta & 0x8000 else delta,
|
|
||||||
})
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _respond(self, gcmd, prefix):
|
|
||||||
s = self.status
|
|
||||||
if not s['available']:
|
|
||||||
gcmd.respond_info("%s: bd_pressure check extension not found "
|
|
||||||
"(stock firmware?), nothing done" % prefix)
|
|
||||||
return
|
|
||||||
gcmd.respond_info("%s: running=%d peak=%d above=%d ms longest=%d ms "
|
|
||||||
"delta=%d" % (prefix, s['running'], s['peak'],
|
|
||||||
s['above_ms'], s['longest_ms'],
|
|
||||||
s['delta']))
|
|
||||||
|
|
||||||
def cmd_START(self, gcmd):
|
|
||||||
# The values read here are still the previous check's, so only
|
|
||||||
# confirm the start instead of printing them.
|
|
||||||
if self._read():
|
|
||||||
self.i2c.i2c_write([REG_CTRL, 1])
|
|
||||||
self.status.update({'running': True, 'peak': 0, 'above_ms': 0,
|
|
||||||
'longest_ms': 0})
|
|
||||||
gcmd.respond_info("BDP_CHECK_START: started")
|
|
||||||
return
|
|
||||||
self._respond(gcmd, "BDP_CHECK_START")
|
|
||||||
|
|
||||||
def cmd_STOP(self, gcmd):
|
|
||||||
if self._read():
|
|
||||||
self.i2c.i2c_write([REG_CTRL, 0])
|
|
||||||
self._read()
|
|
||||||
self._respond(gcmd, "BDP_CHECK_STOP")
|
|
||||||
|
|
||||||
def cmd_QUERY(self, gcmd):
|
|
||||||
self._read()
|
|
||||||
self._respond(gcmd, "BDP_CHECK_QUERY")
|
|
||||||
|
|
||||||
def get_status(self, eventtime):
|
|
||||||
status = dict(self.status)
|
|
||||||
# [val, res, lk, rk, Hk, Ha] per reading, see bdpressure.py
|
|
||||||
try:
|
|
||||||
data = list(getattr(self.sensor, 'PA_data', None) or [])
|
|
||||||
status['pa_points'] = len(data)
|
|
||||||
status['pa_distinct'] = len(set(tuple(d[1:]) for d in data))
|
|
||||||
except Exception:
|
|
||||||
status['pa_points'] = status['pa_distinct'] = -1
|
|
||||||
return status
|
|
||||||
|
|
||||||
|
|
||||||
def load_config(config):
|
|
||||||
return BDPressureCheck(config)
|
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
# Checks the loaded bed mesh for bumps, dips and too much height range.
|
||||||
|
#
|
||||||
|
# The bed is naturally bowl-shaped, so a height range alone cannot tell dirt
|
||||||
|
# from normal shape. This fits a smooth surface (polynomial, degree 4) to the
|
||||||
|
# probed points, leaving out outliers, and looks at how far each point is from
|
||||||
|
# it. Measured on this printer's Beacon scans (33x35 points):
|
||||||
|
# clean plate, cold or hot: worst deviation 0.016 mm
|
||||||
|
# residue on the plate, 2026-11: 0.07 (bed 60C), 0.09 (bed 100C, at the old
|
||||||
|
# mesh edge), 0.30 mm (cold, mesh over it)
|
||||||
|
# Only reads the mesh: it moves nothing and changes nothing.
|
||||||
|
#
|
||||||
|
# Install: copy to ~/klipper/klippy/extras/mesh_check.py (install.sh links it)
|
||||||
|
# and add
|
||||||
|
#
|
||||||
|
# [mesh_check]
|
||||||
|
# bump_limit: 0.03 # mm from the smooth surface that counts as a bump or dip
|
||||||
|
# range_limit: 0.30 # mm between the highest and lowest point
|
||||||
|
#
|
||||||
|
# Commands:
|
||||||
|
# BED_MESH_CHECK [BUMP=<mm>] [RANGE=<mm>]
|
||||||
|
#
|
||||||
|
# Status (printer.mesh_check): result ('ok', 'fail', 'none' = no mesh or the
|
||||||
|
# check failed, 'not run'), range, worst, areas (number of bumps and dips),
|
||||||
|
# summary (no double quotes, usable in a macro's MSG="...")
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
DEGREE = 4
|
||||||
|
MAX_AREAS = 5 # areas named in the report, biggest deviation first
|
||||||
|
MIN_POINTS = 40 # fewer points cannot carry a degree 4 surface reliably
|
||||||
|
|
||||||
|
|
||||||
|
def surface_residuals(z):
|
||||||
|
# Deviation of each point from a smooth surface. Refit without the points
|
||||||
|
# far from it, so a bump does not pull the surface towards itself.
|
||||||
|
ny, nx = z.shape
|
||||||
|
x, y = np.meshgrid(np.linspace(-1., 1., nx), np.linspace(-1., 1., ny))
|
||||||
|
terms = [x.ravel()**i * y.ravel()**j
|
||||||
|
for i in range(DEGREE + 1) for j in range(DEGREE + 1 - i)]
|
||||||
|
a = np.column_stack(terms)
|
||||||
|
values = z.ravel()
|
||||||
|
keep = np.ones(values.size, dtype=bool)
|
||||||
|
residuals = np.zeros(values.size)
|
||||||
|
for _ in range(5):
|
||||||
|
coeffs = np.linalg.lstsq(a[keep], values[keep], rcond=None)[0]
|
||||||
|
residuals = values - a.dot(coeffs)
|
||||||
|
spread = 1.4826 * np.median(
|
||||||
|
np.abs(residuals[keep] - np.median(residuals[keep])))
|
||||||
|
keep = np.abs(residuals) < max(3. * spread, 0.01)
|
||||||
|
return residuals.reshape(z.shape)
|
||||||
|
|
||||||
|
|
||||||
|
def find_areas(residuals, limit):
|
||||||
|
# Groups of touching points (diagonals too) beyond the limit, as
|
||||||
|
# (peak, row min, row max, column min, column max)
|
||||||
|
ny, nx = residuals.shape
|
||||||
|
over = np.abs(residuals) > limit
|
||||||
|
seen = np.zeros(over.shape, dtype=bool)
|
||||||
|
areas = []
|
||||||
|
for start in zip(*np.nonzero(over)):
|
||||||
|
if seen[start]:
|
||||||
|
continue
|
||||||
|
seen[start] = True
|
||||||
|
stack = [start]
|
||||||
|
points = []
|
||||||
|
while stack:
|
||||||
|
j, i = stack.pop()
|
||||||
|
points.append((j, i))
|
||||||
|
for dj in (-1, 0, 1):
|
||||||
|
for di in (-1, 0, 1):
|
||||||
|
nj, ni = j + dj, i + di
|
||||||
|
if (0 <= nj < ny and 0 <= ni < nx and over[nj, ni]
|
||||||
|
and not seen[nj, ni]):
|
||||||
|
seen[nj, ni] = True
|
||||||
|
stack.append((nj, ni))
|
||||||
|
peak = max((residuals[p] for p in points), key=abs)
|
||||||
|
rows = [p[0] for p in points]
|
||||||
|
cols = [p[1] for p in points]
|
||||||
|
areas.append((float(peak), min(rows), max(rows), min(cols), max(cols)))
|
||||||
|
areas.sort(key=lambda area: -abs(area[0]))
|
||||||
|
return areas
|
||||||
|
|
||||||
|
|
||||||
|
def analyse(matrix, mesh_min, mesh_max, bump_limit, range_limit):
|
||||||
|
# Returns the status dictionary. No Klipper objects, so it can be tested
|
||||||
|
# against saved scans.
|
||||||
|
z = np.array(matrix, dtype=float)
|
||||||
|
if z.ndim != 2 or z.size == 0:
|
||||||
|
return {'result': 'none', 'range': 0., 'worst': 0., 'areas': 0,
|
||||||
|
'summary': 'no bed mesh loaded'}
|
||||||
|
height_range = float(z.max() - z.min())
|
||||||
|
ny, nx = z.shape
|
||||||
|
if z.size < MIN_POINTS:
|
||||||
|
return {'result': 'none', 'range': height_range, 'worst': 0.,
|
||||||
|
'areas': 0,
|
||||||
|
'summary': 'mesh too small to check (%d points)' % (z.size,)}
|
||||||
|
residuals = surface_residuals(z)
|
||||||
|
worst = float(np.abs(residuals).max())
|
||||||
|
areas = find_areas(residuals, bump_limit)
|
||||||
|
step_x = (mesh_max[0] - mesh_min[0]) / float(nx - 1)
|
||||||
|
step_y = (mesh_max[1] - mesh_min[1]) / float(ny - 1)
|
||||||
|
problems = []
|
||||||
|
for peak, row0, row1, col0, col1 in areas[:MAX_AREAS]:
|
||||||
|
problems.append("%s %+.2f mm at X%.0f-%.0f Y%.0f-%.0f" % (
|
||||||
|
"bump" if peak > 0. else "dip", peak,
|
||||||
|
mesh_min[0] + col0 * step_x, mesh_min[0] + col1 * step_x,
|
||||||
|
mesh_min[1] + row0 * step_y, mesh_min[1] + row1 * step_y))
|
||||||
|
if len(areas) > MAX_AREAS:
|
||||||
|
problems.append("%d more" % (len(areas) - MAX_AREAS,))
|
||||||
|
too_wide = height_range > range_limit
|
||||||
|
if too_wide:
|
||||||
|
problems.append("range %.2f mm is over the limit of %.2f" % (
|
||||||
|
height_range, range_limit))
|
||||||
|
text = "range %.3f mm, worst deviation %.3f mm" % (height_range, worst)
|
||||||
|
if problems:
|
||||||
|
text = "%s: %s" % (text, ", ".join(problems))
|
||||||
|
return {'result': 'fail' if problems else 'ok', 'range': height_range,
|
||||||
|
'worst': worst, 'areas': len(areas), 'summary': text}
|
||||||
|
|
||||||
|
|
||||||
|
class MeshCheck:
|
||||||
|
def __init__(self, config):
|
||||||
|
self.printer = config.get_printer()
|
||||||
|
self.reactor = self.printer.get_reactor()
|
||||||
|
self.bump_limit = config.getfloat('bump_limit', 0.03, above=0.)
|
||||||
|
self.range_limit = config.getfloat('range_limit', 0.30, above=0.)
|
||||||
|
self.status = {'result': 'not run', 'range': 0., 'worst': 0.,
|
||||||
|
'areas': 0, 'summary': ''}
|
||||||
|
gcode = self.printer.lookup_object('gcode')
|
||||||
|
gcode.register_command('BED_MESH_CHECK', self.cmd_BED_MESH_CHECK,
|
||||||
|
desc="Check the loaded bed mesh for bumps, "
|
||||||
|
"dips and too much height range")
|
||||||
|
|
||||||
|
def cmd_BED_MESH_CHECK(self, gcmd):
|
||||||
|
bump = gcmd.get_float('BUMP', self.bump_limit, above=0.)
|
||||||
|
height_range = gcmd.get_float('RANGE', self.range_limit, above=0.)
|
||||||
|
# A failing analysis must not stop a print: it reports and goes on
|
||||||
|
try:
|
||||||
|
bed_mesh = self.printer.lookup_object('bed_mesh')
|
||||||
|
mesh = bed_mesh.get_status(self.reactor.monotonic())
|
||||||
|
self.status = analyse(mesh['probed_matrix'], mesh['mesh_min'],
|
||||||
|
mesh['mesh_max'], bump, height_range)
|
||||||
|
except Exception:
|
||||||
|
logging.exception("mesh_check: analysis failed")
|
||||||
|
self.status = {'result': 'none', 'range': 0., 'worst': 0.,
|
||||||
|
'areas': 0,
|
||||||
|
'summary': 'check failed, see klippy.log'}
|
||||||
|
msg = "Bed mesh check: %s" % (self.status['summary'],)
|
||||||
|
logging.info("mesh_check: %s (%s)", msg, self.status['result'])
|
||||||
|
gcmd.respond_info(msg)
|
||||||
|
|
||||||
|
def get_status(self, eventtime):
|
||||||
|
return dict(self.status)
|
||||||
|
|
||||||
|
|
||||||
|
def load_config(config):
|
||||||
|
return MeshCheck(config)
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
# Automatic resume after an AFC "NOT FEEDING" buffer fault
|
||||||
|
#
|
||||||
|
# When AFC pauses a print because the buffer stayed empty too long,
|
||||||
|
# PAUSE (print/pause_resume.cfg) calls _AUTO_RESUME_ARM. After `delay` seconds
|
||||||
|
# _AUTO_RESUME runs the normal RESUME: AFC clears its error, the lane check
|
||||||
|
# runs, and _RESUME_PRINT purges into the Blobifier with the purge check. A
|
||||||
|
# failed check (or lane check) stops that RESUME as usual, so the print stays
|
||||||
|
# paused and waits for you.
|
||||||
|
#
|
||||||
|
# Limits, so a real problem (tangled spool, grinding extruder, clog) is not
|
||||||
|
# hidden: at most `max_per_print` automatic resumes per print, and none when
|
||||||
|
# the previous one was less than `min_interval` minutes of printing ago. After
|
||||||
|
# that the print stays paused like before.
|
||||||
|
#
|
||||||
|
# Only between _PRINT_START_FINISH and the end of the print (`active`): a pause
|
||||||
|
# during PRINT_START or a PA test needs CLEAR_PAUSE, not RESUME.
|
||||||
|
#
|
||||||
|
# Turn off: SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=enabled VALUE=False
|
||||||
|
# (until the next restart; change `enabled` below to keep it off)
|
||||||
|
|
||||||
|
[gcode_macro _AUTO_RESUME_CFG]
|
||||||
|
description: Settings and state for the automatic resume after an AFC buffer fault
|
||||||
|
variable_enabled: True
|
||||||
|
variable_max_per_print: 2 # automatic resumes per print
|
||||||
|
variable_min_interval: 10 # minutes of printing since the previous automatic resume
|
||||||
|
variable_delay: 5 # seconds after the pause (AFC finishes its own pause first)
|
||||||
|
variable_faults: ['NOT FEEDING'] # text in AFC's error message
|
||||||
|
# Not 'CLOG DETECTED' (buffer stayed full: the extruder takes no filament):
|
||||||
|
# that is usually a real blockage. On 2026-11-17 a nozzle blocked right after a
|
||||||
|
# swap; the purge check still passed (a blocked nozzle also builds pressure),
|
||||||
|
# so the automatic resume only printed air until the next CLOG pause.
|
||||||
|
variable_clear_faults: ['NOT FEEDING', 'CLOG DETECTED'] # removed from AFC's queue after any resume
|
||||||
|
# State (set by the macros)
|
||||||
|
variable_active: False # True from _PRINT_START_FINISH to the end of the print
|
||||||
|
variable_count: 0 # automatic resumes in this print
|
||||||
|
variable_last_at: -1.0 # print_duration (s) of the last automatic resume, -1 = none
|
||||||
|
variable_pending: '' # fault the timer is waiting to resume from
|
||||||
|
gcode:
|
||||||
|
RESPOND MSG="Auto-resume: {'on' if enabled else 'off'}, {'active' if active else 'not active'}, {count}/{max_per_print} used in this print"
|
||||||
|
|
||||||
|
# Called by _PRINT_START_FINISH (ON=1) and _PRINT_CLEANUP (ON=0)
|
||||||
|
[gcode_macro _AUTO_RESUME_ACTIVE]
|
||||||
|
description: Start (ON=1) or end (ON=0) the automatic resume for a print
|
||||||
|
gcode:
|
||||||
|
{% set on = params.ON|default(1)|int %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=active VALUE={True if on else False}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=count VALUE=0
|
||||||
|
SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=last_at VALUE=-1.0
|
||||||
|
SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=pending VALUE="''"
|
||||||
|
UPDATE_DELAYED_GCODE ID=_AUTO_RESUME DURATION=0
|
||||||
|
{% if on and 'AFC' in printer %}
|
||||||
|
# Old messages would be read as this print's fault: start empty
|
||||||
|
AFC_CLEAR_ALL_MESSAGES
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Called by PAUSE when it pauses a print. AFC's message queue shows its oldest
|
||||||
|
# message first; _RESUME_PRINT removes a buffer fault message once resumed, so
|
||||||
|
# the oldest one is this pause's.
|
||||||
|
[gcode_macro _AUTO_RESUME_ARM]
|
||||||
|
description: Start the automatic resume timer when AFC paused for a buffer fault and the limits allow it
|
||||||
|
gcode:
|
||||||
|
{% set cfg = printer["gcode_macro _AUTO_RESUME_CFG"] %}
|
||||||
|
{% set has_afc = 'AFC' in printer %}
|
||||||
|
{% set msg = printer.AFC.message.message|default('') if has_afc else '' %}
|
||||||
|
{% set fault = (cfg.faults|select('in', msg)|list + [''])[0] %}
|
||||||
|
{% set now = printer.print_stats.print_duration|float %}
|
||||||
|
{% if cfg.enabled and cfg.active and has_afc and printer.AFC.error_state and fault %}
|
||||||
|
{% if cfg.count >= cfg.max_per_print %}
|
||||||
|
_WARN MSG="Auto-resume: not resuming after AFC {fault}, already {cfg.count} automatic resumes in this print. Check the lane, then RESUME." DISPLAY="AFC {fault}: check, then RESUME"
|
||||||
|
{% elif cfg.last_at >= 0 and now - cfg.last_at < cfg.min_interval * 60 %}
|
||||||
|
_WARN MSG="Auto-resume: not resuming after AFC {fault}, the last automatic resume was only {((now - cfg.last_at) / 60)|round(1)} min of printing ago. Check the lane, then RESUME." DISPLAY="AFC {fault} again: check, then RESUME"
|
||||||
|
{% else %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=pending VALUE="'{fault}'"
|
||||||
|
RESPOND MSG="Auto-resume: AFC {fault}, resuming in {cfg.delay} s with the purge check ({cfg.count + 1}/{cfg.max_per_print})"
|
||||||
|
UPDATE_DELAYED_GCODE ID=_AUTO_RESUME DURATION={cfg.delay}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[delayed_gcode _AUTO_RESUME]
|
||||||
|
gcode:
|
||||||
|
{% set cfg = printer["gcode_macro _AUTO_RESUME_CFG"] %}
|
||||||
|
{% set fault = cfg.pending %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=pending VALUE="''"
|
||||||
|
# Only when nothing changed since the pause: still paused, still AFC's
|
||||||
|
# error (a manual RESUME or CANCEL in the meantime ends it)
|
||||||
|
{% if fault and cfg.active and printer.print_stats.state == 'paused'
|
||||||
|
and printer.pause_resume.is_paused and printer.AFC.error_state %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=count VALUE={cfg.count + 1}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=last_at VALUE={printer.print_stats.print_duration|float}
|
||||||
|
RESPOND MSG="Auto-resume {cfg.count + 1}/{cfg.max_per_print} after AFC {fault}"
|
||||||
|
M117 Auto-resume {cfg.count + 1}/{cfg.max_per_print}: AFC {fault}
|
||||||
|
RESUME
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Called by _RESUME_PRINT after a resume: remove a buffer fault message from
|
||||||
|
# the front of AFC's queue, so the next pause reads its own message. Also a
|
||||||
|
# CLOG message after a manual RESUME: left at the front, it would hide the next
|
||||||
|
# NOT FEEDING message and block that automatic resume.
|
||||||
|
[gcode_macro _AUTO_RESUME_CLEAR_FAULT]
|
||||||
|
description: Helper: drop AFC's buffer fault message after a resume
|
||||||
|
gcode:
|
||||||
|
{% set cfg = printer["gcode_macro _AUTO_RESUME_CFG"] %}
|
||||||
|
{% set msg = printer.AFC.message.message|default('') if 'AFC' in printer else '' %}
|
||||||
|
{% if msg and cfg.clear_faults|select('in', msg)|list %}
|
||||||
|
AFC_CLEAR_MESSAGE
|
||||||
|
{% endif %}
|
||||||
@@ -9,10 +9,15 @@
|
|||||||
# the nozzle pressure stayed above the threshold. Catches filament
|
# the nozzle pressure stayed above the threshold. Catches filament
|
||||||
# that never reached the melt zone. Skipped automatically on stock
|
# that never reached the melt zone. Skipped automatically on stock
|
||||||
# firmware or when bdpressure_check.py is not installed.
|
# firmware or when bdpressure_check.py is not installed.
|
||||||
|
# A blocked nozzle builds pressure too, so that alone passes it. The
|
||||||
|
# pressure left when the check stops (delta, a few seconds after the
|
||||||
|
# purge, once the blob is dropped) catches some: it bleeds off slowly
|
||||||
|
# through a blocked nozzle (pressure_max_delta).
|
||||||
#
|
#
|
||||||
# Needs: bdwidth_status.py in ~/klipper/klippy/extras/
|
# Needs: bdwidth_status.py in ~/klipper/klippy/extras/
|
||||||
# bdpressure_check.py in ~/klipper/klippy/extras/ (optional)
|
# bdpressure_check.py in ~/klipper/klippy/extras/ (optional)
|
||||||
# (klipper/install.sh links both; guide: klipper/load_check/afc_blobifier/README.md)
|
# (this repo's install.sh links bdwidth_status.py; bdpressure_check.py
|
||||||
|
# comes from the bd_pressure repo, its klipper/install.sh links it)
|
||||||
# Hook: in [AFC] (AFC/AFC.cfg) change poop_cmd: BLOBIFIER
|
# Hook: in [AFC] (AFC/AFC.cfg) change poop_cmd: BLOBIFIER
|
||||||
# to poop_cmd: BLOBIFIER_CHECKED
|
# to poop_cmd: BLOBIFIER_CHECKED
|
||||||
#
|
#
|
||||||
@@ -45,6 +50,11 @@ variable_motion_check: False # False: skip the bdwidth motion check, pressure
|
|||||||
variable_min_ratio: 0.4 # placeholder: sensed mm / extruded mm below this = not feeding
|
variable_min_ratio: 0.4 # placeholder: sensed mm / extruded mm below this = not feeding
|
||||||
variable_min_extrude: 20 # skip the checks for purges shorter than this (mm)
|
variable_min_extrude: 20 # skip the checks for purges shorter than this (mm)
|
||||||
variable_pressure_min_ms: 5000 # placeholder: longest continuous pressure needed (ms)
|
variable_pressure_min_ms: 5000 # placeholder: longest continuous pressure needed (ms)
|
||||||
|
# Pressure still above the baseline when the check stops = nozzle (partly)
|
||||||
|
# blocked; 0 = off. Data 2026-11-12..17: 16 good purges -3..+10, the two long
|
||||||
|
# purges into a blocked nozzle (2026-11-17) +19 and +21; the two 40 mm purges
|
||||||
|
# into that nozzle gave -2 and -12, so it does not catch every blockage.
|
||||||
|
variable_pressure_max_delta: 15
|
||||||
# bdwidth is not reading after SET_BDWIDTH ... COMMAND=DISABLE and after
|
# bdwidth is not reading after SET_BDWIDTH ... COMMAND=DISABLE and after
|
||||||
# every Klipper restart until an ENABLE (outside a print, often early in a
|
# every Klipper restart until an ENABLE (outside a print, often early in a
|
||||||
# print start). The check then switches it on and waits this long for the
|
# print start). The check then switches it on and waits this long for the
|
||||||
@@ -53,6 +63,7 @@ variable_bdwidth_warmup_ms: 15000
|
|||||||
variable_start_counts: 0
|
variable_start_counts: 0
|
||||||
variable_start_e: 0.0
|
variable_start_e: 0.0
|
||||||
variable_last_failed: False # last check failed in enforce mode (read by _RESUME_PURGE_VERIFY)
|
variable_last_failed: False # last check failed in enforce mode (read by _RESUME_PURGE_VERIFY)
|
||||||
|
variable_swap_failed: False # failed during an infinite spool swap (read by _PURGE_CHECK_SWAP_STOP)
|
||||||
variable_ignore_missing_sensor: False # set by PURGE_CHECK_IGNORE_SENSOR, cleared at print end
|
variable_ignore_missing_sensor: False # set by PURGE_CHECK_IGNORE_SENSOR, cleared at print end
|
||||||
# Hotter purge: the leftover of the previous filament (the piece below the
|
# Hotter purge: the leftover of the previous filament (the piece below the
|
||||||
# cutter) has to melt to be pushed out. When the filament that last went
|
# cutter) has to melt to be pushed out. When the filament that last went
|
||||||
@@ -117,6 +128,7 @@ gcode:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
_PURGE_FLUSH_DONE
|
_PURGE_FLUSH_DONE
|
||||||
|
_PURGE_CHECK_SWAP_STOP
|
||||||
|
|
||||||
# Separate macros so the status is read when they run, not when
|
# Separate macros so the status is read when they run, not when
|
||||||
# BLOBIFIER_CHECKED is rendered
|
# BLOBIFIER_CHECKED is rendered
|
||||||
@@ -185,10 +197,13 @@ gcode:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if 'bdpressure_check' in printer and printer.bdpressure_check.available %}
|
{% if 'bdpressure_check' in printer and printer.bdpressure_check.available %}
|
||||||
{% set p = printer.bdpressure_check %}
|
{% set p = printer.bdpressure_check %}
|
||||||
{% set press = "pressure longest %d ms, total %d ms, peak %d" % (p.longest_ms, p.above_ms, p.peak) %}
|
{% set press = "pressure longest %d ms, total %d ms, peak %d, left %d" % (p.longest_ms, p.above_ms, p.peak, p.delta) %}
|
||||||
{% if p.longest_ms < cfg.pressure_min_ms %}
|
{% if p.longest_ms < cfg.pressure_min_ms %}
|
||||||
{% set _ = failed.append("no sustained nozzle pressure") %}
|
{% set _ = failed.append("no sustained nozzle pressure") %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if cfg.pressure_max_delta > 0 and p.delta > cfg.pressure_max_delta %}
|
||||||
|
{% set _ = failed.append("pressure stays high after the purge (%d > %d): nozzle blocked?" % (p.delta, cfg.pressure_max_delta)) %}
|
||||||
|
{% endif %}
|
||||||
{% elif 'bdpressure_check' in printer %}
|
{% elif 'bdpressure_check' in printer %}
|
||||||
{% if cfg.ignore_missing_sensor %}
|
{% if cfg.ignore_missing_sensor %}
|
||||||
{% set press = "pressure skipped: bd_pressure not answering (ignored, PURGE_CHECK_IGNORE_SENSOR)" %}
|
{% set press = "pressure skipped: bd_pressure not answering (ignored, PURGE_CHECK_IGNORE_SENSOR)" %}
|
||||||
@@ -205,9 +220,38 @@ gcode:
|
|||||||
{% if failed and cfg.mode == "enforce" %}
|
{% if failed and cfg.mode == "enforce" %}
|
||||||
_WARN MSG="PURGE_CHECK: {lane} {failed|join(', ')} - check extruder and lane" DISPLAY="Purge check failed: {lane}, paused"
|
_WARN MSG="PURGE_CHECK: {lane} {failed|join(', ')} - check extruder and lane" DISPLAY="Purge check failed: {lane}, paused"
|
||||||
SET_GCODE_VARIABLE MACRO=_PURGE_CHECK_CFG VARIABLE=last_failed VALUE=True
|
SET_GCODE_VARIABLE MACRO=_PURGE_CHECK_CFG VARIABLE=last_failed VALUE=True
|
||||||
|
# Infinite spool swap: AFC paused the file itself, without PAUSE
|
||||||
|
{% if printer.print_stats.state == "paused" and not printer.pause_resume.is_paused %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_PURGE_CHECK_CFG VARIABLE=swap_failed VALUE=True
|
||||||
|
{% else %}
|
||||||
PAUSE ; no effect while already paused (resume purge): see _RESUME_PURGE_VERIFY
|
PAUSE ; no effect while already paused (resume purge): see _RESUME_PURGE_VERIFY
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# A failed check during an infinite spool swap. PAUSE alone would not stop it:
|
||||||
|
# AFC only looks at its own error state, so it would remap, go back to the print
|
||||||
|
# and restart the file while the printer counts as paused. An error reaches AFC's
|
||||||
|
# CHANGE_TOOL, which then pauses through AFC_error and sets that state, so the
|
||||||
|
# swap stops. Last in BLOBIFIER_CHECKED: the error skips everything after it. It
|
||||||
|
# also skips the rest of AFC's TOOL_LOAD, so the buffer's fault detection may stay
|
||||||
|
# off until the next tool load, and AFC's remap, which the message asks for.
|
||||||
|
[gcode_macro _PURGE_CHECK_SWAP_STOP]
|
||||||
|
description: Helper for BLOBIFIER_CHECKED: stop an infinite spool swap after a failed check
|
||||||
|
gcode:
|
||||||
|
{% if printer["gcode_macro _PURGE_CHECK_CFG"].swap_failed %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_PURGE_CHECK_CFG VARIABLE=swap_failed VALUE=False
|
||||||
|
{% set lane = printer.AFC.current_load|default("", true) %}
|
||||||
|
{% set ns = namespace(tool="") %}
|
||||||
|
{% for name in printer.AFC.lanes %}
|
||||||
|
{% set obj = printer["AFC_stepper " ~ name] if ("AFC_stepper " ~ name) in printer else {} %}
|
||||||
|
{% if lane and obj.runout_lane|default("", true) == lane and not ns.tool %}
|
||||||
|
{% set ns.tool = obj.map %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% set remap = "SET_MAP LANE=%s MAP=%s, then " % (lane, ns.tool) if ns.tool else "set the tool map with SET_MAP, then " %}
|
||||||
|
_ERROR MSG="Spool swap stopped: the purge check failed on {lane}. Check the extruder and lane, run {remap}RESUME. AFC also reports an unexpected CHANGE_TOOL error: that is this stop." DISPLAY="Swap stopped: purge check failed on {lane}"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[gcode_macro PURGE_CHECK_IGNORE_SENSOR]
|
[gcode_macro PURGE_CHECK_IGNORE_SENSOR]
|
||||||
description: Let purges pass without bd_pressure until the print ends (ENABLE=0 to undo)
|
description: Let purges pass without bd_pressure until the print ends (ENABLE=0 to undo)
|
||||||
|
|||||||
@@ -63,6 +63,10 @@
|
|||||||
# if you experience excessive oozing.
|
# if you experience excessive oozing.
|
||||||
# variable_purge_spd: 250 #300 # Speed, in mm/min, of the purge.
|
# variable_purge_spd: 250 #300 # Speed, in mm/min, of the purge.
|
||||||
variable_purge_spd: 150 # Speed, in mm/min, of the purge.
|
variable_purge_spd: 150 # Speed, in mm/min, of the purge.
|
||||||
|
# Purge speed (mm/min) per nozzle size, chosen by the save variable pa_nozzle
|
||||||
|
# (SET_NOZZLE). 150 mm/min is about 6 mm3/s, too much for a 0.2 nozzle.
|
||||||
|
# A size not listed uses purge_spd.
|
||||||
|
variable_purge_spd_nozzle: {"0.4": 150, "0.2": 75}
|
||||||
variable_purge_temp_min: 200 # Minimum nozzle purge temperature.
|
variable_purge_temp_min: 200 # Minimum nozzle purge temperature.
|
||||||
variable_toolhead_x: 70 # From the nozzle to the left of your toolhead
|
variable_toolhead_x: 70 # From the nozzle to the left of your toolhead
|
||||||
variable_toolhead_y: 50 # From the nozzle to the front of your toolhead
|
variable_toolhead_y: 50 # From the nozzle to the front of your toolhead
|
||||||
@@ -278,6 +282,10 @@ variable_shaker_arm_z: 4
|
|||||||
|
|
||||||
gcode:
|
gcode:
|
||||||
|
|
||||||
|
# Purge speed for the fitted nozzle (purge_spd_nozzle above)
|
||||||
|
{% set nozzle = "%g" % printer.save_variables.variables["pa_nozzle"]|default(0.4)|float %}
|
||||||
|
{% set purge_rate = purge_spd_nozzle[nozzle]|float if nozzle in purge_spd_nozzle else purge_spd|float %}
|
||||||
|
|
||||||
# ======================================================================================
|
# ======================================================================================
|
||||||
# ==================== RECORD STATE (INCL. FANS, SPEEDS, ETC...) =======================
|
# ==================== RECORD STATE (INCL. FANS, SPEEDS, ETC...) =======================
|
||||||
# ======================================================================================
|
# ======================================================================================
|
||||||
@@ -444,8 +452,8 @@ gcode:
|
|||||||
{% set pulses_per_retract = (purge_per_blob / retracts_per_blob / 5)|round(0, 'ceil')|int %}
|
{% set pulses_per_retract = (purge_per_blob / retracts_per_blob / 5)|round(0, 'ceil')|int %}
|
||||||
{% set pulses_per_blob = (purge_per_blob / 5)|round(0, 'ceil')|int %}
|
{% set pulses_per_blob = (purge_per_blob / 5)|round(0, 'ceil')|int %}
|
||||||
{% set purge_per_pulse = purge_per_blob / pulses_per_blob %}
|
{% set purge_per_pulse = purge_per_blob / pulses_per_blob %}
|
||||||
{% set pulse_time_constant = purge_per_pulse * 0.95 / purge_spd / (purge_per_pulse * 0.95 / purge_spd + purge_per_pulse * 0.05 / 50) %}
|
{% set pulse_time_constant = purge_per_pulse * 0.95 / purge_rate / (purge_per_pulse * 0.95 / purge_rate + purge_per_pulse * 0.05 / 50) %}
|
||||||
{% set pulse_duration = purge_per_pulse / purge_spd %}
|
{% set pulse_duration = purge_per_pulse / purge_rate %}
|
||||||
|
|
||||||
# Repeat the process until purge_len is reached
|
# Repeat the process until purge_len is reached
|
||||||
{% for blob in range(blobs) %}
|
{% for blob in range(blobs) %}
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
# Bed check: scan the bed and warn about bumps, dips or too much height range
|
||||||
|
# (needs extras/mesh_check.py, which explains the method and the limits)
|
||||||
|
#
|
||||||
|
# BED_SCAN_CHECK [BUMP=0.03] [RANGE=0.30]
|
||||||
|
# Scan now and report. Warns only, for use between prints. No heating and
|
||||||
|
# no contact: X and Y home if needed, Z homes with the Beacon's proximity
|
||||||
|
# mode. Replaces the active mesh, like any scan.
|
||||||
|
#
|
||||||
|
# BED_MESH_CHECK [BUMP=0.03] [RANGE=0.30] (extras/mesh_check.py)
|
||||||
|
# Only check the mesh that is loaded now.
|
||||||
|
#
|
||||||
|
# In PRINT_START a failed check pauses the print before the nozzle heats up:
|
||||||
|
# the toolhead goes up and out of the way so the plate can be cleaned.
|
||||||
|
# Resume levels, homes and scans again, and checks again
|
||||||
|
# BED_CHECK_IGNORE then Resume: the next failed check only warns
|
||||||
|
# Cancel works as usual.
|
||||||
|
#
|
||||||
|
# How the retry works: a PAUSE in a macro only stops the print file, the rest
|
||||||
|
# of the macro still runs, so everything after the check sits in
|
||||||
|
# _PRINT_START_FINISH and is only called when the check allows it. While a
|
||||||
|
# line of the file runs, virtual_sdcard.file_position is the start of that
|
||||||
|
# line. Resume sets the file back there (M26) and resumes, so the file runs
|
||||||
|
# PRINT_START again, as normal print file G-code: an error stops the print as
|
||||||
|
# it always does, which an error in a delayed_gcode would not (the file would
|
||||||
|
# carry on with the first layer).
|
||||||
|
#
|
||||||
|
# The pause goes through PAUSE, so through AFC_PAUSE: AFC_RESUME always restores
|
||||||
|
# AFC's saved position after a pause. Without saving it here, that could be a
|
||||||
|
# stale position from an earlier print, or X0 Y0 (seen after HEAT_SOAK).
|
||||||
|
# RESET_FAILURE first, because AFC does not save over a position it still holds.
|
||||||
|
# PAUSE sees _BED_CHECK_STATE.pending and only pauses: no retract, no park at
|
||||||
|
# the bucket, and RESUME skips _RESUME_PRINT and its purge (the filament is not
|
||||||
|
# loaded yet at this point).
|
||||||
|
|
||||||
|
[mesh_check]
|
||||||
|
bump_limit: 0.03
|
||||||
|
range_limit: 0.30
|
||||||
|
|
||||||
|
[gcode_macro _BED_CHECK_STATE]
|
||||||
|
description: Variables of the print start bed check
|
||||||
|
variable_pending: False # paused by the check, the next RESUME retries
|
||||||
|
variable_ignore: False # BED_CHECK_IGNORE: the next failed check only warns
|
||||||
|
variable_file_position: 0 # start of the PRINT_START line in the print file
|
||||||
|
variable_park_z: 100 # room to reach the plate; free of the bucket above Z10
|
||||||
|
gcode:
|
||||||
|
|
||||||
|
[gcode_macro _BED_CHECK_RESET]
|
||||||
|
description: Forget a pending bed check (start and end of a print)
|
||||||
|
gcode:
|
||||||
|
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=pending VALUE=False
|
||||||
|
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=ignore VALUE=False
|
||||||
|
|
||||||
|
[gcode_macro BED_SCAN_CHECK]
|
||||||
|
description: Scan the bed and warn about bumps, dips or too much height range (not during a print)
|
||||||
|
gcode:
|
||||||
|
{% set state = printer.print_stats.state %}
|
||||||
|
{% if state in ('printing', 'paused') %}
|
||||||
|
_ERROR MSG="BED_SCAN_CHECK: not during a print ({state})" DISPLAY="Bed scan: not during a print"
|
||||||
|
{% else %}
|
||||||
|
SAVE_GCODE_STATE NAME=_bed_scan_check
|
||||||
|
G90
|
||||||
|
{% if 'xy' not in printer.toolhead.homed_axes %}
|
||||||
|
_GUARD_ON PHASE=bed_check_home_xy
|
||||||
|
G28 X Y
|
||||||
|
_GUARD_OFF
|
||||||
|
{% endif %}
|
||||||
|
{% if 'z' not in printer.toolhead.homed_axes %}
|
||||||
|
_GUARD_ON PHASE=bed_check_home_z
|
||||||
|
G28 Z METHOD=PROXIMITY
|
||||||
|
_GUARD_OFF
|
||||||
|
{% endif %}
|
||||||
|
_GUARD_ON PHASE=bed_check_qgl
|
||||||
|
QUAD_GANTRY_LEVEL
|
||||||
|
_GUARD_ON PHASE=bed_check_z
|
||||||
|
G28 Z METHOD=PROXIMITY
|
||||||
|
_GUARD_ON PHASE=bed_check_mesh
|
||||||
|
BED_MESH_CALIBRATE RUNS=2
|
||||||
|
G1 Z10 F1200
|
||||||
|
_GUARD_OFF
|
||||||
|
RESTORE_GCODE_STATE NAME=_bed_scan_check
|
||||||
|
BED_MESH_CHECK {rawparams}
|
||||||
|
_BED_SCAN_CHECK_REPORT
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Separate macro: rendered after BED_MESH_CHECK has run
|
||||||
|
[gcode_macro _BED_SCAN_CHECK_REPORT]
|
||||||
|
description: Helper for BED_SCAN_CHECK: warn when the check failed
|
||||||
|
gcode:
|
||||||
|
{% set check = printer.mesh_check %}
|
||||||
|
{% if check.result == 'fail' %}
|
||||||
|
_WARN MSG="Bed check: {check.summary}. A bump usually means something on the plate: clean it and scan again." DISPLAY="Bed check failed, see console"
|
||||||
|
{% elif check.result == 'none' %}
|
||||||
|
_WARN MSG="Bed check not done: {check.summary}" DISPLAY="Bed check not done"
|
||||||
|
{% else %}
|
||||||
|
M117 Bed check OK
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[gcode_macro BED_CHECK_IGNORE]
|
||||||
|
description: After the print start bed check paused the print: the next failed check only warns (press Resume after this)
|
||||||
|
gcode:
|
||||||
|
{% if printer["gcode_macro _BED_CHECK_STATE"].pending %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=ignore VALUE=True
|
||||||
|
RESPOND MSG="Bed check: press Resume. It scans once more and continues even if the check still fails."
|
||||||
|
{% else %}
|
||||||
|
RESPOND MSG="Bed check: the print is not paused by the check, nothing to ignore"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Called by _PRINT_START_GATE. FILE_POS: start of the PRINT_START line.
|
||||||
|
[gcode_macro _BED_CHECK_PAUSE]
|
||||||
|
description: Helper for PRINT_START: move away from the plate and pause, RESUME scans again
|
||||||
|
gcode:
|
||||||
|
{% set cfg = printer["gcode_macro _BED_CHECK_STATE"] %}
|
||||||
|
{% set summary = printer.mesh_check.summary %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=pending VALUE=True
|
||||||
|
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=file_position VALUE={params.FILE_POS|int}
|
||||||
|
G90
|
||||||
|
_GUARD_ON PHASE=bed_check_park
|
||||||
|
G1 Z{[cfg.park_z, printer.toolhead.axis_maximum.z - 5]|min} F1200
|
||||||
|
G1 X175 Y340 F6000
|
||||||
|
_GUARD_OFF
|
||||||
|
RESET_FAILURE
|
||||||
|
PAUSE
|
||||||
|
_STATUS STATE=paused
|
||||||
|
_WARN MSG="Bed check failed, print paused: {summary}. Clean the plate and press Resume to scan again. To print anyway: BED_CHECK_IGNORE, then Resume." DISPLAY="Bed check failed: clean plate, Resume"
|
||||||
|
|
||||||
|
# Called by RESUME instead of its normal chain while a check is pending.
|
||||||
|
# AFC_RESUME then restores the position that AFC_PAUSE saved in _BED_CHECK_PAUSE.
|
||||||
|
[gcode_macro _BED_CHECK_RETRY]
|
||||||
|
description: Helper for RESUME: go back to the PRINT_START line of the print file and resume
|
||||||
|
gcode:
|
||||||
|
{% set cfg = printer["gcode_macro _BED_CHECK_STATE"] %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_BED_CHECK_STATE VARIABLE=pending VALUE=False
|
||||||
|
# Clear the pause reason from the display
|
||||||
|
M117
|
||||||
|
RESPOND MSG="Bed check: levelling and scanning again"
|
||||||
|
M26 S{cfg.file_position|int}
|
||||||
|
RESUME_BASE
|
||||||
@@ -80,7 +80,7 @@ gcode:
|
|||||||
{% if bed > 40 %}
|
{% if bed > 40 %}
|
||||||
RESPOND TYPE=command MSG="action:prompt_text Note: the bed is at {bed|int} C. The reference runs were on a cold bed, so wait for it to cool unless you want this on purpose."
|
RESPOND TYPE=command MSG="action:prompt_text Note: the bed is at {bed|int} C. The reference runs were on a cold bed, so wait for it to cool unless you want this on purpose."
|
||||||
{% endif %}
|
{% endif %}
|
||||||
RESPOND TYPE=command MSG="action:prompt_text It heats the nozzle to 150 C, homes, levels and takes {'25' if mode == 'measure' else '17'} minutes. The configuration is not changed."
|
RESPOND TYPE=command MSG="action:prompt_text It heats the nozzle to 150 C, homes, levels, wipes the nozzle on the brush and takes {'25' if mode == 'measure' else '17'} minutes. The configuration is not changed."
|
||||||
RESPOND TYPE=command MSG="action:prompt_footer_button Back|TWIST_CALIBRATE|secondary"
|
RESPOND TYPE=command MSG="action:prompt_footer_button Back|TWIST_CALIBRATE|secondary"
|
||||||
RESPOND TYPE=command MSG="action:prompt_footer_button All checked, start|_TWIST_START MODE={mode}|primary"
|
RESPOND TYPE=command MSG="action:prompt_footer_button All checked, start|_TWIST_START MODE={mode}|primary"
|
||||||
RESPOND TYPE=command MSG="action:prompt_show"
|
RESPOND TYPE=command MSG="action:prompt_show"
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
# Bed fans driven by the bed heater (based on Ellis' bed fan macros)
|
# Bed fans driven by the bed heater (based on Ellis' bed fan macros)
|
||||||
|
#
|
||||||
|
# During a print without a heated chamber the fans stay off while the bed heats,
|
||||||
|
# soaks and prints: with the chamber open they only blow room air past the bed.
|
||||||
|
# PRINT_WARMUP sets print_fans_off, _PRINT_CLEANUP clears it. The cooldown after
|
||||||
|
# the print and heating the bed outside a print are not affected.
|
||||||
|
|
||||||
############### Config options ##################
|
############### Config options ##################
|
||||||
|
|
||||||
@@ -7,6 +12,7 @@ variable_threshold: 50 # If bed temp target is above this threshold, fans will
|
|||||||
variable_fast: 1.0 # Fan speed once bed temp is reached
|
variable_fast: 1.0 # Fan speed once bed temp is reached
|
||||||
variable_slow: 0.5 # Fan speed while bed is heating
|
variable_slow: 0.5 # Fan speed while bed is heating
|
||||||
variable_cooldown_temp: 40 # NEW: fans stop below this temp
|
variable_cooldown_temp: 40 # NEW: fans stop below this temp
|
||||||
|
variable_print_fans_off: False # set by PRINT_WARMUP for a print without a heated chamber
|
||||||
gcode:
|
gcode:
|
||||||
|
|
||||||
########## Aliases #########
|
########## Aliases #########
|
||||||
@@ -41,6 +47,7 @@ gcode:
|
|||||||
# Vars
|
# Vars
|
||||||
{% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %}
|
{% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %}
|
||||||
{% set COOLDOWN = printer["gcode_macro _BEDFANVARS"].cooldown_temp|int %}
|
{% set COOLDOWN = printer["gcode_macro _BEDFANVARS"].cooldown_temp|int %}
|
||||||
|
{% set FANS_OFF = printer["gcode_macro _BEDFANVARS"].print_fans_off %}
|
||||||
|
|
||||||
{% if HEATER|lower == "extruder" %}
|
{% if HEATER|lower == "extruder" %}
|
||||||
M104 S{TARGET}
|
M104 S{TARGET}
|
||||||
@@ -67,13 +74,13 @@ gcode:
|
|||||||
# Stop normal heating loop if running
|
# Stop normal heating loop if running
|
||||||
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=0
|
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=0
|
||||||
|
|
||||||
{% elif TARGET >= THRESHOLD %}
|
{% elif TARGET >= THRESHOLD and not FANS_OFF %}
|
||||||
# Heating above threshold
|
# Heating above threshold
|
||||||
BEDFANSSLOW
|
BEDFANSSLOW
|
||||||
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=1
|
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=1
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
# Low temp request
|
# Low temp request, or a print without a heated chamber
|
||||||
BEDFANSOFF
|
BEDFANSOFF
|
||||||
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=0
|
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=0
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -93,8 +100,9 @@ gcode:
|
|||||||
{% set S = params.S|int %}
|
{% set S = params.S|int %}
|
||||||
# Vars
|
# Vars
|
||||||
{% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %}
|
{% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %}
|
||||||
|
{% set FANS_ON = S >= THRESHOLD and not printer["gcode_macro _BEDFANVARS"].print_fans_off %}
|
||||||
|
|
||||||
{% if S >= THRESHOLD %}
|
{% if FANS_ON %}
|
||||||
BEDFANSSLOW # >= Threshold temp: Low speed fans while heating
|
BEDFANSSLOW # >= Threshold temp: Low speed fans while heating
|
||||||
{% else %}
|
{% else %}
|
||||||
BEDFANSOFF # < Threshold temp: Turn bed fans off
|
BEDFANSOFF # < Threshold temp: Turn bed fans off
|
||||||
@@ -109,7 +117,7 @@ gcode:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# Post-heating fan speeds
|
# Post-heating fan speeds
|
||||||
{% if S >= THRESHOLD %}
|
{% if FANS_ON %}
|
||||||
BEDFANSFAST # >= Threshold temp: Higher speed fans after heating finished
|
BEDFANSFAST # >= Threshold temp: Higher speed fans after heating finished
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -152,7 +160,7 @@ gcode:
|
|||||||
# Vars
|
# Vars
|
||||||
{% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %}
|
{% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %}
|
||||||
|
|
||||||
{% if printer.heater_bed.target >= THRESHOLD %} # Continue only if target temp greater than threshold.
|
{% if printer.heater_bed.target >= THRESHOLD and not printer["gcode_macro _BEDFANVARS"].print_fans_off %} # Continue only if target temp greater than threshold.
|
||||||
{% if printer.heater_bed.temperature|int >= (printer.heater_bed.target|int - 1) %}
|
{% if printer.heater_bed.temperature|int >= (printer.heater_bed.target|int - 1) %}
|
||||||
BEDFANSFAST # If within 1 degree of target temp: Higher speed fans
|
BEDFANSFAST # If within 1 degree of target temp: Higher speed fans
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -293,8 +293,12 @@ gcode:
|
|||||||
{% if heat_soak.complete %}
|
{% if heat_soak.complete %}
|
||||||
{heat_soak.complete}
|
{heat_soak.complete}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
# Not RESUME: that goes through AFC_RESUME, which restores AFC's saved
|
||||||
|
# position. HEAT_SOAK pauses with PAUSE_BASE, so AFC saved nothing and
|
||||||
|
# (seen 2026-11-04) sends the toolhead to X0 Y0 at up to 350 mm/s, just
|
||||||
|
# before the _Z_CHECK guard arms.
|
||||||
{% if printer['pause_resume'].is_paused %}
|
{% if printer['pause_resume'].is_paused %}
|
||||||
RESUME
|
_RESUME_PRINT
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
# Printing
|
# Printing
|
||||||
[include print/pause_resume.cfg]
|
[include print/pause_resume.cfg]
|
||||||
[include print/filament.cfg]
|
[include print/filament.cfg]
|
||||||
[include print/nozzle_guard.cfg] # bd_pressure nozzle collision guard (needs extras/bdp_guard.py)
|
[include print/nozzle_guard.cfg] # bd_pressure nozzle collision guard (needs bdp_guard.py, bd_pressure repo)
|
||||||
[include print/homing.cfg]
|
[include print/homing.cfg]
|
||||||
[include print/idle_timeout.cfg]
|
[include print/idle_timeout.cfg]
|
||||||
[include print/print_start_end.cfg]
|
[include print/print_start_end.cfg]
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
[include afc/xy_safety_check.cfg]
|
[include afc/xy_safety_check.cfg]
|
||||||
[include afc/lane_tools.cfg]
|
[include afc/lane_tools.cfg]
|
||||||
[include afc/purge_check.cfg]
|
[include afc/purge_check.cfg]
|
||||||
|
[include afc/auto_resume.cfg] # resume by itself after an AFC buffer fault (purge check first, limited)
|
||||||
[include afc/purge_until_empty.cfg]
|
[include afc/purge_until_empty.cfg]
|
||||||
[include afc/flex_lanes.cfg] # TPU/TPE lanes: slower long moves
|
[include afc/flex_lanes.cfg] # TPU/TPE lanes: slower long moves
|
||||||
|
|
||||||
@@ -54,3 +55,4 @@
|
|||||||
|
|
||||||
# Calibration
|
# Calibration
|
||||||
[include calibration/twist_check.cfg] # TWIST_CALIBRATE: axis twist compensation, with windows in Mainsail (runs scripts/twist_check.py)
|
[include calibration/twist_check.cfg] # TWIST_CALIBRATE: axis twist compensation, with windows in Mainsail (runs scripts/twist_check.py)
|
||||||
|
[include calibration/bed_scan_check.cfg] # BED_SCAN_CHECK, BED_MESH_CHECK: bumps and flatness; PRINT_START pauses on a failed check (needs extras/mesh_check.py)
|
||||||
@@ -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
|
|
||||||
@@ -171,6 +171,9 @@
|
|||||||
# To see what's cached, and which lanes are missing a tracked
|
# To see what's cached, and which lanes are missing a tracked
|
||||||
# spool_id:
|
# spool_id:
|
||||||
# PA_STATUS
|
# 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)
|
# [save_variables] is defined once in ../save_variables.cfg (shared with Blobifier)
|
||||||
@@ -190,18 +193,36 @@ variable_lane_names: "lane1,lane2,lane3,lane4,lane5"
|
|||||||
variable_fallback_nozzle_temp: 260
|
variable_fallback_nozzle_temp: 260
|
||||||
# bd_pressure PA_CALIBRATE parameters -- tune to your printer/filament.
|
# bd_pressure PA_CALIBRATE parameters -- tune to your printer/filament.
|
||||||
# See https://pandapi3d.cn/bdpressure/home for guidance on these values.
|
# 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:
|
# 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
|
# soft TPU buckles or slips in the extruder at 25; PETG (also PETG-CF) is
|
||||||
# lane's material (any case) applies; with several matches the lowest wins.
|
# more viscous at its temperature, 12 matches its slicer flow limit
|
||||||
variable_material_max_volumetric: {"tpu": 8, "tpe": 8, "flex": 8}
|
# (spool 35, PETG-CF at 250C: PA 0.058 at 12, 2026-11-09). A key contained
|
||||||
|
# in the 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, "petg": 12}
|
||||||
|
# Nozzle height (mm) for the test lines (PA_CALIBRATE keeps the current Z).
|
||||||
|
# At 5 they are extruded in the air, clear of the bed and plate.
|
||||||
|
variable_test_z: 5
|
||||||
|
# AFC buffer fault detection during the test lines (0-10, 0 = off). At the
|
||||||
|
# normal 8 the buffer faults after 30 mm in one state, and during the test it
|
||||||
|
# needs far more to reach its other sensor (2026-11-07: ~80 s for the first
|
||||||
|
# change), so every test paused with AFC NOT FEEDING. 2 still catches a lane
|
||||||
|
# that stops feeding. Restored to the [AFC_buffer] config value after
|
||||||
|
# PA_CALIBRATE, or by _PRINT_CLEANUP if the test stops with an error.
|
||||||
|
variable_test_error_sensitivity: 2
|
||||||
variable_acc_wall: 5000
|
variable_acc_wall: 5000
|
||||||
variable_travel_speed: 300
|
variable_travel_speed: 300
|
||||||
variable_acc_to_decel_factor: 50
|
variable_acc_to_decel_factor: 50
|
||||||
# Minimum PA delta before we bother re-saving the cached value
|
# Minimum PA delta before we bother re-saving the cached value
|
||||||
variable_write_threshold: 0.002
|
variable_write_threshold: 0.002
|
||||||
# A calibration is rejected (nothing cached or written to Spoolman, the
|
# A calibration is rejected (nothing saved, the previous PA is kept) when:
|
||||||
# previous PA is kept) when:
|
|
||||||
# - its result is the last PA_CALIBRATE test value: bdpressure.py found no
|
# - 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
|
# 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),
|
# step: 0.098 at the default step, 0.196 for flexibles),
|
||||||
@@ -209,94 +230,74 @@ variable_write_threshold: 0.002
|
|||||||
# - bd_pressure gave fewer than min_points readings or fewer than
|
# - bd_pressure gave fewer than min_points readings or fewer than
|
||||||
# min_distinct different ones (sensor silent or hung; needs
|
# min_distinct different ones (sensor silent or hung; needs
|
||||||
# bdpressure_check.py, otherwise this check is skipped).
|
# 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
|
# 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
|
# 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_material_pa_step: {"tpu": 0.004, "tpe": 0.004, "flex": 0.004}
|
||||||
variable_min_points: 10
|
variable_min_points: 10
|
||||||
variable_min_distinct: 8
|
variable_min_distinct: 8
|
||||||
# PA applied when a rejected lane has no earlier cached value
|
# PA applied when a rejected lane has no earlier cached value
|
||||||
variable_fallback_pa: 0.04
|
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
|
gcode: # intentionally empty -- variables only
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Spoolman write-back: push a calibrated PA value to a spool's "extra"
|
# Fitted nozzle. A PA value only holds for the nozzle it was measured with, so
|
||||||
# field, so the value travels with the spool (e.g. if you move it to a
|
# values are saved per nozzle and spool: pa_value_0_4_spool_15. The size is the
|
||||||
# different printer, or reinstall save_variables from scratch).
|
# 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
|
||||||
# Requires the custom field to exist once -- run _PA_SETUP_SPOOLMAN_FIELD
|
# anything heats. G-code without a size uses the saved one.
|
||||||
# (below) a single time, or create it manually:
|
|
||||||
# curl -X POST http://<spoolman_ip>: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.
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
[gcode_shell_command _pa_write_spoolman]
|
[gcode_macro SET_NOZZLE]
|
||||||
# HISTORICAL NOTE ON ARGUMENT OFFSET (no longer applicable here, kept
|
description: Set the fitted nozzle size, which selects its saved PA values (without SIZE: show it)
|
||||||
# for context): an earlier version of this command ran the script
|
# [SIZE=<mm>]
|
||||||
# inline via `bash -c '<script>' arg1 arg2 ...`, which makes the FIRST
|
|
||||||
# argument after the script string become $0 inside the script, not $1
|
|
||||||
# -- a well-known bash gotcha, confirmed empirically while building
|
|
||||||
# this file:
|
|
||||||
# bash -c 'echo "0=$0 1=$1 2=$2"' alpha beta gamma
|
|
||||||
# -> 0=alpha 1=beta 2=gamma (gamma, the 3rd arg, never reaches $3)
|
|
||||||
# This command now invokes a real .sh FILE instead (`bash script.sh
|
|
||||||
# arg1 arg2 ...`), which does NOT have this offset -- $1 really is the
|
|
||||||
# first argument in that invocation form (also confirmed empirically).
|
|
||||||
# So RUN_SHELL_COMMAND ... PARAMS="a b c d" maps cleanly to $1-$4 in
|
|
||||||
# the script with no placeholder needed.
|
|
||||||
#
|
|
||||||
# WHY THIS CALLS AN EXTERNAL .sh FILE INSTEAD OF EMBEDDING PYTHON
|
|
||||||
# INLINE: Klipper's config parser (Python's configparser) requires
|
|
||||||
# EVERY physical line of a multi-line value to be indented, and strips
|
|
||||||
# that indentation uniformly before passing the value to the shell.
|
|
||||||
# Confirmed empirically while building this file: this dedenting
|
|
||||||
# flattens ALL lines to the same level, which destroys the relative
|
|
||||||
# indentation Python's try/except blocks need to remain valid syntax --
|
|
||||||
# there is no way to embed multi-line, block-structured Python directly
|
|
||||||
# inside a Klipper command: value. Putting the logic in a separate .sh
|
|
||||||
# file sidesteps this entirely, since that file is never touched by
|
|
||||||
# Klipper's config parser.
|
|
||||||
#
|
|
||||||
# The script ships in this folder (klipper-macros/pressure_advance/bd_pa_write_spoolman.sh);
|
|
||||||
# install.sh makes it executable.
|
|
||||||
command: bash ~/printer_data/config/klipper-macros/pressure_advance/bd_pa_write_spoolman.sh
|
|
||||||
verbose: False
|
|
||||||
|
|
||||||
|
|
||||||
[gcode_shell_command _pa_create_spoolman_field]
|
|
||||||
# Same reasoning as _pa_write_spoolman above for using an external
|
|
||||||
# script file -- see the note there. This one has no embedded Python,
|
|
||||||
# so the only real issue was the closing quote sitting at column 0
|
|
||||||
# (un-indented), which is also a config parsing error in Klipper's
|
|
||||||
# parser -- every line of a multi-line value must be indented,
|
|
||||||
# including the very last line.
|
|
||||||
command: bash ~/printer_data/config/klipper-macros/pressure_advance/bd_pa_create_spoolman_field.sh
|
|
||||||
verbose: False
|
|
||||||
|
|
||||||
|
|
||||||
[gcode_macro _PA_SETUP_SPOOLMAN_FIELD]
|
|
||||||
description: One-time setup -- creates the pa_value custom field in Spoolman
|
|
||||||
# REQUIRES bd_pa_create_spoolman_field.sh to already exist on disk at
|
|
||||||
# ~/printer_data/config/ -- see the one-time SSH setup instructions
|
|
||||||
# given alongside this file. This macro just invokes that script; it
|
|
||||||
# does not create it.
|
|
||||||
gcode:
|
gcode:
|
||||||
{% set cfg = printer["gcode_macro _PA_CFG"] %}
|
{% set cfg = printer["gcode_macro _PA_CFG"] %}
|
||||||
{action_respond_info("Creating Spoolman field '%s' at %s ..." % (cfg.spoolman_field, cfg.spoolman_url))}
|
{% set vars = printer.save_variables.variables %}
|
||||||
RUN_SHELL_COMMAND CMD=_pa_create_spoolman_field PARAMS="{cfg.spoolman_url} {cfg.spoolman_field}"
|
{% set current = "%g" % vars["pa_nozzle"]|default(0.4)|float %}
|
||||||
{action_respond_info("Done. Verify with: curl %s/api/v1/field/spool" % cfg.spoolman_url)}
|
{% if not params.SIZE %}
|
||||||
|
RESPOND MSG="Nozzle set: {current} mm. Change it with SET_NOZZLE SIZE=<mm>, sizes: {cfg.nozzle_test.keys()|join(', ')}"
|
||||||
|
{% else %}
|
||||||
|
{% set size = "%g" % params.SIZE|float %}
|
||||||
|
{% if size not in cfg.nozzle_test %}
|
||||||
|
_ERROR MSG="SET_NOZZLE: no PA test settings for {size} mm. Sizes: {cfg.nozzle_test.keys()|join(', ')} (variable_nozzle_test in _PA_CFG)" DISPLAY="Unknown nozzle size"
|
||||||
|
{% elif printer.print_stats.state in ("printing", "paused") %}
|
||||||
|
_ERROR MSG="SET_NOZZLE: not during a print, the nozzle stays {current} mm" DISPLAY="No SET_NOZZLE in a print"
|
||||||
|
{% else %}
|
||||||
|
SAVE_VARIABLE VARIABLE=pa_nozzle VALUE={size}
|
||||||
|
RESPOND MSG="Nozzle set: {size} mm (was {current} mm)"
|
||||||
|
_PA_APPLY_LOADED_LANE
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[gcode_macro _PA_CHECK_NOZZLE]
|
||||||
|
description: Stop the print when the size from the slicer is not the fitted nozzle
|
||||||
|
# NOZZLE=<mm>
|
||||||
|
gcode:
|
||||||
|
{% set vars = printer.save_variables.variables %}
|
||||||
|
{% set fitted = vars["pa_nozzle"]|default(0.4)|float %}
|
||||||
|
{% set sliced = params.NOZZLE|float %}
|
||||||
|
{% if (sliced - fitted)|abs > 0.001 %}
|
||||||
|
_ERROR MSG="Print stopped: sliced for a {'%g' % sliced} mm nozzle, the printer is set to {'%g' % fitted} mm. Slice with the matching profile, or fit that nozzle and run SET_NOZZLE SIZE={'%g' % sliced}" DISPLAY="Nozzle mismatch, print stopped"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Once: values saved before there were per-nozzle values were all measured with
|
||||||
|
# the 0.4 nozzle. Copied at the first start with this macro, so the first print
|
||||||
|
# does not calibrate every lane again. The old pa_value_spool_<id> lines stay in
|
||||||
|
# the variables file; nothing reads them any more.
|
||||||
|
[delayed_gcode _PA_MIGRATE_NOZZLE]
|
||||||
|
initial_duration: 1
|
||||||
|
gcode:
|
||||||
|
{% set vars = printer.save_variables.variables %}
|
||||||
|
{% if "pa_nozzle" not in vars %}
|
||||||
|
{% for name, value in vars.items() %}
|
||||||
|
{% if name.startswith("pa_value_spool_") and ("pa_value_0_4_spool_" ~ name[15:]) not in vars %}
|
||||||
|
SAVE_VARIABLE VARIABLE={"pa_value_0_4_spool_" ~ name[15:]} VALUE={value}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
SAVE_VARIABLE VARIABLE=pa_nozzle VALUE=0.4
|
||||||
|
RESPOND MSG="PA values moved to the 0.4 mm nozzle. Nozzle set: 0.4 mm"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -375,7 +376,7 @@ gcode:
|
|||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# PA cache, keyed by spool_id, stored via Klipper's own save_variables.
|
# PA cache, keyed by nozzle and spool_id, stored via Klipper's own save_variables.
|
||||||
# Requires [save_variables] (save_variables.cfg, see header notes).
|
# Requires [save_variables] (save_variables.cfg, see header notes).
|
||||||
#
|
#
|
||||||
# IMPORTANT: printer.save_variables.variables is read DIRECTLY inline in
|
# IMPORTANT: printer.save_variables.variables is read DIRECTLY inline in
|
||||||
@@ -392,12 +393,13 @@ gcode:
|
|||||||
# value set earlier in the same template render.
|
# value set earlier in the same template render.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
[gcode_macro _PA_CACHE_SET]
|
[gcode_macro _PA_CACHE_SET]
|
||||||
description: Internal -- stores a PA value for a spool_id
|
description: Internal -- stores a PA value for a nozzle and spool_id
|
||||||
# SPOOL_ID=<int> PA=<float>
|
# SPOOL_ID=<int> NOZZLE=<mm> PA=<float>
|
||||||
gcode:
|
gcode:
|
||||||
{% set spool_id = params.SPOOL_ID|default(0)|int %}
|
{% set spool_id = params.SPOOL_ID|default(0)|int %}
|
||||||
|
{% set nozzle = "%g" % params.NOZZLE|float %}
|
||||||
{% set pa = params.PA|default(0.0)|float %}
|
{% set pa = params.PA|default(0.0)|float %}
|
||||||
{% set varname = "pa_value_spool_" ~ spool_id %}
|
{% set varname = "pa_value_" ~ nozzle|replace(".", "_") ~ "_spool_" ~ spool_id %}
|
||||||
SAVE_VARIABLE VARIABLE={varname} VALUE={pa}
|
SAVE_VARIABLE VARIABLE={varname} VALUE={pa}
|
||||||
|
|
||||||
|
|
||||||
@@ -418,7 +420,8 @@ gcode:
|
|||||||
{% set force = params.FORCE|default(0)|int %}
|
{% set force = params.FORCE|default(0)|int %}
|
||||||
{% set vars = printer.save_variables.variables %}
|
{% set vars = printer.save_variables.variables %}
|
||||||
{% set spool_id = vars["pa_lane_" ~ lane ~ "_spool_id"]|default(0)|int %}
|
{% set spool_id = vars["pa_lane_" ~ lane ~ "_spool_id"]|default(0)|int %}
|
||||||
{% set cached = ("pa_value_spool_" ~ spool_id) in vars %}
|
{% set nozzle = "%g" % vars["pa_nozzle"]|default(0.4)|float %}
|
||||||
|
{% set cached = ("pa_value_" ~ nozzle|replace(".", "_") ~ "_spool_" ~ spool_id) in vars %}
|
||||||
{% set key = "AFC_stepper " ~ lane %}
|
{% set key = "AFC_stepper " ~ lane %}
|
||||||
{% set afc_spool = printer[key].spool_id|default(none, true) if key in printer else none %}
|
{% set afc_spool = printer[key].spool_id|default(none, true) if key in printer else none %}
|
||||||
{% if lane and spool_id > 0 and (force or not cached) and afc_spool %}
|
{% if lane and spool_id > 0 and (force or not cached) and afc_spool %}
|
||||||
@@ -443,12 +446,14 @@ gcode:
|
|||||||
{% elif spool_id == 0 %}
|
{% elif spool_id == 0 %}
|
||||||
{action_respond_info("LANE_CALIBRATE_PA: no spool_id recorded for %s yet. Run SET_SPOOL_ID LANE=%s SPOOL_ID=<id> then _PA_TRACK_LANE_SPOOL LANE=%s SPOOL_ID=<id>." % (lane, lane, lane))}
|
{action_respond_info("LANE_CALIBRATE_PA: no spool_id recorded for %s yet. Run SET_SPOOL_ID LANE=%s SPOOL_ID=<id> then _PA_TRACK_LANE_SPOOL LANE=%s SPOOL_ID=<id>." % (lane, lane, lane))}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set pa_varname = "pa_value_spool_" ~ spool_id %}
|
{% set nozzle = "%g" % vars["pa_nozzle"]|default(0.4)|float %}
|
||||||
|
{% set test = cfg.nozzle_test[nozzle] %}
|
||||||
|
{% set pa_varname = "pa_value_" ~ nozzle|replace(".", "_") ~ "_spool_" ~ spool_id %}
|
||||||
{% set cache_found = pa_varname in vars %}
|
{% set cache_found = pa_varname in vars %}
|
||||||
{% set cached_pa = vars[pa_varname]|float if cache_found else 0.0 %}
|
{% set cached_pa = vars[pa_varname]|float if cache_found else 0.0 %}
|
||||||
|
|
||||||
{% if cache_found and force == 0 %}
|
{% if cache_found and force == 0 %}
|
||||||
{action_respond_info("Using cached PA=%.4f for %s (spool %d)" % (cached_pa, lane, spool_id))}
|
{action_respond_info("Using cached PA=%.4f for %s (spool %d, %s mm nozzle)" % (cached_pa, lane, spool_id, nozzle))}
|
||||||
SET_PRESSURE_ADVANCE ADVANCE={cached_pa}
|
SET_PRESSURE_ADVANCE ADVANCE={cached_pa}
|
||||||
{% else %}
|
{% else %}
|
||||||
CHANGE_TOOL LANE={lane}
|
CHANGE_TOOL LANE={lane}
|
||||||
@@ -462,30 +467,44 @@ gcode:
|
|||||||
{% set target = printer.extruder.target|default(0)|float %}
|
{% set target = printer.extruder.target|default(0)|float %}
|
||||||
{% set nozzle_temp = lane_temp if lane_temp > 0 else (target if target > 0 else cfg.fallback_nozzle_temp|float) %}
|
{% set nozzle_temp = lane_temp if lane_temp > 0 else (target if target > 0 else cfg.fallback_nozzle_temp|float) %}
|
||||||
{% set material = lane_obj.material|default("", true)|string|lower %}
|
{% set material = lane_obj.material|default("", true)|string|lower %}
|
||||||
{% set vol = namespace(max=cfg.max_volumetric|float) %}
|
{% set vol = namespace(max=test.max_volumetric|float) %}
|
||||||
{% for key, flow in cfg.material_max_volumetric.items() %}
|
{% for key, flow in cfg.material_max_volumetric.items() %}
|
||||||
{% if key in material and flow|float < vol.max %}
|
{% if key in material and flow|float < vol.max %}
|
||||||
{% set vol.max = flow|float %}
|
{% set vol.max = flow|float %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% set step = namespace(pa=cfg.pa_step|float) %}
|
{% set step = namespace(pa=test.pa_step|float) %}
|
||||||
{% for key, s in cfg.material_pa_step.items() %}
|
{% for key, s in cfg.material_pa_step.items() %}
|
||||||
{% if key in material and s|float > step.pa %}
|
{% if key in material and s|float > step.pa %}
|
||||||
{% set step.pa = s|float %}
|
{% set step.pa = s|float %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{action_respond_info("Calibrating PA for %s (spool %d) at %.0fC, %g mm3/s, PA 0-%.3f..." % (lane, spool_id, nozzle_temp, vol.max, 49 * step.pa))}
|
{action_respond_info("Calibrating PA for %s (spool %d, %s mm nozzle) at %.0fC, %g mm3/s, PA 0-%.3f..." % (lane, spool_id, nozzle, nozzle_temp, vol.max, 49 * step.pa))}
|
||||||
M117 Calibrating PA: {lane}
|
M117 Calibrating PA: {lane}
|
||||||
|
|
||||||
G1 Z50 F3000
|
G1 Z50 F3000
|
||||||
G4 P400
|
G4 P400
|
||||||
G1 X30 Y349 Z10 F3000
|
G1 X30 Y349 Z10 F3000
|
||||||
G4 P400
|
G4 P400
|
||||||
G1 Z0 F3000
|
G1 Z{cfg.test_z} F3000
|
||||||
G4 P400
|
G4 P400
|
||||||
|
# Buffer fault detection for the test (see test_error_sensitivity).
|
||||||
|
# lowered=True lets _FIRST_LAYER_FAULT_DETECTION ON=0 restore it,
|
||||||
|
# here and in _PRINT_CLEANUP when the test stops with an error.
|
||||||
|
{% set fl = printer["gcode_macro _FIRST_LAYER_FAULT_DETECTION"] %}
|
||||||
|
{% set buf_key = "afc_buffer " ~ fl.buffer|lower %}
|
||||||
|
{% set normal_sens = printer.configfile.settings[buf_key].filament_error_sensitivity|default(0)|float if buf_key in printer.configfile.settings else 0 %}
|
||||||
|
{% set lower_sens = normal_sens > 0 and cfg.test_error_sensitivity|float != normal_sens %}
|
||||||
|
{% if lower_sens %}
|
||||||
|
AFC_SET_ERROR_SENSITIVITY BUFFER={fl.buffer} SENSITIVITY={cfg.test_error_sensitivity}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_FIRST_LAYER_FAULT_DETECTION VARIABLE=lowered VALUE=True
|
||||||
|
{% endif %}
|
||||||
PA_CALIBRATE NOZZLE_TEMP={nozzle_temp} MAX_VOLUMETRIC={vol.max} ACC_WALL={cfg.acc_wall} TRAVEL_SPEED={cfg.travel_speed} ACC_TO_DECEL_FACTOR={cfg.acc_to_decel_factor} PA_STEP={step.pa}
|
PA_CALIBRATE NOZZLE_TEMP={nozzle_temp} MAX_VOLUMETRIC={vol.max} ACC_WALL={cfg.acc_wall} TRAVEL_SPEED={cfg.travel_speed} ACC_TO_DECEL_FACTOR={cfg.acc_to_decel_factor} PA_STEP={step.pa}
|
||||||
|
{% if lower_sens %}
|
||||||
|
_FIRST_LAYER_FAULT_DETECTION ON=0
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
# IMPORTANT: we do NOT read printer.extruder.pressure_advance
|
# IMPORTANT: we do NOT read printer.extruder.pressure_advance
|
||||||
# here. Klipper fully evaluates a macro's Jinja2 template
|
# here. Klipper fully evaluates a macro's Jinja2 template
|
||||||
@@ -505,7 +524,7 @@ gcode:
|
|||||||
# triggered (and its own template is rendered), PA_CALIBRATE
|
# triggered (and its own template is rendered), PA_CALIBRATE
|
||||||
# above has already finished and printer.extruder.pressure_advance
|
# above has already finished and printer.extruder.pressure_advance
|
||||||
# is current.
|
# is current.
|
||||||
_PA_AFTER_CALIBRATE LANE={lane} SPOOL_ID={spool_id} CACHE_FOUND={1 if cache_found else 0} CACHED_PA={cached_pa} SWEEP_END={49 * step.pa}
|
_PA_AFTER_CALIBRATE LANE={lane} SPOOL_ID={spool_id} NOZZLE={nozzle} CACHE_FOUND={1 if cache_found else 0} CACHED_PA={cached_pa} SWEEP_END={49 * step.pa}
|
||||||
BLOBIFIER_CLEAN
|
BLOBIFIER_CLEAN
|
||||||
G4 P400
|
G4 P400
|
||||||
G1 Z10 F3000
|
G1 Z10 F3000
|
||||||
@@ -516,14 +535,15 @@ gcode:
|
|||||||
|
|
||||||
[gcode_macro _PA_AFTER_CALIBRATE]
|
[gcode_macro _PA_AFTER_CALIBRATE]
|
||||||
description: Internal -- runs immediately after PA_CALIBRATE completes; reads the fresh PA value and caches it
|
description: Internal -- runs immediately after PA_CALIBRATE completes; reads the fresh PA value and caches it
|
||||||
# LANE=<lane_name> SPOOL_ID=<int> CACHE_FOUND=<0|1> CACHED_PA=<float> SWEEP_END=<last PA tested>
|
# LANE=<lane_name> SPOOL_ID=<int> NOZZLE=<mm> CACHE_FOUND=<0|1> CACHED_PA=<float> SWEEP_END=<last PA tested>
|
||||||
gcode:
|
gcode:
|
||||||
{% set lane = params.LANE|default("")|string %}
|
{% set lane = params.LANE|default("")|string %}
|
||||||
{% set spool_id = params.SPOOL_ID|default(0)|int %}
|
{% set spool_id = params.SPOOL_ID|default(0)|int %}
|
||||||
{% set cache_found = params.CACHE_FOUND|default(0)|int %}
|
{% set cache_found = params.CACHE_FOUND|default(0)|int %}
|
||||||
{% set cached_pa = params.CACHED_PA|default(0.0)|float %}
|
{% set cached_pa = params.CACHED_PA|default(0.0)|float %}
|
||||||
{% set cfg = printer["gcode_macro _PA_CFG"] %}
|
{% set cfg = printer["gcode_macro _PA_CFG"] %}
|
||||||
{% set sweep_end = params.SWEEP_END|default(49 * cfg.pa_step|float)|float %}
|
{% set sweep_end = params.SWEEP_END|float %}
|
||||||
|
{% set nozzle = "%g" % params.NOZZLE|float %}
|
||||||
|
|
||||||
# This template is evaluated only once this macro is actually
|
# This template is evaluated only once this macro is actually
|
||||||
# triggered -- which happens after PA_CALIBRATE (queued earlier by
|
# triggered -- which happens after PA_CALIBRATE (queued earlier by
|
||||||
@@ -556,16 +576,14 @@ gcode:
|
|||||||
_WARN MSG="PA calibration for {lane} (spool {spool_id}) rejected: {problems|join('; ')}. Nothing saved; using PA={'%.4f' % keep} ({'cached' if use_cache else 'fallback'}). Fix the cause, then LANE_CALIBRATE_PA LANE={lane} FORCE=1" DISPLAY="PA cal rejected: {lane}, see console"
|
_WARN MSG="PA calibration for {lane} (spool {spool_id}) rejected: {problems|join('; ')}. Nothing saved; using PA={'%.4f' % keep} ({'cached' if use_cache else 'fallback'}). Fix the cause, then LANE_CALIBRATE_PA LANE={lane} FORCE=1" DISPLAY="PA cal rejected: {lane}, see console"
|
||||||
SET_PRESSURE_ADVANCE ADVANCE={keep}
|
SET_PRESSURE_ADVANCE ADVANCE={keep}
|
||||||
{% else %}
|
{% else %}
|
||||||
{action_respond_info("Calibration complete for %s: PA=%.4f" % (lane, new_pa))}
|
{action_respond_info("Calibration complete for %s (%s mm nozzle): PA=%.4f" % (lane, nozzle, new_pa))}
|
||||||
M117 PA cal done: {new_pa|round(4)}
|
M117 PA cal done: {new_pa|round(4)}
|
||||||
|
|
||||||
{% set delta = (new_pa - cached_pa)|abs if cache_found else 999 %}
|
{% set delta = (new_pa - cached_pa)|abs if cache_found else 999 %}
|
||||||
{% if delta > cfg.write_threshold|float %}
|
{% if delta > cfg.write_threshold|float %}
|
||||||
_PA_CACHE_SET SPOOL_ID={spool_id} PA={new_pa}
|
_PA_CACHE_SET SPOOL_ID={spool_id} NOZZLE={nozzle} PA={new_pa}
|
||||||
{action_respond_info("Writing PA=%.4f to Spoolman spool %d" % (new_pa, spool_id))}
|
|
||||||
RUN_SHELL_COMMAND CMD=_pa_write_spoolman PARAMS="{spool_id} {cfg.spoolman_url} {cfg.spoolman_field} {new_pa}"
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{action_respond_info("PA change below threshold (%.4f), skipping cache/Spoolman write" % cfg.write_threshold|float)}
|
{action_respond_info("PA change below threshold (%.4f), keeping the saved value" % cfg.write_threshold|float)}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -691,14 +709,15 @@ gcode:
|
|||||||
{% set spool_id = vars[lane_varname]|default(0)|int if lane_varname in vars else 0 %}
|
{% set spool_id = vars[lane_varname]|default(0)|int if lane_varname in vars else 0 %}
|
||||||
|
|
||||||
{% if spool_id > 0 %}
|
{% if spool_id > 0 %}
|
||||||
{% set pa_varname = "pa_value_spool_" ~ spool_id %}
|
{% set nozzle = "%g" % vars["pa_nozzle"]|default(0.4)|float %}
|
||||||
|
{% set pa_varname = "pa_value_" ~ nozzle|replace(".", "_") ~ "_spool_" ~ spool_id %}
|
||||||
{% if pa_varname in vars %}
|
{% if pa_varname in vars %}
|
||||||
{% set cached_pa = vars[pa_varname]|float %}
|
{% set cached_pa = vars[pa_varname]|float %}
|
||||||
SET_PRESSURE_ADVANCE ADVANCE={cached_pa}
|
SET_PRESSURE_ADVANCE ADVANCE={cached_pa}
|
||||||
{action_respond_info("Lane %s loaded: applied cached PA=%.4f (spool %d)" % (lane, cached_pa, spool_id))}
|
{action_respond_info("Lane %s loaded: applied cached PA=%.4f (spool %d, %s mm nozzle)" % (lane, cached_pa, spool_id, nozzle))}
|
||||||
M117 PA: {lane} = {cached_pa|round(4)}
|
M117 PA: {lane} = {cached_pa|round(4)}
|
||||||
{% else %}
|
{% else %}
|
||||||
{action_respond_info("Lane %s loaded: spool %d has no cached PA yet. Run LANE_CALIBRATE_PA LANE=%s or PA_CALIBRATE_ALL_LANES." % (lane, spool_id, lane))}
|
{action_respond_info("Lane %s loaded: spool %d has no PA for the %s mm nozzle yet, PA stays %.4f. Run LANE_CALIBRATE_PA LANE=%s or PA_CALIBRATE_ALL_LANES; a print start does this itself." % (lane, spool_id, nozzle, printer.extruder.pressure_advance|float, lane))}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{action_respond_info("Lane %s loaded: no spool_id recorded yet (run SET_SPOOL_ID first)." % lane)}
|
{action_respond_info("Lane %s loaded: no spool_id recorded yet (run SET_SPOOL_ID first)." % lane)}
|
||||||
@@ -726,15 +745,16 @@ gcode:
|
|||||||
{% set cfg = printer["gcode_macro _PA_CFG"] %}
|
{% set cfg = printer["gcode_macro _PA_CFG"] %}
|
||||||
{% set lane_list = cfg.lane_names.split(",") %}
|
{% set lane_list = cfg.lane_names.split(",") %}
|
||||||
{% set vars = printer.save_variables.variables %}
|
{% set vars = printer.save_variables.variables %}
|
||||||
|
{% set nozzle = "%g" % vars["pa_nozzle"]|default(0.4)|float %}
|
||||||
|
|
||||||
{action_respond_info("=== PA Status ===")}
|
{action_respond_info("=== PA Status, %s mm nozzle ===" % nozzle)}
|
||||||
{% for lane in lane_list %}
|
{% for lane in lane_list %}
|
||||||
{% set lane = lane.strip() %}
|
{% set lane = lane.strip() %}
|
||||||
{% if lane != "" %}
|
{% if lane != "" %}
|
||||||
{% set spool_varname = "pa_lane_" ~ lane ~ "_spool_id" %}
|
{% set spool_varname = "pa_lane_" ~ lane ~ "_spool_id" %}
|
||||||
{% set spool_id = vars[spool_varname]|default(0)|int if spool_varname in vars else 0 %}
|
{% set spool_id = vars[spool_varname]|default(0)|int if spool_varname in vars else 0 %}
|
||||||
{% if spool_id > 0 %}
|
{% if spool_id > 0 %}
|
||||||
{% set pa_varname = "pa_value_spool_" ~ spool_id %}
|
{% set pa_varname = "pa_value_" ~ nozzle|replace(".", "_") ~ "_spool_" ~ spool_id %}
|
||||||
{% if pa_varname in vars %}
|
{% if pa_varname in vars %}
|
||||||
{action_respond_info(" %s (spool %d): PA=%.4f cached" % (lane, spool_id, vars[pa_varname]|float))}
|
{action_respond_info(" %s (spool %d): PA=%.4f cached" % (lane, spool_id, vars[pa_varname]|float))}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
SPOOL_ID=$1
|
|
||||||
BASE_URL=$2
|
|
||||||
FIELD=$3
|
|
||||||
PA_VALUE=$4
|
|
||||||
CURRENT=$(curl -sf "${BASE_URL}/api/v1/spool/${SPOOL_ID}" 2>/dev/null)
|
|
||||||
EXTRA=$(echo "$CURRENT" | python3 -c "
|
|
||||||
import sys, json
|
|
||||||
try:
|
|
||||||
d = json.load(sys.stdin)
|
|
||||||
e = d.get('extra', {})
|
|
||||||
e['$FIELD'] = '$PA_VALUE'
|
|
||||||
print(json.dumps(e))
|
|
||||||
except Exception:
|
|
||||||
print(json.dumps({'$FIELD': '$PA_VALUE'}))
|
|
||||||
" 2>/dev/null)
|
|
||||||
if [ -z "$EXTRA" ]; then
|
|
||||||
EXTRA="{\"$FIELD\": \"$PA_VALUE\"}"
|
|
||||||
fi
|
|
||||||
curl -sf -X PATCH "${BASE_URL}/api/v1/spool/${SPOOL_ID}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"extra\": $EXTRA}" > /tmp/pa_spoolman_write_result 2>&1
|
|
||||||
@@ -117,7 +117,9 @@ gcode:
|
|||||||
G21
|
G21
|
||||||
M83
|
M83
|
||||||
M109 S{NOZZLE_TEMP}
|
M109 S{NOZZLE_TEMP}
|
||||||
G1 E4
|
# At the test flow. Without F this ran at the speed of the move before
|
||||||
|
# (F3000 in LANE_CALIBRATE_PA: 120 mm3/s), too much for a small nozzle.
|
||||||
|
G1 E4 F{MAX_VOLUMETRIC / 2.405 * 60}
|
||||||
SET_PRESSURE_ADVANCE ADVANCE=0.04; Override pressure advance value
|
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} ACCEL_TO_DECEL={ACC_TO_DEC}
|
||||||
SET_VELOCITY_LIMIT ACCEL={ACC_WALL} MINIMUM_CRUISE_RATIO={MIN_CRUISE}
|
SET_VELOCITY_LIMIT ACCEL={ACC_WALL} MINIMUM_CRUISE_RATIO={MIN_CRUISE}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Nozzle collision guard: bd_pressure watches the nozzle force during moves
|
# Nozzle collision guard: bd_pressure watches the nozzle force during moves
|
||||||
# that must not touch anything (needs extras/bdp_guard.py and the bd_pressure
|
# that must not touch anything (needs bdp_guard.py from the bd_pressure repo,
|
||||||
# load-check firmware). See extras/bdp_guard.py.
|
# klipper/, and its load-check firmware). See klipper/load_check/README.md there.
|
||||||
#
|
#
|
||||||
# mode: stop shuts Klipper down on a touch; log only measures and reports
|
# mode: stop shuts Klipper down on a touch; log only measures and reports
|
||||||
# each phase (console and klippy.log, "bdp_guard:"). A phase can override it
|
# each phase (console and klippy.log, "bdp_guard:"). A phase can override it
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
# PAUSE -> AFC_PAUSE (saves position, z-hop) -> this PAUSE -> PAUSE_BASE
|
# PAUSE -> AFC_PAUSE (saves position, z-hop) -> this PAUSE -> PAUSE_BASE
|
||||||
# RESUME -> AFC_RESUME -> this RESUME -> HEAT_SOAK_RESUME -> _RESUME_PRINT
|
# RESUME -> AFC_RESUME -> this RESUME -> HEAT_SOAK_RESUME -> _RESUME_PRINT
|
||||||
# -> RESUME_BASE, then AFC restores the saved position
|
# -> RESUME_BASE, then AFC restores the saved position
|
||||||
|
# A finished HEAT_SOAK calls _RESUME_PRINT directly: AFC saved no position for
|
||||||
|
# its pause, so AFC_RESUME would send the toolhead to X0 Y0.
|
||||||
# RESUME is defined only here: heating/heat_soak.cfg used to define its own,
|
# RESUME is defined only here: heating/heat_soak.cfg used to define its own,
|
||||||
# which replaced this one completely (no unretract, no fan restore).
|
# which replaced this one completely (no unretract, no fan restore).
|
||||||
# After a PAUSE, _RESUME_PRINT purges into the Blobifier with the purge check
|
# After a PAUSE, _RESUME_PRINT purges into the Blobifier with the purge check
|
||||||
@@ -14,6 +16,12 @@
|
|||||||
# (the lane AFC was loading when a tool change failed, otherwise the loaded
|
# (the lane AFC was loading when a tool change failed, otherwise the loaded
|
||||||
# lane), and RESUME stops with an error when another lane (or none) is loaded.
|
# lane), and RESUME stops with an error when another lane (or none) is loaded.
|
||||||
# RESUME LANE_CHECK=0 resumes anyway (e.g. after remapping with SET_MAP).
|
# RESUME LANE_CHECK=0 resumes anyway (e.g. after remapping with SET_MAP).
|
||||||
|
# An AFC "NOT FEEDING" buffer fault pause (not "CLOG DETECTED") during a
|
||||||
|
# print runs this RESUME by itself after a few seconds, within limits
|
||||||
|
# (afc/auto_resume.cfg).
|
||||||
|
# A failed bed check in PRINT_START (calibration/bed_scan_check.cfg) pauses with
|
||||||
|
# _BED_CHECK_STATE.pending set: PAUSE then only pauses, and RESUME runs
|
||||||
|
# PRINT_START again instead of this chain's purge and lane check.
|
||||||
|
|
||||||
# https://klipperscreen.readthedocs.io/en/latest/macros/#recommended
|
# https://klipperscreen.readthedocs.io/en/latest/macros/#recommended
|
||||||
[gcode_macro PAUSE]
|
[gcode_macro PAUSE]
|
||||||
@@ -23,7 +31,9 @@ variable_saved_fan_speed: 0.0
|
|||||||
variable_parked: False # set by PAUSE, used by _RESUME_PRINT
|
variable_parked: False # set by PAUSE, used by _RESUME_PRINT
|
||||||
variable_expected_lane: '' # AFC lane the print needs after RESUME ('' = no check)
|
variable_expected_lane: '' # AFC lane the print needs after RESUME ('' = no check)
|
||||||
gcode:
|
gcode:
|
||||||
{% if not printer.pause_resume.is_paused %}
|
{% if printer["gcode_macro _BED_CHECK_STATE"].pending %}
|
||||||
|
PAUSE_BASE
|
||||||
|
{% elif not printer.pause_resume.is_paused %}
|
||||||
# AFC sets next_lane during a tool change and still has it when a failed
|
# AFC sets next_lane during a tool change and still has it when a failed
|
||||||
# change pauses the print; it clears it once CHANGE_TOOL returns
|
# change pauses the print; it clears it once CHANGE_TOOL returns
|
||||||
{% if 'AFC' in printer %}
|
{% if 'AFC' in printer %}
|
||||||
@@ -44,6 +54,9 @@ gcode:
|
|||||||
_STATUS STATE=paused
|
_STATUS STATE=paused
|
||||||
# Set fan to S28 (28/255 ≈ 0.1098)
|
# Set fan to S28 (28/255 ≈ 0.1098)
|
||||||
M106 S28
|
M106 S28
|
||||||
|
{% if 'gcode_macro _AUTO_RESUME_ARM' in printer %}
|
||||||
|
_AUTO_RESUME_ARM ; AFC buffer fault: resume by itself after the purge check (afc/auto_resume.cfg)
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
PAUSE_BASE
|
PAUSE_BASE
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -52,7 +65,11 @@ gcode:
|
|||||||
description: Resume the print (while HEAT_SOAK runs: skip the soak phase)
|
description: Resume the print (while HEAT_SOAK runs: skip the soak phase)
|
||||||
rename_existing: RESUME_BASE
|
rename_existing: RESUME_BASE
|
||||||
gcode:
|
gcode:
|
||||||
|
{% if printer["gcode_macro _BED_CHECK_STATE"].pending %}
|
||||||
|
_BED_CHECK_RETRY
|
||||||
|
{% else %}
|
||||||
HEAT_SOAK_RESUME ON_RESUME=_RESUME_PRINT {rawparams}
|
HEAT_SOAK_RESUME ON_RESUME=_RESUME_PRINT {rawparams}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[gcode_macro _RESUME_PRINT]
|
[gcode_macro _RESUME_PRINT]
|
||||||
description: Resume after PAUSE: purge and check (or unretract), restore the part fan, continue the print
|
description: Resume after PAUSE: purge and check (or unretract), restore the part fan, continue the print
|
||||||
@@ -92,6 +109,9 @@ gcode:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=parked VALUE=False
|
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=parked VALUE=False
|
||||||
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=expected_lane VALUE="''"
|
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=expected_lane VALUE="''"
|
||||||
|
{% if 'gcode_macro _AUTO_RESUME_CLEAR_FAULT' in printer %}
|
||||||
|
_AUTO_RESUME_CLEAR_FAULT
|
||||||
|
{% endif %}
|
||||||
# Clear the pause reason from the display (no comment on an M117 line: it would show)
|
# Clear the pause reason from the display (no comment on an M117 line: it would show)
|
||||||
M117
|
M117
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
# PRINT_START runs on a soaked bed:
|
# PRINT_START runs on a soaked bed:
|
||||||
# PRINT_WARMUP bed heats while the nozzle cools and the printer homes,
|
# PRINT_WARMUP bed heats while the nozzle cools and the printer homes,
|
||||||
# wait for the bed, HEAT_SOAK
|
# wait for the bed, HEAT_SOAK
|
||||||
# PRINT_START QGL, Z, contact Z calibration, mesh, load the initial tool,
|
# PRINT_START QGL, Z, contact Z calibration, mesh, bed check (a failed
|
||||||
# PA for all lanes, XY reference
|
# check pauses, RESUME runs PRINT_START again, see
|
||||||
|
# calibration/bed_scan_check.cfg), then _PRINT_START_FINISH:
|
||||||
|
# load the initial tool, PA for all lanes, XY reference
|
||||||
# The filament is loaded after the Z calibration, so the contact always
|
# The filament is loaded after the Z calibration, so the contact always
|
||||||
# touches a clean nozzle that has not been oozing at 150C for minutes.
|
# touches a clean nozzle that has not been oozing at 150C for minutes.
|
||||||
# Chamber prints are the exception: PRINT_WARMUP loads and purges the first
|
# Chamber prints are the exception: PRINT_WARMUP loads and purges the first
|
||||||
@@ -24,8 +26,14 @@ gcode:
|
|||||||
{% set target_chamber = params.CHAMBER|default("0")|int %}
|
{% set target_chamber = params.CHAMBER|default("0")|int %}
|
||||||
{% set initial_tool = params.TOOL|default("0")|int %}
|
{% set initial_tool = params.TOOL|default("0")|int %}
|
||||||
|
|
||||||
|
# First, so a wrong nozzle stops the print before anything heats
|
||||||
|
{% if params.NOZZLE %}
|
||||||
|
_PA_CHECK_NOZZLE NOZZLE={params.NOZZLE}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
RESET_FAILURE
|
RESET_FAILURE
|
||||||
CLEAR_PAUSE
|
CLEAR_PAUSE
|
||||||
|
_BED_CHECK_RESET
|
||||||
# Clear what an earlier print or error left on the display
|
# Clear what an earlier print or error left on the display
|
||||||
M117
|
M117
|
||||||
|
|
||||||
@@ -37,14 +45,12 @@ gcode:
|
|||||||
SKEW_PROFILE LOAD=Califlower
|
SKEW_PROFILE LOAD=Califlower
|
||||||
M106 S0
|
M106 S0
|
||||||
|
|
||||||
|
# Bed fans only help to heat a closed chamber: off for this print without
|
||||||
|
# one (heating/bed_fans.cfg). Set before the bed target, which reads it.
|
||||||
|
SET_GCODE_VARIABLE MACRO=_BEDFANVARS VARIABLE=print_fans_off VALUE={target_chamber <= 30}
|
||||||
|
|
||||||
# Bed first, so it heats during the rest of the warmup
|
# Bed first, so it heats during the rest of the warmup
|
||||||
{% if target_bed < 60 %}
|
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={target_bed}
|
||||||
RESPOND MSG="Using PID for <60°C bed"
|
|
||||||
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={target_bed} PID_KP=33.606 PID_KI=0.694 PID_KD=407.058
|
|
||||||
{% else %}
|
|
||||||
RESPOND MSG="Using PID for ≥60°C bed"
|
|
||||||
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={target_bed} pid_Kp=46.843 pid_Ki=2.002 pid_Kd=274.034
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# Only to get the toolhead over the bed for the soak; the Z that counts
|
# Only to get the toolhead over the bed for the soak; the Z that counts
|
||||||
# is the contact calibration in PRINT_START on the soaked bed
|
# is the contact calibration in PRINT_START on the soaked bed
|
||||||
@@ -193,10 +199,14 @@ gcode:
|
|||||||
RESUME_BASE
|
RESUME_BASE
|
||||||
|
|
||||||
[gcode_macro PRINT_START]
|
[gcode_macro PRINT_START]
|
||||||
description: Print start after HEAT_SOAK: QGL, Z calibration, mesh, load the initial tool, PA
|
description: Print start after HEAT_SOAK: QGL, Z calibration, mesh, bed check, then _PRINT_START_FINISH
|
||||||
gcode:
|
gcode:
|
||||||
{% set target_extruder = params.EXTRUDER|int %}
|
{% set target_extruder = params.EXTRUDER|int %}
|
||||||
{% set initial_tool = params.TOOL|default("0")|int %}
|
{% set initial_tool = params.TOOL|default("0")|int %}
|
||||||
|
# Rendered while this line of the print file runs: the start of the line,
|
||||||
|
# where a retry after a failed bed check goes back to. -1: not from a file.
|
||||||
|
{% set sd = printer.virtual_sdcard %}
|
||||||
|
{% set file_pos = sd.file_position if sd.is_active else -1 %}
|
||||||
|
|
||||||
RESPOND MSG="print start macro continued"
|
RESPOND MSG="print start macro continued"
|
||||||
_LIGHTS_ON
|
_LIGHTS_ON
|
||||||
@@ -235,6 +245,35 @@ gcode:
|
|||||||
# From here on the nozzle extrudes and AFC cuts and loads: guard off
|
# From here on the nozzle extrudes and AFC cuts and loads: guard off
|
||||||
_GUARD_OFF
|
_GUARD_OFF
|
||||||
|
|
||||||
|
BED_MESH_CHECK
|
||||||
|
_PRINT_START_GATE EXTRUDER={target_extruder} TOOL={initial_tool} FILE_POS={file_pos}
|
||||||
|
|
||||||
|
# Separate macro: rendered after BED_MESH_CHECK has run. Pausing does not stop
|
||||||
|
# a running macro, so what follows the check must not be in PRINT_START itself.
|
||||||
|
[gcode_macro _PRINT_START_GATE]
|
||||||
|
description: Helper for PRINT_START: pause when the bed check failed, else go on with _PRINT_START_FINISH
|
||||||
|
gcode:
|
||||||
|
{% set check = printer.mesh_check %}
|
||||||
|
{% set ignore = printer["gcode_macro _BED_CHECK_STATE"].ignore %}
|
||||||
|
{% set file_pos = params.FILE_POS|int %}
|
||||||
|
{% if check.result == 'fail' and not ignore and file_pos >= 0 %}
|
||||||
|
_BED_CHECK_PAUSE FILE_POS={file_pos}
|
||||||
|
{% else %}
|
||||||
|
{% if check.result == 'fail' %}
|
||||||
|
_WARN MSG="Bed check failed, continuing: {check.summary}" DISPLAY="Bed check failed, continuing"
|
||||||
|
{% elif check.result != 'ok' %}
|
||||||
|
_WARN MSG="Bed check not done, continuing: {check.summary}" DISPLAY="Bed check not done"
|
||||||
|
{% endif %}
|
||||||
|
_BED_CHECK_RESET
|
||||||
|
_PRINT_START_FINISH EXTRUDER={params.EXTRUDER} TOOL={params.TOOL}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[gcode_macro _PRINT_START_FINISH]
|
||||||
|
description: Helper for PRINT_START after the bed check: load the initial tool, PA, XY reference
|
||||||
|
gcode:
|
||||||
|
{% set target_extruder = params.EXTRUDER|int %}
|
||||||
|
{% set initial_tool = params.TOOL|default("0")|int %}
|
||||||
|
|
||||||
# Heat over the bucket, then undo the retracts of the previous PRINT_END
|
# Heat over the bucket, then undo the retracts of the previous PRINT_END
|
||||||
_STATUS STATE=heating_extruder
|
_STATUS STATE=heating_extruder
|
||||||
BLOBIFIER_PARK
|
BLOBIFIER_PARK
|
||||||
@@ -267,6 +306,11 @@ gcode:
|
|||||||
# ("AFC NOT FEEDING"); the slicer switches it back at layer 2
|
# ("AFC NOT FEEDING"); the slicer switches it back at layer 2
|
||||||
_FIRST_LAYER_FAULT_DETECTION ON=1
|
_FIRST_LAYER_FAULT_DETECTION ON=1
|
||||||
|
|
||||||
|
# From here on an AFC buffer fault pause resumes by itself (afc/auto_resume.cfg)
|
||||||
|
{% if 'gcode_macro _AUTO_RESUME_ACTIVE' in printer %}
|
||||||
|
_AUTO_RESUME_ACTIVE ON=1
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
RESPOND MSG="starting"
|
RESPOND MSG="starting"
|
||||||
_STATUS STATE=printing
|
_STATUS STATE=printing
|
||||||
|
|
||||||
@@ -286,7 +330,7 @@ gcode:
|
|||||||
|
|
||||||
M400 ; wait for buffer to clear
|
M400 ; wait for buffer to clear
|
||||||
G92 E0 ; zero the extruder
|
G92 E0 ; zero the extruder
|
||||||
_NOZZLE_RETRACT ; so the nozzle does not leak while cooling down
|
_NOZZLE_RETRACT LENGTH=2 ; so the nozzle does not leak while cooling down (plus the slicer's own retract)
|
||||||
|
|
||||||
TURN_OFF_HEATERS
|
TURN_OFF_HEATERS
|
||||||
iHEATER_OFF ; Turns off the chamber heater
|
iHEATER_OFF ; Turns off the chamber heater
|
||||||
@@ -307,9 +351,11 @@ gcode:
|
|||||||
|
|
||||||
# End-of-print cleanup shared by PRINT_END and CANCEL_PRINT
|
# End-of-print cleanup shared by PRINT_END and CANCEL_PRINT
|
||||||
[gcode_macro _PRINT_CLEANUP]
|
[gcode_macro _PRINT_CLEANUP]
|
||||||
description: Heaters (incl. chamber heater) and part fan off, flow back to 100%, bdwidth off, mesh and skew cleared, nozzle guard off
|
description: Heaters (incl. chamber heater) and part fan off, flow back to 100%, bdwidth off, mesh and skew cleared, nozzle guard off, AFC runouts cleared, auto-resume off, SpoolSense tag update
|
||||||
gcode:
|
gcode:
|
||||||
_GUARD_OFF ; a print start that failed while it was armed
|
_GUARD_OFF ; a print start that failed while it was armed
|
||||||
|
_BED_CHECK_RESET ; cancelled while the bed check had it paused
|
||||||
|
SET_GCODE_VARIABLE MACRO=_BEDFANVARS VARIABLE=print_fans_off VALUE=False
|
||||||
TURN_OFF_HEATERS
|
TURN_OFF_HEATERS
|
||||||
iHEATER_OFF ; stops the chamber heater control loop too
|
iHEATER_OFF ; stops the chamber heater control loop too
|
||||||
M107
|
M107
|
||||||
@@ -323,6 +369,21 @@ gcode:
|
|||||||
SET_GCODE_VARIABLE MACRO=_PURGE_CHECK_CFG VARIABLE=ignore_missing_sensor VALUE=False
|
SET_GCODE_VARIABLE MACRO=_PURGE_CHECK_CFG VARIABLE=ignore_missing_sensor VALUE=False
|
||||||
{% endif %}
|
{% endif %}
|
||||||
_FIRST_LAYER_FAULT_DETECTION ON=0 ; a print that ended during the first layer
|
_FIRST_LAYER_FAULT_DETECTION ON=0 ; a print that ended during the first layer
|
||||||
|
{% if 'gcode_macro _AUTO_RESUME_ACTIVE' in printer %}
|
||||||
|
_AUTO_RESUME_ACTIVE ON=0 ; also stops a pending automatic resume
|
||||||
|
{% endif %}
|
||||||
|
# Infinite spool is set up per print (SET_RUNOUT): clear every lane's runout
|
||||||
|
{% if 'AFC' in printer %}
|
||||||
|
{% for lane in printer.AFC.lanes|default([]) if printer["AFC_stepper " ~ lane].runout_lane|default(none) %}
|
||||||
|
SET_RUNOUT LANE={lane} RUNOUT=NONE
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
# SpoolSense (spoolsense.cfg in the config folder, not in this repo): the
|
||||||
|
# middleware deducts the filament of this print (also a cancelled one) and
|
||||||
|
# writes it to the spool's NFC tag at its next scan
|
||||||
|
{% if 'gcode_macro UPDATE_TAG' in printer %}
|
||||||
|
UPDATE_TAG
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
# AFC buffer fault detection (filament_error_sensitivity, 0-10, higher =
|
# AFC buffer fault detection (filament_error_sensitivity, 0-10, higher =
|
||||||
# pauses sooner) with its own value during the first layer.
|
# pauses sooner) with its own value during the first layer.
|
||||||
|
|||||||
+62
-6
@@ -2,14 +2,70 @@
|
|||||||
|
|
||||||
`twist_check.py` is the axis twist calibration: start it with the macro
|
`twist_check.py` is the axis twist calibration: start it with the macro
|
||||||
`TWIST_CALIBRATE` in Mainsail, and see [twist_check.md](twist_check.md) for how
|
`TWIST_CALIBRATE` in Mainsail, and see [twist_check.md](twist_check.md) for how
|
||||||
to use it. The rest of this page is about the firmware scripts.
|
to use it. The rest of this page is about MCU firmware updates.
|
||||||
|
|
||||||
# MCU firmware update scripts
|
# MCU firmware updates: aldis
|
||||||
|
|
||||||
|
Klipper firmware on the MCUs is updated with
|
||||||
|
[aldis](https://github.com/mjonuschat/aldis) (GPL-3.0). It finds every MCU in
|
||||||
|
the running Klipper/Moonraker setup, compares its firmware with the Klipper
|
||||||
|
checkout in `~/klipper`, and builds and flashes only the ones that are out of
|
||||||
|
date, using the build config each MCU reports itself. It stops Klipper only
|
||||||
|
for the flash, and shows its plan first. It also updates Beacon's firmware.
|
||||||
|
|
||||||
|
Its source is included as a git submodule in `external/aldis`, pinned to the
|
||||||
|
release in use (v0.4.0). On the Pi you run the released program instead,
|
||||||
|
installed in `~/aldis`; the submodule stays empty there (Moonraker does not
|
||||||
|
fetch submodules), which is fine. To get the source on a PC:
|
||||||
|
`git submodule update --init`.
|
||||||
|
|
||||||
|
## Install (once, on the Pi)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p ~/aldis && curl -fL "https://github.com/mjonuschat/aldis/releases/latest/download/aldis-$(uname -m)-linux.tar.xz" | tar xJ -C ~/aldis --strip-components=1 && chmod +x ~/aldis/aldis
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ~/aldis/aldis setup
|
||||||
|
```
|
||||||
|
|
||||||
|
`setup` installs udev rules for the USB bootloaders and a narrow sudo rule so
|
||||||
|
aldis can stop and start Klipper. `sudo ~/aldis/aldis setup --check` verifies
|
||||||
|
them. Optional: `sudo ~/aldis/aldis setup --agent` runs it as a service that
|
||||||
|
the web UI can manage (restart Moonraker once afterwards).
|
||||||
|
|
||||||
|
## Use (between prints only)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
~/aldis/aldis status
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
~/aldis/aldis update
|
||||||
|
```
|
||||||
|
|
||||||
|
- `status`: which MCUs it found and whether their firmware is current (reads only).
|
||||||
|
- `update`: builds and flashes the outdated MCUs, asking per MCU.
|
||||||
|
`update --pull` also pulls Klipper first; `update <mcu>` limits it.
|
||||||
|
- `self-update`: installs a newer aldis release (`--check` only reports).
|
||||||
|
|
||||||
|
Notes for this printer (checked 2026-11-07):
|
||||||
|
- All Klipper MCUs (`mcu` Leviathan, `Turtle_1`, `MC_1`, `EBB42`, `nhk`,
|
||||||
|
`iHeater`) run `v0.13.0-777`, and Beacon 2.1.0; all report `mcu_kconfig`,
|
||||||
|
which aldis needs (Klipper `v0.13.0-753` or newer).
|
||||||
|
- Every board has Katapult (CAN or USB), which aldis supports.
|
||||||
|
- Flashing the Leviathan (USB-CAN bridge) resets the CAN bus.
|
||||||
|
- aldis writes each MCU's build config to `~/klipper/.config`. The named build
|
||||||
|
configs used by the old script (`leviathan`, `EBB42`, ...) are not touched.
|
||||||
|
- Not covered: the bd_pressure sensor (not a Klipper MCU; it has its own
|
||||||
|
`stm32flash` procedure in the bd_pressure repo) and Katapult itself (see below).
|
||||||
|
|
||||||
|
# Old scripts
|
||||||
|
|
||||||
| Script | Does |
|
| Script | Does |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `update_all_mcus.sh` | Pulls Klipper, builds and flashes **Klipper** to every MCU, prints a summary, restarts Klipper |
|
| `archive/update_all_mcus.sh` | **Archived 2026-11-07, replaced by aldis.** Pulls Klipper, builds and flashes **Klipper** to every MCU, prints a summary, restarts Klipper |
|
||||||
| `update_katapult_all_mcus.sh` | Builds and flashes **Katapult** (the bootloader) to every MCU |
|
| `update_katapult_all_mcus.sh` | Builds and flashes **Katapult** (the bootloader) to every MCU. Still in use: aldis does not update bootloaders |
|
||||||
|
|
||||||
Based on the [Voron guide to automating MCU updates](https://docs.vorondesign.com/community/howto/drachenkatze/automating_klipper_mcu_updates.html)
|
Based on the [Voron guide to automating MCU updates](https://docs.vorondesign.com/community/howto/drachenkatze/automating_klipper_mcu_updates.html)
|
||||||
and [Esoterical's CANBus guide](https://canbus.esoterical.online/).
|
and [Esoterical's CANBus guide](https://canbus.esoterical.online/).
|
||||||
@@ -17,7 +73,7 @@ and [Esoterical's CANBus guide](https://canbus.esoterical.online/).
|
|||||||
Run them on the Klipper host, between prints:
|
Run them on the Klipper host, between prints:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
~/klipper-macros/scripts/update_all_mcus.sh
|
~/klipper-macros/scripts/update_katapult_all_mcus.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
They stop Klipper while flashing (and need `sudo` for that).
|
They stop Klipper while flashing (and need `sudo` for that).
|
||||||
@@ -96,5 +152,5 @@ not used by the flashing itself; they only document the UUIDs.
|
|||||||
|
|
||||||
`update_katapult_all_mcus.sh` ends after the last board: it does not print
|
`update_katapult_all_mcus.sh` ends after the last board: it does not print
|
||||||
the summary and does not start Klipper again. Run `sudo systemctl start
|
the summary and does not start Klipper again. Run `sudo systemctl start
|
||||||
klipper` afterwards, or add the last lines of `update_all_mcus.sh`
|
klipper` afterwards, or add the last lines of `archive/update_all_mcus.sh`
|
||||||
(`print_summary` and the restart) to it.
|
(`print_summary` and the restart) to it.
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# ARCHIVED 2026-11-07: replaced by aldis (https://github.com/mjonuschat/aldis),
|
||||||
|
# see scripts/README.md. Kept for reference; the IDs below are still this printer's.
|
||||||
# https://docs.vorondesign.com/community/howto/drachenkatze/automating_klipper_mcu_updates.html
|
# https://docs.vorondesign.com/community/howto/drachenkatze/automating_klipper_mcu_updates.html
|
||||||
# https://canbus.esoterical.online/mainboard_klipper_updating.html
|
# https://canbus.esoterical.online/mainboard_klipper_updating.html
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ The calibration clears the active bed mesh (saved profiles stay).
|
|||||||
|
|
||||||
## What the run does
|
## What the run does
|
||||||
|
|
||||||
It heats the nozzle to 150 C, homes, runs QGL and sets Z by contact. It then
|
It heats the nozzle to 150 C, homes, runs QGL, wipes the nozzle on the Blobifier
|
||||||
visits each point twice, the second pass in reverse order to cancel slow drift.
|
brush and sets Z by contact. It then visits each point twice, the second pass in reverse order to cancel slow drift.
|
||||||
The nozzle touches the bed at every point. At the end it lifts to Z10 and turns
|
The nozzle touches the bed at every point. At the end it lifts to Z10 and turns
|
||||||
the nozzle heater off. The bed heater is not touched.
|
the nozzle heater off. The bed heater is not touched.
|
||||||
|
|
||||||
@@ -140,6 +140,7 @@ that computer, under its own home directory.
|
|||||||
- Mainsail with `[respond]`, for the windows
|
- Mainsail with `[respond]`, for the windows
|
||||||
- `gcode_shell_command`, to start the script from a macro
|
- `gcode_shell_command`, to start the script from a macro
|
||||||
- Beacon, used in contact and proximity mode
|
- Beacon, used in contact and proximity mode
|
||||||
|
- The Blobifier macros (`BLOBIFIER_CLEAN`) and the nozzle guard (`_GUARD_ON`)
|
||||||
- Python 3 on the Pi (standard library only), and Moonraker trusting localhost
|
- Python 3 on the Pi (standard library only), and Moonraker trusting localhost
|
||||||
- For Verify: `[bdp_touch]` and the bd_pressure load-check firmware
|
- For Verify: `[bdp_touch]` and the bd_pressure load-check firmware
|
||||||
- `[axis_twist_compensation]` is not needed for the first Measure; the result
|
- `[axis_twist_compensation]` is not needed for the first Measure; the result
|
||||||
|
|||||||
+10
-2
@@ -26,7 +26,7 @@ Modes:
|
|||||||
y 175/295. With good compensation, bdp - proximity is flat along X.
|
y 175/295. With good compensation, bdp - proximity is flat along X.
|
||||||
|
|
||||||
Both: BED_MESH_CLEAR (the active mesh only; saved profiles stay), nozzle 150C,
|
Both: BED_MESH_CLEAR (the active mesh only; saved profiles stay), nozzle 150C,
|
||||||
HOME, QGL, contact Z, 2 passes (second in reverse order to cancel slow drift),
|
HOME, QGL, G28 Z, nozzle wipe (BLOBIFIER_CLEAN), contact Z, 2 passes (second in reverse order to cancel slow drift),
|
||||||
then Z10 and nozzle off. The bed heater is not touched.
|
then Z10 and nozzle off. The bed heater is not touched.
|
||||||
|
|
||||||
Safety: refuses to start when Klipper is not ready, a print runs or another
|
Safety: refuses to start when Klipper is not ready, a print runs or another
|
||||||
@@ -210,7 +210,8 @@ def preflight(p, mode):
|
|||||||
raise Problem("A print is running or paused. Try again afterwards.")
|
raise Problem("A print is running or paused. Try again afterwards.")
|
||||||
objects = p.get("/printer/objects/list")["objects"]
|
objects = p.get("/printer/objects/list")["objects"]
|
||||||
settings = p.query("configfile")["configfile"]["settings"]
|
settings = p.query("configfile")["configfile"]["settings"]
|
||||||
missing = [m for m in ("HOME", "_NOZZLE_CONTACT_TEMP", "_TWIST_STATE")
|
missing = [m for m in ("HOME", "_NOZZLE_CONTACT_TEMP", "_TWIST_STATE",
|
||||||
|
"_GUARD_ON", "BLOBIFIER_CLEAN")
|
||||||
if "gcode_macro " + m not in objects]
|
if "gcode_macro " + m not in objects]
|
||||||
missing += [s for s in ["beacon"] + (["bdp_touch"] * (mode == "verify"))
|
missing += [s for s in ["beacon"] + (["bdp_touch"] * (mode == "verify"))
|
||||||
if s not in settings]
|
if s not in settings]
|
||||||
@@ -287,6 +288,13 @@ def run_points(p, mode, path):
|
|||||||
p.gcode("_NOZZLE_CONTACT_TEMP WAIT=1")
|
p.gcode("_NOZZLE_CONTACT_TEMP WAIT=1")
|
||||||
p.gcode("HOME")
|
p.gcode("HOME")
|
||||||
p.gcode("QUAD_GANTRY_LEVEL")
|
p.gcode("QUAD_GANTRY_LEVEL")
|
||||||
|
# As in PRINT_START. Plastic left on the nozzle sets the contact Z too high
|
||||||
|
# and squeezes away during the run: the touches then sink by ~0.004 mm per
|
||||||
|
# point (2026-11-04). QGL moved Z, so home again before the brush takes the
|
||||||
|
# nozzle below Z0. The bristles press on the nozzle: guard in log mode.
|
||||||
|
p.gcode("M117 Twist %s: cleaning the nozzle" % mode)
|
||||||
|
p.gcode("G28 Z")
|
||||||
|
p.gcode("_GUARD_ON PHASE=brush MODE=log\nBLOBIFIER_CLEAN\n_GUARD_OFF")
|
||||||
p.gcode("G28 Z METHOD=CONTACT CALIBRATE=1")
|
p.gcode("G28 Z METHOD=CONTACT CALIBRATE=1")
|
||||||
p.gcode("G90")
|
p.gcode("G90")
|
||||||
p.say("%d points, %d passes. The nozzle will touch the bed at each one."
|
p.say("%d points, %d passes. The nozzle will touch the bed at each one."
|
||||||
|
|||||||
Reference in new issue
Block a user