瀏覽代碼

Merge pull request #4856 from thinkyhead/rc_bltouch_update

Fix and extend BLTouch support
Scott Lahteine 8 年之前
父節點
當前提交
82b0014f5e
共有 5 個檔案被更改,包括 59 行新增20 行删除
  1. 13
    2
      Marlin/Conditionals_LCD.h
  2. 29
    3
      Marlin/Marlin_main.cpp
  3. 0
    9
      Marlin/enum.h
  4. 5
    2
      Marlin/language_en.h
  5. 12
    4
      Marlin/ultralcd.cpp

+ 13
- 2
Marlin/Conditionals_LCD.h 查看文件

@@ -318,6 +318,7 @@
318 318
 
319 319
   /**
320 320
    * The BLTouch Probe emulates a servo probe
321
+   * and uses "special" angles for its state.
321 322
    */
322 323
   #if ENABLED(BLTOUCH)
323 324
     #ifndef Z_ENDSTOP_SERVO_NR
@@ -326,12 +327,22 @@
326 327
     #ifndef NUM_SERVOS
327 328
       #define NUM_SERVOS (Z_ENDSTOP_SERVO_NR + 1)
328 329
     #endif
329
-    #undef Z_SERVO_ANGLES
330
-    #define Z_SERVO_ANGLES {10,90} // For BLTouch 10=deploy, 90=retract
331 330
     #undef DEACTIVATE_SERVOS_AFTER_MOVE
331
+    #undef Z_SERVO_ANGLES
332
+    #define Z_SERVO_ANGLES { BLTOUCH_DEPLOY, BLTOUCH_STOW }
333
+
334
+    #define BLTOUCH_DEPLOY    10
335
+    #define BLTOUCH_STOW   90
336
+    #define BLTOUCH_SELFTEST 120
337
+    #define BLTOUCH_RELEASE  160
338
+    #define _TEST_BLTOUCH(P) (READ(P##_PIN) != P##_ENDSTOP_INVERTING)
339
+
332 340
     #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
333 341
       #undef Z_MIN_ENDSTOP_INVERTING
334 342
       #define Z_MIN_ENDSTOP_INVERTING false
343
+      #define TEST_BLTOUCH() _TEST_BLTOUCH(Z_MIN)
344
+    #else
345
+      #define TEST_BLTOUCH() _TEST_BLTOUCH(Z_MIN_PROBE)
335 346
     #endif
336 347
   #endif
337 348
 

+ 29
- 3
Marlin/Marlin_main.cpp 查看文件

@@ -1866,6 +1866,12 @@ static void clean_up_after_endstop_or_probe_move() {
1866 1866
   #define DEPLOY_PROBE() set_probe_deployed(true)
1867 1867
   #define STOW_PROBE() set_probe_deployed(false)
1868 1868
 
1869
+  #if ENABLED(BLTOUCH)
1870
+    FORCE_INLINE void set_bltouch_deployed(const bool &deploy) {
1871
+      servo[Z_ENDSTOP_SERVO_NR].move(deploy ? BLTOUCH_DEPLOY : BLTOUCH_STOW);
1872
+    }
1873
+  #endif
1874
+
1869 1875
   // returns false for ok and true for failure
1870 1876
   static bool set_probe_deployed(bool deploy) {
1871 1877
 
@@ -1881,9 +1887,9 @@ static void clean_up_after_endstop_or_probe_move() {
1881 1887
     // Make room for probe
1882 1888
     do_probe_raise(_Z_PROBE_DEPLOY_HEIGHT);
1883 1889
 
1884
-    // Check BLTOUCH probe status for an error
1890
+    // When deploying make sure BLTOUCH is not already triggered
1885 1891
     #if ENABLED(BLTOUCH)
1886
-      if (servo[Z_ENDSTOP_SERVO_NR].read() == BLTouchState_Error) { stop(); return true; }
1892
+      if (deploy && TEST_BLTOUCH()) { stop(); return true; }
1887 1893
     #endif
1888 1894
 
1889 1895
     #if ENABLED(Z_PROBE_SLED)
@@ -1911,7 +1917,7 @@ static void clean_up_after_endstop_or_probe_move() {
1911 1917
 
1912 1918
           dock_sled(!deploy);
1913 1919
 
1914
-        #elif HAS_Z_SERVO_ENDSTOP
1920
+        #elif HAS_Z_SERVO_ENDSTOP && DISABLED(BLTOUCH)
1915 1921
 
1916 1922
           servo[Z_ENDSTOP_SERVO_NR].move(z_servo_angle[deploy ? 0 : 1]);
1917 1923
 
@@ -1948,9 +1954,19 @@ static void clean_up_after_endstop_or_probe_move() {
1948 1954
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
1949 1955
     #endif
1950 1956
 
1957
+    // Deploy BLTouch at the start of any probe
1958
+    #if ENABLED(BLTOUCH)
1959
+      set_bltouch_deployed(true);
1960
+    #endif
1961
+
1951 1962
     // Move down until probe triggered
1952 1963
     do_blocking_move_to_z(LOGICAL_Z_POSITION(z), MMM_TO_MMS(fr_mm_m));
1953 1964
 
1965
+    // Retract BLTouch immediately after a probe
1966
+    #if ENABLED(BLTOUCH)
1967
+      set_bltouch_deployed(false);
1968
+    #endif
1969
+
1954 1970
     // Clear endstop flags
1955 1971
     endstops.hit_on_purpose();
1956 1972
 
@@ -2182,11 +2198,21 @@ static void clean_up_after_endstop_or_probe_move() {
2182 2198
  */
2183 2199
 
2184 2200
 static void do_homing_move(AxisEnum axis, float where, float fr_mm_s = 0.0) {
2201
+
2202
+  #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
2203
+    set_bltouch_deployed(true);
2204
+  #endif
2205
+
2185 2206
   current_position[axis] = 0;
2186 2207
   sync_plan_position();
2187 2208
   current_position[axis] = where;
2188 2209
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], (fr_mm_s != 0.0) ? fr_mm_s : homing_feedrate_mm_s[axis], active_extruder);
2189 2210
   stepper.synchronize();
2211
+
2212
+  #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
2213
+    set_bltouch_deployed(false);
2214
+  #endif
2215
+
2190 2216
   endstops.hit_on_purpose();
2191 2217
 }
2192 2218
 

+ 0
- 9
Marlin/enum.h 查看文件

@@ -124,15 +124,6 @@ enum TempState {
124 124
   };
125 125
 #endif
126 126
 
127
-#if ENABLED(BLTOUCH)
128
-  enum BLTouchState {
129
-    BLTouchState_Deploy   = 10,
130
-    BLTouchState_Stow     = 90,
131
-    BLTouchState_Selftest = 120,
132
-    BLTouchState_Error    = 160
133
-  };
134
-#endif
135
-
136 127
 #if ENABLED(FILAMENT_CHANGE_FEATURE)
137 128
   enum FilamentChangeMenuResponse {
138 129
     FILAMENT_CHANGE_RESPONSE_WAIT_FOR,

+ 5
- 2
Marlin/language_en.h 查看文件

@@ -366,8 +366,11 @@
366 366
 #ifndef MSG_ZPROBE_OUT
367 367
   #define MSG_ZPROBE_OUT                      "Z probe out. bed"
368 368
 #endif
369
-#ifndef MSG_RESET_BLTOUCH
370
-  #define MSG_RESET_BLTOUCH                   "Reset BLTouch"
369
+#ifndef MSG_BLTOUCH_RESET
370
+  #define MSG_BLTOUCH_SELFTEST                "BLTouch Self-Test"
371
+#endif
372
+#ifndef MSG_BLTOUCH_RESET
373
+  #define MSG_BLTOUCH_RESET                   "Reset BLTouch"
371 374
 #endif
372 375
 #ifndef MSG_HOME
373 376
   #define MSG_HOME                            "Home"  // Used as MSG_HOME " " MSG_X MSG_Y MSG_Z " " MSG_FIRST

+ 12
- 4
Marlin/ultralcd.cpp 查看文件

@@ -31,8 +31,7 @@
31 31
 #include "utility.h"
32 32
 
33 33
 #if ENABLED(BLTOUCH)
34
-  #include "servo.h"
35
-  extern Servo servo[NUM_SERVOS];
34
+  #include "endstops.h"
36 35
 #endif
37 36
 
38 37
 #if ENABLED(PRINTCOUNTER)
@@ -593,8 +592,8 @@ void kill_screen(const char* lcd_msg) {
593 592
     MENU_ITEM(back, MSG_WATCH);
594 593
 
595 594
     #if ENABLED(BLTOUCH)
596
-      if (servo[Z_ENDSTOP_SERVO_NR].read() == BLTouchState_Error)
597
-        MENU_ITEM(gcode, MSG_RESET_BLTOUCH, "M280 S90 P" STRINGIFY(Z_ENDSTOP_SERVO_NR));
595
+      if (!endstops.z_probe_enabled && TEST_BLTOUCH())
596
+        MENU_ITEM(gcode, MSG_BLTOUCH_RESET, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_RESET)));
598 597
     #endif
599 598
 
600 599
     if (planner.movesplanned() || IS_SD_PRINTING) {
@@ -1251,6 +1250,15 @@ void kill_screen(const char* lcd_msg) {
1251 1250
     MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
1252 1251
 
1253 1252
     //
1253
+    // BLTouch Self-Test and Reset
1254
+    //
1255
+    #if ENABLED(BLTOUCH)
1256
+      MENU_ITEM(gcode, MSG_BLTOUCH_TEST, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_SELFTEST)));
1257
+      if (!endstops.z_probe_enabled && TEST_BLTOUCH())
1258
+        MENU_ITEM(gcode, MSG_BLTOUCH_RESET, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_RESET)));
1259
+    #endif
1260
+
1261
+    //
1254 1262
     // Switch power on/off
1255 1263
     //
1256 1264
     #if HAS_POWER_SWITCH

Loading…
取消
儲存