|
@@ -1655,6 +1655,10 @@ static void setup_for_endstop_move() {
|
1655
|
1655
|
feedrate = old_feedrate;
|
1656
|
1656
|
}
|
1657
|
1657
|
|
|
1658
|
+ inline void do_blocking_move_to_x(float x) {
|
|
1659
|
+ do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]);
|
|
1660
|
+ }
|
|
1661
|
+
|
1658
|
1662
|
inline void do_blocking_move_to_z(float z) {
|
1659
|
1663
|
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z);
|
1660
|
1664
|
}
|
|
@@ -1686,6 +1690,63 @@ static void setup_for_endstop_move() {
|
1686
|
1690
|
|
1687
|
1691
|
#if HAS_BED_PROBE
|
1688
|
1692
|
|
|
1693
|
+ inline void raise_z_after_probing() {
|
|
1694
|
+ #if Z_RAISE_AFTER_PROBING > 0
|
|
1695
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
1696
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("raise_z_after_probing()");
|
|
1697
|
+ #endif
|
|
1698
|
+ do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
|
|
1699
|
+ #endif
|
|
1700
|
+ }
|
|
1701
|
+#endif
|
|
1702
|
+
|
|
1703
|
+#if ENABLED(Z_PROBE_SLED)
|
|
1704
|
+
|
|
1705
|
+ #ifndef SLED_DOCKING_OFFSET
|
|
1706
|
+ #define SLED_DOCKING_OFFSET 0
|
|
1707
|
+ #endif
|
|
1708
|
+
|
|
1709
|
+ /**
|
|
1710
|
+ * Method to dock/undock a sled designed by Charles Bell.
|
|
1711
|
+ *
|
|
1712
|
+ * dock[in] If true, move to MAX_X and engage the electromagnet
|
|
1713
|
+ * offset[in] The additional distance to move to adjust docking location
|
|
1714
|
+ */
|
|
1715
|
+ static void dock_sled(bool dock, int offset = 0) {
|
|
1716
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
1717
|
+ if (DEBUGGING(LEVELING)) {
|
|
1718
|
+ SERIAL_ECHOPAIR("dock_sled(", dock);
|
|
1719
|
+ SERIAL_ECHOLNPGM(")");
|
|
1720
|
+ }
|
|
1721
|
+ #endif
|
|
1722
|
+
|
|
1723
|
+ if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
|
|
1724
|
+ axis_unhomed_error(true);
|
|
1725
|
+ return;
|
|
1726
|
+ }
|
|
1727
|
+
|
|
1728
|
+ if (endstops.z_probe_enabled == !dock) return; // already docked/undocked?
|
|
1729
|
+
|
|
1730
|
+ float oldXpos = current_position[X_AXIS]; // save x position
|
|
1731
|
+ if (dock) {
|
|
1732
|
+ raise_z_after_probing(); // raise Z
|
|
1733
|
+ // Dock sled a bit closer to ensure proper capturing
|
|
1734
|
+ do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
|
|
1735
|
+ digitalWrite(SLED_PIN, LOW); // turn off magnet
|
|
1736
|
+ }
|
|
1737
|
+ else {
|
|
1738
|
+ float z_loc = current_position[Z_AXIS];
|
|
1739
|
+ if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
|
|
1740
|
+ do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
|
|
1741
|
+ digitalWrite(SLED_PIN, HIGH); // turn on magnet
|
|
1742
|
+ }
|
|
1743
|
+ do_blocking_move_to_x(oldXpos); // return to position before docking
|
|
1744
|
+ }
|
|
1745
|
+
|
|
1746
|
+#endif // Z_PROBE_SLED
|
|
1747
|
+
|
|
1748
|
+#if HAS_BED_PROBE
|
|
1749
|
+
|
1689
|
1750
|
static void deploy_z_probe() {
|
1690
|
1751
|
|
1691
|
1752
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -1694,7 +1755,11 @@ static void setup_for_endstop_move() {
|
1694
|
1755
|
|
1695
|
1756
|
if (endstops.z_probe_enabled) return;
|
1696
|
1757
|
|
1697
|
|
- #if HAS_Z_SERVO_ENDSTOP
|
|
1758
|
+ #if ENABLED(Z_PROBE_SLED)
|
|
1759
|
+
|
|
1760
|
+ dock_sled(false);
|
|
1761
|
+
|
|
1762
|
+ #elif HAS_Z_SERVO_ENDSTOP
|
1698
|
1763
|
|
1699
|
1764
|
// Make room for Z Servo
|
1700
|
1765
|
raise_z_for_servo(Z_RAISE_BEFORE_PROBING);
|
|
@@ -1792,7 +1857,11 @@ static void setup_for_endstop_move() {
|
1792
|
1857
|
|
1793
|
1858
|
if (!endstops.z_probe_enabled) return;
|
1794
|
1859
|
|
1795
|
|
- #if HAS_Z_SERVO_ENDSTOP
|
|
1860
|
+ #if ENABLED(Z_PROBE_SLED)
|
|
1861
|
+
|
|
1862
|
+ dock_sled(true);
|
|
1863
|
+
|
|
1864
|
+ #elif HAS_Z_SERVO_ENDSTOP
|
1796
|
1865
|
|
1797
|
1866
|
// Make room for the servo
|
1798
|
1867
|
raise_z_for_servo(Z_RAISE_AFTER_PROBING);
|
|
@@ -2040,19 +2109,6 @@ static void setup_for_endstop_move() {
|
2040
|
2109
|
do_blocking_move_to(x, y, current_position[Z_AXIS]);
|
2041
|
2110
|
}
|
2042
|
2111
|
|
2043
|
|
- inline void do_blocking_move_to_x(float x) {
|
2044
|
|
- do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]);
|
2045
|
|
- }
|
2046
|
|
-
|
2047
|
|
- inline void raise_z_after_probing() {
|
2048
|
|
- #if Z_RAISE_AFTER_PROBING > 0
|
2049
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2050
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("raise_z_after_probing()");
|
2051
|
|
- #endif
|
2052
|
|
- do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
|
2053
|
|
- #endif
|
2054
|
|
- }
|
2055
|
|
-
|
2056
|
2112
|
static void clean_up_after_endstop_move() {
|
2057
|
2113
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2058
|
2114
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("clean_up_after_endstop_move > ENDSTOPS_ONLY_FOR_HOMING > endstops.not_homing()");
|
|
@@ -2229,55 +2285,6 @@ static void setup_for_endstop_move() {
|
2229
|
2285
|
}
|
2230
|
2286
|
#endif
|
2231
|
2287
|
|
2232
|
|
-#if ENABLED(Z_PROBE_SLED)
|
2233
|
|
-
|
2234
|
|
- #ifndef SLED_DOCKING_OFFSET
|
2235
|
|
- #define SLED_DOCKING_OFFSET 0
|
2236
|
|
- #endif
|
2237
|
|
-
|
2238
|
|
- /**
|
2239
|
|
- * Method to dock/undock a sled designed by Charles Bell.
|
2240
|
|
- *
|
2241
|
|
- * dock[in] If true, move to MAX_X and engage the electromagnet
|
2242
|
|
- * offset[in] The additional distance to move to adjust docking location
|
2243
|
|
- */
|
2244
|
|
- static void dock_sled(bool dock, int offset = 0) {
|
2245
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2246
|
|
- if (DEBUGGING(LEVELING)) {
|
2247
|
|
- SERIAL_ECHOPAIR("dock_sled(", dock);
|
2248
|
|
- SERIAL_ECHOLNPGM(")");
|
2249
|
|
- }
|
2250
|
|
- #endif
|
2251
|
|
-
|
2252
|
|
- if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
|
2253
|
|
- axis_unhomed_error(true);
|
2254
|
|
- return;
|
2255
|
|
- }
|
2256
|
|
-
|
2257
|
|
- if (endstops.z_probe_enabled == !dock) return; // already docked/undocked?
|
2258
|
|
-
|
2259
|
|
- float oldXpos = current_position[X_AXIS]; // save x position
|
2260
|
|
- if (dock) {
|
2261
|
|
- raise_z_after_probing(); // raise Z
|
2262
|
|
- // Dock sled a bit closer to ensure proper capturing
|
2263
|
|
- do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
|
2264
|
|
- digitalWrite(SLED_PIN, LOW); // turn off magnet
|
2265
|
|
- }
|
2266
|
|
- else {
|
2267
|
|
- float z_loc = current_position[Z_AXIS];
|
2268
|
|
- if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
|
2269
|
|
- do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
|
2270
|
|
- digitalWrite(SLED_PIN, HIGH); // turn on magnet
|
2271
|
|
- }
|
2272
|
|
- do_blocking_move_to_x(oldXpos); // return to position before docking
|
2273
|
|
-
|
2274
|
|
- endstops.enable_z_probe(!dock); // logically disable docked probe
|
2275
|
|
- }
|
2276
|
|
-
|
2277
|
|
-#endif // Z_PROBE_SLED
|
2278
|
|
-
|
2279
|
|
-
|
2280
|
|
-
|
2281
|
2288
|
/**
|
2282
|
2289
|
* Home an individual axis
|
2283
|
2290
|
*/
|
|
@@ -2306,24 +2313,13 @@ static void homeaxis(AxisEnum axis) {
|
2306
|
2313
|
current_position[axis] = 0;
|
2307
|
2314
|
sync_plan_position();
|
2308
|
2315
|
|
2309
|
|
- #if ENABLED(Z_PROBE_SLED)
|
2310
|
|
- #define _Z_DEPLOY (dock_sled(false))
|
2311
|
|
- #define _Z_STOW (dock_sled(true))
|
2312
|
|
- #elif (ENABLED(AUTO_BED_LEVELING_FEATURE) && HAS_Z_SERVO_ENDSTOP) || ENABLED(FIX_MOUNTED_PROBE)
|
2313
|
|
- #define _Z_DEPLOY (deploy_z_probe())
|
2314
|
|
- #define _Z_STOW (stow_z_probe())
|
2315
|
|
- #elif HAS_Z_SERVO_ENDSTOP
|
2316
|
|
- #define _Z_DEPLOY do{ raise_z_for_servo(Z_RAISE_BEFORE_PROBING); DEPLOY_Z_SERVO(); endstops.z_probe_enabled = true; }while(0)
|
2317
|
|
- #define _Z_STOW do{ raise_z_for_servo(Z_RAISE_AFTER_PROBING); STOW_Z_SERVO(); endstops.z_probe_enabled = false; }while(0)
|
2318
|
|
- #endif
|
2319
|
|
-
|
2320
|
2316
|
// Homing Z towards the bed? Deploy the Z probe or endstop.
|
2321
|
|
- #if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED) || ENABLED(FIX_MOUNTED_PROBE)
|
|
2317
|
+ #if HAS_BED_PROBE
|
2322
|
2318
|
if (axis == Z_AXIS && axis_home_dir < 0) {
|
2323
|
2319
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2324
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > " STRINGIFY(_Z_DEPLOY));
|
|
2320
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > deploy_z_probe()");
|
2325
|
2321
|
#endif
|
2326
|
|
- _Z_DEPLOY;
|
|
2322
|
+ deploy_z_probe();
|
2327
|
2323
|
}
|
2328
|
2324
|
#endif
|
2329
|
2325
|
|
|
@@ -2441,12 +2437,12 @@ static void homeaxis(AxisEnum axis) {
|
2441
|
2437
|
axis_homed[axis] = true;
|
2442
|
2438
|
|
2443
|
2439
|
// Put away the Z probe
|
2444
|
|
- #if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED) || ENABLED(FIX_MOUNTED_PROBE)
|
|
2440
|
+ #if HAS_BED_PROBE
|
2445
|
2441
|
if (axis == Z_AXIS && axis_home_dir < 0) {
|
2446
|
2442
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2447
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > " STRINGIFY(_Z_STOW));
|
|
2443
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > stow_z_probe()");
|
2448
|
2444
|
#endif
|
2449
|
|
- _Z_STOW;
|
|
2445
|
+ stow_z_probe();
|
2450
|
2446
|
}
|
2451
|
2447
|
#endif
|
2452
|
2448
|
|
|
@@ -3468,9 +3464,7 @@ inline void gcode_G28() {
|
3468
|
3464
|
#endif // !DELTA
|
3469
|
3465
|
}
|
3470
|
3466
|
|
3471
|
|
- #if ENABLED(Z_PROBE_SLED)
|
3472
|
|
- dock_sled(false); // engage (un-dock) the Z probe
|
3473
|
|
- #elif ENABLED(FIX_MOUNTED_PROBE) || ENABLED(MECHANICAL_PROBE) || ENABLED(Z_PROBE_ALLEN_KEY) || (ENABLED(DELTA) && HAS_Z_SERVO_ENDSTOP)
|
|
3467
|
+ #if HAS_BED_PROBE
|
3474
|
3468
|
deploy_z_probe();
|
3475
|
3469
|
#endif
|
3476
|
3470
|
|
|
@@ -3721,14 +3715,7 @@ inline void gcode_G28() {
|
3721
|
3715
|
|
3722
|
3716
|
#endif // !AUTO_BED_LEVELING_GRID
|
3723
|
3717
|
|
3724
|
|
- #if ENABLED(DELTA)
|
3725
|
|
- // Allen Key Probe for Delta
|
3726
|
|
- #if ENABLED(Z_PROBE_ALLEN_KEY) || HAS_Z_SERVO_ENDSTOP
|
3727
|
|
- stow_z_probe();
|
3728
|
|
- #else
|
3729
|
|
- raise_z_after_probing(); // for non Allen Key probes, such as simple mechanical probe
|
3730
|
|
- #endif
|
3731
|
|
- #else // !DELTA
|
|
3718
|
+ #if DISABLED(DELTA)
|
3732
|
3719
|
if (verbose_level > 0)
|
3733
|
3720
|
planner.bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
|
3734
|
3721
|
|
|
@@ -3788,7 +3775,7 @@ inline void gcode_G28() {
|
3788
|
3775
|
#if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)
|
3789
|
3776
|
+ Z_RAISE_AFTER_PROBING
|
3790
|
3777
|
#endif
|
3791
|
|
- ;
|
|
3778
|
+ ;
|
3792
|
3779
|
// current_position[Z_AXIS] += home_offset[Z_AXIS]; // The Z probe determines Z=0, not "Z home"
|
3793
|
3780
|
sync_plan_position();
|
3794
|
3781
|
|
|
@@ -3796,18 +3783,13 @@ inline void gcode_G28() {
|
3796
|
3783
|
if (DEBUGGING(LEVELING)) DEBUG_POS("> corrected Z in G29", current_position);
|
3797
|
3784
|
#endif
|
3798
|
3785
|
}
|
3799
|
|
-
|
3800
|
|
- // Sled assembly for Cartesian bots
|
3801
|
|
- #if ENABLED(Z_PROBE_SLED)
|
3802
|
|
- dock_sled(true); // dock the sled
|
3803
|
|
- #elif !HAS_Z_SERVO_ENDSTOP && DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED)
|
3804
|
|
- // Raise Z axis for non-delta and non servo based probes
|
3805
|
|
- raise_z_after_probing();
|
3806
|
|
- #endif
|
3807
|
|
-
|
3808
|
3786
|
#endif // !DELTA
|
3809
|
3787
|
|
3810
|
|
- #if ENABLED(MECHANICAL_PROBE)
|
|
3788
|
+ #if DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED) && !HAS_Z_SERVO_ENDSTOP
|
|
3789
|
+ raise_z_after_probing();
|
|
3790
|
+ #endif
|
|
3791
|
+
|
|
3792
|
+ #if ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) || ENABLED(MECHANICAL_PROBE)
|
3811
|
3793
|
stow_z_probe();
|
3812
|
3794
|
#endif
|
3813
|
3795
|
|
|
@@ -3838,38 +3820,38 @@ inline void gcode_G28() {
|
3838
|
3820
|
KEEPALIVE_STATE(IN_HANDLER);
|
3839
|
3821
|
}
|
3840
|
3822
|
|
3841
|
|
- #if DISABLED(Z_PROBE_SLED) // could be avoided
|
|
3823
|
+#endif //AUTO_BED_LEVELING_FEATURE
|
3842
|
3824
|
|
3843
|
|
- /**
|
3844
|
|
- * G30: Do a single Z probe at the current XY
|
3845
|
|
- */
|
3846
|
|
- inline void gcode_G30() {
|
3847
|
|
- deploy_z_probe(); // Engage Z Servo endstop if available. Z_PROBE_SLED is missed here.
|
|
3825
|
+#if HAS_BED_PROBE
|
3848
|
3826
|
|
3849
|
|
- stepper.synchronize();
|
3850
|
|
- // TODO: clear the leveling matrix or the planner will be set incorrectly
|
3851
|
|
- setup_for_endstop_move(); // Too late. Must be done before deploying.
|
|
3827
|
+ /**
|
|
3828
|
+ * G30: Do a single Z probe at the current XY
|
|
3829
|
+ */
|
|
3830
|
+ inline void gcode_G30() {
|
|
3831
|
+ deploy_z_probe();
|
3852
|
3832
|
|
3853
|
|
- run_z_probe();
|
|
3833
|
+ stepper.synchronize();
|
|
3834
|
+ // TODO: clear the leveling matrix or the planner will be set incorrectly
|
|
3835
|
+ setup_for_endstop_move(); // Too late. Must be done before deploying.
|
3854
|
3836
|
|
3855
|
|
- SERIAL_PROTOCOLPGM("Bed X: ");
|
3856
|
|
- SERIAL_PROTOCOL(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
|
3857
|
|
- SERIAL_PROTOCOLPGM(" Y: ");
|
3858
|
|
- SERIAL_PROTOCOL(current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
|
3859
|
|
- SERIAL_PROTOCOLPGM(" Z: ");
|
3860
|
|
- SERIAL_PROTOCOL(current_position[Z_AXIS] + 0.0001);
|
3861
|
|
- SERIAL_EOL;
|
|
3837
|
+ run_z_probe();
|
3862
|
3838
|
|
3863
|
|
- clean_up_after_endstop_move(); // Too early. must be done after the stowing.
|
|
3839
|
+ SERIAL_PROTOCOLPGM("Bed X: ");
|
|
3840
|
+ SERIAL_PROTOCOL(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
|
|
3841
|
+ SERIAL_PROTOCOLPGM(" Y: ");
|
|
3842
|
+ SERIAL_PROTOCOL(current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
|
|
3843
|
+ SERIAL_PROTOCOLPGM(" Z: ");
|
|
3844
|
+ SERIAL_PROTOCOL(current_position[Z_AXIS] + 0.0001);
|
|
3845
|
+ SERIAL_EOL;
|
3864
|
3846
|
|
3865
|
|
- stow_z_probe(); // Retract Z Servo endstop if available. Z_PROBE_SLED is missed here.
|
|
3847
|
+ clean_up_after_endstop_move(); // Too early. must be done after the stowing.
|
3866
|
3848
|
|
3867
|
|
- report_current_position();
|
3868
|
|
- }
|
|
3849
|
+ stow_z_probe();
|
3869
|
3850
|
|
3870
|
|
- #endif //!Z_PROBE_SLED
|
|
3851
|
+ report_current_position();
|
|
3852
|
+ }
|
3871
|
3853
|
|
3872
|
|
-#endif //AUTO_BED_LEVELING_FEATURE
|
|
3854
|
+#endif // HAS_BED_PROBE
|
3873
|
3855
|
|
3874
|
3856
|
/**
|
3875
|
3857
|
* G92: Set current position to given X Y Z E
|
|
@@ -6875,24 +6857,24 @@ void process_next_command() {
|
6875
|
6857
|
break;
|
6876
|
6858
|
#endif
|
6877
|
6859
|
|
6878
|
|
- #if ENABLED(AUTO_BED_LEVELING_FEATURE)
|
6879
|
|
-
|
6880
|
|
- #if DISABLED(Z_PROBE_SLED)
|
|
6860
|
+ #if HAS_BED_PROBE
|
6881
|
6861
|
|
6882
|
|
- case 30: // G30 Single Z probe
|
6883
|
|
- gcode_G30();
|
6884
|
|
- break;
|
|
6862
|
+ case 30: // G30 Single Z probe
|
|
6863
|
+ gcode_G30();
|
|
6864
|
+ break;
|
6885
|
6865
|
|
6886
|
|
- #else // Z_PROBE_SLED
|
|
6866
|
+ #if ENABLED(Z_PROBE_SLED)
|
6887
|
6867
|
|
6888
|
6868
|
case 31: // G31: dock the sled
|
|
6869
|
+ stow_z_probe();
|
|
6870
|
+ break;
|
6889
|
6871
|
case 32: // G32: undock the sled
|
6890
|
|
- dock_sled(codenum == 31);
|
|
6872
|
+ deploy_z_probe();
|
6891
|
6873
|
break;
|
6892
|
6874
|
|
6893
|
6875
|
#endif // Z_PROBE_SLED
|
6894
|
6876
|
|
6895
|
|
- #endif // AUTO_BED_LEVELING_FEATURE
|
|
6877
|
+ #endif // HAS_BED_PROBE
|
6896
|
6878
|
|
6897
|
6879
|
case 90: // G90
|
6898
|
6880
|
relative_mode = false;
|