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>
This commit is contained in:
parent
a477c50592
commit
364c22fe84
|
@ -6,6 +6,10 @@ All dates in this document are approximate.
|
||||||
|
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
20190710: The optional parameters of the PROBE_ACCURACY command have
|
||||||
|
changed. It may be necessary to update any macros or scripts that use
|
||||||
|
that command.
|
||||||
|
|
||||||
20190628: All configuration options have been removed from the
|
20190628: All configuration options have been removed from the
|
||||||
[skew_correction] section. Configuration for skew_correction
|
[skew_correction] section. Configuration for skew_correction
|
||||||
is now done via the SET_SKEW gcode. See skew_correction.md
|
is now done via the SET_SKEW gcode. See skew_correction.md
|
||||||
|
|
|
@ -231,10 +231,12 @@ enabled:
|
||||||
for details).
|
for details).
|
||||||
- `QUERY_PROBE`: Report the current status of the probe ("triggered"
|
- `QUERY_PROBE`: Report the current status of the probe ("triggered"
|
||||||
or "open").
|
or "open").
|
||||||
- `PROBE_ACCURACY [REPEAT=<times>] [SPEED=<speed mm/s>] [X=<x pos>]
|
- `PROBE_ACCURACY [PROBE_SPEED=<mm/s>] [SAMPLES=<count>]
|
||||||
[Y=<y pos>] [Z=<z height>]`: Calculate the maximum, minimum, average,
|
[SAMPLE_RETRACT_DIST=<mm>]`: Calculate the maximum, minimum,
|
||||||
median and standard deviation. The default values are: REPEAT=10,
|
average, median, and standard deviation of multiple probe
|
||||||
SPEED=probe config speed, X=current X, Y=current Y and Z=10.
|
samples. By default, 10 SAMPLES are taken. Otherwise the optional
|
||||||
|
parameters default to their equivalent setting in the probe config
|
||||||
|
section.
|
||||||
- `PROBE_CALIBRATE [SPEED=<speed>] [<probe_parameter>=<value>]`: Run a
|
- `PROBE_CALIBRATE [SPEED=<speed>] [<probe_parameter>=<value>]`: Run a
|
||||||
helper script useful for calibrating the probe's z_offset. See the
|
helper script useful for calibrating the probe's z_offset. See the
|
||||||
PROBE command for details on the optional probe parameters. See the
|
PROBE command for details on the optional probe parameters. See the
|
||||||
|
|
|
@ -150,32 +150,26 @@ 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(
|
||||||
|
"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')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
pos = toolhead.get_position()
|
pos = toolhead.get_position()
|
||||||
number_of_reads = self.gcode.get_int('REPEAT', params, default=10,
|
self.gcode.respond_info("PROBE_ACCURACY at X:%.3f Y:%.3f Z:%.3f"
|
||||||
minval=4, maxval=50)
|
" (samples=%d retract=%.3f speed=%.1f\n"
|
||||||
speed = self.gcode.get_int('SPEED', params, default=self.speed,
|
% (pos[0], pos[1], pos[2],
|
||||||
minval=1, maxval=30)
|
sample_count, sample_retract_dist, speed))
|
||||||
z_start_position = self.gcode.get_float(
|
# Probe bed sample_count times
|
||||||
'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
|
|
||||||
positions = []
|
positions = []
|
||||||
for i in range(number_of_reads):
|
while len(positions) < sample_count:
|
||||||
# Move Z to start reading position
|
# Probe position
|
||||||
self._move(start_pos, speed)
|
|
||||||
# Probe
|
|
||||||
pos = self._probe(speed)
|
pos = self._probe(speed)
|
||||||
positions.append(pos)
|
positions.append(pos)
|
||||||
# Move Z to start reading position
|
# Retract
|
||||||
self._move(start_pos, speed)
|
liftpos = [None, None, pos[2] + sample_retract_dist]
|
||||||
|
self._move(liftpos, 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])
|
||||||
|
@ -183,9 +177,9 @@ class PrinterProbe:
|
||||||
median = self._calc_median(positions)[2]
|
median = self._calc_median(positions)[2]
|
||||||
# calculate the standard deviation
|
# calculate the standard deviation
|
||||||
deviation_sum = 0
|
deviation_sum = 0
|
||||||
for i in range(number_of_reads):
|
for i in range(len(positions)):
|
||||||
deviation_sum += pow(positions[i][2] - avg_value, 2)
|
deviation_sum += pow(positions[i][2] - avg_value, 2.)
|
||||||
sigma = (deviation_sum / number_of_reads) ** 0.5
|
sigma = (deviation_sum / len(positions)) ** 0.5
|
||||||
# Show information
|
# Show information
|
||||||
self.gcode.respond_info(
|
self.gcode.respond_info(
|
||||||
"probe accuracy results: maximum %.6f, minimum %.6f, "
|
"probe accuracy results: maximum %.6f, minimum %.6f, "
|
||||||
|
|
Loading…
Reference in New Issue