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>
This commit is contained in:
Kevin O'Connor 2026-01-19 21:53:27 -05:00
parent 57b94520de
commit 8be004401e
4 changed files with 126 additions and 6 deletions

View file

@ -138,6 +138,8 @@ class LDC1612:
def get_mcu(self):
return self.i2c.get_mcu()
def read_reg(self, reg):
if self.mcu.is_fileoutput():
return 0
params = self.i2c.i2c_read([reg], 2)
response = bytearray(params['response'])
return (response[0] << 8) | response[1]
@ -155,8 +157,6 @@ class LDC1612:
[self.oid, clock, tfreq, trsync_oid, hit_reason, err_reason])
def clear_home(self):
self.ldc1612_setup_home_cmd.send([self.oid, 0, 0, 0, 0, 0])
if self.mcu.is_fileoutput():
return 0.
params = self.query_ldc1612_home_state_cmd.send([self.oid])
tclock = self.mcu.clock32_to_clock64(params['trigger_clock'])
return self.mcu.clock_to_print_time(tclock)
@ -200,7 +200,8 @@ class LDC1612:
# noise or wrong signal as a correctly initialized device
manuf_id = self.read_reg(REG_MANUFACTURER_ID)
dev_id = self.read_reg(REG_DEVICE_ID)
if manuf_id != LDC1612_MANUF_ID or dev_id != LDC1612_DEV_ID:
if ((manuf_id != LDC1612_MANUF_ID or dev_id != LDC1612_DEV_ID)
and not self.mcu.is_fileoutput()):
raise self.printer.command_error(
"Invalid ldc1612 id (got %x,%x vs %x,%x).\n"
"This is generally indicative of connection problems\n"

View file

@ -313,6 +313,13 @@ class EddyGatherSamples:
if est_print_time > end_time + 1.0:
raise self._printer.command_error(
"probe_eddy_current sensor outage")
if mcu.is_fileoutput():
# In debugging mode
if pos_time is not None:
toolhead_pos = self._lookup_toolhead_pos(pos_time)
self._probe_results.append((toolhead_pos[2], toolhead_pos))
self._probe_times.pop(0)
continue
reactor.pause(systime + 0.010)
def _pull_freq(self, start_time, end_time):
# Find average sensor frequency between time range
@ -421,7 +428,7 @@ class EddyDescend:
if res != mcu.MCU_trsync.REASON_ENDSTOP_HIT:
return 0.
if self._mcu.is_fileoutput():
return home_end_time
trigger_time = home_end_time
self._trigger_time = trigger_time
return trigger_time
# Probe session interface
@ -437,8 +444,6 @@ class EddyDescend:
# Perform probing move
phoming = self._printer.lookup_object('homing')
trig_pos = phoming.probing_move(self, pos, speed)
if not self._trigger_time:
return trig_pos
# Extract samples
start_time = self._trigger_time + 0.050
end_time = start_time + 0.100

84
test/klippy/eddy.cfg Normal file
View file

@ -0,0 +1,84 @@
# Test config for probe_eddy_current
[stepper_x]
step_pin: PF0
dir_pin: PF1
enable_pin: !PD7
microsteps: 16
rotation_distance: 40
endstop_pin: ^PE5
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_y]
step_pin: PF6
dir_pin: !PF7
enable_pin: !PF2
microsteps: 16
rotation_distance: 40
endstop_pin: ^PJ1
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_z]
step_pin: PL3
dir_pin: PL1
enable_pin: !PK0
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
position_max: 200
[extruder]
step_pin: PA4
dir_pin: PA6
enable_pin: !PA2
microsteps: 16
rotation_distance: 33.5
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PB4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK5
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 250
[heater_bed]
heater_pin: PH5
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK6
control: watermark
min_temp: 0
max_temp: 130
[probe_eddy_current eddy]
z_offset: 0.4
x_offset: -5
y_offset: -4
sensor_type: ldc1612
speed: 10.0
intb_pin: PK7
[bed_mesh]
mesh_min: 10,10
mesh_max: 180,180
[mcu]
serial: /dev/ttyACM0
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
# Dummy calibration data
[probe_eddy_current eddy]
calibrate =
0.050000:3300000.000,1.000000:3200000.000,5.000000:3000000.000

30
test/klippy/eddy.test Normal file
View file

@ -0,0 +1,30 @@
# Test case for probe_eddy_current support
CONFIG eddy.cfg
DICTIONARY atmega2560.dict
# Start by homing the printer.
G28
G1 F6000
# Z / X / Y moves
G1 Z1
G1 X1
G1 Y1
# Run bed_mesh_calibrate
BED_MESH_CALIBRATE
G1 Z2
BED_MESH_CALIBRATE METHOD=scan
G1 Z2
BED_MESH_CALIBRATE METHOD=rapid_scan
# Move again
G1 Z5 X0 Y0
# Do regular probe
PROBE
# Move again
G1 Z9