Add initial support for probes requiring Tare and Enable pins

This commit is contained in:
InsanityAutomation
2020-12-05 15:50:07 -05:00
parent e8ed880e62
commit 750bc64202
5 changed files with 82 additions and 3 deletions
+22
View File
@@ -996,6 +996,28 @@
// Feedrate (mm/min) for the "accurate" probe of each point
#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
// For probes that require an explicit enable input such as feedback an arm is deployed or an opto switch reporting in-range
//#define PROBE_NEEDS_ENABLE
#if ENABLED(PROBE_NEEDS_ENABLE)
#define PROBE_NEEDS_ENABLE_STATE LOW
#endif
//#define PROBE_ENABLE_PIN PC6 // Override default probe enable pin
// Probe requires Tare - Usefull for Strain guage or Piezo type probes which may see force from cabling or bowden tubes following moves
//#define PROBE_NEEDS_TARE
#if ENABLED(PROBE_NEEDS_TARE)
#define PROBE_TARE_TIME 200 // Time to hold tare pin
#define PROBE_TARE_DELAY 200 // Dwell following tare before continuing
#define PROBE_TARE_STATE HIGH // State to write pin for tare
//#define PROBE_TARE_PIN PA5 // Override default Tare pin
#if ENABLED(PROBE_NEEDS_ENABLE)
// Assume probe enable will come on in a Z window rather than detecting probe deployment.
// Useful when TARE can be assured outside enable range to avoid potential crash situations.
// Prevents tare unless enable switch is off
//#define PROBE_ENABLE_WINDOW
#endif
#endif
/**
* Multiple Probing
*
+19 -2
View File
@@ -280,6 +280,14 @@ void Endstops::init() {
#endif
#endif
#if PIN_EXISTS(PROBE_ENABLE_PIN)
SET_INPUT(PROBE_ENABLE_PIN)
#endif
#if ENABLED(PROBE_NEEDS_TARE)
probe.tare_z_probe();
#endif
TERN_(ENDSTOP_INTERRUPTS_FEATURE, setup_endstop_interrupts());
// Enable endstops
@@ -582,7 +590,7 @@ void Endstops::update() {
#endif
#endif
#if HAS_Z_MIN && !Z_SPI_SENSORLESS
#if HAS_Z_MIN && !Z_SPI_SENSORLESS && DISABLED(PROBE_NEEDS_ENABLE)
UPDATE_ENDSTOP_BIT(Z, MIN);
#if ENABLED(Z_MULTI_ENDSTOPS)
#if HAS_Z2_MIN
@@ -608,10 +616,19 @@ void Endstops::update() {
#endif
// When closing the gap check the enabled probe
#if HAS_CUSTOM_PROBE_PIN
#if HAS_CUSTOM_PROBE_PIN && DISABLED(PROBE_NEEDS_ENABLE)
UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
#endif
#if ENABLED(PROBE_NEEDS_ENABLE)
#if HAS_CUSTOM_PROBE_PIN
UPDATE_ENDSTOP_BIT(Z, MIN);
SET_BIT_TO(live_state, _ENDSTOP(Z, MIN), ((READ(_ENDSTOP_PIN(Z, MIN)) != _ENDSTOP_INVERTING(Z, MIN_PROBE) && (READ(PROBE_ENABLE_PIN) == PROBE_NEEDS_ENABLE_STATE))));
#else
SET_BIT_TO(live_state, _ENDSTOP(Z, MIN), ((READ(_ENDSTOP_PIN(Z, MIN)) != _ENDSTOP_INVERTING(Z, MIN) && (READ(PROBE_ENABLE_PIN) == PROBE_NEEDS_ENABLE_STATE))));
#endif
#endif
#if HAS_Z_MAX && !Z_SPI_SENSORLESS
// Check both Z dual endstops
#if ENABLED(Z_MULTI_ENDSTOPS)
+4
View File
@@ -1603,6 +1603,10 @@ void homeaxis(const AxisEnum axis) {
if (axis == Z_AXIS && bltouch.deploy()) return; // The initial DEPLOY
#endif
#if ENABLED(PROBE_NEEDS_TARE)
if (probe.tare_z_probe()) return;
#endif
#if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM)
const xy_float_t backoff = SENSORLESS_BACKOFF_MM;
if (((ENABLED(X_SENSORLESS) && axis == X_AXIS) || (ENABLED(Y_SENSORLESS) && axis == Y_AXIS)) && backoff[axis])
+33 -1
View File
@@ -479,6 +479,26 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
return !probe_triggered;
}
#if ENABLED(PROBE_NEEDS_TARE)
bool Probe::tare_z_probe() {
#if ENABLED(PROBE_ENABLE_WINDOW)
if ((READ(PROBE_ENABLE_PIN) == PROBE_NEEDS_ENABLE_STATE)) {
SERIAL_ECHOLN("Cannot tare probe, already Enabled");
return true;
}
#endif
SERIAL_ECHOLN("Taring the probe");
WRITE(PROBE_TARE_PIN, PROBE_TARE_STATE);
delay(PROBE_TARE_TIME);
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.
*
@@ -492,6 +512,11 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
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) {
// Do a first probe at the fast speed
#if ENABLED(PROBE_NEEDS_TARE)
if(tare_z_probe()) return true;
#endif
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?
#if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -505,7 +530,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
#else
UNUSED(plbl);
#endif
return probe_fail || early_fail;
return (int)(probe_fail || early_fail);
};
// Stop the probe before it goes too low to prevent damage.
@@ -516,6 +541,10 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
#if TOTAL_PROBING == 2
// Do a first probe at the fast speed
#if ENABLED(PROBE_NEEDS_TARE)
if(tare_z_probe()) return true;
#endif
if (try_to_probe(PSTR("FAST"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST),
sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
@@ -554,6 +583,9 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
#endif
{
// Probe downward slowly to find the bed
#if ENABLED(PROBE_NEEDS_TARE)
if(tare_z_probe()) return true;
#endif
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;
+4
View File
@@ -206,6 +206,10 @@ public:
static void set_probing_paused(const bool p);
#endif
#if ENABLED(PROBE_NEEDS_TARE)
static bool tare_z_probe();
#endif
private:
static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s);
static void do_z_raise(const float z_raise);