Commit graph

6113 commits

Author SHA1 Message Date
Kevin O'Connor
1fe9fb3ad4 trigger_analog: Don't report trigger time as the peak time
Some checks failed
Build test / build (push) Waiting to run
klipper3d deploy / deploy (push) Has been cancelled
There are some rare corner cases where reporting the peak time could
cause hard to debug issues (for example, the peak time could
theoretically be a significant time prior to the actual trigger time,
which could possibly cause unexpected clock rollover issues).  Now
that the host code does not utilize the peak time for "tap" detection,
it can be removed from the mcu code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-29 20:57:55 -05:00
Timofey Titovets
0795fb0141 probe_eddy_current: analyze tap data
To cancel out any lag, filter data on the host
Then to avoid derivatives lag,
compute central difference.

Assume that peak velocity is always the moment
right before collision happens.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-29 20:57:55 -05:00
Timofey Titovets
5fb9902dda sos_filter: define filtfilt call
To implement host-side analysis of tap data,
we need a way to apply the same filtering as on the mcu.
As bonus, it cancels the induced signal delay.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-29 20:57:55 -05:00
Timofey Titovets
dfe6d3f066 docs: describe calibration output
Add a hint about the connection between the calibration output
and tap threshold.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-01-29 20:57:55 -05:00
Timofey Titovets
a03eed7115 docs: describe tap calibration routine
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-01-29 20:57:55 -05:00
Kevin O'Connor
5c23f9296a probe_eddy_current: implement tap support
Use SOS filters + derivative filter to generate dF/dT on mcu.
Feed that to the MCU's trigger_analog peak detection.
Interpret peak time as a tap event

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-01-29 20:57:55 -05:00
Kevin O'Connor
08f4b65c7c probe_eddy_current: Make EddyScanningProbe a long lived class
Create the class at the start of PrinterEddyProbe and call it as
needed.  This makes the class life-cycle similar to EddyDescend.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-29 20:57:55 -05:00
Kevin O'Connor
8922481034 probe_eddy_current: Create trigger_analog instance in main PrinterEddyProbe
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-29 20:57:55 -05:00
Kevin O'Connor
9957546ae0 probe_eddy_current: Rework EddyGatherSamples()
Rework the internal EddyGatherSamples() class with a goal of making it
easier to add tap analysis in the future.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-29 20:57:55 -05:00
Timofey Titovets
7f822f3a5c
probe: fix sign inversion in probe calibrate (#7178)
Some checks failed
Build test / build (push) Has been cancelled
Commit 2a1027ce inadvertently flipped the signs in probe_calibrate_finalize().

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-01-26 19:03:55 -05:00
Kevin O'Connor
4d9d57c0bd test: Add a bed_mesh test case
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-26 18:40:48 -05:00
Kevin O'Connor
7e394d6dd7 bed_mesh: Fix tuple vs list error
Commit 2e0c2262e incorrectly changed the internal fpt variable from a
list to a tuple.

Reported by @nefelim4ag.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-26 18:30:18 -05:00
Kevin O'Connor
c9d904aa9d trigger_analog: Add initial support for detecting "tap" events
Some checks failed
Build test / build (push) Has been cancelled
klipper3d deploy / deploy (push) Has been cancelled
Add a new "diff_peak_gt" trigger type.  This will be useful with
detecting ldc1612 "tap" events.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:55:39 -05:00
Kevin O'Connor
9a97ade74f sos_filter: Implement auto_offset feature
Add a setting that will enable the mcu sos_filter code to
automatically set an offset using the first read measurement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:55:39 -05:00
Kevin O'Connor
30720d29b5 trigger_analog: Avoid storing value_frac_bits in MCU_SosFilter
It is simpler for callers to convert values to their desired format.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
36b9898117 trigger_analog: Set the MCU_SosFilter coeff_frac_bits in set_filter_design()
This parameter is rarely changed and is directly tied to the
coefficients in the filter "design".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
16755481cc trigger_analog: Support scaling the filter's initial start state
Add a new set_start_state() method to MCU_SosFilter that can arrange
for the filter to better handle a non-zero initial starting state.

Also, this removes the previous 1.0 gram initial start state for load
cells as it tares the initial value.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
58cc059e31 sensor_ldc1612: Convert homing code to use trigger_analog system
Remove the homing code from sensor_ldc1612.c and utilize the generic
homing support found in trigger_analog.c .

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
147022dee2 trigger_analog: Update to support generic trigger types
Rework the trigger_analog code to support different "trigger"
conditions.  This merges in features of ldc1612.c into
trigger_analog.c, such as error code reporting in the MCU.  This is in
preparation for using trigger_analog with ldc1612.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
73a6184407 trigger_analog: Check if trigger_analog is allocated in trigger_analog_update()
Check if the trigger_analog struct has been allocated in
trigger_analog_update() itself.  This makes the code easier to use in
the sensor code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
87c8b505a7 trigger_analog: Attach trigger_analog to sensor during initialization
Avoid setting up a "connect" callback - just register the association
using mcu.add_config_cmd() .

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
5bd791d96e hx71x: Make sure to use the same cmd_queue for all commands
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
f9b1b9c1b5 trigger_analog: Create trigger_dispatch within MCU_trigger_analog
Don't require callers of MCU_trigger_analog to create the
mcu.TriggerDispatch() instance - instead, create it within the
MCU_trigger_analog() class.

Also, make it easier to use MCU_trigger_analog without an
MCU_SosFilter - the MCU_trigger_analog can automatically create an
empty filter if needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
402303aa22 trigger_analog: New trigger_analog.py file
Rename sos_filter.py to trigger_analog.py and copy MCU_trigger_analog
class from load_cell_probe.py to this new file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
165fe1730d load_cell_probe: Move phoming.probing_move() interface to MCU_trigger_analog
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
067539e0a3 load_cell_probe: Move set_endstop_range() code to LoadCellProbingMove
Move this load cell specific code from MCU_trigger_analog class to
LoadCellProbingMove class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
7ec82baca3 sos_filter: Move offset/scale support from trigger_analog.c to sos_filter.c
Support offsetting and scaling the initial raw value prior to
processing in the sos_filter.

Remove that support from trigger_analog.c .

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
109f13c797 sos_filter: Consistently use "frac_bits" instead of "int_bits"
Internally describe the Qx.y format using the number of fractional
bits.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
3b5045ed9e sos_filter: Handle fixed point conversion within MCU_SosFilter
Merge the logic from the FixedPointSosFilter class into the
MCU_SosFilter class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
6413399784 sos_filter: No need to support "is_init" in MCU_SosFilter
Rename the SosFilter class to MCU_SosFilter.  Automatically reload the
filter coefficients on a reset_filter() call, so there is no need to
support loading of the filter at init time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
40242b2e33 sos_filter: Propagate overflow errors instead of a shutdown
Pass an overflow error back to the caller instead of invoking a
shutdown().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
fd195ff4ce sos_filter: Remove unnecessary "const" declarations
A "const" declaration on a local integer does not do anything in C
code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
667c57e444 sos_filter: Remove unnecessary is_active flag
It's reasonable to deactivate the filter by setting n_sections=0, and
this makes the code a little easier to use when the host doesn't
actually need any filtering.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
ec08ff5a1e trigger_analog: Rename load_cell_probe.c to trigger_analog.c
Rename the mcu based load_cell_probe code to trigger_analog.  This is
a rename of the C code files, struct names, and command names.  There
is no change in behavior (other than naming) with this change.

This is in preparation for using the load_cell_probe functionality
with other sensors.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:49:01 -05:00
Kevin O'Connor
2956c1e223 probe: Support passing gcmd to probe.get_offsets()
Make it possible for the probe's get_offsets() code to depend on the
parameters of the probe request.  This is in preparation for eddy
"tap" support.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-25 12:47:29 -05:00
Kevin O'Connor
a353efa5b6 probe: Return to start XY position on each attempt in PROBE_ACCURACY
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:13:15 -05:00
Kevin O'Connor
32a5f2b042 probe: Deprecate last_z_result and add new last_probe_position
Deprecate the PROBE command's exported value
`{printer.probe.last_z_result}`.  This value effectively returns the
toolhead Z position when the probe triggers and user's then need to
adjust the result using the probe's configured z_offset.

Introduce a new `{printer.probe.last_probe_position}` as a
replacement.  This replacement has an easier to understand behavior -
it states that the probe hardware estimates that if the toolhead is
commanded to last_probe_position.x, last_probe_position.y and descends
then the tip of the toolhead should first make contact at a Z height
of last_probe_position.z .  That is, the new exported value already
takes into account the probe's configured xyz offsets.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:13:15 -05:00
Kevin O'Connor
2a1027ce41 probe: Convert pull_probed_results() to return ProbeResult
Change the low-level probe code to return ProbeResult tuples from
probe_session.pull_probed_results().  Also update callers to use the
calculated bed_xyz values found in the tuple instead of calculating
them from the probe's xyz offsets.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:13:15 -05:00
Kevin O'Connor
f33c76da22 load_cell_probe: Pass probe_offsets to TapSession()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:13:15 -05:00
Kevin O'Connor
8c2c90b8d6 probe_eddy_current: Pass probe_offsets class to EddyDescend
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:13:15 -05:00
Kevin O'Connor
252fc18c12 probe: Pass probe_offsets to HomingViaProbeHelper() class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:13:15 -05:00
Kevin O'Connor
2e0c2262e7 probe: Convert ProbePointsHelper to use ProbeResult
Change the ProbePointsHelper class to return ProbeResult tuples.
Callers of this class are also updated so that they use the tuple's
bed_xyz parameters instead of manually calculating these values from
the probe xyz offsets.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:13:15 -05:00
Kevin O'Connor
9ccb4d96e9 manual_probe: Report final probe results in new ProbeResult named tuple
Return the manual probe results in a named tuple containing (bed_x,
bed_y, bed_z, test_x, test_y, and test_z) components.  For a manual
probe the test_xyz will always be equal to bed_xyz, but these
components may differ when using automated z probes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:13:15 -05:00
Kevin O'Connor
3c56eb7f6f load_cell_probe: Enhance regression test case
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-21 12:06:27 -05:00
Kevin O'Connor
bb96318725 ci-install: Install scipy/numpy in github regression test case environment
This is in preparation for enhanced load_cell test cases which require
these packages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-20 11:34:21 -05:00
Kevin O'Connor
8be004401e probe_eddy_current: Implement regression test case
Update the code to support simple regression test cases.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-20 11:34:21 -05:00
Kevin O'Connor
57b94520de mcu: Generate a dummy response to query commands when in debugging mode
Previously a querycmd.send() request would silently hang if the code
is run in "file output" mode (that is, it is not communicating with a
real micro-controller).  This behavior makes it hard to implement
regression tests and is generally confusing.

Change the code to respond with a dummy response (typically all zeros
and empty strings) instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-20 11:34:21 -05:00
Kevin O'Connor
1cde5e2018 mcu: Pass conn_helper to CommandWrapper and CommandQueryWrapper
Pass the low-level MCUConnectHelper class to these helper classes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-20 11:34:21 -05:00
Kevin O'Connor
e590bc87d8 spi_flash: Don't import mcu module
Avoid using mcu.CommandQueryWrapper() and mcu.CommandWrapper()
classes.  Instead, implement local variants of these classes.  This
will make it easier to modify the mcu classes without fear of breaking
the spi_flash code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-20 11:34:21 -05:00
Kevin O'Connor
48f0b3cad6 gcode_move: Export more than 4 components in gcode_position status
Some checks failed
Build test / build (push) Has been cancelled
Commit f04895f5 documented that "{printer.gcode_move.gcode_position}"
may contain more than 4 components, however the code was not actually
updated to export that additional information.  (Commit ac6cab91 only
made the change to "homing_origin" and "position".)

Export the information in gcode_position as intended.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-01-11 17:30:28 -05:00