Quellcode durchsuchen

Patch G28 servo stow to use Conditionals, raise_z_after_probing

Scott Lahteine vor 9 Jahren
Ursprung
Commit
b3a37b493d
3 geänderte Dateien mit 63 neuen und 51 gelöschten Zeilen
  1. 5
    1
      Marlin/Conditionals.h
  2. 57
    49
      Marlin/Marlin_main.cpp
  3. 1
    1
      Marlin/SanityCheck.h

+ 5
- 1
Marlin/Conditionals.h Datei anzeigen

349
     #define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
349
     #define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
350
     #define MIN_PROBE_Y (max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
350
     #define MIN_PROBE_Y (max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
351
     #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
351
     #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
352
+  #else
353
+    #ifndef Z_RAISE_AFTER_PROBING
354
+      #define Z_RAISE_AFTER_PROBING 15
355
+    #endif
352
   #endif
356
   #endif
353
 
357
 
354
   #define HAS_Z_ENDSTOP_SERVO (defined(Z_ENDSTOP_SERVO_NR) && Z_ENDSTOP_SERVO_NR >= 0)
358
   #define HAS_Z_ENDSTOP_SERVO (defined(Z_ENDSTOP_SERVO_NR) && Z_ENDSTOP_SERVO_NR >= 0)
732
       #define Z_ENDSTOP_SERVO_NR -1
736
       #define Z_ENDSTOP_SERVO_NR -1
733
     #endif
737
     #endif
734
     #if X_ENDSTOP_SERVO_NR >= 0 || Y_ENDSTOP_SERVO_NR >= 0 || HAS_Z_ENDSTOP_SERVO
738
     #if X_ENDSTOP_SERVO_NR >= 0 || Y_ENDSTOP_SERVO_NR >= 0 || HAS_Z_ENDSTOP_SERVO
735
-      #define HAS_SERVO_ENDSTOPS true
739
+      #define HAS_SERVO_ENDSTOPS
736
       #define SERVO_ENDSTOP_IDS { X_ENDSTOP_SERVO_NR, Y_ENDSTOP_SERVO_NR, Z_ENDSTOP_SERVO_NR }
740
       #define SERVO_ENDSTOP_IDS { X_ENDSTOP_SERVO_NR, Y_ENDSTOP_SERVO_NR, Z_ENDSTOP_SERVO_NR }
737
     #endif
741
     #endif
738
   #endif
742
   #endif

+ 57
- 49
Marlin/Marlin_main.cpp Datei anzeigen

372
   };
372
   };
373
 #endif
373
 #endif
374
 
374
 
375
-#if HAS_SERVO_ENDSTOPS
375
+#if ENABLED(HAS_SERVO_ENDSTOPS)
376
   const int servo_endstop_id[] = SERVO_ENDSTOP_IDS;
376
   const int servo_endstop_id[] = SERVO_ENDSTOP_IDS;
377
   const int servo_endstop_angle[][2] = SERVO_ENDSTOP_ANGLES;
377
   const int servo_endstop_angle[][2] = SERVO_ENDSTOP_ANGLES;
378
 #endif
378
 #endif
719
     servo[3].detach();
719
     servo[3].detach();
720
   #endif
720
   #endif
721
 
721
 
722
-   #if HAS_SERVO_ENDSTOPS
722
+   #if ENABLED(HAS_SERVO_ENDSTOPS)
723
 
723
 
724
     endstops.enable_z_probe(false);
724
     endstops.enable_z_probe(false);
725
 
725
 
1719
 
1719
 
1720
     if (endstops.z_probe_enabled) return;
1720
     if (endstops.z_probe_enabled) return;
1721
 
1721
 
1722
-    #if HAS_SERVO_ENDSTOPS
1722
+    #if ENABLED(HAS_SERVO_ENDSTOPS)
1723
 
1723
 
1724
       // Engage Z Servo endstop if enabled
1724
       // Engage Z Servo endstop if enabled
1725
       if (servo_endstop_id[Z_AXIS] >= 0) servo[servo_endstop_id[Z_AXIS]].move(servo_endstop_angle[Z_AXIS][0]);
1725
       if (servo_endstop_id[Z_AXIS] >= 0) servo[servo_endstop_id[Z_AXIS]].move(servo_endstop_angle[Z_AXIS][0]);
1806
   }
1806
   }
1807
 
1807
 
1808
   static void stow_z_probe(bool doRaise = true) {
1808
   static void stow_z_probe(bool doRaise = true) {
1809
-    #if !(HAS_SERVO_ENDSTOPS && (Z_RAISE_AFTER_PROBING > 0))
1809
+    #if !(ENABLED(HAS_SERVO_ENDSTOPS) && (Z_RAISE_AFTER_PROBING > 0))
1810
       UNUSED(doRaise);
1810
       UNUSED(doRaise);
1811
     #endif
1811
     #endif
1812
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1812
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1815
 
1815
 
1816
     if (!endstops.z_probe_enabled) return;
1816
     if (!endstops.z_probe_enabled) return;
1817
 
1817
 
1818
-    #if HAS_SERVO_ENDSTOPS
1818
+    #if ENABLED(HAS_SERVO_ENDSTOPS)
1819
 
1819
 
1820
       // Retract Z Servo endstop if enabled
1820
       // Retract Z Servo endstop if enabled
1821
       if (servo_endstop_id[Z_AXIS] >= 0) {
1821
       if (servo_endstop_id[Z_AXIS] >= 0) {
2057
 
2057
 
2058
   #endif // DELTA
2058
   #endif // DELTA
2059
 
2059
 
2060
-  #if HAS_SERVO_ENDSTOPS && DISABLED(Z_PROBE_SLED)
2060
+  #if ENABLED(HAS_SERVO_ENDSTOPS) && DISABLED(Z_PROBE_SLED)
2061
 
2061
 
2062
     void raise_z_for_servo() {
2062
     void raise_z_for_servo() {
2063
       float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_PROBING;
2063
       float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_PROBING;
2168
     sync_plan_position();
2168
     sync_plan_position();
2169
 
2169
 
2170
     #if ENABLED(Z_PROBE_SLED)
2170
     #if ENABLED(Z_PROBE_SLED)
2171
-      #define _Z_SERVO_TEST       (axis != Z_AXIS)      // deploy Z, servo.move XY
2172
-      #define _Z_PROBE_SUBTEST    false                 // Z will never be invoked
2171
+      #define _Z_SERVO_TEST       (axis != Z_AXIS)      // already deployed Z
2172
+      #define _Z_SERVO_SUBTEST    false                 // Z will never be invoked
2173
       #define _Z_DEPLOY           (dock_sled(false))
2173
       #define _Z_DEPLOY           (dock_sled(false))
2174
       #define _Z_STOW             (dock_sled(true))
2174
       #define _Z_STOW             (dock_sled(true))
2175
     #elif SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE)
2175
     #elif SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE)
2176
-      #define _Z_SERVO_TEST       (axis != Z_AXIS)      // servo.move XY
2177
-      #define _Z_PROBE_SUBTEST    false                 // Z will never be invoked
2176
+      #define _Z_SERVO_TEST       (axis != Z_AXIS)      // already deployed Z
2177
+      #define _Z_SERVO_SUBTEST    false                 // Z will never be invoked
2178
       #define _Z_DEPLOY           (deploy_z_probe())
2178
       #define _Z_DEPLOY           (deploy_z_probe())
2179
       #define _Z_STOW             (stow_z_probe())
2179
       #define _Z_STOW             (stow_z_probe())
2180
-    #elif HAS_SERVO_ENDSTOPS
2181
-      #define _Z_SERVO_TEST       true                  // servo.move X, Y, Z
2182
-      #define _Z_PROBE_SUBTEST    (axis == Z_AXIS)      // Z is a probe
2180
+    #elif ENABLED(HAS_SERVO_ENDSTOPS)
2181
+      #define _Z_SERVO_TEST       true                  // Z not deployed yet
2182
+      #define _Z_SERVO_SUBTEST    (axis == Z_AXIS)      // Z is a probe
2183
     #endif
2183
     #endif
2184
 
2184
 
2185
-    if (axis == Z_AXIS) {
2186
-      // If there's a Z probe that needs deployment...
2187
-      #if ENABLED(Z_PROBE_SLED) || SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE)
2188
-        // ...and homing Z towards the bed? Deploy it.
2189
-        if (axis_home_dir < 0) _Z_DEPLOY;
2190
-      #endif
2191
-    }
2185
+    // If there's a Z probe that needs deployment...
2186
+    #if ENABLED(Z_PROBE_SLED) || SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE)
2187
+      // ...and homing Z towards the bed? Deploy it.
2188
+      if (axis == Z_AXIS && axis_home_dir < 0) {
2189
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
2190
+          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> SERVO_LEVELING > " STRINGIFY(_Z_DEPLOY));
2191
+        #endif
2192
+        _Z_DEPLOY;
2193
+      }
2194
+    #endif
2192
 
2195
 
2193
-    #if HAS_SERVO_ENDSTOPS
2194
-      // Engage an X or Y Servo endstop if enabled
2196
+    #if ENABLED(HAS_SERVO_ENDSTOPS)
2197
+      // Engage an X, Y (or Z) Servo endstop if enabled
2195
       if (_Z_SERVO_TEST && servo_endstop_id[axis] >= 0) {
2198
       if (_Z_SERVO_TEST && servo_endstop_id[axis] >= 0) {
2196
         servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][0]);
2199
         servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][0]);
2197
-        if (_Z_PROBE_SUBTEST) endstops.z_probe_enabled = true;
2200
+        if (_Z_SERVO_SUBTEST) endstops.z_probe_enabled = true;
2198
       }
2201
       }
2199
     #endif
2202
     #endif
2200
 
2203
 
2311
     axis_known_position[axis] = true;
2314
     axis_known_position[axis] = true;
2312
     axis_homed[axis] = true;
2315
     axis_homed[axis] = true;
2313
 
2316
 
2314
-    // Put away the Z probe
2317
+    // Put away the Z probe with a function
2315
     #if ENABLED(Z_PROBE_SLED) || SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE)
2318
     #if ENABLED(Z_PROBE_SLED) || SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE)
2316
       if (axis == Z_AXIS && axis_home_dir < 0) {
2319
       if (axis == Z_AXIS && axis_home_dir < 0) {
2317
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2320
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2321
       }
2324
       }
2322
     #endif
2325
     #endif
2323
 
2326
 
2324
-    // Retract Servo endstop if enabled
2325
-    #if HAS_SERVO_ENDSTOPS
2327
+    // Retract X, Y (or Z) Servo endstop if enabled
2328
+    #if ENABLED(HAS_SERVO_ENDSTOPS)
2326
       if (_Z_SERVO_TEST && servo_endstop_id[axis] >= 0) {
2329
       if (_Z_SERVO_TEST && servo_endstop_id[axis] >= 0) {
2330
+        // Raise the servo probe before stow outside ABL context.
2331
+        // This is a workaround to allow use of a Servo Probe without
2332
+        // ABL until more global probe handling is implemented.
2333
+        #if Z_RAISE_AFTER_PROBING > 0
2334
+          if (axis == Z_AXIS) {
2335
+            #if ENABLED(DEBUG_LEVELING_FEATURE)
2336
+              if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Raise Z (after) by ", Z_RAISE_AFTER_PROBING);
2337
+            #endif
2338
+            current_position[Z_AXIS] = Z_RAISE_AFTER_PROBING;
2339
+            feedrate = homing_feedrate[Z_AXIS];
2340
+            line_to_current_position();
2341
+            stepper.synchronize();
2342
+          }
2343
+        #endif
2344
+
2327
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2345
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2328
           if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> SERVO_ENDSTOPS > Stow with servo.move()");
2346
           if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> SERVO_ENDSTOPS > Stow with servo.move()");
2329
         #endif
2347
         #endif
2330
-        // Raise the servo probe before stow outside ABL context... This is a workaround that allows the use of a Servo Probe without ABL until a more global probe handling is implemented.
2331
-        #if DISABLED(AUTO_BED_LEVELING_FEATURE)
2332
-          #ifndef Z_RAISE_AFTER_PROBING
2333
-            #define Z_RAISE_AFTER_PROBING 15                 // default height
2334
-          #endif
2335
-          current_position[Z_AXIS] = Z_RAISE_AFTER_PROBING;
2336
-          feedrate = homing_feedrate[Z_AXIS];
2337
-          line_to_current_position();
2338
-          stepper.synchronize();
2339
-        #endif
2340
-
2341
         servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][1]);
2348
         servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][1]);
2342
-        if (_Z_PROBE_SUBTEST) endstops.enable_z_probe(false);
2349
+        if (_Z_SERVO_SUBTEST) endstops.enable_z_probe(false);
2343
       }
2350
       }
2344
-    #endif
2351
+
2352
+    #endif // HAS_SERVO_ENDSTOPS
2345
 
2353
 
2346
   }
2354
   }
2347
 
2355
 
3630
         #endif
3638
         #endif
3631
 
3639
 
3632
         current_position[Z_AXIS] = -zprobe_zoffset + (z_tmp - real_z)
3640
         current_position[Z_AXIS] = -zprobe_zoffset + (z_tmp - real_z)
3633
-          #if HAS_SERVO_ENDSTOPS || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)
3641
+          #if ENABLED(HAS_SERVO_ENDSTOPS) || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)
3634
              + Z_RAISE_AFTER_PROBING
3642
              + Z_RAISE_AFTER_PROBING
3635
           #endif
3643
           #endif
3636
           ;
3644
           ;
3647
         dock_sled(true); // dock the sled
3655
         dock_sled(true); // dock the sled
3648
       #elif Z_RAISE_AFTER_PROBING > 0
3656
       #elif Z_RAISE_AFTER_PROBING > 0
3649
         // Raise Z axis for non-delta and non servo based probes
3657
         // Raise Z axis for non-delta and non servo based probes
3650
-        #if !defined(HAS_SERVO_ENDSTOPS) && DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED)
3658
+        #if DISABLED(HAS_SERVO_ENDSTOPS) && DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED)
3651
           raise_z_after_probing();
3659
           raise_z_after_probing();
3652
         #endif
3660
         #endif
3653
       #endif
3661
       #endif
3691
      * G30: Do a single Z probe at the current XY
3699
      * G30: Do a single Z probe at the current XY
3692
      */
3700
      */
3693
     inline void gcode_G30() {
3701
     inline void gcode_G30() {
3694
-      #if HAS_SERVO_ENDSTOPS
3702
+      #if ENABLED(HAS_SERVO_ENDSTOPS)
3695
         raise_z_for_servo();
3703
         raise_z_for_servo();
3696
       #endif
3704
       #endif
3697
       deploy_z_probe(); // Engage Z Servo endstop if available. Z_PROBE_SLED is missed here.
3705
       deploy_z_probe(); // Engage Z Servo endstop if available. Z_PROBE_SLED is missed here.
3713
 
3721
 
3714
       clean_up_after_endstop_move(); // Too early. must be done after the stowing.
3722
       clean_up_after_endstop_move(); // Too early. must be done after the stowing.
3715
 
3723
 
3716
-      #if HAS_SERVO_ENDSTOPS
3724
+      #if ENABLED(HAS_SERVO_ENDSTOPS)
3717
         raise_z_for_servo();
3725
         raise_z_for_servo();
3718
       #endif
3726
       #endif
3719
       stow_z_probe(false); // Retract Z Servo endstop if available. Z_PROBE_SLED is missed here.
3727
       stow_z_probe(false); // Retract Z Servo endstop if available. Z_PROBE_SLED is missed here.
5822
  */
5830
  */
5823
 inline void gcode_M400() { stepper.synchronize(); }
5831
 inline void gcode_M400() { stepper.synchronize(); }
5824
 
5832
 
5825
-#if ENABLED(AUTO_BED_LEVELING_FEATURE) && DISABLED(Z_PROBE_SLED) && (HAS_SERVO_ENDSTOPS || ENABLED(Z_PROBE_ALLEN_KEY))
5833
+#if ENABLED(AUTO_BED_LEVELING_FEATURE) && DISABLED(Z_PROBE_SLED) && (ENABLED(HAS_SERVO_ENDSTOPS) || ENABLED(Z_PROBE_ALLEN_KEY))
5826
 
5834
 
5827
   /**
5835
   /**
5828
    * M401: Engage Z Servo endstop if available
5836
    * M401: Engage Z Servo endstop if available
5829
    */
5837
    */
5830
   inline void gcode_M401() {
5838
   inline void gcode_M401() {
5831
-    #if HAS_SERVO_ENDSTOPS
5839
+    #if ENABLED(HAS_SERVO_ENDSTOPS)
5832
       raise_z_for_servo();
5840
       raise_z_for_servo();
5833
     #endif
5841
     #endif
5834
     deploy_z_probe();
5842
     deploy_z_probe();
5838
    * M402: Retract Z Servo endstop if enabled
5846
    * M402: Retract Z Servo endstop if enabled
5839
    */
5847
    */
5840
   inline void gcode_M402() {
5848
   inline void gcode_M402() {
5841
-    #if HAS_SERVO_ENDSTOPS
5849
+    #if ENABLED(HAS_SERVO_ENDSTOPS)
5842
       raise_z_for_servo();
5850
       raise_z_for_servo();
5843
     #endif
5851
     #endif
5844
     stow_z_probe(false);
5852
     stow_z_probe(false);
5845
   }
5853
   }
5846
 
5854
 
5847
-#endif // AUTO_BED_LEVELING_FEATURE && (HAS_SERVO_ENDSTOPS || Z_PROBE_ALLEN_KEY) && !Z_PROBE_SLED
5855
+#endif // AUTO_BED_LEVELING_FEATURE && (ENABLED(HAS_SERVO_ENDSTOPS) || Z_PROBE_ALLEN_KEY) && !Z_PROBE_SLED
5848
 
5856
 
5849
 #if ENABLED(FILAMENT_WIDTH_SENSOR)
5857
 #if ENABLED(FILAMENT_WIDTH_SENSOR)
5850
 
5858
 
7038
         gcode_M400();
7046
         gcode_M400();
7039
         break;
7047
         break;
7040
 
7048
 
7041
-      #if ENABLED(AUTO_BED_LEVELING_FEATURE) && (HAS_SERVO_ENDSTOPS || ENABLED(Z_PROBE_ALLEN_KEY)) && DISABLED(Z_PROBE_SLED)
7049
+      #if ENABLED(AUTO_BED_LEVELING_FEATURE) && (ENABLED(HAS_SERVO_ENDSTOPS) || ENABLED(Z_PROBE_ALLEN_KEY)) && DISABLED(Z_PROBE_SLED)
7042
         case 401:
7050
         case 401:
7043
           gcode_M401();
7051
           gcode_M401();
7044
           break;
7052
           break;
7045
         case 402:
7053
         case 402:
7046
           gcode_M402();
7054
           gcode_M402();
7047
           break;
7055
           break;
7048
-      #endif // AUTO_BED_LEVELING_FEATURE && (HAS_SERVO_ENDSTOPS || Z_PROBE_ALLEN_KEY) && !Z_PROBE_SLED
7056
+      #endif // AUTO_BED_LEVELING_FEATURE && (ENABLED(HAS_SERVO_ENDSTOPS) || Z_PROBE_ALLEN_KEY) && !Z_PROBE_SLED
7049
 
7057
 
7050
       #if ENABLED(FILAMENT_WIDTH_SENSOR)
7058
       #if ENABLED(FILAMENT_WIDTH_SENSOR)
7051
         case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
7059
         case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width

+ 1
- 1
Marlin/SanityCheck.h Datei anzeigen

174
 /**
174
 /**
175
  * Servo deactivation depends on servo endstops
175
  * Servo deactivation depends on servo endstops
176
  */
176
  */
177
-#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) && !HAS_SERVO_ENDSTOPS
177
+#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) && DISABLED(HAS_SERVO_ENDSTOPS)
178
   #error "At least one of the ?_ENDSTOP_SERVO_NR is required for DEACTIVATE_SERVOS_AFTER_MOVE."
178
   #error "At least one of the ?_ENDSTOP_SERVO_NR is required for DEACTIVATE_SERVOS_AFTER_MOVE."
179
 #endif
179
 #endif
180
 
180
 

Laden…
Abbrechen
Speichern