Merge branch 'ProbesRequiringEnablePin' into CR-6Devel

This commit is contained in:
InsanityAutomation
2020-12-12 14:04:48 -05:00
7 changed files with 99 additions and 10 deletions
+23
View File
@@ -1006,6 +1006,29 @@
// Feedrate (mm/min) for the "accurate" probe of each point
#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
// Fail to probe if the probe does not indicate itself as active.
// This may be a switch indicating proper deployment, or an optical switch to report the carriage is near the bed.
//#define PROBE_ACTIVE_INPUT
#if ENABLED(PROBE_ACTIVE_INPUT)
#define PROBE_ACTIVE_INPUT_STATE LOW // State indicating probe is active
//#define PROBE_ACTIVE_INPUT_PIN PC6 // Override default pin
#endif
// Probe should be tared prior to each probe
// Useful for strain or piezo sensors which must exclude strain such
// as that from cables or bowden cables pulling on the carriage.
//#define PROBE_TARE
#if ENABLED(PROBE_TARE)
#define PROBE_TARE_TIME 200 // Time to hold tare pin (milliseconds)
#define PROBE_TARE_DELAY 200 // Delay after tare before (milliseconds)
#define PROBE_TARE_STATE HIGH // State to write pin for tare
//#define PROBE_TARE_PIN PA5 // Override default pin
#if ENABLED(PROBE_ACTIVE_INPUT)
// Fail to tare/probe if PROBE_ACTIVE_INPUT reports the probe to be active
//#define PROBE_TARE_ONLY_WHILE_INACTIVE
#endif
#endif
/**
* Multiple Probing
*
+14 -4
View File
@@ -280,6 +280,14 @@ void Endstops::init() {
#endif
#endif
#if PIN_EXISTS(PROBE_ACTIVE_INPUT)
SET_INPUT(PROBE_ACTIVE_INPUT_PIN);
#endif
#if ENABLED(PROBE_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 && NONE(Z_SPI_SENSORLESS, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
UPDATE_ENDSTOP_BIT(Z, MIN);
#if ENABLED(Z_MULTI_ENDSTOPS)
#if HAS_Z2_MIN
@@ -607,10 +615,12 @@ void Endstops::update() {
#endif
#endif
// When closing the gap check the enabled probe
#if HAS_CUSTOM_PROBE_PIN
UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
#if ENABLED(PROBE_ACTIVE_INPUT)
if (READ(PROBE_ACTIVE_INPUT_PIN) == PROBE_ACTIVE_INPUT_STATE)
#endif
{
UPDATE_ENDSTOP_BIT(Z, TERN(HAS_CUSTOM_PROBE_PIN, MIN_PROBE, MIN));
}
#if HAS_Z_MAX && !Z_SPI_SENSORLESS
// Check both Z dual endstops
+8 -3
View File
@@ -1599,9 +1599,14 @@ void homeaxis(const AxisEnum axis) {
// Fast move towards endstop until triggered
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:");
#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
if (axis == Z_AXIS && bltouch.deploy()) return; // The initial DEPLOY
#endif
if (axis == Z_AXIS) {
#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
if (bltouch.deploy()) return; // The initial DEPLOY
#endif
#if BOTH(HOMING_Z_WITH_PROBE, PROBE_TARE)
if (probe.tare_z_probe()) return;
#endif
}
#if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM)
const xy_float_t backoff = SENSORLESS_BACKOFF_MM;
+40 -1
View File
@@ -502,6 +502,33 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
return !probe_triggered;
}
#if ENABLED(PROBE_TARE)
/**
* @brief Tare the Z probe
*
* @details Signals to the probe to tare measurement
*
* @return TRUE if the tare cold not be completed
*/
bool Probe::tare_z_probe() {
#if ENABLED(PROBE_TARE_ONLY_WHILE_INACTIVE)
if ((READ(PROBE_ACTIVE_INPUT_PIN) == PROBE_ACTIVE_INPUT_STATE)) {
SERIAL_ECHOLN("Cannot tare probe, already active");
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.
*
@@ -513,8 +540,13 @@ 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*/) {
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
#if ENABLED(PROBE_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)
@@ -539,6 +571,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_TARE)
if(tare_z_probe()) return NAN;
#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;
@@ -577,6 +613,9 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
#endif
{
// Probe downward slowly to find the bed
#if ENABLED(PROBE_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_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);
+1 -1
View File
@@ -69,7 +69,7 @@
// Probe
//
#define PROBE_TARE_PIN PA5
#define PROBE_ENABLE_PIN PC6 // Optoswitch to Enable Z Probe
#define PROBE_ACTIVE_INPUT_PIN PC6 // Optoswitch to indicate probe is near bed (active)
//
// Steppers
+9 -1
View File
@@ -12,10 +12,18 @@ set -e
use_example_configs "Creality/Ender-3 V2"
opt_enable MARLIN_DEV_MODE
exec_test $1 $2 "Ender 3 v2" "$3"
restore_configs
use_example_configs "Creality/Ender-3 V2"
opt_disable CLASSIC_JERK
opt_add SDCARD_EEPROM_EMULATION
exec_test $1 $2 "Ender 3 v2, SD EEPROM, w/o CLASSIC_JERK" "$3"
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_ACTIVE_INPUT PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE
exec_test $1 $2 "Creality V4.5.2 PROBE_ACTIVE_INPUT, PROBE_TARE_ONLY_WHILE_INACTIVE" "$3"
restore_configs