From 8be004401e929d5c4e750880f257ab8a7c5a80be Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 19 Jan 2026 21:53:27 -0500 Subject: [PATCH] probe_eddy_current: Implement regression test case Update the code to support simple regression test cases. Signed-off-by: Kevin O'Connor --- klippy/extras/ldc1612.py | 7 +-- klippy/extras/probe_eddy_current.py | 11 ++-- test/klippy/eddy.cfg | 84 +++++++++++++++++++++++++++++ test/klippy/eddy.test | 30 +++++++++++ 4 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 test/klippy/eddy.cfg create mode 100644 test/klippy/eddy.test diff --git a/klippy/extras/ldc1612.py b/klippy/extras/ldc1612.py index 29c8cad2d..db539c650 100644 --- a/klippy/extras/ldc1612.py +++ b/klippy/extras/ldc1612.py @@ -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" diff --git a/klippy/extras/probe_eddy_current.py b/klippy/extras/probe_eddy_current.py index c7b415d02..b833f9ab9 100644 --- a/klippy/extras/probe_eddy_current.py +++ b/klippy/extras/probe_eddy_current.py @@ -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 diff --git a/test/klippy/eddy.cfg b/test/klippy/eddy.cfg new file mode 100644 index 000000000..11946ebe4 --- /dev/null +++ b/test/klippy/eddy.cfg @@ -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 diff --git a/test/klippy/eddy.test b/test/klippy/eddy.test new file mode 100644 index 000000000..5251be122 --- /dev/null +++ b/test/klippy/eddy.test @@ -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