mirror of https://github.com/Desuuuu/klipper.git
probe: Add support for configuring lift_speed
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
e3dde19932
commit
c36fe76d69
|
@ -569,6 +569,10 @@
|
||||||
#sample_retract_dist: 2.0
|
#sample_retract_dist: 2.0
|
||||||
# The distance (in mm) to lift the toolhead between each sample (if
|
# The distance (in mm) to lift the toolhead between each sample (if
|
||||||
# sampling more than once). The default is 2mm.
|
# sampling more than once). The default is 2mm.
|
||||||
|
#lift_speed: 5.0
|
||||||
|
# Speed (in mm/s) of the Z axis when lifting the probe between
|
||||||
|
# samples. The default is to use the same value as the 'speed'
|
||||||
|
# parameter.
|
||||||
#samples_result: average
|
#samples_result: average
|
||||||
# The calculation method when sampling more than once - either
|
# The calculation method when sampling more than once - either
|
||||||
# "median" or "average". The default is average.
|
# "median" or "average". The default is average.
|
||||||
|
|
|
@ -264,7 +264,7 @@ section is enabled:
|
||||||
|
|
||||||
The following commands are available when a "probe" config section is
|
The following commands are available when a "probe" config section is
|
||||||
enabled:
|
enabled:
|
||||||
- `PROBE [PROBE_SPEED=<mm/s>] [SAMPLES=<count>]
|
- `PROBE [PROBE_SPEED=<mm/s>] [LIFT_SPEED=<mm/s>] [SAMPLES=<count>]
|
||||||
[SAMPLE_RETRACT_DIST=<mm>] [SAMPLES_TOLERANCE=<mm>]
|
[SAMPLE_RETRACT_DIST=<mm>] [SAMPLES_TOLERANCE=<mm>]
|
||||||
[SAMPLES_TOLERANCE_RETRIES=<count>]
|
[SAMPLES_TOLERANCE_RETRIES=<count>]
|
||||||
[SAMPLES_RESULT=median|average]`: Move the nozzle downwards until
|
[SAMPLES_RESULT=median|average]`: Move the nozzle downwards until
|
||||||
|
|
|
@ -17,7 +17,8 @@ class PrinterProbe:
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.name = config.get_name()
|
self.name = config.get_name()
|
||||||
self.mcu_probe = mcu_probe
|
self.mcu_probe = mcu_probe
|
||||||
self.speed = config.getfloat('speed', 5.0)
|
self.speed = config.getfloat('speed', 5.0, above=0.)
|
||||||
|
self.lift_speed = config.getfloat('lift_speed', self.speed, above=0.)
|
||||||
self.x_offset = config.getfloat('x_offset', 0.)
|
self.x_offset = config.getfloat('x_offset', 0.)
|
||||||
self.y_offset = config.getfloat('y_offset', 0.)
|
self.y_offset = config.getfloat('y_offset', 0.)
|
||||||
self.z_offset = config.getfloat('z_offset')
|
self.z_offset = config.getfloat('z_offset')
|
||||||
|
@ -58,6 +59,11 @@ class PrinterProbe:
|
||||||
if pin_params['invert'] or pin_params['pullup']:
|
if pin_params['invert'] or pin_params['pullup']:
|
||||||
raise pins.error("Can not pullup/invert probe virtual endstop")
|
raise pins.error("Can not pullup/invert probe virtual endstop")
|
||||||
return self.mcu_probe
|
return self.mcu_probe
|
||||||
|
def get_lift_speed(self, params=None):
|
||||||
|
if params is not None:
|
||||||
|
return self.gcode.get_float("LIFT_SPEED", params,
|
||||||
|
self.lift_speed, above=0.)
|
||||||
|
return self.lift_speed
|
||||||
def get_offsets(self):
|
def get_offsets(self):
|
||||||
return self.x_offset, self.y_offset, self.z_offset
|
return self.x_offset, self.y_offset, self.z_offset
|
||||||
def _probe(self, speed):
|
def _probe(self, speed):
|
||||||
|
@ -103,6 +109,7 @@ class PrinterProbe:
|
||||||
def run_probe(self, params={}):
|
def run_probe(self, params={}):
|
||||||
speed = self.gcode.get_float(
|
speed = self.gcode.get_float(
|
||||||
"PROBE_SPEED", params, self.speed, above=0.)
|
"PROBE_SPEED", params, self.speed, above=0.)
|
||||||
|
lift_speed = self.get_lift_speed(params)
|
||||||
sample_count = self.gcode.get_int(
|
sample_count = self.gcode.get_int(
|
||||||
"SAMPLES", params, self.sample_count, minval=1)
|
"SAMPLES", params, self.sample_count, minval=1)
|
||||||
sample_retract_dist = self.gcode.get_float(
|
sample_retract_dist = self.gcode.get_float(
|
||||||
|
@ -132,7 +139,7 @@ class PrinterProbe:
|
||||||
# Retract
|
# Retract
|
||||||
if len(positions) < sample_count:
|
if len(positions) < sample_count:
|
||||||
liftpos = [None, None, pos[2] + sample_retract_dist]
|
liftpos = [None, None, pos[2] + sample_retract_dist]
|
||||||
self._move(liftpos, speed)
|
self._move(liftpos, lift_speed)
|
||||||
# Calculate and return result
|
# Calculate and return result
|
||||||
if samples_result == 'median':
|
if samples_result == 'median':
|
||||||
return self._calc_median(positions)
|
return self._calc_median(positions)
|
||||||
|
@ -150,17 +157,20 @@ class PrinterProbe:
|
||||||
"probe: %s" % (["open", "TRIGGERED"][not not res],))
|
"probe: %s" % (["open", "TRIGGERED"][not not res],))
|
||||||
cmd_PROBE_ACCURACY_help = "Probe Z-height accuracy at current XY position"
|
cmd_PROBE_ACCURACY_help = "Probe Z-height accuracy at current XY position"
|
||||||
def cmd_PROBE_ACCURACY(self, params):
|
def cmd_PROBE_ACCURACY(self, params):
|
||||||
speed = self.gcode.get_float(
|
speed = self.gcode.get_float("PROBE_SPEED", params,
|
||||||
"PROBE_SPEED", params, self.speed, above=0.)
|
self.speed, above=0.)
|
||||||
|
lift_speed = self.get_lift_speed(params)
|
||||||
sample_count = self.gcode.get_int("SAMPLES", params, 10, minval=1)
|
sample_count = self.gcode.get_int("SAMPLES", params, 10, minval=1)
|
||||||
sample_retract_dist = self.gcode.get_float(
|
sample_retract_dist = self.gcode.get_float(
|
||||||
"SAMPLE_RETRACT_DIST", params, self.sample_retract_dist, above=0.)
|
"SAMPLE_RETRACT_DIST", params, self.sample_retract_dist, above=0.)
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
pos = toolhead.get_position()
|
pos = toolhead.get_position()
|
||||||
self.gcode.respond_info("PROBE_ACCURACY at X:%.3f Y:%.3f Z:%.3f"
|
self.gcode.respond_info("PROBE_ACCURACY at X:%.3f Y:%.3f Z:%.3f"
|
||||||
" (samples=%d retract=%.3f speed=%.1f\n"
|
" (samples=%d retract=%.3f"
|
||||||
|
" speed=%.1f lift_speed=%.1f)\n"
|
||||||
% (pos[0], pos[1], pos[2],
|
% (pos[0], pos[1], pos[2],
|
||||||
sample_count, sample_retract_dist, speed))
|
sample_count, sample_retract_dist,
|
||||||
|
speed, lift_speed))
|
||||||
# Probe bed sample_count times
|
# Probe bed sample_count times
|
||||||
positions = []
|
positions = []
|
||||||
while len(positions) < sample_count:
|
while len(positions) < sample_count:
|
||||||
|
@ -169,7 +179,7 @@ class PrinterProbe:
|
||||||
positions.append(pos)
|
positions.append(pos)
|
||||||
# Retract
|
# Retract
|
||||||
liftpos = [None, None, pos[2] + sample_retract_dist]
|
liftpos = [None, None, pos[2] + sample_retract_dist]
|
||||||
self._move(liftpos, speed)
|
self._move(liftpos, lift_speed)
|
||||||
# Calculate maximum, minimum and average values
|
# Calculate maximum, minimum and average values
|
||||||
max_value = max([p[2] for p in positions])
|
max_value = max([p[2] for p in positions])
|
||||||
min_value = min([p[2] for p in positions])
|
min_value = min([p[2] for p in positions])
|
||||||
|
@ -200,11 +210,12 @@ class PrinterProbe:
|
||||||
def cmd_PROBE_CALIBRATE(self, params):
|
def cmd_PROBE_CALIBRATE(self, params):
|
||||||
manual_probe.verify_no_manual_probe(self.printer)
|
manual_probe.verify_no_manual_probe(self.printer)
|
||||||
# Perform initial probe
|
# Perform initial probe
|
||||||
|
lift_speed = self.get_lift_speed(params)
|
||||||
curpos = self.run_probe(params)
|
curpos = self.run_probe(params)
|
||||||
# Move away from the bed
|
# Move away from the bed
|
||||||
self.probe_calibrate_z = curpos[2]
|
self.probe_calibrate_z = curpos[2]
|
||||||
curpos[2] += 5.
|
curpos[2] += 5.
|
||||||
self._move(curpos, self.speed)
|
self._move(curpos, lift_speed)
|
||||||
# Move the nozzle over the probe point
|
# Move the nozzle over the probe point
|
||||||
curpos[0] += self.x_offset
|
curpos[0] += self.x_offset
|
||||||
curpos[1] += self.y_offset
|
curpos[1] += self.y_offset
|
||||||
|
@ -336,7 +347,7 @@ class ProbePointsHelper:
|
||||||
self._manual_probe_start()
|
self._manual_probe_start()
|
||||||
return
|
return
|
||||||
# Perform automatic probing
|
# Perform automatic probing
|
||||||
self.lift_speed = min(self.speed, probe.speed)
|
self.lift_speed = probe.get_lift_speed(params)
|
||||||
self.probe_offsets = probe.get_offsets()
|
self.probe_offsets = probe.get_offsets()
|
||||||
if self.horizontal_move_z < self.probe_offsets[2]:
|
if self.horizontal_move_z < self.probe_offsets[2]:
|
||||||
raise self.gcode.error("horizontal_move_z can't be less than"
|
raise self.gcode.error("horizontal_move_z can't be less than"
|
||||||
|
|
Loading…
Reference in New Issue