瀏覽代碼

🚸 Use Z_STEPPER_ALIGN_STEPPER_XY to enable

Scott Lahteine 2 年之前
父節點
當前提交
bb2f100fcd

+ 11
- 9
Marlin/Configuration_adv.h 查看文件

@@ -959,15 +959,17 @@
959 959
     //#define Z_STEPPERS_ORIENTATION 0
960 960
   #endif
961 961
 
962
-  // Provide Z stepper positions for more rapid convergence in bed alignment.
963
-  // Requires triple stepper drivers (i.e., set NUM_Z_STEPPER_DRIVERS to 3)
964
-  //#define Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS
965
-  #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
966
-    // Define Stepper XY positions for Z1, Z2, Z3 corresponding to
967
-    // the Z screw positions in the bed carriage.
968
-    // Define one position per Z stepper in stepper driver order.
969
-    #define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } }
970
-  #else
962
+  /**
963
+   * Z Stepper positions for more rapid convergence in bed alignment.
964
+   * Requires NUM_Z_STEPPER_DRIVERS to be 3 or 4.
965
+   *
966
+   * Define Stepper XY positions for Z1, Z2, Z3... corresponding to the screw
967
+   * positions in the bed carriage, with one position per Z stepper in stepper
968
+   * driver order.
969
+   */
970
+  //#define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } }
971
+
972
+  #ifndef Z_STEPPER_ALIGN_STEPPER_XY
971 973
     // Amplification factor. Used to scale the correction step up or down in case
972 974
     // the stepper (spindle) position is farther out than the test point.
973 975
     #define Z_STEPPER_ALIGN_AMP 1.0       // Use a value > 1.0 NOTE: This may cause instability!

+ 2
- 2
Marlin/src/feature/z_stepper_align.cpp 查看文件

@@ -35,7 +35,7 @@ ZStepperAlign z_stepper_align;
35 35
 
36 36
 xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPER_DRIVERS];
37 37
 
38
-#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
38
+#if HAS_Z_STEPPER_ALIGN_STEPPER_XY
39 39
   xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPER_DRIVERS];
40 40
 #endif
41 41
 
@@ -103,7 +103,7 @@ void ZStepperAlign::reset_to_default() {
103 103
 
104 104
   COPY(xy, xy_init);
105 105
 
106
-  #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
106
+  #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
107 107
     constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY;
108 108
     static_assert(
109 109
       COUNT(stepper_xy_init) == NUM_Z_STEPPER_DRIVERS,

+ 1
- 1
Marlin/src/feature/z_stepper_align.h 查看文件

@@ -31,7 +31,7 @@ class ZStepperAlign {
31 31
   public:
32 32
     static xy_pos_t xy[NUM_Z_STEPPER_DRIVERS];
33 33
 
34
-    #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
34
+    #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
35 35
       static xy_pos_t stepper_xy[NUM_Z_STEPPER_DRIVERS];
36 36
     #endif
37 37
 

+ 15
- 15
Marlin/src/gcode/calibrate/G34_M422.cpp 查看文件

@@ -41,7 +41,7 @@
41 41
   #include "../../module/tool_change.h"
42 42
 #endif
43 43
 
44
-#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
44
+#if HAS_Z_STEPPER_ALIGN_STEPPER_XY
45 45
   #include "../../libs/least_squares_fit.h"
46 46
 #endif
47 47
 
@@ -122,7 +122,7 @@ void GcodeSuite::G34() {
122 122
         break;
123 123
       }
124 124
 
125
-      const float z_auto_align_amplification = TERN(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP));
125
+      const float z_auto_align_amplification = TERN(HAS_Z_STEPPER_ALIGN_STEPPER_XY, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP));
126 126
       if (!WITHIN(ABS(z_auto_align_amplification), 0.5f, 2.0f)) {
127 127
         SERIAL_ECHOLNPGM("?(A)mplification out of bounds (0.5-2.0).");
128 128
         break;
@@ -179,7 +179,7 @@ void GcodeSuite::G34() {
179 179
       // Now, the Z origin lies below the build plate. That allows to probe deeper, before run_z_probe throws an error.
180 180
       // This hack is un-done at the end of G34 - either by re-homing, or by using the probed heights of the last iteration.
181 181
 
182
-      #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
182
+      #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY
183 183
         float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N_1(NUM_Z_STEPPER_DRIVERS, 10000.0f);
184 184
       #else
185 185
         float last_z_align_level_indicator = 10000.0f;
@@ -188,7 +188,7 @@ void GcodeSuite::G34() {
188 188
             z_maxdiff = 0.0f,
189 189
             amplification = z_auto_align_amplification;
190 190
 
191
-      #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
191
+      #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY
192 192
         bool adjustment_reverse = false;
193 193
       #endif
194 194
 
@@ -256,7 +256,7 @@ void GcodeSuite::G34() {
256 256
         z_maxdiff = z_measured_max - z_measured_min;
257 257
         z_probe = Z_BASIC_CLEARANCE + z_measured_max + z_maxdiff;
258 258
 
259
-        #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
259
+        #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
260 260
           // Replace the initial values in z_measured with calculated heights at
261 261
           // each stepper position. This allows the adjustment algorithm to be
262 262
           // shared between both possible probing mechanisms.
@@ -338,7 +338,7 @@ void GcodeSuite::G34() {
338 338
           return false;
339 339
         };
340 340
 
341
-        #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
341
+        #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
342 342
           // Check if the applied corrections go in the correct direction.
343 343
           // Calculate the sum of the absolute deviations from the mean of the probe measurements.
344 344
           // Compare to the last iteration to ensure it's getting better.
@@ -370,7 +370,7 @@ void GcodeSuite::G34() {
370 370
           float z_align_move = z_measured[zstepper] - z_measured_min;
371 371
           const float z_align_abs = ABS(z_align_move);
372 372
 
373
-          #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
373
+          #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY
374 374
             // Optimize one iteration's correction based on the first measurements
375 375
             if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
376 376
 
@@ -394,7 +394,7 @@ void GcodeSuite::G34() {
394 394
           // Lock all steppers except one
395 395
           stepper.set_all_z_lock(true, zstepper);
396 396
 
397
-          #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
397
+          #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY
398 398
             // Decreasing accuracy was detected so move was inverted.
399 399
             // Will match reversed Z steppers on dual steppers. Triple will need more work to map.
400 400
             if (adjustment_reverse) {
@@ -467,7 +467,7 @@ void GcodeSuite::G34() {
467 467
  *
468 468
  *   S<index> : Index of the probe point to set
469 469
  *
470
- * With Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS:
470
+ * With Z_STEPPER_ALIGN_STEPPER_XY:
471 471
  *   W<index> : Index of the Z stepper position to set
472 472
  *              The W and S parameters may not be combined.
473 473
  *
@@ -488,18 +488,18 @@ void GcodeSuite::M422() {
488 488
 
489 489
   const bool is_probe_point = parser.seen('S');
490 490
 
491
-  if (TERN0(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, is_probe_point && parser.seen('W'))) {
491
+  if (TERN0(HAS_Z_STEPPER_ALIGN_STEPPER_XY, is_probe_point && parser.seen('W'))) {
492 492
     SERIAL_ECHOLNPGM("?(S) and (W) may not be combined.");
493 493
     return;
494 494
   }
495 495
 
496 496
   xy_pos_t *pos_dest = (
497
-    TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !is_probe_point ? z_stepper_align.stepper_xy :)
497
+    TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !is_probe_point ? z_stepper_align.stepper_xy :)
498 498
     z_stepper_align.xy
499 499
   );
500 500
 
501
-  if (!is_probe_point && TERN1(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !parser.seen('W'))) {
502
-    SERIAL_ECHOLNPGM("?(S)" TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, " or (W)") " is required.");
501
+  if (!is_probe_point && TERN1(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !parser.seen('W'))) {
502
+    SERIAL_ECHOLNPGM("?(S)" TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, " or (W)") " is required.");
503 503
     return;
504 504
   }
505 505
 
@@ -513,7 +513,7 @@ void GcodeSuite::M422() {
513 513
     }
514 514
   }
515 515
   else {
516
-    #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
516
+    #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
517 517
       position_index = parser.intval('W') - 1;
518 518
       if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) {
519 519
         SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid.");
@@ -551,7 +551,7 @@ void GcodeSuite::M422_report(const bool forReplay/*=true*/) {
551 551
       SP_Y_STR, z_stepper_align.xy[i].y
552 552
     );
553 553
   }
554
-  #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
554
+  #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
555 555
     LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) {
556 556
       report_echo_start(forReplay);
557 557
       SERIAL_ECHOLNPGM_P(

+ 3
- 2
Marlin/src/inc/Conditionals_adv.h 查看文件

@@ -630,7 +630,8 @@
630 630
 #endif
631 631
 
632 632
 #if ENABLED(Z_STEPPER_AUTO_ALIGN)
633
-  #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
633
+  #ifdef Z_STEPPER_ALIGN_STEPPER_XY
634
+    #define HAS_Z_STEPPER_ALIGN_STEPPER_XY 1
634 635
     #undef Z_STEPPER_ALIGN_AMP
635 636
   #endif
636 637
   #ifndef Z_STEPPER_ALIGN_AMP
@@ -986,7 +987,7 @@
986 987
 #endif
987 988
 
988 989
 // Flag whether least_squares_fit.cpp is used
989
-#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
990
+#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, HAS_Z_STEPPER_ALIGN_STEPPER_XY)
990 991
   #define NEED_LSF 1
991 992
 #endif
992 993
 

+ 4
- 2
Marlin/src/inc/SanityCheck.h 查看文件

@@ -613,6 +613,8 @@
613 613
   #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 1."
614 614
 #elif defined(NOZZLE_PARK_Y_ONLY)
615 615
   #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 2."
616
+#elif defined(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
617
+  #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS is now just Z_STEPPER_ALIGN_STEPPER_XY."
616 618
 #endif
617 619
 
618 620
 constexpr float arm[] = AXIS_RELATIVE_MODES;
@@ -3479,10 +3481,10 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
3479 3481
     #error "Z_STEPPER_AUTO_ALIGN requires NUM_Z_STEPPER_DRIVERS greater than 1."
3480 3482
   #elif !HAS_BED_PROBE
3481 3483
     #error "Z_STEPPER_AUTO_ALIGN requires a Z-bed probe."
3482
-  #elif ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
3484
+  #elif HAS_Z_STEPPER_ALIGN_STEPPER_XY
3483 3485
     static_assert(WITHIN(Z_STEPPER_ALIGN_AMP, 0.5, 2.0), "Z_STEPPER_ALIGN_AMP must be between 0.5 and 2.0.");
3484 3486
     #if NUM_Z_STEPPER_DRIVERS < 3
3485
-      #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS requires NUM_Z_STEPPER_DRIVERS to be 3 or 4."
3487
+      #error "Z_STEPPER_ALIGN_STEPPER_XY requires NUM_Z_STEPPER_DRIVERS to be 3 or 4."
3486 3488
     #endif
3487 3489
   #endif
3488 3490
 #endif

+ 4
- 4
Marlin/src/module/settings.cpp 查看文件

@@ -341,11 +341,11 @@ typedef struct SettingsDataStruct {
341 341
   #endif
342 342
 
343 343
   //
344
-  // Z_STEPPER_AUTO_ALIGN, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS
344
+  // Z_STEPPER_AUTO_ALIGN, HAS_Z_STEPPER_ALIGN_STEPPER_XY
345 345
   //
346 346
   #if ENABLED(Z_STEPPER_AUTO_ALIGN)
347 347
     xy_pos_t z_stepper_align_xy[NUM_Z_STEPPER_DRIVERS];             // M422 S X Y
348
-    #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
348
+    #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
349 349
       xy_pos_t z_stepper_align_stepper_xy[NUM_Z_STEPPER_DRIVERS];   // M422 W X Y
350 350
     #endif
351 351
   #endif
@@ -1005,7 +1005,7 @@ void MarlinSettings::postprocess() {
1005 1005
 
1006 1006
     #if ENABLED(Z_STEPPER_AUTO_ALIGN)
1007 1007
       EEPROM_WRITE(z_stepper_align.xy);
1008
-      #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
1008
+      #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
1009 1009
         EEPROM_WRITE(z_stepper_align.stepper_xy);
1010 1010
       #endif
1011 1011
     #endif
@@ -1924,7 +1924,7 @@ void MarlinSettings::postprocess() {
1924 1924
 
1925 1925
       #if ENABLED(Z_STEPPER_AUTO_ALIGN)
1926 1926
         EEPROM_READ(z_stepper_align.xy);
1927
-        #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
1927
+        #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
1928 1928
           EEPROM_READ(z_stepper_align.stepper_xy);
1929 1929
         #endif
1930 1930
       #endif

+ 1
- 1
buildroot/tests/DUE 查看文件

@@ -37,7 +37,7 @@ exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), ExtUI, S-Curve, many options
37 37
 restore_configs
38 38
 opt_set MOTHERBOARD BOARD_RADDS NUM_Z_STEPPER_DRIVERS 3
39 39
 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \
40
-           Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS Z_SAFE_HOMING
40
+           Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_STEPPER_XY Z_SAFE_HOMING
41 41
 pins_set ramps/RAMPS X_MAX_PIN -1
42 42
 pins_set ramps/RAMPS Y_MAX_PIN -1
43 43
 exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3"

Loading…
取消
儲存