Files
firmware/docs/notes/60-background.md
Oleksandr ShyshatskyiandClaude Opus 5 42d876d5eb The auto-PA sweep is host code; only the per-line verdict is in the eBoard
firmwareExe runs a real PA calibration at print start, inside the nozzle clean.
CommMgr::paTestMgr @0x791640 prints one slow-fast-slow line per candidate at
Y = 50 + 5*i for seven fixed PA values, asks the eBoard to score each line, keeps
the smallest that scores 9, repeats until three sweeps have produced a winner and
averages those three. All of that is host code and is recovered here in full.

Only the verdict crosses into the closed toolhead MCU, over two commands that
pa_adjust.py already forwards -- and pa_adjust.py is in our tree byte-identical
to FlashForge's, with [pa_adjust] already in printer.base.cfg. So PA_ACTION and
PA_GET should answer on a Reforge machine today; that is step one of the port.

This supersedes "sensor unknown" in 60-background.md and "callable, not
reproducible" in 25-app-vs-klipper-ownership.md. What stays unknown is narrower:
which sensor the eBoard samples, what ACTION=11 and PC=666 select, and what the
non-9 verdicts mean.

Two findings that shape the port. PA_GET only respond_info()s its value, so the
sweep cannot be a G-code macro -- it needs an extra that queries the eBoard
directly. And PA_ACTION is an immediate MCU command, so FlashForge never
synchronises the measurement window with motion; the port must copy that timing
rather than improve it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kw2rehvQJ7LSc28hPikfqk
2026-08-30 23:03:37 +03:00

56 lines
3.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Background: filament system, calibration, persistent state
Context recovered from the binary. Written when none of it was ported and the stock
touchscreen still handled it; both halves of that have since changed. The runout
handling, filament load/unload and the offset calibration below ARE ported now
(`ff-runout.cfg`, `ff-filament.cfg`, `ff_tool_offset.py`), and there is no stock
touchscreen on a modded printer — `firmwareExe` is replaced and HelixScreen is the only
UI. What is genuinely still unported is marked as such per item. Kept as reference.
## Filament system
- 4 channels; per-channel presence (`fd_ex0..3`) and motion/clog (`fm_ex0..3`)
sensors; `manual_stepper gear_stepper` is the tool lock motor, not a feed hub.
Errors: E0162 runout, E0163 clog.
- **Runout auto-swap** (the flagship app feature): on runout mid-print the app pauses,
finds another channel with the same material/color, switches channel (possibly a
head change), refeeds, purges, restores position and resumes. All app-side.
- Load ≈ heat, `G92 E0`, `G1 E150`/`G1 E145` long feed; unload ≈ feed assist then
retract ramp `G1 E-50 F150` … tip forming.
- Pre-print screen parses 3MF per-tool type/color and lets the user remap slicer
tools to physical channels (`SDCARD_SET_GCODE_EX_USED_BASE/CHANGED`).
- Drying box: separate MCU on `/dev/ttyS3`, own textual protocol (`DryingService`),
2 chambers with temp/humidity control. Not Klipper at all.
## Calibration flows (all driven by the app)
- **Bed leveling**: eddy probe, 10×10 bicubic; factory mesh saved as profile
`MESH_DATA`, per-print mesh as `default`; `SAVE_CONFIG` after.
- **Nozzle offset calibration** (`testEddyExtruderOffsetForward*`): heats and cleans
each nozzle, probes the fixed under-bed sensor with the eddy, then touches it with
each nozzle; circular probing + least-squares circle fit for XY; results →
`tN_offset_x/y/z`, `z_station_pos` in extruder.json. Reimplemented in Klipper as
`TOOL_LOCATE_SENSOR` / `TOOL_CALIBRATE_TOOL_OFFSET`
(`45-tool-offset-calibration.md`,
`46-offset-calibration-recovered.md`); the JSON is imported by
`FF_IMPORT_FIRMWARE_CONFIG` — once per install, run for you at the first boot
by `bin/ff-startup.py` — and is never a runtime source.
- **Input shaper**: `STEPPER_RESONANCE_FACTORY_CALIBRATE` (fork) / `SHAPER_CALIBRATE`.
- **Auto PA**: seven PA candidates, one slow-fast-slow line each, scored by the closed
eBoard MCU via `PA_ACTION`/`PA_GET`; the mean of three passing sweeps is stored as a
per-tool table via `SET_PA_ADVANCE`. Host side fully recovered — see
[`51-pa-calibration-recovered.md`](51-pa-calibration-recovered.md).
## Persistent state map (/usr/data/firmwareRes/config/)
- `extruder.json`, `test.json`, `zoffset.json` — motion-critical, see
`40-offsets.md`. **Back these up.**
- `filament.json` — per-channel `exN_filament_type/color/diameter`.
- `general.json`/`print.json` — UI toggles: `levelOpen` (per-print leveling),
`openDoorPause`, `filamentDetected`, `aiCheck`, camera, LED…
- `total.json` — maintenance counters/service reminders.
- `levelData` — 10×10 mesh copy the UI renders.
Also worth backing up before any experiment: `/usr/data/config/printer.cfg` (+
`printer.base/macro/motor/override.cfg`) and the whole `/usr/prog/klipper/` fork tree.