Browse Source

Option for extra endstop check (#18424)

Speaka 4 years ago
parent
commit
2c238e4fc2
No account linked to committer's email address

+ 3
- 0
Marlin/Configuration.h View File

@@ -719,6 +719,9 @@
719 719
  */
720 720
 //#define ENDSTOP_NOISE_THRESHOLD 2
721 721
 
722
+// Check for stuck or disconnected endstops during homing moves.
723
+//#define DETECT_BROKEN_ENDSTOP
724
+
722 725
 //=============================================================================
723 726
 //============================== Movement Settings ============================
724 727
 //=============================================================================

+ 6
- 10
Marlin/src/module/endstops.cpp View File

@@ -861,10 +861,6 @@ void Endstops::update() {
861 861
 
862 862
 #if ENABLED(SPI_ENDSTOPS)
863 863
 
864
-  #define X_STOP (X_HOME_DIR < 0 ? X_MIN : X_MAX)
865
-  #define Y_STOP (Y_HOME_DIR < 0 ? Y_MIN : Y_MAX)
866
-  #define Z_STOP (Z_HOME_DIR < 0 ? Z_MIN : Z_MAX)
867
-
868 864
   bool Endstops::tmc_spi_homing_check() {
869 865
     bool hit = false;
870 866
     #if X_SPI_SENSORLESS
@@ -875,7 +871,7 @@ void Endstops::update() {
875 871
           || stepperZ.test_stall_status()
876 872
         #endif
877 873
       )) {
878
-        SBI(live_state, X_STOP);
874
+        SBI(live_state, X_ENDSTOP);
879 875
         hit = true;
880 876
       }
881 877
     #endif
@@ -887,7 +883,7 @@ void Endstops::update() {
887 883
           || stepperZ.test_stall_status()
888 884
         #endif
889 885
       )) {
890
-        SBI(live_state, Y_STOP);
886
+        SBI(live_state, Y_ENDSTOP);
891 887
         hit = true;
892 888
       }
893 889
     #endif
@@ -899,7 +895,7 @@ void Endstops::update() {
899 895
           || stepperY.test_stall_status()
900 896
         #endif
901 897
       )) {
902
-        SBI(live_state, Z_STOP);
898
+        SBI(live_state, Z_ENDSTOP);
903 899
         hit = true;
904 900
       }
905 901
     #endif
@@ -907,9 +903,9 @@ void Endstops::update() {
907 903
   }
908 904
 
909 905
   void Endstops::clear_endstop_state() {
910
-    TERN_(X_SPI_SENSORLESS, CBI(live_state, X_STOP));
911
-    TERN_(Y_SPI_SENSORLESS, CBI(live_state, Y_STOP));
912
-    TERN_(Z_SPI_SENSORLESS, CBI(live_state, Z_STOP));
906
+    TERN_(X_SPI_SENSORLESS, CBI(live_state, X_ENDSTOP));
907
+    TERN_(Y_SPI_SENSORLESS, CBI(live_state, Y_ENDSTOP));
908
+    TERN_(Z_SPI_SENSORLESS, CBI(live_state, Z_ENDSTOP));
913 909
   }
914 910
 
915 911
 #endif // SPI_ENDSTOPS

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

@@ -38,6 +38,10 @@ enum EndstopEnum : char {
38 38
   Z4_MIN, Z4_MAX
39 39
 };
40 40
 
41
+#define X_ENDSTOP (X_HOME_DIR < 0 ? X_MIN : X_MAX)
42
+#define Y_ENDSTOP (Y_HOME_DIR < 0 ? Y_MIN : Y_MAX)
43
+#define Z_ENDSTOP (Z_HOME_DIR < 0 ? TERN(HOMING_Z_WITH_PROBE, Z_MIN, Z_MIN_PROBE) : Z_MAX)
44
+
41 45
 class Endstops {
42 46
   public:
43 47
     #if HAS_EXTRA_ENDSTOPS

+ 15
- 0
Marlin/src/module/motion.cpp View File

@@ -1606,6 +1606,21 @@ void homeaxis(const AxisEnum axis) {
1606 1606
       #endif
1607 1607
     );
1608 1608
 
1609
+    #if ENABLED(DETECT_BROKEN_ENDSTOP)
1610
+      // Check for a broken endstop
1611
+      EndstopEnum es;
1612
+      switch (axis) {
1613
+        default:
1614
+        case X_AXIS: es = X_ENDSTOP; break;
1615
+        case Y_AXIS: es = Y_ENDSTOP; break;
1616
+        case Z_AXIS: es = Z_ENDSTOP; break;
1617
+      }
1618
+      if (TEST(endstops.state(), es)) {
1619
+        SERIAL_ECHO_MSG("Bad ", axis_codes[axis], " Endstop?");
1620
+        kill(GET_TEXT(MSG_KILL_HOMING_FAILED));
1621
+      }
1622
+    #endif
1623
+
1609 1624
     // Slow move towards endstop until triggered
1610 1625
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 2 Slow:");
1611 1626
 

+ 1
- 1
buildroot/tests/mega2560-tests View File

@@ -71,7 +71,7 @@ opt_set NUM_SERVOS 1
71 71
 opt_enable ZONESTAR_LCD Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE BOOT_MARLIN_LOGO_ANIMATED \
72 72
            AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \
73 73
            NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \
74
-           PRUSA_MMU2 MMU2_MENUS PRUSA_MMU2_S_MODE DIRECT_STEPPING \
74
+           PRUSA_MMU2 MMU2_MENUS PRUSA_MMU2_S_MODE DIRECT_STEPPING DETECT_BROKEN_ENDSTOP \
75 75
            FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING
76 76
 exec_test $1 $2 "RAMPS | ZONESTAR + Chinese | MMU2 | Servo | 3-Point + Debug | G38 ..."
77 77
 

Loading…
Cancel
Save