Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion klippy/extras/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def calc_probe_z_average(positions, method='average'):

# Helper to implement common probing commands
class ProbeCommandHelper:
def __init__(self, config, probe, query_endstop=None):
def __init__(self, config, probe, query_endstop=None,
replace_z_offset=False):
self.printer = config.get_printer()
self.probe = probe
self.query_endstop = query_endstop
Expand All @@ -57,6 +58,8 @@ def __init__(self, config, probe, query_endstop=None):
# Other commands
gcode.register_command('PROBE_ACCURACY', self.cmd_PROBE_ACCURACY,
desc=self.cmd_PROBE_ACCURACY_help)
if replace_z_offset:
return
gcode.register_command('Z_OFFSET_APPLY_PROBE',
self.cmd_Z_OFFSET_APPLY_PROBE,
desc=self.cmd_Z_OFFSET_APPLY_PROBE_help)
Expand Down
28 changes: 26 additions & 2 deletions klippy/extras/probe_eddy_current.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def __init__(self, config):
# Current calibration data
self.cal_freqs = []
self.cal_zpos = []
self.cal_z_offset = config.getfloat('calibrate_z_offset', .0,
minval=-1.0, maxval=1.0)
cal = config.get('calibrate', None)
if cal is not None:
cal = [list(map(float, d.strip().split(':', 1)))
Expand All @@ -31,12 +33,15 @@ def __init__(self, config):
gcode.register_mux_command("PROBE_EDDY_CURRENT_CALIBRATE", "CHIP",
cname, self.cmd_EDDY_CALIBRATE,
desc=self.cmd_EDDY_CALIBRATE_help)
gcode.register_command('Z_OFFSET_APPLY_PROBE',
self.cmd_Z_OFFSET_APPLY_PROBE,
desc=self.cmd_Z_OFFSET_APPLY_PROBE_help)
def is_calibrated(self):
return len(self.cal_freqs) > 2
def load_calibration(self, cal):
cal = sorted([(c[1], c[0]) for c in cal])
self.cal_freqs = [c[0] for c in cal]
self.cal_zpos = [c[1] for c in cal]
self.cal_zpos = [c[1] + self.cal_z_offset for c in cal]
def apply_calibration(self, samples):
cur_temp = self.drift_comp.get_temperature()
for i, (samp_time, freq, dummy_z) in enumerate(samples):
Expand Down Expand Up @@ -188,12 +193,30 @@ def post_manual_probe(self, kin_pos):
cal_contents.pop()
configfile = self.printer.lookup_object('configfile')
configfile.set(self.name, 'calibrate', ''.join(cal_contents))
configfile.set(self.name, 'calibrate_z_offset', "%.3f" %
(0.,))
cmd_EDDY_CALIBRATE_help = "Calibrate eddy current probe"
def cmd_EDDY_CALIBRATE(self, gcmd):
self.probe_speed = gcmd.get_float("PROBE_SPEED", 5., above=0.)
# Start manual probe
manual_probe.ManualProbeHelper(self.printer, gcmd,
self.post_manual_probe)
cmd_Z_OFFSET_APPLY_PROBE_help = "Adjust the probe's z_offset"
def cmd_Z_OFFSET_APPLY_PROBE(self, gcmd):
gcode_move = self.printer.lookup_object("gcode_move")
offset = gcode_move.get_status()['homing_origin'].z
if offset == 0:
gcmd.respond_info("Nothing to do: Z Offset is 0")
return
new_calibrate = self.cal_z_offset - offset
gcmd.respond_info(
"%s: calibrate_z_offset: %.3f\n"
"The SAVE_CONFIG command will update the printer config file\n"
"with the above and restart the printer."
% (self.name, new_calibrate))
configfile = self.printer.lookup_object('configfile')
configfile.set(self.name, 'calibrate_z_offset', "%.3f" %
(new_calibrate,))
def register_drift_compensation(self, comp):
self.drift_comp = comp

Expand Down Expand Up @@ -457,7 +480,8 @@ def __init__(self, config):
self.param_helper = probe.ProbeParameterHelper(config)
self.eddy_descend = EddyDescend(
config, self.sensor_helper, self.calibration, self.param_helper)
self.cmd_helper = probe.ProbeCommandHelper(config, self)
self.cmd_helper = probe.ProbeCommandHelper(config, self,
replace_z_offset=True)
self.probe_offsets = probe.ProbeOffsetsHelper(config)
self.probe_session = probe.ProbeSessionHelper(
config, self.param_helper, self.eddy_descend.start_probe_session)
Expand Down