Browse Source

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>
InsanityAutomation 3 years ago
parent
commit
2963229dfa
No account linked to committer's email address

+ 27
- 0
Marlin/Configuration.h View File

@@ -1007,6 +1007,33 @@
1007 1007
 #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
1008 1008
 
1009 1009
 /**
1010
+ * Probe Activation Switch
1011
+ * A switch indicating proper deployment, or an optical
1012
+ * switch triggered when the carriage is near the bed.
1013
+ */
1014
+//#define PROBE_ACTIVATION_SWITCH
1015
+#if ENABLED(PROBE_ACTIVATION_SWITCH)
1016
+  #define PROBE_ACTIVATION_SWITCH_STATE LOW // State indicating probe is active
1017
+  //#define PROBE_ACTIVATION_SWITCH_PIN PC6 // Override default pin
1018
+#endif
1019
+
1020
+/**
1021
+ * Tare Probe (determine zero-point) prior to each probe.
1022
+ * Useful for a strain gauge or piezo sensor that needs to factor out
1023
+ * elements such as cables pulling on the carriage.
1024
+ */
1025
+//#define PROBE_TARE
1026
+#if ENABLED(PROBE_TARE)
1027
+  #define PROBE_TARE_TIME  200    // (ms) Time to hold tare pin
1028
+  #define PROBE_TARE_DELAY 200    // (ms) Delay after tare before
1029
+  #define PROBE_TARE_STATE HIGH   // State to write pin for tare
1030
+  //#define PROBE_TARE_PIN PA5    // Override default pin
1031
+  #if ENABLED(PROBE_ACTIVATION_SWITCH)
1032
+    //#define PROBE_TARE_ONLY_WHILE_INACTIVE  // Fail to tare/probe if PROBE_ACTIVATION_SWITCH is active
1033
+  #endif
1034
+#endif
1035
+
1036
+/**
1010 1037
  * Multiple Probing
1011 1038
  *
1012 1039
  * You may get improved results by probing 2 or more times.

+ 1
- 0
Marlin/src/core/language.h View File

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

+ 1
- 0
Marlin/src/gcode/probe/M401_M402.cpp View File

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

+ 8
- 0
Marlin/src/inc/SanityCheck.h View File

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

+ 17
- 4
Marlin/src/module/endstops.cpp View File

@@ -280,6 +280,12 @@ void Endstops::init() {
280 280
     #endif
281 281
   #endif
282 282
 
283
+  #if ENABLED(PROBE_ACTIVATION_SWITCH)
284
+    SET_INPUT(PROBE_ACTIVATION_SWITCH_PIN);
285
+  #endif
286
+
287
+  TERN_(PROBE_TARE, probe.tare());
288
+
283 289
   TERN_(ENDSTOP_INTERRUPTS_FEATURE, setup_endstop_interrupts());
284 290
 
285 291
   // Enable endstops
@@ -458,6 +464,9 @@ void _O2 Endstops::report_states() {
458 464
   #if HAS_Z4_MAX
459 465
     ES_REPORT(Z4_MAX);
460 466
   #endif
467
+  #if BOTH(MARLIN_DEV_MODE, PROBE_ACTIVATION_SWITCH)
468
+    print_es_state(READ(PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE, PSTR(STR_PROBE_EN));
469
+  #endif
461 470
   #if HAS_CUSTOM_PROBE_PIN
462 471
     print_es_state(PROBE_TRIGGERED(), PSTR(STR_Z_PROBE));
463 472
   #endif
@@ -582,7 +591,7 @@ void Endstops::update() {
582 591
     #endif
583 592
   #endif
584 593
 
585
-  #if HAS_Z_MIN && !Z_SPI_SENSORLESS
594
+  #if HAS_Z_MIN && NONE(Z_SPI_SENSORLESS, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
586 595
     UPDATE_ENDSTOP_BIT(Z, MIN);
587 596
     #if ENABLED(Z_MULTI_ENDSTOPS)
588 597
       #if HAS_Z2_MIN
@@ -607,9 +616,13 @@ void Endstops::update() {
607 616
     #endif
608 617
   #endif
609 618
 
610
-  // When closing the gap check the enabled probe
611
-  #if HAS_CUSTOM_PROBE_PIN
612
-    UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
619
+  #if HAS_BED_PROBE
620
+    // When closing the gap check the enabled probe
621
+    if (true
622
+      #if ENABLED(PROBE_ACTIVATION_SWITCH)
623
+        || READ(PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE
624
+      #endif
625
+    ) UPDATE_ENDSTOP_BIT(Z, TERN(HAS_CUSTOM_PROBE_PIN, MIN_PROBE, MIN));
613 626
   #endif
614 627
 
615 628
   #if HAS_Z_MAX && !Z_SPI_SENSORLESS

+ 5
- 2
Marlin/src/module/motion.cpp View File

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

+ 36
- 1
Marlin/src/module/probe.cpp View File

@@ -512,6 +512,33 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
512 512
   return !probe_triggered;
513 513
 }
514 514
 
515
+#if ENABLED(PROBE_TARE)
516
+  /**
517
+   * @brief Tare the Z probe
518
+   *
519
+   * @details Signal to the probe to tare itself
520
+   *
521
+   * @return TRUE if the tare cold not be completed
522
+   */
523
+  bool Probe::tare() {
524
+    #if BOTH(PROBE_ACTIVATION_SWITCH, PROBE_TARE_ONLY_WHILE_INACTIVE)
525
+      if (READ(PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE) {
526
+        SERIAL_ECHOLNPGM("Cannot tare an active probe");
527
+        return true;
528
+      }
529
+    #endif
530
+
531
+    SERIAL_ECHOLNPGM("Taring probe");
532
+    OUT_WRITE(PROBE_TARE_PIN, PROBE_TARE_STATE);
533
+    delay(PROBE_TARE_TIME);
534
+    OUT_WRITE(PROBE_TARE_PIN, !PROBE_TARE_STATE);
535
+    delay(PROBE_TARE_DELAY);
536
+
537
+    endstops.hit_on_purpose();
538
+    return false;
539
+  }
540
+#endif
541
+
515 542
 /**
516 543
  * @brief Probe at the current XY (possibly more than once) to find the bed Z.
517 544
  *
@@ -523,8 +550,11 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
523 550
 float Probe::run_z_probe(const bool sanity_check/*=true*/) {
524 551
   DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING));
525 552
 
526
-  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) {
553
+  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 {
527 554
     // Do a first probe at the fast speed
555
+
556
+    if (TERN0(PROBE_TARE, tare())) return true;
557
+
528 558
     const bool probe_fail = probe_down_to_z(z_probe_low_point, fr_mm_s),            // No probe trigger?
529 559
                early_fail = (scheck && current_position.z > -offset.z + clearance); // Probe triggered too high?
530 560
     #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -549,6 +579,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
549 579
   #if TOTAL_PROBING == 2
550 580
 
551 581
     // Do a first probe at the fast speed
582
+    if (TERN0(PROBE_TARE, tare())) return NAN;
583
+
552 584
     if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
553 585
                      sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
554 586
 
@@ -586,6 +618,9 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
586 618
     )
587 619
   #endif
588 620
     {
621
+      // If the probe won't tare, return
622
+      if (TERN0(PROBE_TARE, tare())) return true;
623
+
589 624
       // Probe downward slowly to find the bed
590 625
       if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW),
591 626
                        sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN;

+ 4
- 0
Marlin/src/module/probe.h View File

@@ -210,6 +210,10 @@ public:
210 210
     static void set_probing_paused(const bool p);
211 211
   #endif
212 212
 
213
+  #if ENABLED(PROBE_TARE)
214
+    static bool tare();
215
+  #endif
216
+
213 217
 private:
214 218
   static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s);
215 219
   static void do_z_raise(const float z_raise);

+ 9
- 0
buildroot/tests/STM32F103RET6_creality-tests View File

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

Loading…
Cancel
Save