2017-09-08 22:35:25 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-02-12 22:06:53 +01:00
|
|
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-08 22:35:25 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* probe.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if HAS_BED_PROBE
|
|
|
|
|
2018-09-23 18:50:03 +02:00
|
|
|
#include "../libs/buzzer.h"
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#include "probe.h"
|
|
|
|
#include "motion.h"
|
|
|
|
#include "temperature.h"
|
|
|
|
#include "endstops.h"
|
|
|
|
|
|
|
|
#include "../gcode/gcode.h"
|
|
|
|
#include "../lcd/ultralcd.h"
|
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if ANY(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY, PROBE_TRIGGERED_WHEN_STOWED_TEST) || (QUIET_PROBING && ENABLED(PROBING_STEPPERS_OFF))
|
2019-01-20 04:50:33 +01:00
|
|
|
#include "../Marlin.h" // for stop(), disable_e_steppers
|
2018-11-30 19:48:46 +01:00
|
|
|
#endif
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
#if HAS_LEVELING
|
|
|
|
#include "../feature/bedlevel/bedlevel.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(DELTA)
|
2019-02-04 10:41:55 +01:00
|
|
|
#include "delta.h"
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-20 02:25:59 +02:00
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
|
|
#include "planner.h"
|
|
|
|
#endif
|
|
|
|
|
2019-05-04 06:53:15 +02:00
|
|
|
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
|
|
|
#include "../feature/backlash.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
float zprobe_zoffset; // Initialized by settings.load()
|
|
|
|
|
2019-03-17 11:57:25 +01:00
|
|
|
#if ENABLED(BLTOUCH)
|
|
|
|
#include "../feature/bltouch.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
#if HAS_Z_SERVO_PROBE
|
2019-02-04 10:41:55 +01:00
|
|
|
#include "servo.h"
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
|
|
|
|
2018-09-09 21:59:12 +02:00
|
|
|
#if ENABLED(SENSORLESS_PROBING)
|
|
|
|
#include "stepper.h"
|
|
|
|
#include "../feature/tmc_util.h"
|
|
|
|
#endif
|
|
|
|
|
2018-11-30 19:48:46 +01:00
|
|
|
#if QUIET_PROBING
|
|
|
|
#include "stepper_indirection.h"
|
|
|
|
#endif
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#include "../core/debug_out.h"
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#if ENABLED(Z_PROBE_SLED)
|
|
|
|
|
|
|
|
#ifndef SLED_DOCKING_OFFSET
|
|
|
|
#define SLED_DOCKING_OFFSET 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to dock/undock a sled designed by Charles Bell.
|
|
|
|
*
|
|
|
|
* stow[in] If false, move to MAX_X and engage the solenoid
|
|
|
|
* If true, move to MAX_X and release the solenoid
|
|
|
|
*/
|
|
|
|
static void dock_sled(bool stow) {
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")");
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
// Dock sled a bit closer to ensure proper capturing
|
|
|
|
do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET - ((stow) ? 1 : 0));
|
|
|
|
|
|
|
|
#if HAS_SOLENOID_1 && DISABLED(EXT_SOLENOID)
|
|
|
|
WRITE(SOL1_PIN, !stow); // switch solenoid
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif ENABLED(Z_PROBE_ALLEN_KEY)
|
|
|
|
|
|
|
|
void run_deploy_moves_script() {
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_DEPLOY_1_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_1_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_1_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_1_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_1_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_1_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float deploy_1[] = { Z_PROBE_ALLEN_KEY_DEPLOY_1_X, Z_PROBE_ALLEN_KEY_DEPLOY_1_Y, Z_PROBE_ALLEN_KEY_DEPLOY_1_Z };
|
|
|
|
do_blocking_move_to(deploy_1, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_DEPLOY_2_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_2_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_2_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_2_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_2_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_2_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_2_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_2_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_2_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float deploy_2[] = { Z_PROBE_ALLEN_KEY_DEPLOY_2_X, Z_PROBE_ALLEN_KEY_DEPLOY_2_Y, Z_PROBE_ALLEN_KEY_DEPLOY_2_Z };
|
|
|
|
do_blocking_move_to(deploy_2, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_DEPLOY_3_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_3_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_3_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_3_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_3_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_3_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_3_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float deploy_3[] = { Z_PROBE_ALLEN_KEY_DEPLOY_3_X, Z_PROBE_ALLEN_KEY_DEPLOY_3_Y, Z_PROBE_ALLEN_KEY_DEPLOY_3_Z };
|
|
|
|
do_blocking_move_to(deploy_3, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_DEPLOY_4_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_4_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_4_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_4_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_4_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_4_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_4_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_4_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_4_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_4_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_4_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float deploy_4[] = { Z_PROBE_ALLEN_KEY_DEPLOY_4_X, Z_PROBE_ALLEN_KEY_DEPLOY_4_Y, Z_PROBE_ALLEN_KEY_DEPLOY_4_Z };
|
|
|
|
do_blocking_move_to(deploy_4, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_DEPLOY_4_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_DEPLOY_5_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_5_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_5_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_5_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_5_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_5_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_5_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_5_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_5_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_5_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_DEPLOY_5_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float deploy_5[] = { Z_PROBE_ALLEN_KEY_DEPLOY_5_X, Z_PROBE_ALLEN_KEY_DEPLOY_5_Y, Z_PROBE_ALLEN_KEY_DEPLOY_5_Z };
|
|
|
|
do_blocking_move_to(deploy_5, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_DEPLOY_5_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void run_stow_moves_script() {
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_STOW_1_X) || defined(Z_PROBE_ALLEN_KEY_STOW_1_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_1_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_1_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_1_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_1_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_1_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_1_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_1_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float stow_1[] = { Z_PROBE_ALLEN_KEY_STOW_1_X, Z_PROBE_ALLEN_KEY_STOW_1_Y, Z_PROBE_ALLEN_KEY_STOW_1_Z };
|
|
|
|
do_blocking_move_to(stow_1, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_STOW_2_X) || defined(Z_PROBE_ALLEN_KEY_STOW_2_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_2_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_2_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_2_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_2_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_2_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_2_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_2_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float stow_2[] = { Z_PROBE_ALLEN_KEY_STOW_2_X, Z_PROBE_ALLEN_KEY_STOW_2_Y, Z_PROBE_ALLEN_KEY_STOW_2_Z };
|
|
|
|
do_blocking_move_to(stow_2, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_STOW_3_X) || defined(Z_PROBE_ALLEN_KEY_STOW_3_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_3_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_3_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_3_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_3_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_3_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_3_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_3_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float stow_3[] = { Z_PROBE_ALLEN_KEY_STOW_3_X, Z_PROBE_ALLEN_KEY_STOW_3_Y, Z_PROBE_ALLEN_KEY_STOW_3_Z };
|
|
|
|
do_blocking_move_to(stow_3, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_STOW_4_X) || defined(Z_PROBE_ALLEN_KEY_STOW_4_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_4_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_4_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_4_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_4_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_4_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_4_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_4_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float stow_4[] = { Z_PROBE_ALLEN_KEY_STOW_4_X, Z_PROBE_ALLEN_KEY_STOW_4_Y, Z_PROBE_ALLEN_KEY_STOW_4_Z };
|
|
|
|
do_blocking_move_to(stow_4, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
#if defined(Z_PROBE_ALLEN_KEY_STOW_5_X) || defined(Z_PROBE_ALLEN_KEY_STOW_5_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_5_Z)
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_5_X
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_5_X current_position[X_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_5_Y
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_5_Y current_position[Y_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_5_Z
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_5_Z current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
#ifndef Z_PROBE_ALLEN_KEY_STOW_5_FEEDRATE
|
|
|
|
#define Z_PROBE_ALLEN_KEY_STOW_5_FEEDRATE 0.0
|
|
|
|
#endif
|
|
|
|
const float stow_5[] = { Z_PROBE_ALLEN_KEY_STOW_5_X, Z_PROBE_ALLEN_KEY_STOW_5_Y, Z_PROBE_ALLEN_KEY_STOW_5_Z };
|
|
|
|
do_blocking_move_to(stow_5, MMM_TO_MMS(Z_PROBE_ALLEN_KEY_STOW_5_FEEDRATE));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-10-02 04:33:52 +02:00
|
|
|
#endif // Z_PROBE_ALLEN_KEY
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
#if QUIET_PROBING
|
|
|
|
void probing_pause(const bool p) {
|
|
|
|
#if ENABLED(PROBING_HEATERS_OFF)
|
|
|
|
thermalManager.pause(p);
|
|
|
|
#endif
|
|
|
|
#if ENABLED(PROBING_FANS_OFF)
|
2019-01-12 07:41:48 +01:00
|
|
|
thermalManager.set_fans_paused(p);
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
2018-10-02 12:13:58 +02:00
|
|
|
#if ENABLED(PROBING_STEPPERS_OFF)
|
|
|
|
disable_e_steppers();
|
2019-05-08 04:25:54 +02:00
|
|
|
#if DISABLED(DELTA, HOME_AFTER_DEACTIVATE)
|
2018-10-02 12:13:58 +02:00
|
|
|
disable_X(); disable_Y();
|
|
|
|
#endif
|
|
|
|
#endif
|
2017-09-08 22:35:25 +02:00
|
|
|
if (p) safe_delay(
|
|
|
|
#if DELAY_BEFORE_PROBING > 25
|
|
|
|
DELAY_BEFORE_PROBING
|
|
|
|
#else
|
|
|
|
25
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif // QUIET_PROBING
|
|
|
|
|
2018-03-10 06:18:08 +01:00
|
|
|
/**
|
|
|
|
* Raise Z to a minimum height to make room for a probe to move
|
|
|
|
*/
|
|
|
|
inline void do_probe_raise(const float z_raise) {
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("do_probe_raise(", z_raise, ")");
|
2018-03-10 06:18:08 +01:00
|
|
|
|
|
|
|
float z_dest = z_raise;
|
|
|
|
if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
|
|
|
|
|
|
|
|
NOMORE(z_dest, Z_MAX_POS);
|
|
|
|
|
|
|
|
if (z_dest > current_position[Z_AXIS])
|
|
|
|
do_blocking_move_to_z(z_dest);
|
|
|
|
}
|
|
|
|
|
2018-10-27 02:18:20 +02:00
|
|
|
FORCE_INLINE void probe_specific_action(const bool deploy) {
|
|
|
|
#if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
|
2019-04-16 08:32:43 +02:00
|
|
|
do {
|
|
|
|
#if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED)
|
2019-04-16 19:35:58 +02:00
|
|
|
if (deploy == (READ(Z_MIN_PROBE_PIN) == Z_MIN_PROBE_ENDSTOP_INVERTING)) break;
|
2019-04-16 08:32:43 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
BUZZ(100, 659);
|
|
|
|
BUZZ(100, 698);
|
|
|
|
|
|
|
|
PGM_P const ds_str = deploy ? PSTR(MSG_MANUAL_DEPLOY) : PSTR(MSG_MANUAL_STOW);
|
|
|
|
ui.return_to_status(); // To display the new status message
|
|
|
|
ui.set_status_P(ds_str, 99);
|
|
|
|
serialprintPGM(ds_str);
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
|
|
wait_for_user = true;
|
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Stow Probe"), PSTR("Continue"));
|
|
|
|
#endif
|
|
|
|
while (wait_for_user) idle();
|
|
|
|
ui.reset_status();
|
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
|
|
} while(
|
|
|
|
#if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED)
|
|
|
|
true
|
|
|
|
#else
|
|
|
|
false
|
|
|
|
#endif
|
|
|
|
);
|
2018-10-27 02:18:20 +02:00
|
|
|
|
|
|
|
#endif // PAUSE_BEFORE_DEPLOY_STOW
|
|
|
|
|
|
|
|
#if ENABLED(SOLENOID_PROBE)
|
|
|
|
|
|
|
|
#if HAS_SOLENOID_1
|
|
|
|
WRITE(SOL1_PIN, deploy);
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
2018-10-27 02:18:20 +02:00
|
|
|
|
|
|
|
#elif ENABLED(Z_PROBE_SLED)
|
|
|
|
|
|
|
|
dock_sled(!deploy);
|
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
#elif HAS_Z_SERVO_PROBE
|
|
|
|
|
|
|
|
#if DISABLED(BLTOUCH)
|
|
|
|
MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]);
|
|
|
|
#elif ENABLED(BLTOUCH_HS_MODE)
|
|
|
|
// In HIGH SPEED MODE, use the normal retractable probe logic in this code
|
|
|
|
// i.e. no intermediate STOWs and DEPLOYs in between individual probe actions
|
|
|
|
if (deploy) bltouch.deploy(); else bltouch.stow();
|
|
|
|
#endif
|
2018-10-27 02:18:20 +02:00
|
|
|
|
|
|
|
#elif ENABLED(Z_PROBE_ALLEN_KEY)
|
|
|
|
|
|
|
|
deploy ? run_deploy_moves_script() : run_stow_moves_script();
|
|
|
|
|
|
|
|
#elif ENABLED(RACK_AND_PINION_PROBE)
|
2018-10-28 02:30:21 +01:00
|
|
|
|
2018-10-27 02:18:20 +02:00
|
|
|
do_blocking_move_to_x(deploy ? Z_PROBE_DEPLOY_X : Z_PROBE_RETRACT_X);
|
|
|
|
|
2018-11-24 04:07:24 +01:00
|
|
|
#elif DISABLED(PAUSE_BEFORE_DEPLOY_STOW)
|
|
|
|
|
|
|
|
UNUSED(deploy);
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
2018-10-27 02:18:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// returns false for ok and true for failure
|
|
|
|
bool set_probe_deployed(const bool deploy) {
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
DEBUG_POS("set_probe_deployed", current_position);
|
|
|
|
DEBUG_ECHOLNPAIR("deploy: ", deploy);
|
|
|
|
}
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
if (endstops.z_probe_enabled == deploy) return false;
|
|
|
|
|
2018-02-19 15:36:43 +01:00
|
|
|
// Make room for probe to deploy (or stow)
|
2018-02-24 23:35:31 +01:00
|
|
|
// Fix-mounted probe should only raise for deploy
|
2018-09-24 06:43:43 +02:00
|
|
|
// unless PAUSE_BEFORE_DEPLOY_STOW is enabled
|
|
|
|
#if ENABLED(FIX_MOUNTED_PROBE) && DISABLED(PAUSE_BEFORE_DEPLOY_STOW)
|
2018-03-10 06:18:47 +01:00
|
|
|
const bool deploy_stow_condition = deploy;
|
|
|
|
#else
|
|
|
|
constexpr bool deploy_stow_condition = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For beds that fall when Z is powered off only raise for trusted Z
|
|
|
|
#if ENABLED(UNKNOWN_Z_NO_RAISE)
|
2018-06-12 04:29:31 +02:00
|
|
|
const bool unknown_condition = TEST(axis_known_position, Z_AXIS);
|
2018-03-10 06:18:47 +01:00
|
|
|
#else
|
|
|
|
constexpr float unknown_condition = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (deploy_stow_condition && unknown_condition)
|
2018-05-13 08:10:34 +02:00
|
|
|
do_probe_raise(MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
|
2017-09-08 22:35:25 +02:00
|
|
|
#if ENABLED(Z_PROBE_SLED)
|
|
|
|
#define _AUE_ARGS true, false, false
|
|
|
|
#else
|
|
|
|
#define _AUE_ARGS
|
|
|
|
#endif
|
|
|
|
if (axis_unhomed_error(_AUE_ARGS)) {
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ERROR_MSG(MSG_STOP_UNHOMED);
|
2017-09-08 22:35:25 +02:00
|
|
|
stop();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const float oldXpos = current_position[X_AXIS],
|
|
|
|
oldYpos = current_position[Y_AXIS];
|
|
|
|
|
2018-10-27 02:18:20 +02:00
|
|
|
#if ENABLED(PROBE_TRIGGERED_WHEN_STOWED_TEST)
|
2019-03-01 07:27:45 +01:00
|
|
|
#if USES_Z_MIN_PROBE_ENDSTOP
|
2018-10-27 02:18:20 +02:00
|
|
|
#define PROBE_STOWED() (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING)
|
|
|
|
#else
|
|
|
|
#define PROBE_STOWED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING)
|
|
|
|
#endif
|
|
|
|
#endif
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-10-27 02:18:20 +02:00
|
|
|
#ifdef PROBE_STOWED
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-10-27 02:18:20 +02:00
|
|
|
// Only deploy/stow if needed
|
|
|
|
if (PROBE_STOWED() == deploy) {
|
2017-09-08 22:35:25 +02:00
|
|
|
if (!deploy) endstops.enable_z_probe(false); // Switch off triggered when stowed probes early
|
|
|
|
// otherwise an Allen-Key probe can't be stowed.
|
2018-10-27 02:18:20 +02:00
|
|
|
probe_specific_action(deploy);
|
|
|
|
}
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-10-27 02:18:20 +02:00
|
|
|
if (PROBE_STOWED() == deploy) { // Unchanged after deploy/stow action?
|
2017-09-08 22:35:25 +02:00
|
|
|
if (IsRunning()) {
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ERROR_MSG("Z-Probe failed");
|
2017-09-08 22:35:25 +02:00
|
|
|
LCD_ALERTMESSAGEPGM("Err: ZPROBE");
|
|
|
|
}
|
|
|
|
stop();
|
|
|
|
return true;
|
2018-10-27 02:18:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-10-27 02:18:20 +02:00
|
|
|
probe_specific_action(deploy);
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
do_blocking_move_to(oldXpos, oldYpos, current_position[Z_AXIS]); // return to position before deploy
|
|
|
|
endstops.enable_z_probe(deploy);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-04-30 10:25:47 +02:00
|
|
|
#ifdef Z_AFTER_PROBING
|
2018-03-11 19:07:55 +01:00
|
|
|
// After probing move to a preferred Z position
|
|
|
|
void move_z_after_probing() {
|
|
|
|
if (current_position[Z_AXIS] != Z_AFTER_PROBING) {
|
|
|
|
do_blocking_move_to_z(Z_AFTER_PROBING);
|
|
|
|
current_position[Z_AXIS] = Z_AFTER_PROBING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
/**
|
|
|
|
* @brief Used by run_z_probe to do a single Z probe move.
|
|
|
|
*
|
|
|
|
* @param z Z destination
|
|
|
|
* @param fr_mm_s Feedrate in mm/s
|
|
|
|
* @return true to indicate an error
|
|
|
|
*/
|
2018-04-21 22:43:21 +02:00
|
|
|
|
2018-04-24 00:13:01 +02:00
|
|
|
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
|
2018-04-21 22:43:21 +02:00
|
|
|
const char msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n";
|
|
|
|
#endif
|
|
|
|
|
2018-04-30 23:28:20 +02:00
|
|
|
static bool do_probe_move(const float z, const float fr_mm_s) {
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-04-24 00:13:01 +02:00
|
|
|
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
|
2018-04-21 22:43:21 +02:00
|
|
|
// Wait for bed to heat back up between probing points
|
|
|
|
if (thermalManager.isHeatingBed()) {
|
|
|
|
serialprintPGM(msg_wait_for_bed_heating);
|
|
|
|
LCD_MESSAGEPGM(MSG_BED_HEATING);
|
2018-11-24 03:39:12 +01:00
|
|
|
thermalManager.wait_for_bed();
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.reset_status();
|
2018-04-21 22:43:21 +02:00
|
|
|
}
|
2018-04-24 01:00:06 +02:00
|
|
|
#endif
|
2018-04-21 22:43:21 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
#if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE)
|
|
|
|
if (bltouch.deploy()) return true; // DEPLOY in LOW SPEED MODE on every probe action
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
|
|
|
|
2018-09-09 21:59:12 +02:00
|
|
|
// Disable stealthChop if used. Enable diag1 pin on driver.
|
|
|
|
#if ENABLED(SENSORLESS_PROBING)
|
2019-02-02 01:09:01 +01:00
|
|
|
sensorless_t stealth_states { false, false, false, false, false, false, false };
|
2018-09-09 21:59:12 +02:00
|
|
|
#if ENABLED(DELTA)
|
2018-12-07 22:34:21 +01:00
|
|
|
stealth_states.x = tmc_enable_stallguard(stepperX);
|
|
|
|
stealth_states.y = tmc_enable_stallguard(stepperY);
|
2018-09-09 21:59:12 +02:00
|
|
|
#endif
|
2018-12-07 22:34:21 +01:00
|
|
|
stealth_states.z = tmc_enable_stallguard(stepperZ);
|
2018-11-05 03:51:54 +01:00
|
|
|
endstops.enable(true);
|
2018-09-09 21:59:12 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#if QUIET_PROBING
|
|
|
|
probing_pause(true);
|
|
|
|
#endif
|
|
|
|
|
2018-11-05 03:51:54 +01:00
|
|
|
// Move down until the probe is triggered
|
2018-04-30 23:28:20 +02:00
|
|
|
do_blocking_move_to_z(z, fr_mm_s);
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
// Check to see if the probe was triggered
|
2018-10-01 03:42:47 +02:00
|
|
|
const bool probe_triggered =
|
2019-03-17 05:43:06 +01:00
|
|
|
#if BOTH(DELTA, SENSORLESS_PROBING)
|
2018-09-09 21:59:12 +02:00
|
|
|
endstops.trigger_state() & (_BV(X_MIN) | _BV(Y_MIN) | _BV(Z_MIN))
|
2017-09-08 22:35:25 +02:00
|
|
|
#else
|
2018-09-09 21:59:12 +02:00
|
|
|
TEST(endstops.trigger_state(),
|
|
|
|
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
|
|
|
Z_MIN
|
|
|
|
#else
|
|
|
|
Z_MIN_PROBE
|
|
|
|
#endif
|
|
|
|
)
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
2018-09-09 21:59:12 +02:00
|
|
|
;
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
#if QUIET_PROBING
|
|
|
|
probing_pause(false);
|
|
|
|
#endif
|
|
|
|
|
2018-09-09 21:59:12 +02:00
|
|
|
// Re-enable stealthChop if used. Disable diag1 pin on driver.
|
|
|
|
#if ENABLED(SENSORLESS_PROBING)
|
2018-11-05 03:51:54 +01:00
|
|
|
endstops.not_homing();
|
2018-09-09 21:59:12 +02:00
|
|
|
#if ENABLED(DELTA)
|
2018-12-07 22:34:21 +01:00
|
|
|
tmc_disable_stallguard(stepperX, stealth_states.x);
|
|
|
|
tmc_disable_stallguard(stepperY, stealth_states.y);
|
2018-09-09 21:59:12 +02:00
|
|
|
#endif
|
2018-12-07 22:34:21 +01:00
|
|
|
tmc_disable_stallguard(stepperZ, stealth_states.z);
|
2018-09-09 21:59:12 +02:00
|
|
|
#endif
|
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
#if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE)
|
|
|
|
if (probe_triggered && bltouch.stow()) return true; // STOW in LOW SPEED MODE on trigger on every probe action
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
|
|
|
|
2018-09-09 21:59:12 +02:00
|
|
|
// Clear endstop flags
|
2017-09-08 22:35:25 +02:00
|
|
|
endstops.hit_on_purpose();
|
|
|
|
|
|
|
|
// Get Z where the steppers were interrupted
|
|
|
|
set_current_from_steppers_for_axis(Z_AXIS);
|
|
|
|
|
|
|
|
// Tell the planner where we actually are
|
2018-09-17 04:24:15 +02:00
|
|
|
sync_plan_position();
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
return !probe_triggered;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-12-07 23:33:51 +01:00
|
|
|
* @details Used by probe_pt to do a single Z probe at the current position.
|
2017-09-08 22:35:25 +02:00
|
|
|
* Leaves current_position[Z_AXIS] at the height where the probe triggered.
|
|
|
|
*
|
|
|
|
* @return The raw Z position where the probe was triggered
|
|
|
|
*/
|
2018-05-30 04:54:13 +02:00
|
|
|
static float run_z_probe() {
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-04-12 01:59:46 +02:00
|
|
|
// Stop the probe before it goes too low to prevent damage.
|
|
|
|
// If Z isn't known then probe to -10mm.
|
2018-06-12 04:29:31 +02:00
|
|
|
const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -zprobe_zoffset + Z_PROBE_LOW_POINT : -10.0;
|
2018-04-09 08:46:23 +02:00
|
|
|
|
2017-12-07 23:33:51 +01:00
|
|
|
// Double-probing does a fast probe followed by a slow probe
|
|
|
|
#if MULTIPLE_PROBING == 2
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
// Do a first probe at the fast speed
|
2018-05-30 04:54:13 +02:00
|
|
|
if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) {
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
DEBUG_ECHOLNPGM("FAST Probe fail!");
|
|
|
|
DEBUG_POS("<<< run_z_probe", current_position);
|
|
|
|
}
|
2018-05-30 04:54:13 +02:00
|
|
|
return NAN;
|
|
|
|
}
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2017-12-08 10:49:33 +01:00
|
|
|
float first_probe_z = current_position[Z_AXIS];
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("1st Probe Z:", first_probe_z);
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
// move up to make clearance for the probe
|
2018-07-13 04:36:24 +02:00
|
|
|
do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-09-09 21:59:12 +02:00
|
|
|
#elif Z_PROBE_SPEED_FAST != Z_PROBE_SPEED_SLOW
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-02-02 09:32:11 +01:00
|
|
|
// If the nozzle is well over the travel height then
|
2017-09-08 22:35:25 +02:00
|
|
|
// move down quickly before doing the slow probe
|
2018-09-09 21:59:12 +02:00
|
|
|
const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (zprobe_zoffset < 0 ? -zprobe_zoffset : 0);
|
2018-02-02 09:32:11 +01:00
|
|
|
if (current_position[Z_AXIS] > z) {
|
2017-09-08 22:35:25 +02:00
|
|
|
// If we don't make it to the z position (i.e. the probe triggered), move up to make clearance for the probe
|
2018-04-30 10:35:07 +02:00
|
|
|
if (!do_probe_move(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST)))
|
2017-09-08 22:35:25 +02:00
|
|
|
do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-12-07 23:33:51 +01:00
|
|
|
#if MULTIPLE_PROBING > 2
|
|
|
|
float probes_total = 0;
|
|
|
|
for (uint8_t p = MULTIPLE_PROBING + 1; --p;) {
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
|
|
|
|
2018-05-30 04:54:13 +02:00
|
|
|
// move down slowly to find bed
|
|
|
|
if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) {
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
DEBUG_ECHOLNPGM("SLOW Probe fail!");
|
|
|
|
DEBUG_POS("<<< run_z_probe", current_position);
|
|
|
|
}
|
2018-05-30 04:54:13 +02:00
|
|
|
return NAN;
|
|
|
|
}
|
2017-12-07 23:33:51 +01:00
|
|
|
|
2018-12-08 21:36:46 +01:00
|
|
|
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
2019-05-04 06:53:15 +02:00
|
|
|
backlash.measure_with_probe();
|
2018-12-08 21:36:46 +01:00
|
|
|
#endif
|
|
|
|
|
2017-12-07 23:33:51 +01:00
|
|
|
#if MULTIPLE_PROBING > 2
|
|
|
|
probes_total += current_position[Z_AXIS];
|
2018-07-13 04:36:24 +02:00
|
|
|
if (p > 1) do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
|
2017-09-08 22:35:25 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-12-07 23:33:51 +01:00
|
|
|
#if MULTIPLE_PROBING > 2
|
|
|
|
|
|
|
|
// Return the average value of all probes
|
2018-07-01 22:20:28 +02:00
|
|
|
const float measured_z = probes_total * (1.0f / (MULTIPLE_PROBING));
|
2017-12-07 23:33:51 +01:00
|
|
|
|
|
|
|
#elif MULTIPLE_PROBING == 2
|
|
|
|
|
|
|
|
const float z2 = current_position[Z_AXIS];
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2);
|
2017-12-07 23:33:51 +01:00
|
|
|
|
|
|
|
// Return a weighted average of the fast and slow probes
|
2018-05-30 04:54:13 +02:00
|
|
|
const float measured_z = (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
|
2017-12-07 23:33:51 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
// Return the single probe result
|
2018-05-30 04:54:13 +02:00
|
|
|
const float measured_z = current_position[Z_AXIS];
|
2017-12-07 23:33:51 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
|
2018-05-30 04:54:13 +02:00
|
|
|
|
|
|
|
return measured_z;
|
2017-09-08 22:35:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* - Move to the given XY
|
|
|
|
* - Deploy the probe, if not already deployed
|
|
|
|
* - Probe the bed, get the Z position
|
|
|
|
* - Depending on the 'stow' flag
|
|
|
|
* - Stow the probe, or
|
|
|
|
* - Raise to the BETWEEN height
|
|
|
|
* - Return the probed Z position
|
|
|
|
*/
|
2018-04-12 01:59:46 +02:00
|
|
|
float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) {
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
DEBUG_ECHOLNPAIR(
|
|
|
|
">>> probe_pt(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
|
|
|
|
", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
|
|
|
|
", ", int(verbose_level),
|
|
|
|
", ", probe_relative ? "probe" : "nozzle", "_relative)"
|
|
|
|
);
|
|
|
|
DEBUG_POS("", current_position);
|
|
|
|
}
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2017-11-25 10:59:46 +01:00
|
|
|
// TODO: Adapt for SCARA, where the offset rotates
|
|
|
|
float nx = rx, ny = ry;
|
2018-04-12 01:59:46 +02:00
|
|
|
if (probe_relative) {
|
2017-11-25 10:59:46 +01:00
|
|
|
if (!position_is_reachable_by_probe(rx, ry)) return NAN; // The given position is in terms of the probe
|
|
|
|
nx -= (X_PROBE_OFFSET_FROM_EXTRUDER); // Get the nozzle position
|
|
|
|
ny -= (Y_PROBE_OFFSET_FROM_EXTRUDER);
|
|
|
|
}
|
|
|
|
else if (!position_is_reachable(nx, ny)) return NAN; // The given position is in terms of the nozzle
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2017-11-27 03:18:52 +01:00
|
|
|
const float nz =
|
2017-11-25 00:10:27 +01:00
|
|
|
#if ENABLED(DELTA)
|
|
|
|
// Move below clip height or xy move will be aborted by do_blocking_move_to
|
2018-05-13 08:10:34 +02:00
|
|
|
MIN(current_position[Z_AXIS], delta_clip_start_height)
|
2017-11-25 00:10:27 +01:00
|
|
|
#else
|
|
|
|
current_position[Z_AXIS]
|
|
|
|
#endif
|
|
|
|
;
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2017-11-25 00:10:27 +01:00
|
|
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
2017-09-08 22:35:25 +02:00
|
|
|
feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
|
|
|
|
|
2017-11-25 00:10:27 +01:00
|
|
|
// Move the probe to the starting XYZ
|
|
|
|
do_blocking_move_to(nx, ny, nz);
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
float measured_z = NAN;
|
|
|
|
if (!DEPLOY_PROBE()) {
|
2018-04-12 01:59:46 +02:00
|
|
|
measured_z = run_z_probe() + zprobe_zoffset;
|
2017-09-08 22:35:25 +02:00
|
|
|
|
2018-04-12 04:14:48 +02:00
|
|
|
const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
|
|
|
|
if (big_raise || raise_after == PROBE_PT_RAISE)
|
|
|
|
do_blocking_move_to_z(current_position[Z_AXIS] + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
|
2018-03-21 07:01:43 +01:00
|
|
|
else if (raise_after == PROBE_PT_STOW)
|
2017-09-08 22:35:25 +02:00
|
|
|
if (STOW_PROBE()) measured_z = NAN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose_level > 2) {
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3);
|
|
|
|
SERIAL_ECHOPAIR_F(" Y: ", LOGICAL_Y_POSITION(ry), 3);
|
|
|
|
SERIAL_ECHOLNPAIR_F(" Z: ", measured_z, 3);
|
2017-09-08 22:35:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
feedrate_mm_s = old_feedrate_mm_s;
|
|
|
|
|
|
|
|
if (isnan(measured_z)) {
|
2019-06-08 04:43:20 +02:00
|
|
|
#if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE)
|
|
|
|
bltouch.stow();
|
|
|
|
#else
|
|
|
|
STOW_PROBE();
|
|
|
|
#endif
|
2017-09-08 22:35:25 +02:00
|
|
|
LCD_MESSAGEPGM(MSG_ERR_PROBING_FAILED);
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED);
|
2017-09-08 22:35:25 +02:00
|
|
|
}
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< probe_pt");
|
2018-05-30 04:54:13 +02:00
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
return measured_z;
|
|
|
|
}
|
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
#if HAS_Z_SERVO_PROBE
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
void servo_probe_init() {
|
|
|
|
/**
|
|
|
|
* Set position of Z Servo Endstop
|
|
|
|
*
|
|
|
|
* The servo might be deployed and positioned too low to stow
|
|
|
|
* when starting up the machine or rebooting the board.
|
|
|
|
* There's no way to know where the nozzle is positioned until
|
|
|
|
* homing has been done - no homing with z-probe without init!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
STOW_Z_SERVO();
|
|
|
|
}
|
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
#endif // HAS_Z_SERVO_PROBE
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
#endif // HAS_BED_PROBE
|