aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/probe.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-07-10 15:11:11 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-07-10 15:21:09 -0400
commit364c22fe8472cac712b6ada06a0a967df98e636a (patch)
tree691aabb7042093845996bd6bc84ef12e718a7e0a /klippy/extras/probe.py
parenta477c50592d698b8b7b7c6290e2d11e551a242a8 (diff)
downloadkutter-364c22fe8472cac712b6ada06a0a967df98e636a.tar.gz
kutter-364c22fe8472cac712b6ada06a0a967df98e636a.tar.xz
kutter-364c22fe8472cac712b6ada06a0a967df98e636a.zip
probe: Rework the PROBE_ACCURACY command parameters
Don't default to a Z location of 10, as that could cause damage if the probe's z_offset is greater than 10. Instead, use the "retract distance" method that is used for normal multi-sample probing. Update the PROBE_ACCURACY command parameter names to use the same parameter names as the PROBE command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/probe.py')
-rw-r--r--klippy/extras/probe.py42
1 files changed, 18 insertions, 24 deletions
diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py
index a6c71428..a13d4098 100644
--- a/klippy/extras/probe.py
+++ b/klippy/extras/probe.py
@@ -150,32 +150,26 @@ class PrinterProbe:
"probe: %s" % (["open", "TRIGGERED"][not not res],))
cmd_PROBE_ACCURACY_help = "Probe Z-height accuracy at current XY position"
def cmd_PROBE_ACCURACY(self, params):
+ speed = self.gcode.get_float(
+ "PROBE_SPEED", params, self.speed, above=0.)
+ sample_count = self.gcode.get_int("SAMPLES", params, 10, minval=1)
+ sample_retract_dist = self.gcode.get_float(
+ "SAMPLE_RETRACT_DIST", params, self.sample_retract_dist, above=0.)
toolhead = self.printer.lookup_object('toolhead')
pos = toolhead.get_position()
- number_of_reads = self.gcode.get_int('REPEAT', params, default=10,
- minval=4, maxval=50)
- speed = self.gcode.get_int('SPEED', params, default=self.speed,
- minval=1, maxval=30)
- z_start_position = self.gcode.get_float(
- 'Z', params, default=10., minval=self.z_offset, maxval=70.)
- x_start_position = self.gcode.get_float('X', params, default=pos[0])
- y_start_position = self.gcode.get_float('Y', params, default=pos[1])
- start_pos = [x_start_position, y_start_position, z_start_position]
- self.gcode.respond_info("probe accuracy: at X:%.3f Y:%.3f Z:%.3f\n"
- " "
- "and read %d times with speed of %d mm/s" % (
- x_start_position, y_start_position,
- z_start_position, number_of_reads, speed))
- # Probe bed "number_of_reads" times
+ self.gcode.respond_info("PROBE_ACCURACY at X:%.3f Y:%.3f Z:%.3f"
+ " (samples=%d retract=%.3f speed=%.1f\n"
+ % (pos[0], pos[1], pos[2],
+ sample_count, sample_retract_dist, speed))
+ # Probe bed sample_count times
positions = []
- for i in range(number_of_reads):
- # Move Z to start reading position
- self._move(start_pos, speed)
- # Probe
+ while len(positions) < sample_count:
+ # Probe position
pos = self._probe(speed)
positions.append(pos)
- # Move Z to start reading position
- self._move(start_pos, speed)
+ # Retract
+ liftpos = [None, None, pos[2] + sample_retract_dist]
+ self._move(liftpos, speed)
# Calculate maximum, minimum and average values
max_value = max([p[2] for p in positions])
min_value = min([p[2] for p in positions])
@@ -183,9 +177,9 @@ class PrinterProbe:
median = self._calc_median(positions)[2]
# calculate the standard deviation
deviation_sum = 0
- for i in range(number_of_reads):
- deviation_sum += pow(positions[i][2] - avg_value, 2)
- sigma = (deviation_sum / number_of_reads) ** 0.5
+ for i in range(len(positions)):
+ deviation_sum += pow(positions[i][2] - avg_value, 2.)
+ sigma = (deviation_sum / len(positions)) ** 0.5
# Show information
self.gcode.respond_info(
"probe accuracy results: maximum %.6f, minimum %.6f, "