Browse Source

Merge pull request #4839 from thinkyhead/rc_bltouch_servo_nr

Better BLTOUCH support
Scott Lahteine 7 years ago
parent
commit
9a9e9afcf8
28 changed files with 60 additions and 10 deletions
  1. 6
    2
      Marlin/Conditionals_post.h
  2. 1
    0
      Marlin/Configuration.h
  3. 5
    0
      Marlin/Marlin_main.cpp
  4. 4
    8
      Marlin/SanityCheck.h
  5. 9
    0
      Marlin/enum.h
  6. 1
    0
      Marlin/example_configurations/Cartesio/Configuration.h
  7. 1
    0
      Marlin/example_configurations/Felix/Configuration.h
  8. 1
    0
      Marlin/example_configurations/Felix/DUAL/Configuration.h
  9. 1
    0
      Marlin/example_configurations/Hephestos/Configuration.h
  10. 1
    0
      Marlin/example_configurations/Hephestos_2/Configuration.h
  11. 1
    0
      Marlin/example_configurations/K8200/Configuration.h
  12. 1
    0
      Marlin/example_configurations/K8400/Configuration.h
  13. 1
    0
      Marlin/example_configurations/K8400/Dual-head/Configuration.h
  14. 1
    0
      Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h
  15. 1
    0
      Marlin/example_configurations/RigidBot/Configuration.h
  16. 1
    0
      Marlin/example_configurations/SCARA/Configuration.h
  17. 1
    0
      Marlin/example_configurations/TAZ4/Configuration.h
  18. 1
    0
      Marlin/example_configurations/WITBOX/Configuration.h
  19. 1
    0
      Marlin/example_configurations/adafruit/ST7565/Configuration.h
  20. 1
    0
      Marlin/example_configurations/delta/biv2.5/Configuration.h
  21. 1
    0
      Marlin/example_configurations/delta/generic/Configuration.h
  22. 1
    0
      Marlin/example_configurations/delta/kossel_mini/Configuration.h
  23. 1
    0
      Marlin/example_configurations/delta/kossel_pro/Configuration.h
  24. 1
    0
      Marlin/example_configurations/delta/kossel_xl/Configuration.h
  25. 1
    0
      Marlin/example_configurations/makibox/Configuration.h
  26. 1
    0
      Marlin/example_configurations/tvrrug/Round2/Configuration.h
  27. 3
    0
      Marlin/language_en.h
  28. 11
    0
      Marlin/ultralcd.cpp

+ 6
- 2
Marlin/Conditionals_post.h View File

@@ -118,9 +118,13 @@
118 118
    * The BLTouch Probe emulates a servo probe
119 119
    */
120 120
   #if ENABLED(BLTOUCH)
121
-    #undef Z_ENDSTOP_SERVO_NR
121
+    #ifndef Z_ENDSTOP_SERVO_NR
122
+      #define Z_ENDSTOP_SERVO_NR 0
123
+    #endif
124
+    #ifndef NUM_SERVOS
125
+      #define NUM_SERVOS (Z_ENDSTOP_SERVO_NR + 1)
126
+    #endif
122 127
     #undef Z_SERVO_ANGLES
123
-    #define Z_ENDSTOP_SERVO_NR 0
124 128
     #define Z_SERVO_ANGLES {10,90} // For BLTouch 10=deploy, 90=retract
125 129
     #undef DEACTIVATE_SERVOS_AFTER_MOVE
126 130
     #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)

+ 1
- 0
Marlin/Configuration.h View File

@@ -528,6 +528,7 @@
528 528
 //#define FIX_MOUNTED_PROBE
529 529
 
530 530
 // The BLTouch probe emulates a servo probe.
531
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
531 532
 //#define BLTOUCH
532 533
 
533 534
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 5
- 0
Marlin/Marlin_main.cpp View File

@@ -1881,6 +1881,11 @@ static void clean_up_after_endstop_or_probe_move() {
1881 1881
     // Make room for probe
1882 1882
     do_probe_raise(_Z_PROBE_DEPLOY_HEIGHT);
1883 1883
 
1884
+    // Check BLTOUCH probe status for an error
1885
+    #if ENABLED(BLTOUCH)
1886
+      if (servo[Z_ENDSTOP_SERVO_NR].read() == BLTouchState_Error) { stop(); return true; }
1887
+    #endif
1888
+
1884 1889
     #if ENABLED(Z_PROBE_SLED)
1885 1890
       if (axis_unhomed_error(true, false, false)) { stop(); return true; }
1886 1891
     #elif ENABLED(Z_PROBE_ALLEN_KEY)

+ 4
- 8
Marlin/SanityCheck.h View File

@@ -306,12 +306,8 @@
306 306
 /**
307 307
  * Limited number of servos
308 308
  */
309
-#if defined(NUM_SERVOS) && NUM_SERVOS > 0
310
-  #if NUM_SERVOS > 4
311
-    #error "The maximum number of SERVOS in Marlin is 4."
312
-  #elif HAS_Z_SERVO_ENDSTOP && Z_ENDSTOP_SERVO_NR >= NUM_SERVOS
313
-    #error "Z_ENDSTOP_SERVO_NR must be smaller than NUM_SERVOS."
314
-  #endif
309
+#if NUM_SERVOS > 4
310
+  #error "The maximum number of SERVOS in Marlin is 4."
315 311
 #endif
316 312
 
317 313
 /**
@@ -367,7 +363,7 @@
367 363
     #ifndef NUM_SERVOS
368 364
       #error "You must set NUM_SERVOS for a Z servo probe (Z_ENDSTOP_SERVO_NR)."
369 365
     #elif Z_ENDSTOP_SERVO_NR >= NUM_SERVOS
370
-      #error "Z_ENDSTOP_SERVO_NR must be less than NUM_SERVOS."
366
+      #error "Z_ENDSTOP_SERVO_NR must be smaller than NUM_SERVOS."
371 367
     #endif
372 368
   #endif
373 369
 
@@ -404,7 +400,7 @@
404 400
   #if (ENABLED(FIX_MOUNTED_PROBE) && (ENABLED(Z_PROBE_ALLEN_KEY) || HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED))) \
405 401
        || (ENABLED(Z_PROBE_ALLEN_KEY) && (HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED))) \
406 402
        || (HAS_Z_SERVO_ENDSTOP && ENABLED(Z_PROBE_SLED))
407
-    #error "Please define only one type of probe: Z Servo, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or FIX_MOUNTED_PROBE."
403
+    #error "Please define only one type of probe: Z Servo/BLTOUCH, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or FIX_MOUNTED_PROBE."
408 404
   #endif
409 405
 
410 406
   /**

+ 9
- 0
Marlin/enum.h View File

@@ -124,6 +124,15 @@ 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
+
127 136
 #if ENABLED(FILAMENT_CHANGE_FEATURE)
128 137
   enum FilamentChangeMenuResponse {
129 138
     FILAMENT_CHANGE_RESPONSE_WAIT_FOR,

+ 1
- 0
Marlin/example_configurations/Cartesio/Configuration.h View File

@@ -511,6 +511,7 @@
511 511
 //#define FIX_MOUNTED_PROBE
512 512
 
513 513
 // The BLTouch probe emulates a servo probe.
514
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
514 515
 //#define BLTOUCH
515 516
 
516 517
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/Felix/Configuration.h View File

@@ -494,6 +494,7 @@
494 494
 //#define FIX_MOUNTED_PROBE
495 495
 
496 496
 // The BLTouch probe emulates a servo probe.
497
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
497 498
 //#define BLTOUCH
498 499
 
499 500
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/Felix/DUAL/Configuration.h View File

@@ -492,6 +492,7 @@
492 492
 //#define FIX_MOUNTED_PROBE
493 493
 
494 494
 // The BLTouch probe emulates a servo probe.
495
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
495 496
 //#define BLTOUCH
496 497
 
497 498
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/Hephestos/Configuration.h View File

@@ -503,6 +503,7 @@
503 503
 //#define FIX_MOUNTED_PROBE
504 504
 
505 505
 // The BLTouch probe emulates a servo probe.
506
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
506 507
 //#define BLTOUCH
507 508
 
508 509
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/Hephestos_2/Configuration.h View File

@@ -505,6 +505,7 @@
505 505
 #define FIX_MOUNTED_PROBE
506 506
 
507 507
 // The BLTouch probe emulates a servo probe.
508
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
508 509
 //#define BLTOUCH
509 510
 
510 511
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/K8200/Configuration.h View File

@@ -528,6 +528,7 @@
528 528
 //#define FIX_MOUNTED_PROBE
529 529
 
530 530
 // The BLTouch probe emulates a servo probe.
531
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
531 532
 //#define BLTOUCH
532 533
 
533 534
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/K8400/Configuration.h View File

@@ -511,6 +511,7 @@
511 511
 //#define FIX_MOUNTED_PROBE
512 512
 
513 513
 // The BLTouch probe emulates a servo probe.
514
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
514 515
 //#define BLTOUCH
515 516
 
516 517
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/K8400/Dual-head/Configuration.h View File

@@ -511,6 +511,7 @@
511 511
 //#define FIX_MOUNTED_PROBE
512 512
 
513 513
 // The BLTouch probe emulates a servo probe.
514
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
514 515
 //#define BLTOUCH
515 516
 
516 517
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h View File

@@ -511,6 +511,7 @@
511 511
 //#define FIX_MOUNTED_PROBE
512 512
 
513 513
 // The BLTouch probe emulates a servo probe.
514
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
514 515
 //#define BLTOUCH
515 516
 
516 517
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/RigidBot/Configuration.h View File

@@ -509,6 +509,7 @@
509 509
 //#define FIX_MOUNTED_PROBE
510 510
 
511 511
 // The BLTouch probe emulates a servo probe.
512
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
512 513
 //#define BLTOUCH
513 514
 
514 515
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/SCARA/Configuration.h View File

@@ -521,6 +521,7 @@
521 521
 //#define FIX_MOUNTED_PROBE
522 522
 
523 523
 // The BLTouch probe emulates a servo probe.
524
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
524 525
 //#define BLTOUCH
525 526
 
526 527
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/TAZ4/Configuration.h View File

@@ -532,6 +532,7 @@
532 532
 //#define FIX_MOUNTED_PROBE
533 533
 
534 534
 // The BLTouch probe emulates a servo probe.
535
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
535 536
 //#define BLTOUCH
536 537
 
537 538
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/WITBOX/Configuration.h View File

@@ -503,6 +503,7 @@
503 503
 //#define FIX_MOUNTED_PROBE
504 504
 
505 505
 // The BLTouch probe emulates a servo probe.
506
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
506 507
 //#define BLTOUCH
507 508
 
508 509
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/adafruit/ST7565/Configuration.h View File

@@ -511,6 +511,7 @@
511 511
 //#define FIX_MOUNTED_PROBE
512 512
 
513 513
 // The BLTouch probe emulates a servo probe.
514
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
514 515
 //#define BLTOUCH
515 516
 
516 517
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/delta/biv2.5/Configuration.h View File

@@ -554,6 +554,7 @@
554 554
 //#define FIX_MOUNTED_PROBE
555 555
 
556 556
 // The BLTouch probe emulates a servo probe.
557
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
557 558
 //#define BLTOUCH
558 559
 
559 560
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/delta/generic/Configuration.h View File

@@ -554,6 +554,7 @@
554 554
 //#define FIX_MOUNTED_PROBE
555 555
 
556 556
 // The BLTouch probe emulates a servo probe.
557
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
557 558
 //#define BLTOUCH
558 559
 
559 560
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

@@ -554,6 +554,7 @@
554 554
 //#define FIX_MOUNTED_PROBE
555 555
 
556 556
 // The BLTouch probe emulates a servo probe.
557
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
557 558
 //#define BLTOUCH
558 559
 
559 560
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration.h View File

@@ -550,6 +550,7 @@
550 550
 //#define FIX_MOUNTED_PROBE
551 551
 
552 552
 // The BLTouch probe emulates a servo probe.
553
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
553 554
 //#define BLTOUCH
554 555
 
555 556
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration.h View File

@@ -560,6 +560,7 @@
560 560
 #define FIX_MOUNTED_PROBE
561 561
 
562 562
 // The BLTouch probe emulates a servo probe.
563
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
563 564
 //#define BLTOUCH
564 565
 
565 566
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/makibox/Configuration.h View File

@@ -514,6 +514,7 @@
514 514
 //#define FIX_MOUNTED_PROBE
515 515
 
516 516
 // The BLTouch probe emulates a servo probe.
517
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
517 518
 //#define BLTOUCH
518 519
 
519 520
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 1
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

@@ -507,6 +507,7 @@
507 507
 //#define FIX_MOUNTED_PROBE
508 508
 
509 509
 // The BLTouch probe emulates a servo probe.
510
+// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override.
510 511
 //#define BLTOUCH
511 512
 
512 513
 // Z Servo Probe, such as an endstop switch on a rotating arm.

+ 3
- 0
Marlin/language_en.h View File

@@ -366,6 +366,9 @@
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"
371
+#endif
369 372
 #ifndef MSG_HOME
370 373
   #define MSG_HOME                            "Home"  // Used as MSG_HOME " " MSG_X MSG_Y MSG_Z " " MSG_FIRST
371 374
 #endif

+ 11
- 0
Marlin/ultralcd.cpp View File

@@ -30,6 +30,11 @@
30 30
 #include "configuration_store.h"
31 31
 #include "utility.h"
32 32
 
33
+#if ENABLED(BLTOUCH)
34
+  #include "servo.h"
35
+  extern Servo servo[NUM_SERVOS];
36
+#endif
37
+
33 38
 #if ENABLED(PRINTCOUNTER)
34 39
   #include "printcounter.h"
35 40
   #include "duration_t.h"
@@ -586,6 +591,12 @@ void kill_screen(const char* lcd_msg) {
586 591
   static void lcd_main_menu() {
587 592
     START_MENU();
588 593
     MENU_ITEM(back, MSG_WATCH);
594
+
595
+    #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));
598
+    #endif
599
+
589 600
     if (planner.movesplanned() || IS_SD_PRINTING) {
590 601
       MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu);
591 602
     }

Loading…
Cancel
Save