Browse Source

Homing feedrates as XYZ array (#20426)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
rafaljot 3 years ago
parent
commit
fbcc07261d
No account linked to committer's email address

+ 2
- 3
Marlin/Configuration.h View File

@@ -1001,7 +1001,7 @@
1001 1001
 #define XY_PROBE_SPEED (133*60)
1002 1002
 
1003 1003
 // Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2)
1004
-#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
1004
+#define Z_PROBE_SPEED_FAST (4*60)
1005 1005
 
1006 1006
 // Feedrate (mm/min) for the "accurate" probe of each point
1007 1007
 #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
@@ -1458,8 +1458,7 @@
1458 1458
 #endif
1459 1459
 
1460 1460
 // Homing speeds (mm/min)
1461
-#define HOMING_FEEDRATE_XY (50*60)
1462
-#define HOMING_FEEDRATE_Z  (4*60)
1461
+#define HOMING_FEEDRATE_MM_M { (50*60), (50*60), (4*60) }
1463 1462
 
1464 1463
 // Validate that endstops are triggered on homing moves
1465 1464
 #define VALIDATE_HOMING_ENDSTOPS

+ 1
- 5
Marlin/src/inc/Conditionals_post.h View File

@@ -2317,11 +2317,7 @@
2317 2317
     #define Z_PROBE_OFFSET_RANGE_MAX 20
2318 2318
   #endif
2319 2319
   #ifndef XY_PROBE_SPEED
2320
-    #ifdef HOMING_FEEDRATE_XY
2321
-      #define XY_PROBE_SPEED HOMING_FEEDRATE_XY
2322
-    #else
2323
-      #define XY_PROBE_SPEED 4000
2324
-    #endif
2320
+    #define XY_PROBE_SPEED ((homing_feedrate_mm_m.x + homing_feedrate_mm_m.y) / 2)
2325 2321
   #endif
2326 2322
   #ifndef NOZZLE_TO_PROBE_OFFSET
2327 2323
     #define NOZZLE_TO_PROBE_OFFSET { 0, 0, 0 }

+ 3
- 1
Marlin/src/inc/SanityCheck.h View File

@@ -189,7 +189,9 @@
189 189
 #elif defined(ENDSTOPS_ONLY_FOR_HOMING)
190 190
   #error "ENDSTOPS_ONLY_FOR_HOMING is deprecated. Use (disable) ENDSTOPS_ALWAYS_ON_DEFAULT instead."
191 191
 #elif defined(HOMING_FEEDRATE)
192
-  #error "HOMING_FEEDRATE is deprecated. Set individual rates with HOMING_FEEDRATE_(XY|Z|E) instead."
192
+  #error "HOMING_FEEDRATE is now set using the HOMING_FEEDRATE_MM_M array instead."
193
+#elif defined(HOMING_FEEDRATE_XY) || defined(HOMING_FEEDRATE_Z)
194
+  #error "HOMING_FEEDRATE_XY and HOMING_FEEDRATE_Z are now set using the HOMING_FEEDRATE_MM_M array instead."
193 195
 #elif defined(MANUAL_HOME_POSITIONS)
194 196
   #error "MANUAL_HOME_POSITIONS is deprecated. Set MANUAL_[XYZ]_HOME_POS as-needed instead."
195 197
 #elif defined(PID_ADD_EXTRUSION_RATE)

+ 3
- 13
Marlin/src/module/motion.cpp View File

@@ -143,16 +143,6 @@ xyze_pos_t destination; // {0}
143 143
 feedRate_t feedrate_mm_s = MMM_TO_MMS(1500);
144 144
 int16_t feedrate_percentage = 100;
145 145
 
146
-// Homing feedrate is const progmem - compare to constexpr in the header
147
-const feedRate_t homing_feedrate_mm_s[XYZ] PROGMEM = {
148
-  #if ENABLED(DELTA)
149
-    MMM_TO_MMS(HOMING_FEEDRATE_Z), MMM_TO_MMS(HOMING_FEEDRATE_Z),
150
-  #else
151
-    MMM_TO_MMS(HOMING_FEEDRATE_XY), MMM_TO_MMS(HOMING_FEEDRATE_XY),
152
-  #endif
153
-  MMM_TO_MMS(HOMING_FEEDRATE_Z)
154
-};
155
-
156 146
 // Cartesian conversion result goes here:
157 147
 xyz_pos_t cartes;
158 148
 
@@ -195,7 +185,7 @@ xyz_pos_t cartes;
195 185
 #endif
196 186
 
197 187
 #if HAS_ABL_NOT_UBL
198
-  float xy_probe_feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
188
+  feedRate_t xy_probe_feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
199 189
 #endif
200 190
 
201 191
 /**
@@ -510,7 +500,7 @@ void do_z_clearance(const float &zclear, const bool z_trusted/*=true*/, const bo
510 500
   const bool rel = raise_on_untrusted && !z_trusted;
511 501
   float zdest = zclear + (rel ? current_position.z : 0.0f);
512 502
   if (!lower_allowed) NOLESS(zdest, current_position.z);
513
-  do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), TERN(HAS_BED_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST), homing_feedrate(Z_AXIS)));
503
+  do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), TERN(HAS_BED_PROBE, z_probe_fast_mm_s, homing_feedrate(Z_AXIS)));
514 504
 }
515 505
 
516 506
 //
@@ -1841,7 +1831,7 @@ void homeaxis(const AxisEnum axis) {
1841 1831
       current_position[axis] -= ABS(endstop_backoff[axis]) * axis_home_dir;
1842 1832
       line_to_current_position(
1843 1833
         #if HOMING_Z_WITH_PROBE
1844
-          (axis == Z_AXIS) ? MMM_TO_MMS(Z_PROBE_SPEED_FAST) :
1834
+          (axis == Z_AXIS) ? z_probe_fast_mm_s :
1845 1835
         #endif
1846 1836
         homing_feedrate(axis)
1847 1837
       );

+ 19
- 3
Marlin/src/module/motion.h View File

@@ -57,7 +57,7 @@ extern xyz_pos_t cartes;
57 57
 #endif
58 58
 
59 59
 #if HAS_ABL_NOT_UBL
60
-  extern float xy_probe_feedrate_mm_s;
60
+  extern feedRate_t xy_probe_feedrate_mm_s;
61 61
   #define XY_PROBE_FEEDRATE_MM_S xy_probe_feedrate_mm_s
62 62
 #elif defined(XY_PROBE_SPEED)
63 63
   #define XY_PROBE_FEEDRATE_MM_S MMM_TO_MMS(XY_PROBE_SPEED)
@@ -65,12 +65,28 @@ extern xyz_pos_t cartes;
65 65
   #define XY_PROBE_FEEDRATE_MM_S PLANNER_XY_FEEDRATE()
66 66
 #endif
67 67
 
68
+constexpr feedRate_t z_probe_fast_mm_s = MMM_TO_MMS(Z_PROBE_SPEED_FAST);
69
+
68 70
 /**
69 71
  * Feed rates are often configured with mm/m
70 72
  * but the planner and stepper like mm/s units.
71 73
  */
72
-extern const feedRate_t homing_feedrate_mm_s[XYZ];
73
-FORCE_INLINE feedRate_t homing_feedrate(const AxisEnum a) { return pgm_read_float(&homing_feedrate_mm_s[a]); }
74
+constexpr xyz_feedrate_t homing_feedrate_mm_m = HOMING_FEEDRATE_MM_M;
75
+FORCE_INLINE feedRate_t homing_feedrate(const AxisEnum a) {
76
+  float v;
77
+  #if ENABLED(DELTA)
78
+    v = homing_feedrate_mm_m.z;
79
+  #else
80
+    switch (a) {
81
+      case X_AXIS: v = homing_feedrate_mm_m.x; break;
82
+      case Y_AXIS: v = homing_feedrate_mm_m.y; break;
83
+      case Z_AXIS:
84
+          default: v = homing_feedrate_mm_m.z;
85
+    }
86
+  #endif
87
+  return MMM_TO_MMS(v);
88
+}
89
+
74 90
 feedRate_t get_homing_bump_feedrate(const AxisEnum axis);
75 91
 
76 92
 /**

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

@@ -516,7 +516,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
516 516
   #if TOTAL_PROBING == 2
517 517
 
518 518
     // Do a first probe at the fast speed
519
-    if (try_to_probe(PSTR("FAST"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST),
519
+    if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
520 520
                      sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
521 521
 
522 522
     const float first_probe_z = current_position.z;
@@ -524,7 +524,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
524 524
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("1st Probe Z:", first_probe_z);
525 525
 
526 526
     // Raise to give the probe clearance
527
-    do_blocking_move_to_z(current_position.z + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
527
+    do_blocking_move_to_z(current_position.z + Z_CLEARANCE_MULTI_PROBE, z_probe_fast_mm_s);
528 528
 
529 529
   #elif Z_PROBE_SPEED_FAST != Z_PROBE_SPEED_SLOW
530 530
 
@@ -533,8 +533,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
533 533
     const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (offset.z < 0 ? -offset.z : 0);
534 534
     if (current_position.z > z) {
535 535
       // Probe down fast. If the probe never triggered, raise for probe clearance
536
-      if (!probe_down_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST)))
537
-        do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
536
+      if (!probe_down_to_z(z, z_probe_fast_mm_s))
537
+        do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, z_probe_fast_mm_s);
538 538
     }
539 539
   #endif
540 540
 
@@ -582,7 +582,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
582 582
           #if EXTRA_PROBING > 0
583 583
             < TOTAL_PROBING - 1
584 584
           #endif
585
-        ) do_blocking_move_to_z(z + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
585
+        ) do_blocking_move_to_z(z + Z_CLEARANCE_MULTI_PROBE, z_probe_fast_mm_s);
586 586
       #endif
587 587
     }
588 588
 
@@ -672,7 +672,7 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise
672 672
   if (!isnan(measured_z)) {
673 673
     const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
674 674
     if (big_raise || raise_after == PROBE_PT_RAISE)
675
-      do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
675
+      do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s);
676 676
     else if (raise_after == PROBE_PT_STOW)
677 677
       if (stow()) measured_z = NAN;   // Error on stow?
678 678
 

Loading…
Cancel
Save