PROBE_DOUBLE_TOUCH => MULTIPLE_PROBING

This commit is contained in:
Scott Lahteine 2017-12-07 16:33:51 -06:00
parent d7800e7975
commit ae663a4198
5 changed files with 56 additions and 20 deletions

View File

@ -690,14 +690,16 @@
// X and Y axis travel speed (mm/m) between probes // X and Y axis travel speed (mm/m) between probes
#define XY_PROBE_SPEED 8000 #define XY_PROBE_SPEED 8000
// Speed for the first approach when double-probing (with PROBE_DOUBLE_TOUCH) // Speed for the first approach when double-probing (MULTIPLE_PROBING == 2)
#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
// Speed for the "accurate" probe of each point // Speed for the "accurate" probe of each point
#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2) #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
// Use double touch for probing // The number of probes to perform at each point.
//#define PROBE_DOUBLE_TOUCH // Set to 2 for a fast/slow probe, using the second probe result.
// Set to 3 or more for slow probes, averaging the results.
//#define MULTIPLE_PROBING 2
/** /**
* Z probes require clearance when deploying, stowing, and moving between * Z probes require clearance when deploying, stowing, and moving between

View File

@ -742,7 +742,7 @@
//#define BEZIER_CURVE_SUPPORT //#define BEZIER_CURVE_SUPPORT
// G38.2 and G38.3 Probe Target // G38.2 and G38.3 Probe Target
// Enable PROBE_DOUBLE_TOUCH if you want G38 to double touch // Set MULTIPLE_PROBING if you want G38 to double touch
//#define G38_PROBE_TARGET //#define G38_PROBE_TARGET
#if ENABLED(G38_PROBE_TARGET) #if ENABLED(G38_PROBE_TARGET)
#define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

View File

@ -35,7 +35,7 @@ static bool G38_run_probe() {
bool G38_pass_fail = false; bool G38_pass_fail = false;
#if ENABLED(PROBE_DOUBLE_TOUCH) #if MULTIPLE_PROBING > 1
// Get direction of move and retract // Get direction of move and retract
float retract_mm[XYZ]; float retract_mm[XYZ];
LOOP_XYZ(i) { LOOP_XYZ(i) {
@ -62,7 +62,7 @@ static bool G38_run_probe() {
G38_pass_fail = true; G38_pass_fail = true;
#if ENABLED(PROBE_DOUBLE_TOUCH) #if MULTIPLE_PROBING > 1
// Move away by the retract distance // Move away by the retract distance
set_destination_from_current(); set_destination_from_current();
LOOP_XYZ(i) destination[i] += retract_mm[i]; LOOP_XYZ(i) destination[i] += retract_mm[i];

View File

@ -227,6 +227,8 @@
#error "UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN is now SEGMENT_LEVELED_MOVES. Please update your configuration." #error "UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN is now SEGMENT_LEVELED_MOVES. Please update your configuration."
#elif HAS_PID_HEATING && (defined(K1) || !defined(PID_K1)) #elif HAS_PID_HEATING && (defined(K1) || !defined(PID_K1))
#error "K1 is now PID_K1. Please update your configuration." #error "K1 is now PID_K1. Please update your configuration."
#elif defined(PROBE_DOUBLE_TOUCH)
#error "PROBE_DOUBLE_TOUCH is now MULTIPLE_PROBING. Please update your configuration."
#endif #endif
/** /**
@ -711,6 +713,10 @@ static_assert(1 >= 0
#error "Probes need Z_CLEARANCE_BETWEEN_PROBES >= 0." #error "Probes need Z_CLEARANCE_BETWEEN_PROBES >= 0."
#endif #endif
#if MULTIPLE_PROBING && MULTIPLE_PROBING < 2
#error "MULTIPLE_PROBING must be >= 2."
#endif
#else #else
/** /**

View File

@ -507,7 +507,7 @@ static bool do_probe_move(const float z, const float fr_mm_m) {
} }
/** /**
* @details Used by probe_pt to do a single Z probe. * @details Used by probe_pt to do a single Z probe at the current position.
* Leaves current_position[Z_AXIS] at the height where the probe triggered. * Leaves current_position[Z_AXIS] at the height where the probe triggered.
* *
* @return The raw Z position where the probe was triggered * @return The raw Z position where the probe was triggered
@ -521,7 +521,8 @@ static float run_z_probe() {
// Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding // Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
gcode.refresh_cmd_timeout(); gcode.refresh_cmd_timeout();
#if ENABLED(PROBE_DOUBLE_TOUCH) // Double-probing does a fast probe followed by a slow probe
#if MULTIPLE_PROBING == 2
// Do a first probe at the fast speed // Do a first probe at the fast speed
if (do_probe_move(-10, Z_PROBE_SPEED_FAST)) return NAN; if (do_probe_move(-10, Z_PROBE_SPEED_FAST)) return NAN;
@ -549,22 +550,49 @@ static float run_z_probe() {
} }
#endif #endif
#if MULTIPLE_PROBING > 2
float probes_total = 0;
for (uint8_t p = MULTIPLE_PROBING + 1; --p;) {
#endif
// Move down slowly to find bed, not too far // Move down slowly to find bed, not too far
if (do_probe_move(-10, Z_PROBE_SPEED_SLOW)) return NAN; if (do_probe_move(-10, Z_PROBE_SPEED_SLOW)) return NAN;
#if MULTIPLE_PROBING > 2
probes_total += current_position[Z_AXIS];
if (p > 1) do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
}
#endif
#if MULTIPLE_PROBING > 2
// Return the average value of all probes
return probes_total * (1.0 / (MULTIPLE_PROBING));
#elif MULTIPLE_PROBING == 2
const float z2 = current_position[Z_AXIS];
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("2nd Probe Z:", z2);
SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - z2);
}
#endif
// Return a weighted average of the fast and slow probes
return (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
#else
// Return the single probe result
return current_position[Z_AXIS];
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
#endif #endif
// Debug: compare probe heights
#if ENABLED(PROBE_DOUBLE_TOUCH) && ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("2nd Probe Z:", current_position[Z_AXIS]);
SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
}
#endif
return current_position[Z_AXIS];
} }
/** /**