Probe Tare, Probe Activation Switch (#20379)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Co-authored-by: Victor Mateus Oliveira <rhapsodyv@gmail.com>
Co-authored-by: Jason Smith <jason.inet@gmail.com>
2.0.x
InsanityAutomation 4 years ago committed by GitHub
parent 7a168205eb
commit 2963229dfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1006,6 +1006,33 @@
// Feedrate (mm/min) for the "accurate" probe of each point // Feedrate (mm/min) 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)
/**
* Probe Activation Switch
* A switch indicating proper deployment, or an optical
* switch triggered when the carriage is near the bed.
*/
//#define PROBE_ACTIVATION_SWITCH
#if ENABLED(PROBE_ACTIVATION_SWITCH)
#define PROBE_ACTIVATION_SWITCH_STATE LOW // State indicating probe is active
//#define PROBE_ACTIVATION_SWITCH_PIN PC6 // Override default pin
#endif
/**
* Tare Probe (determine zero-point) prior to each probe.
* Useful for a strain gauge or piezo sensor that needs to factor out
* elements such as cables pulling on the carriage.
*/
//#define PROBE_TARE
#if ENABLED(PROBE_TARE)
#define PROBE_TARE_TIME 200 // (ms) Time to hold tare pin
#define PROBE_TARE_DELAY 200 // (ms) Delay after tare before
#define PROBE_TARE_STATE HIGH // State to write pin for tare
//#define PROBE_TARE_PIN PA5 // Override default pin
#if ENABLED(PROBE_ACTIVATION_SWITCH)
//#define PROBE_TARE_ONLY_WHILE_INACTIVE // Fail to tare/probe if PROBE_ACTIVATION_SWITCH is active
#endif
#endif
/** /**
* Multiple Probing * Multiple Probing
* *

@ -154,6 +154,7 @@
#define STR_Z4_MIN "z4_min" #define STR_Z4_MIN "z4_min"
#define STR_Z4_MAX "z4_max" #define STR_Z4_MAX "z4_max"
#define STR_Z_PROBE "z_probe" #define STR_Z_PROBE "z_probe"
#define STR_PROBE_EN "probe_en"
#define STR_FILAMENT_RUNOUT_SENSOR "filament" #define STR_FILAMENT_RUNOUT_SENSOR "filament"
#define STR_PROBE_OFFSET "Probe Offset" #define STR_PROBE_OFFSET "Probe Offset"
#define STR_SKEW_MIN "min_skew_factor: " #define STR_SKEW_MIN "min_skew_factor: "

@ -33,6 +33,7 @@
*/ */
void GcodeSuite::M401() { void GcodeSuite::M401() {
probe.deploy(); probe.deploy();
TERN_(PROBE_TARE, probe.tare());
report_current_position(); report_current_position();
} }

@ -1409,6 +1409,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "Z_SAFE_HOMING is recommended when homing with a probe. Enable it or comment out this line to continue." #error "Z_SAFE_HOMING is recommended when homing with a probe. Enable it or comment out this line to continue."
#endif #endif
#if ENABLED(PROBE_ACTIVATION_SWITCH)
#ifndef PROBE_ACTIVATION_SWITCH_STATE
#error "PROBE_ACTIVATION_SWITCH_STATE is required for PROBE_ACTIVATION_SWITCH."
#elif !PIN_EXISTS(PROBE_ACTIVATION_SWITCH)
#error "A PROBE_ACTIVATION_SWITCH_PIN is required for PROBE_ACTIVATION_SWITCH."
#endif
#endif
#else #else
/** /**

@ -280,6 +280,12 @@ void Endstops::init() {
#endif #endif
#endif #endif
#if ENABLED(PROBE_ACTIVATION_SWITCH)
SET_INPUT(PROBE_ACTIVATION_SWITCH_PIN);
#endif
TERN_(PROBE_TARE, probe.tare());
TERN_(ENDSTOP_INTERRUPTS_FEATURE, setup_endstop_interrupts()); TERN_(ENDSTOP_INTERRUPTS_FEATURE, setup_endstop_interrupts());
// Enable endstops // Enable endstops
@ -458,6 +464,9 @@ void _O2 Endstops::report_states() {
#if HAS_Z4_MAX #if HAS_Z4_MAX
ES_REPORT(Z4_MAX); ES_REPORT(Z4_MAX);
#endif #endif
#if BOTH(MARLIN_DEV_MODE, PROBE_ACTIVATION_SWITCH)
print_es_state(READ(PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE, PSTR(STR_PROBE_EN));
#endif
#if HAS_CUSTOM_PROBE_PIN #if HAS_CUSTOM_PROBE_PIN
print_es_state(PROBE_TRIGGERED(), PSTR(STR_Z_PROBE)); print_es_state(PROBE_TRIGGERED(), PSTR(STR_Z_PROBE));
#endif #endif
@ -582,7 +591,7 @@ void Endstops::update() {
#endif #endif
#endif #endif
#if HAS_Z_MIN && !Z_SPI_SENSORLESS #if HAS_Z_MIN && NONE(Z_SPI_SENSORLESS, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
UPDATE_ENDSTOP_BIT(Z, MIN); UPDATE_ENDSTOP_BIT(Z, MIN);
#if ENABLED(Z_MULTI_ENDSTOPS) #if ENABLED(Z_MULTI_ENDSTOPS)
#if HAS_Z2_MIN #if HAS_Z2_MIN
@ -607,9 +616,13 @@ void Endstops::update() {
#endif #endif
#endif #endif
// When closing the gap check the enabled probe #if HAS_BED_PROBE
#if HAS_CUSTOM_PROBE_PIN // When closing the gap check the enabled probe
UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); if (true
#if ENABLED(PROBE_ACTIVATION_SWITCH)
|| READ(PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE
#endif
) UPDATE_ENDSTOP_BIT(Z, TERN(HAS_CUSTOM_PROBE_PIN, MIN_PROBE, MIN));
#endif #endif
#if HAS_Z_MAX && !Z_SPI_SENSORLESS #if HAS_Z_MAX && !Z_SPI_SENSORLESS

@ -1589,8 +1589,11 @@ void homeaxis(const AxisEnum axis) {
// Fast move towards endstop until triggered // Fast move towards endstop until triggered
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:");
#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) #if HOMING_Z_WITH_PROBE
if (axis == Z_AXIS && bltouch.deploy()) return; // The initial DEPLOY if (axis == Z_AXIS) {
if (TERN0(BLTOUCH, bltouch.deploy())) return;
if (TERN0(PROBE_TARE, probe.tare())) return;
}
#endif #endif
#if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM) #if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM)

@ -512,6 +512,33 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
return !probe_triggered; return !probe_triggered;
} }
#if ENABLED(PROBE_TARE)
/**
* @brief Tare the Z probe
*
* @details Signal to the probe to tare itself
*
* @return TRUE if the tare cold not be completed
*/
bool Probe::tare() {
#if BOTH(PROBE_ACTIVATION_SWITCH, PROBE_TARE_ONLY_WHILE_INACTIVE)
if (READ(PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE) {
SERIAL_ECHOLNPGM("Cannot tare an active probe");
return true;
}
#endif
SERIAL_ECHOLNPGM("Taring probe");
OUT_WRITE(PROBE_TARE_PIN, PROBE_TARE_STATE);
delay(PROBE_TARE_TIME);
OUT_WRITE(PROBE_TARE_PIN, !PROBE_TARE_STATE);
delay(PROBE_TARE_DELAY);
endstops.hit_on_purpose();
return false;
}
#endif
/** /**
* @brief Probe at the current XY (possibly more than once) to find the bed Z. * @brief Probe at the current XY (possibly more than once) to find the bed Z.
* *
@ -523,8 +550,11 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
float Probe::run_z_probe(const bool sanity_check/*=true*/) { float Probe::run_z_probe(const bool sanity_check/*=true*/) {
DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING)); DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING));
auto try_to_probe = [&](PGM_P const plbl, const float &z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck, const float clearance) { auto try_to_probe = [&](PGM_P const plbl, const float &z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck, const float clearance) -> bool {
// Do a first probe at the fast speed // Do a first probe at the fast speed
if (TERN0(PROBE_TARE, tare())) return true;
const bool probe_fail = probe_down_to_z(z_probe_low_point, fr_mm_s), // No probe trigger? const bool probe_fail = probe_down_to_z(z_probe_low_point, fr_mm_s), // No probe trigger?
early_fail = (scheck && current_position.z > -offset.z + clearance); // Probe triggered too high? early_fail = (scheck && current_position.z > -offset.z + clearance); // Probe triggered too high?
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
@ -549,6 +579,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
#if TOTAL_PROBING == 2 #if TOTAL_PROBING == 2
// Do a first probe at the fast speed // Do a first probe at the fast speed
if (TERN0(PROBE_TARE, tare())) return NAN;
if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s, if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN; sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
@ -586,6 +618,9 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
) )
#endif #endif
{ {
// If the probe won't tare, return
if (TERN0(PROBE_TARE, tare())) return true;
// Probe downward slowly to find the bed // Probe downward slowly to find the bed
if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW), if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW),
sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN; sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN;

@ -210,6 +210,10 @@ public:
static void set_probing_paused(const bool p); static void set_probing_paused(const bool p);
#endif #endif
#if ENABLED(PROBE_TARE)
static bool tare();
#endif
private: private:
static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s); static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s);
static void do_z_raise(const float z_raise); static void do_z_raise(const float z_raise);

@ -19,3 +19,12 @@ opt_add SDCARD_EEPROM_EMULATION
exec_test $1 $2 "Ender 3 v2, SD EEPROM, w/o CLASSIC_JERK" "$3" exec_test $1 $2 "Ender 3 v2, SD EEPROM, w/o CLASSIC_JERK" "$3"
restore_configs restore_configs
opt_set SERIAL_PORT 1
opt_set MOTHERBOARD BOARD_CREALITY_V452
opt_disable NOZZLE_TO_PROBE_OFFSET
opt_enable NOZZLE_AS_PROBE Z_SAFE_HOMING Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
opt_enable PROBE_ACTIVATION_SWITCH PROBE_ACTIVATION_SWITCH_PIN PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE
exec_test $1 $2 "Creality V4.5.2 PROBE_ACTIVATION_SWITCH, Probe Tare" "$3"
# clean up
restore_configs

Loading…
Cancel
Save