Kaynağa Gözat

Split the software endstop capability by axis.

Based on #7975 and #7979
Scott Lahteine 6 yıl önce
ebeveyn
işleme
060d16d26b
4 değiştirilmiş dosya ile 89 ekleme ve 29 silme
  1. 22
    2
      Marlin/Configuration.h
  2. 20
    17
      Marlin/Marlin_main.cpp
  3. 19
    0
      Marlin/SanityCheck.h
  4. 28
    10
      Marlin/ultralcd.cpp

+ 22
- 2
Marlin/Configuration.h Dosyayı Görüntüle

@@ -785,10 +785,30 @@
785 785
 #define Y_MAX_POS Y_BED_SIZE
786 786
 #define Z_MAX_POS 200
787 787
 
788
-// If enabled, axes won't move below MIN_POS in response to movement commands.
788
+/**
789
+ * Software Endstops
790
+ *
791
+ * - Prevent moves outside the set machine bounds.
792
+ * - Individual axes can be disabled, if desired.
793
+ * - X and Y only apply to Cartesian robots.
794
+ * - Use 'M211' to set software endstops on/off or report current state
795
+ */
796
+
797
+// Min software endstops curtail movement below minimum coordinate bounds
789 798
 #define MIN_SOFTWARE_ENDSTOPS
790
-// If enabled, axes won't move above MAX_POS in response to movement commands.
799
+#if ENABLED(MIN_SOFTWARE_ENDSTOPS)
800
+  #define MIN_SOFTWARE_ENDSTOP_X
801
+  #define MIN_SOFTWARE_ENDSTOP_Y
802
+  #define MIN_SOFTWARE_ENDSTOP_Z
803
+#endif
804
+
805
+// Max software endstops curtail movement above maximum coordinate bounds
791 806
 #define MAX_SOFTWARE_ENDSTOPS
807
+#if ENABLED(MAX_SOFTWARE_ENDSTOPS)
808
+  #define MAX_SOFTWARE_ENDSTOP_X
809
+  #define MAX_SOFTWARE_ENDSTOP_Y
810
+  #define MAX_SOFTWARE_ENDSTOP_Z
811
+#endif
792 812
 
793 813
 /**
794 814
  * Filament Runout Sensor

+ 20
- 17
Marlin/Marlin_main.cpp Dosyayı Görüntüle

@@ -11719,27 +11719,30 @@ void ok_to_send() {
11719 11719
    * Constrain the given coordinates to the software endstops.
11720 11720
    */
11721 11721
 
11722
-  // NOTE: This makes no sense for delta beds other than Z-axis.
11723
-  //       For delta the X/Y would need to be clamped at
11724
-  //       DELTA_PRINTABLE_RADIUS from center of bed, but delta
11725
-  //       now enforces is_position_reachable for X/Y regardless
11726
-  //       of HAS_SOFTWARE_ENDSTOPS, so that enforcement would be
11727
-  //       redundant here.
11728
-
11722
+  /**
11723
+   * Constrain the given coordinates to the software endstops.
11724
+   *
11725
+   * NOTE: This will only apply to Z on DELTA and SCARA. XY is
11726
+   *       constrained to a circle on these kinematic systems.
11727
+   */
11729 11728
   void clamp_to_software_endstops(float target[XYZ]) {
11730 11729
     if (!soft_endstops_enabled) return;
11731
-    #if ENABLED(MIN_SOFTWARE_ENDSTOPS)
11732
-      #if DISABLED(DELTA)
11733
-        NOLESS(target[X_AXIS], soft_endstop_min[X_AXIS]);
11734
-        NOLESS(target[Y_AXIS], soft_endstop_min[Y_AXIS]);
11735
-      #endif
11730
+    #if ENABLED(MIN_SOFTWARE_ENDSTOP_X)
11731
+      NOLESS(target[X_AXIS], soft_endstop_min[X_AXIS]);
11732
+    #endif
11733
+    #if ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
11734
+      NOLESS(target[Y_AXIS], soft_endstop_min[Y_AXIS]);
11735
+    #endif
11736
+    #if ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
11736 11737
       NOLESS(target[Z_AXIS], soft_endstop_min[Z_AXIS]);
11737 11738
     #endif
11738
-    #if ENABLED(MAX_SOFTWARE_ENDSTOPS)
11739
-      #if DISABLED(DELTA)
11740
-        NOMORE(target[X_AXIS], soft_endstop_max[X_AXIS]);
11741
-        NOMORE(target[Y_AXIS], soft_endstop_max[Y_AXIS]);
11742
-      #endif
11739
+    #if ENABLED(MAX_SOFTWARE_ENDSTOP_X)
11740
+      NOMORE(target[X_AXIS], soft_endstop_max[X_AXIS]);
11741
+    #endif
11742
+    #if ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
11743
+      NOMORE(target[Y_AXIS], soft_endstop_max[Y_AXIS]);
11744
+    #endif
11745
+    #if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
11743 11746
       NOMORE(target[Z_AXIS], soft_endstop_max[Z_AXIS]);
11744 11747
     #endif
11745 11748
   }

+ 19
- 0
Marlin/SanityCheck.h Dosyayı Görüntüle

@@ -255,6 +255,25 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE,
255 255
   "Movement bounds ([XY]_MIN_POS, [XY]_MAX_POS) are too narrow to contain [XY]_BED_SIZE.");
256 256
 
257 257
 /**
258
+ * Granular software endstops (Marlin >= 1.1.7)
259
+ */
260
+#if ENABLED(MIN_SOFTWARE_ENDSTOPS) && DISABLED(MIN_SOFTWARE_ENDSTOP_Z)
261
+  #if IS_KINEMATIC
262
+    #error "MIN_SOFTWARE_ENDSTOPS on DELTA/SCARA also requires MIN_SOFTWARE_ENDSTOP_Z."
263
+  #elif DISABLED(MIN_SOFTWARE_ENDSTOP_X) && DISABLED(MIN_SOFTWARE_ENDSTOP_Y)
264
+    #error "MIN_SOFTWARE_ENDSTOPS requires at least one of the MIN_SOFTWARE_ENDSTOP_[XYZ] options."
265
+  #endif
266
+#endif
267
+
268
+#if ENABLED(MAX_SOFTWARE_ENDSTOPS) && DISABLED(MAX_SOFTWARE_ENDSTOP_Z)
269
+  #if IS_KINEMATIC
270
+    #error "MAX_SOFTWARE_ENDSTOPS on DELTA/SCARA also requires MAX_SOFTWARE_ENDSTOP_Z."
271
+  #elif DISABLED(MAX_SOFTWARE_ENDSTOP_X) && DISABLED(MAX_SOFTWARE_ENDSTOP_Y)
272
+    #error "MAX_SOFTWARE_ENDSTOPS requires at least one of the MAX_SOFTWARE_ENDSTOP_[XYZ] options."
273
+  #endif
274
+#endif
275
+
276
+/**
258 277
  * Progress Bar
259 278
  */
260 279
 #if ENABLED(LCD_PROGRESS_BAR)

+ 28
- 10
Marlin/ultralcd.cpp Dosyayı Görüntüle

@@ -2845,17 +2845,35 @@ void kill_screen(const char* lcd_msg) {
2845 2845
       float min = current_position[axis] - 1000,
2846 2846
             max = current_position[axis] + 1000;
2847 2847
 
2848
-      #if HAS_SOFTWARE_ENDSTOPS
2849
-        // Limit to software endstops, if enabled
2850
-        if (soft_endstops_enabled) {
2851
-          #if ENABLED(MIN_SOFTWARE_ENDSTOPS)
2852
-            min = soft_endstop_min[axis];
2853
-          #endif
2854
-          #if ENABLED(MAX_SOFTWARE_ENDSTOPS)
2855
-            max = soft_endstop_max[axis];
2856
-          #endif
2848
+      // Limit to software endstops, if enabled
2849
+      #if ENABLED(MIN_SOFTWARE_ENDSTOPS) || ENABLED(MAX_SOFTWARE_ENDSTOPS)
2850
+        if (soft_endstops_enabled) switch (axis) {
2851
+          case X_AXIS:
2852
+            #if ENABLED(MIN_SOFTWARE_ENDSTOP_X)
2853
+              min = soft_endstop_min[X_AXIS];
2854
+            #endif
2855
+            #if ENABLED(MAX_SOFTWARE_ENDSTOP_X)
2856
+              max = soft_endstop_max[X_AXIS];
2857
+            #endif
2858
+            break;
2859
+          case Y_AXIS:
2860
+            #if ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
2861
+              min = soft_endstop_min[Y_AXIS];
2862
+            #endif
2863
+            #if ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
2864
+              max = soft_endstop_max[Y_AXIS];
2865
+            #endif
2866
+            break;
2867
+          case Z_AXIS:
2868
+            #if ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
2869
+              min = soft_endstop_min[Z_AXIS];
2870
+            #endif
2871
+            #if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
2872
+              max = soft_endstop_max[Z_AXIS];
2873
+            #endif
2874
+            break;
2857 2875
         }
2858
-      #endif
2876
+      #endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
2859 2877
 
2860 2878
       // Delta limits XY based on the current offset from center
2861 2879
       // This assumes the center is 0,0

Loading…
İptal
Kaydet