Browse Source

Document, adjust some homing code

Scott Lahteine 3 years ago
parent
commit
a87e5197cf
3 changed files with 45 additions and 33 deletions
  1. 2
    2
      Marlin/src/feature/z_stepper_align.cpp
  2. 38
    26
      Marlin/src/module/motion.cpp
  3. 5
    5
      Marlin/src/module/probe.cpp

+ 2
- 2
Marlin/src/feature/z_stepper_align.cpp View File

@@ -58,7 +58,7 @@ void ZStepperAlign::reset_to_default() {
58 58
       "Z_STEPPER_ALIGN_XY point " STRINGIFY(N) " is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.")
59 59
     VALIDATE_ALIGN_POINT(0); VALIDATE_ALIGN_POINT(1); VALIDATE_ALIGN_POINT(2); VALIDATE_ALIGN_POINT(3);
60 60
 
61
-  #else // !defined(Z_STEPPER_ALIGN_XY)
61
+  #else // !Z_STEPPER_ALIGN_XY
62 62
 
63 63
     const xy_pos_t xy_init[] = {
64 64
       #if NUM_Z_STEPPER_DRIVERS >= 3  // First probe point...
@@ -99,7 +99,7 @@ void ZStepperAlign::reset_to_default() {
99 99
       #endif
100 100
     };
101 101
 
102
-  #endif // !defined(Z_STEPPER_ALIGN_XY)
102
+  #endif // !Z_STEPPER_ALIGN_XY
103 103
 
104 104
   COPY(xy, xy_init);
105 105
 

+ 38
- 26
Marlin/src/module/motion.cpp View File

@@ -1293,23 +1293,17 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) {
1293 1293
 void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0) {
1294 1294
   DEBUG_SECTION(log_move, "do_homing_move", DEBUGGING(LEVELING));
1295 1295
 
1296
-  const feedRate_t real_fr_mm_s = fr_mm_s ?: homing_feedrate(axis);
1296
+  const feedRate_t home_fr_mm_s = fr_mm_s ?: homing_feedrate(axis);
1297 1297
 
1298 1298
   if (DEBUGGING(LEVELING)) {
1299 1299
     DEBUG_ECHOPAIR("...(", axis_codes[axis], ", ", distance, ", ");
1300 1300
     if (fr_mm_s)
1301 1301
       DEBUG_ECHO(fr_mm_s);
1302 1302
     else
1303
-      DEBUG_ECHOPAIR("[", real_fr_mm_s, "]");
1303
+      DEBUG_ECHOPAIR("[", home_fr_mm_s, "]");
1304 1304
     DEBUG_ECHOLNPGM(")");
1305 1305
   }
1306 1306
 
1307
-  #if ALL(HOMING_Z_WITH_PROBE, HAS_HEATED_BED, WAIT_FOR_BED_HEATER)
1308
-    // Wait for bed to heat back up between probing points
1309
-    if (axis == Z_AXIS && distance < 0)
1310
-      thermalManager.wait_for_bed_heating();
1311
-  #endif
1312
-
1313 1307
   // Only do some things when moving towards an endstop
1314 1308
   const int8_t axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS)
1315 1309
                 ? x_home_dir(active_extruder) : home_dir(axis);
@@ -1321,9 +1315,14 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
1321 1315
 
1322 1316
   if (is_home_dir) {
1323 1317
 
1324
-    #if HOMING_Z_WITH_PROBE && HAS_QUIET_PROBING
1325
-      if (axis == Z_AXIS) probe.set_probing_paused(true);
1326
-    #endif
1318
+    if (TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS)) {
1319
+      #if ALL(HAS_HEATED_BED, WAIT_FOR_BED_HEATER)
1320
+        // Wait for bed to heat back up between probing points
1321
+        thermalManager.wait_for_bed_heating();
1322
+      #endif
1323
+
1324
+      TERN_(HAS_QUIET_PROBING, probe.set_probing_paused(true));
1325
+    }
1327 1326
 
1328 1327
     // Disable stealthChop if used. Enable diag1 pin on driver.
1329 1328
     TERN_(SENSORLESS_HOMING, stealth_states = start_sensorless_homing_per_axis(axis));
@@ -1334,7 +1333,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
1334 1333
     current_position[axis] = 0;
1335 1334
     sync_plan_position();
1336 1335
     current_position[axis] = distance;
1337
-    line_to_current_position(real_fr_mm_s);
1336
+    line_to_current_position(home_fr_mm_s);
1338 1337
   #else
1339 1338
     // Get the ABC or XYZ positions in mm
1340 1339
     abce_pos_t target = planner.get_axis_positions_mm();
@@ -1352,7 +1351,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
1352 1351
       #if HAS_DIST_MM_ARG
1353 1352
         , cart_dist_mm
1354 1353
       #endif
1355
-      , real_fr_mm_s, active_extruder
1354
+      , home_fr_mm_s, active_extruder
1356 1355
     );
1357 1356
   #endif
1358 1357
 
@@ -1571,7 +1570,9 @@ void homeaxis(const AxisEnum axis) {
1571 1570
   const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS)
1572 1571
               ? x_home_dir(active_extruder) : home_dir(axis);
1573 1572
 
1574
-  // Homing Z towards the bed? Deploy the Z probe or endstop.
1573
+  //
1574
+  // Homing Z with a probe? Raise Z (maybe) and deploy the Z probe.
1575
+  //
1575 1576
   if (TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && probe.deploy()))
1576 1577
     return;
1577 1578
 
@@ -1586,23 +1587,34 @@ void homeaxis(const AxisEnum axis) {
1586 1587
     }
1587 1588
   #endif
1588 1589
 
1589
-  // Fast move towards endstop until triggered
1590
-  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:");
1591
-
1590
+  //
1591
+  // Deploy BLTouch or tare the probe just before probing
1592
+  //
1592 1593
   #if HOMING_Z_WITH_PROBE
1593 1594
     if (axis == Z_AXIS) {
1594
-      if (TERN0(BLTOUCH, bltouch.deploy())) return;
1595
+      if (TERN0(BLTOUCH, bltouch.deploy())) return;   // BLTouch was deployed above, but get the alarm state.
1595 1596
       if (TERN0(PROBE_TARE, probe.tare())) return;
1596 1597
     }
1597 1598
   #endif
1598 1599
 
1600
+  //
1601
+  // Back away to prevent an early X/Y sensorless trigger
1602
+  //
1599 1603
   #if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM)
1600 1604
     const xy_float_t backoff = SENSORLESS_BACKOFF_MM;
1601
-    if (((ENABLED(X_SENSORLESS) && axis == X_AXIS) || (ENABLED(Y_SENSORLESS) && axis == Y_AXIS)) && backoff[axis])
1602
-      do_homing_move(axis, -ABS(backoff[axis]) * axis_home_dir, homing_feedrate(axis));
1605
+    if ((TERN0(X_SENSORLESS, axis == X_AXIS) || TERN0(Y_SENSORLESS, axis == Y_AXIS)) && backoff[axis]) {
1606
+      const float backoff_length = -ABS(backoff[axis]) * axis_home_dir;
1607
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Sensorless backoff: ", backoff_length, "mm");
1608
+      do_homing_move(axis, backoff_length, homing_feedrate(axis));
1609
+    }
1603 1610
   #endif
1604 1611
 
1605
-  do_homing_move(axis, 1.5f * max_length(TERN(DELTA, Z_AXIS, axis)) * axis_home_dir);
1612
+  //
1613
+  // Fast move towards endstop until triggered
1614
+  //
1615
+  const float move_length = 1.5f * max_length(TERN(DELTA, Z_AXIS, axis)) * axis_home_dir;
1616
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Home Fast: ", move_length, "mm");
1617
+  do_homing_move(axis, move_length);
1606 1618
 
1607 1619
   #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
1608 1620
     if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
@@ -1617,7 +1629,7 @@ void homeaxis(const AxisEnum axis) {
1617 1629
   // If a second homing move is configured...
1618 1630
   if (bump) {
1619 1631
     // Move away from the endstop by the axis HOMING_BUMP_MM
1620
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away:");
1632
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Move Away: ", -bump, "mm");
1621 1633
     do_homing_move(axis, -bump
1622 1634
       #if HOMING_Z_WITH_PROBE
1623 1635
         , MMM_TO_MMS(axis == Z_AXIS ? Z_PROBE_SPEED_FAST : 0)
@@ -1639,14 +1651,14 @@ void homeaxis(const AxisEnum axis) {
1639 1651
       }
1640 1652
     #endif
1641 1653
 
1642
-    // Slow move towards endstop until triggered
1643
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 2 Slow:");
1644
-
1645 1654
     #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
1646 1655
       if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE)
1647 1656
     #endif
1648 1657
 
1649
-    do_homing_move(axis, 2 * bump, get_homing_bump_feedrate(axis));
1658
+    // Slow move towards endstop until triggered
1659
+    const float rebump = bump * 2;
1660
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Re-bump: ", rebump, "mm");
1661
+    do_homing_move(axis, rebump, get_homing_bump_feedrate(axis));
1650 1662
 
1651 1663
     #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
1652 1664
       if (axis == Z_AXIS) bltouch.stow(); // The final STOW

+ 5
- 5
Marlin/src/module/probe.cpp View File

@@ -373,19 +373,19 @@ bool Probe::set_deployed(const bool deploy) {
373 373
   // Fix-mounted probe should only raise for deploy
374 374
   // unless PAUSE_BEFORE_DEPLOY_STOW is enabled
375 375
   #if EITHER(FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE) && DISABLED(PAUSE_BEFORE_DEPLOY_STOW)
376
-    const bool deploy_stow_condition = deploy;
376
+    const bool z_raise_wanted = deploy;
377 377
   #else
378
-    constexpr bool deploy_stow_condition = true;
378
+    constexpr bool z_raise_wanted = true;
379 379
   #endif
380 380
 
381 381
   // For beds that fall when Z is powered off only raise for trusted Z
382 382
   #if ENABLED(UNKNOWN_Z_NO_RAISE)
383
-    const bool unknown_condition = axis_is_trusted(Z_AXIS);
383
+    const bool z_is_trusted = axis_is_trusted(Z_AXIS);
384 384
   #else
385
-    constexpr float unknown_condition = true;
385
+    constexpr float z_is_trusted = true;
386 386
   #endif
387 387
 
388
-  if (deploy_stow_condition && unknown_condition)
388
+  if (z_is_trusted && z_raise_wanted)
389 389
     do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
390 390
 
391 391
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)

Loading…
Cancel
Save