浏览代码

Document, adjust some homing code

Scott Lahteine 4 年前
父节点
当前提交
a87e5197cf
共有 3 个文件被更改,包括 45 次插入33 次删除
  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 查看文件

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

+ 38
- 26
Marlin/src/module/motion.cpp 查看文件

1293
 void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0) {
1293
 void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0) {
1294
   DEBUG_SECTION(log_move, "do_homing_move", DEBUGGING(LEVELING));
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
   if (DEBUGGING(LEVELING)) {
1298
   if (DEBUGGING(LEVELING)) {
1299
     DEBUG_ECHOPAIR("...(", axis_codes[axis], ", ", distance, ", ");
1299
     DEBUG_ECHOPAIR("...(", axis_codes[axis], ", ", distance, ", ");
1300
     if (fr_mm_s)
1300
     if (fr_mm_s)
1301
       DEBUG_ECHO(fr_mm_s);
1301
       DEBUG_ECHO(fr_mm_s);
1302
     else
1302
     else
1303
-      DEBUG_ECHOPAIR("[", real_fr_mm_s, "]");
1303
+      DEBUG_ECHOPAIR("[", home_fr_mm_s, "]");
1304
     DEBUG_ECHOLNPGM(")");
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
   // Only do some things when moving towards an endstop
1307
   // Only do some things when moving towards an endstop
1314
   const int8_t axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS)
1308
   const int8_t axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS)
1315
                 ? x_home_dir(active_extruder) : home_dir(axis);
1309
                 ? x_home_dir(active_extruder) : home_dir(axis);
1321
 
1315
 
1322
   if (is_home_dir) {
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
     // Disable stealthChop if used. Enable diag1 pin on driver.
1327
     // Disable stealthChop if used. Enable diag1 pin on driver.
1329
     TERN_(SENSORLESS_HOMING, stealth_states = start_sensorless_homing_per_axis(axis));
1328
     TERN_(SENSORLESS_HOMING, stealth_states = start_sensorless_homing_per_axis(axis));
1334
     current_position[axis] = 0;
1333
     current_position[axis] = 0;
1335
     sync_plan_position();
1334
     sync_plan_position();
1336
     current_position[axis] = distance;
1335
     current_position[axis] = distance;
1337
-    line_to_current_position(real_fr_mm_s);
1336
+    line_to_current_position(home_fr_mm_s);
1338
   #else
1337
   #else
1339
     // Get the ABC or XYZ positions in mm
1338
     // Get the ABC or XYZ positions in mm
1340
     abce_pos_t target = planner.get_axis_positions_mm();
1339
     abce_pos_t target = planner.get_axis_positions_mm();
1352
       #if HAS_DIST_MM_ARG
1351
       #if HAS_DIST_MM_ARG
1353
         , cart_dist_mm
1352
         , cart_dist_mm
1354
       #endif
1353
       #endif
1355
-      , real_fr_mm_s, active_extruder
1354
+      , home_fr_mm_s, active_extruder
1356
     );
1355
     );
1357
   #endif
1356
   #endif
1358
 
1357
 
1571
   const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS)
1570
   const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS)
1572
               ? x_home_dir(active_extruder) : home_dir(axis);
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
   if (TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && probe.deploy()))
1576
   if (TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && probe.deploy()))
1576
     return;
1577
     return;
1577
 
1578
 
1586
     }
1587
     }
1587
   #endif
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
   #if HOMING_Z_WITH_PROBE
1593
   #if HOMING_Z_WITH_PROBE
1593
     if (axis == Z_AXIS) {
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
       if (TERN0(PROBE_TARE, probe.tare())) return;
1596
       if (TERN0(PROBE_TARE, probe.tare())) return;
1596
     }
1597
     }
1597
   #endif
1598
   #endif
1598
 
1599
 
1600
+  //
1601
+  // Back away to prevent an early X/Y sensorless trigger
1602
+  //
1599
   #if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM)
1603
   #if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM)
1600
     const xy_float_t backoff = SENSORLESS_BACKOFF_MM;
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
   #endif
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
   #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
1619
   #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
1608
     if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
1620
     if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
1617
   // If a second homing move is configured...
1629
   // If a second homing move is configured...
1618
   if (bump) {
1630
   if (bump) {
1619
     // Move away from the endstop by the axis HOMING_BUMP_MM
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
     do_homing_move(axis, -bump
1633
     do_homing_move(axis, -bump
1622
       #if HOMING_Z_WITH_PROBE
1634
       #if HOMING_Z_WITH_PROBE
1623
         , MMM_TO_MMS(axis == Z_AXIS ? Z_PROBE_SPEED_FAST : 0)
1635
         , MMM_TO_MMS(axis == Z_AXIS ? Z_PROBE_SPEED_FAST : 0)
1639
       }
1651
       }
1640
     #endif
1652
     #endif
1641
 
1653
 
1642
-    // Slow move towards endstop until triggered
1643
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 2 Slow:");
1644
-
1645
     #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
1654
     #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
1646
       if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE)
1655
       if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE)
1647
     #endif
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
     #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
1663
     #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
1652
       if (axis == Z_AXIS) bltouch.stow(); // The final STOW
1664
       if (axis == Z_AXIS) bltouch.stow(); // The final STOW

+ 5
- 5
Marlin/src/module/probe.cpp 查看文件

373
   // Fix-mounted probe should only raise for deploy
373
   // Fix-mounted probe should only raise for deploy
374
   // unless PAUSE_BEFORE_DEPLOY_STOW is enabled
374
   // unless PAUSE_BEFORE_DEPLOY_STOW is enabled
375
   #if EITHER(FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE) && DISABLED(PAUSE_BEFORE_DEPLOY_STOW)
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
   #else
377
   #else
378
-    constexpr bool deploy_stow_condition = true;
378
+    constexpr bool z_raise_wanted = true;
379
   #endif
379
   #endif
380
 
380
 
381
   // For beds that fall when Z is powered off only raise for trusted Z
381
   // For beds that fall when Z is powered off only raise for trusted Z
382
   #if ENABLED(UNKNOWN_Z_NO_RAISE)
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
   #else
384
   #else
385
-    constexpr float unknown_condition = true;
385
+    constexpr float z_is_trusted = true;
386
   #endif
386
   #endif
387
 
387
 
388
-  if (deploy_stow_condition && unknown_condition)
388
+  if (z_is_trusted && z_raise_wanted)
389
     do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
389
     do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
390
 
390
 
391
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
391
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)

正在加载...
取消
保存