瀏覽代碼

Homing/probing feedrate, comments

Scott Lahteine 8 年之前
父節點
當前提交
e69d1e2879
共有 1 個文件被更改,包括 44 次插入51 次删除
  1. 44
    51
      Marlin/Marlin_main.cpp

+ 44
- 51
Marlin/Marlin_main.cpp 查看文件

@@ -307,7 +307,7 @@ static uint8_t cmd_queue_index_r = 0,
307 307
  * Feed rates are often configured with mm/m
308 308
  * but the planner and stepper like mm/s units.
309 309
  */
310
-const float homing_feedrate_mm_s[] = {
310
+float constexpr homing_feedrate_mm_s[] = {
311 311
   #if ENABLED(DELTA)
312 312
     MMM_TO_MMS(HOMING_FEEDRATE_Z), MMM_TO_MMS(HOMING_FEEDRATE_Z),
313 313
   #else
@@ -1368,6 +1368,9 @@ static void set_axis_is_at_home(AxisEnum axis) {
1368 1368
 
1369 1369
   #if ENABLED(MORGAN_SCARA)
1370 1370
 
1371
+    /**
1372
+     * Morgan SCARA homes XY at the same time
1373
+     */
1371 1374
     if (axis == X_AXIS || axis == Y_AXIS) {
1372 1375
 
1373 1376
       float homeposition[XYZ];
@@ -1399,34 +1402,37 @@ static void set_axis_is_at_home(AxisEnum axis) {
1399 1402
   #endif
1400 1403
   {
1401 1404
     current_position[axis] = LOGICAL_POSITION(base_home_pos(axis), axis);
1405
+  }
1402 1406
 
1407
+  /**
1408
+   * Z Probe Z Homing? Account for the probe's Z offset.
1409
+   */
1410
+  #if HAS_BED_PROBE && Z_HOME_DIR < 0
1403 1411
     if (axis == Z_AXIS) {
1404
-      #if HAS_BED_PROBE && Z_HOME_DIR < 0
1405
-        #if HOMING_Z_WITH_PROBE
1406
-          current_position[Z_AXIS] -= zprobe_zoffset;
1407
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
1408
-            if (DEBUGGING(LEVELING)) {
1409
-              SERIAL_ECHOLNPGM("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***");
1410
-              SERIAL_ECHOLNPAIR("> zprobe_zoffset = ", zprobe_zoffset);
1411
-            }
1412
-          #endif
1413
-        #elif ENABLED(DEBUG_LEVELING_FEATURE)
1414
-          if (DEBUGGING(LEVELING))
1415
-            SERIAL_ECHOLNPGM("*** Z HOMED TO ENDSTOP (Z_MIN_PROBE_ENDSTOP) ***");
1412
+      #if HOMING_Z_WITH_PROBE
1413
+
1414
+        current_position[Z_AXIS] -= zprobe_zoffset;
1415
+
1416
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
1417
+          if (DEBUGGING(LEVELING)) {
1418
+            SERIAL_ECHOLNPGM("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***");
1419
+            SERIAL_ECHOLNPAIR("> zprobe_zoffset = ", zprobe_zoffset);
1420
+          }
1416 1421
         #endif
1422
+
1423
+      #elif ENABLED(DEBUG_LEVELING_FEATURE)
1424
+
1425
+        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("*** Z HOMED TO ENDSTOP (Z_MIN_PROBE_ENDSTOP) ***");
1426
+
1417 1427
       #endif
1418 1428
     }
1429
+  #endif
1419 1430
 
1420
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
1421
-      if (DEBUGGING(LEVELING)) {
1422
-        SERIAL_ECHOPAIR("> home_offset[", axis_codes[axis]);
1423
-        SERIAL_ECHOLNPAIR("] = ", home_offset[axis]);
1424
-        DEBUG_POS("", current_position);
1425
-      }
1426
-    #endif
1427
-  }
1428 1431
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1429 1432
     if (DEBUGGING(LEVELING)) {
1433
+      SERIAL_ECHOPAIR("> home_offset[", axis_codes[axis]);
1434
+      SERIAL_ECHOLNPAIR("] = ", home_offset[axis]);
1435
+      DEBUG_POS("", current_position);
1430 1436
       SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis_codes[axis]);
1431 1437
       SERIAL_ECHOLNPGM(")");
1432 1438
     }
@@ -1437,7 +1443,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
1437 1443
  * Some planner shorthand inline functions
1438 1444
  */
1439 1445
 inline float get_homing_bump_feedrate(AxisEnum axis) {
1440
-  const int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
1446
+  int constexpr homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
1441 1447
   int hbd = homing_bump_divisor[axis];
1442 1448
   if (hbd < 1) {
1443 1449
     hbd = 10;
@@ -1475,13 +1481,13 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
1475 1481
   /**
1476 1482
    * Calculate delta, start a line, and set current_position to destination
1477 1483
    */
1478
-  void prepare_uninterpolated_move_to_destination() {
1484
+  void prepare_uninterpolated_move_to_destination(const float fr_mm_s=0.0) {
1479 1485
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1480 1486
       if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
1481 1487
     #endif
1482 1488
     refresh_cmd_timeout();
1483 1489
     inverse_kinematics(destination);
1484
-    planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], destination[E_AXIS], MMS_SCALED(feedrate_mm_s), active_extruder);
1490
+    planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], destination[E_AXIS], MMS_SCALED(fr_mm_s ? fr_mm_s : feedrate_mm_s), active_extruder);
1485 1491
     set_current_to_destination();
1486 1492
   }
1487 1493
 #endif
@@ -1499,7 +1505,7 @@ void do_blocking_move_to(const float &x, const float &y, const float &z, const f
1499 1505
 
1500 1506
   #if ENABLED(DELTA)
1501 1507
 
1502
-    feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1508
+    feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1503 1509
 
1504 1510
     set_destination_to_current();          // sync destination at the start
1505 1511
 
@@ -1561,41 +1567,37 @@ void do_blocking_move_to(const float &x, const float &y, const float &z, const f
1561 1567
 
1562 1568
     // If Z needs to raise, do it before moving XY
1563 1569
     if (current_position[Z_AXIS] < z) {
1564
-      feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : homing_feedrate_mm_s[Z_AXIS];
1565 1570
       destination[Z_AXIS] = z;
1566
-      prepare_uninterpolated_move_to_destination();
1571
+      prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : homing_feedrate_mm_s[Z_AXIS]);
1567 1572
     }
1568 1573
 
1569
-    feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1570
-
1571 1574
     destination[X_AXIS] = x;
1572 1575
     destination[Y_AXIS] = y;
1573
-    prepare_uninterpolated_move_to_destination();
1576
+    prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S);
1574 1577
 
1575 1578
     // If Z needs to lower, do it after moving XY
1576 1579
     if (current_position[Z_AXIS] > z) {
1577
-      feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : homing_feedrate_mm_s[Z_AXIS];
1578 1580
       destination[Z_AXIS] = z;
1579
-      prepare_uninterpolated_move_to_destination();
1581
+      prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : homing_feedrate_mm_s[Z_AXIS]);
1580 1582
     }
1581 1583
 
1582 1584
   #else
1583 1585
 
1584 1586
     // If Z needs to raise, do it before moving XY
1585 1587
     if (current_position[Z_AXIS] < z) {
1586
-      feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : homing_feedrate_mm_s[Z_AXIS];
1588
+      feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate_mm_s[Z_AXIS];
1587 1589
       current_position[Z_AXIS] = z;
1588 1590
       line_to_current_position();
1589 1591
     }
1590 1592
 
1591
-    feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1593
+    feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1592 1594
     current_position[X_AXIS] = x;
1593 1595
     current_position[Y_AXIS] = y;
1594 1596
     line_to_current_position();
1595 1597
 
1596 1598
     // If Z needs to lower, do it after moving XY
1597 1599
     if (current_position[Z_AXIS] > z) {
1598
-      feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : homing_feedrate_mm_s[Z_AXIS];
1600
+      feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate_mm_s[Z_AXIS];
1599 1601
       current_position[Z_AXIS] = z;
1600 1602
       line_to_current_position();
1601 1603
     }
@@ -2221,7 +2223,7 @@ static void clean_up_after_endstop_or_probe_move() {
2221 2223
  * Home an individual linear axis
2222 2224
  */
2223 2225
 
2224
-static void do_homing_move(AxisEnum axis, float where, float fr_mm_s = 0.0) {
2226
+static void do_homing_move(AxisEnum axis, float where, float fr_mm_s=0.0) {
2225 2227
 
2226 2228
   #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
2227 2229
     if (axis == Z_AXIS) set_bltouch_deployed(true);
@@ -2230,7 +2232,7 @@ static void do_homing_move(AxisEnum axis, float where, float fr_mm_s = 0.0) {
2230 2232
   current_position[axis] = 0;
2231 2233
   sync_plan_position();
2232 2234
   current_position[axis] = where;
2233
-  planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], (fr_mm_s != 0.0) ? fr_mm_s : homing_feedrate_mm_s[axis], active_extruder);
2235
+  planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], fr_mm_s ? fr_mm_s : homing_feedrate_mm_s[axis], active_extruder);
2234 2236
   stepper.synchronize();
2235 2237
 
2236 2238
   #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
@@ -2287,23 +2289,13 @@ static void homeaxis(AxisEnum axis) {
2287 2289
     if (axis == Z_AXIS) stepper.set_homing_flag(true);
2288 2290
   #endif
2289 2291
 
2290
-  // Move towards the endstop until an endstop is triggered
2292
+  // 1. Fast move towards endstop until triggered
2293
+  // 2. Move away from the endstop by the axis HOME_BUMP_MM
2294
+  // 3. Slow move towards endstop until triggered
2291 2295
   do_homing_move(axis, 1.5 * max_length(axis) * axis_home_dir);
2292
-
2293
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
2294
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("> 1st Home ", current_position[axis]);
2295
-  #endif
2296
-
2297
-  // Move away from the endstop by the axis HOME_BUMP_MM
2298 2296
   do_homing_move(axis, -home_bump_mm(axis) * axis_home_dir);
2299
-
2300
-  // Move slowly towards the endstop until triggered
2301 2297
   do_homing_move(axis, 2 * home_bump_mm(axis) * axis_home_dir, get_homing_bump_feedrate(axis));
2302 2298
 
2303
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
2304
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("> 2nd Home ", current_position[axis]);
2305
-  #endif
2306
-
2307 2299
   #if ENABLED(Z_DUAL_ENDSTOPS)
2308 2300
     if (axis == Z_AXIS) {
2309 2301
       float adj = fabs(z_endstop_adj);
@@ -2349,7 +2341,8 @@ static void homeaxis(AxisEnum axis) {
2349 2341
 
2350 2342
   #else
2351 2343
 
2352
-    // Set the axis position to its home position (plus home offsets)
2344
+    // For cartesian/core machines,
2345
+    // set the axis to its home position
2353 2346
     set_axis_is_at_home(axis);
2354 2347
     sync_plan_position();
2355 2348
 

Loading…
取消
儲存