Browse Source

🚸 Use Z_STEPPER_ALIGN_STEPPER_XY to enable

Scott Lahteine 3 years ago
parent
commit
bb2f100fcd

+ 11
- 9
Marlin/Configuration_adv.h View File

959
     //#define Z_STEPPERS_ORIENTATION 0
959
     //#define Z_STEPPERS_ORIENTATION 0
960
   #endif
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
     // Amplification factor. Used to scale the correction step up or down in case
973
     // Amplification factor. Used to scale the correction step up or down in case
972
     // the stepper (spindle) position is farther out than the test point.
974
     // the stepper (spindle) position is farther out than the test point.
973
     #define Z_STEPPER_ALIGN_AMP 1.0       // Use a value > 1.0 NOTE: This may cause instability!
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 View File

35
 
35
 
36
 xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPER_DRIVERS];
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
   xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPER_DRIVERS];
39
   xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPER_DRIVERS];
40
 #endif
40
 #endif
41
 
41
 
103
 
103
 
104
   COPY(xy, xy_init);
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
     constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY;
107
     constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY;
108
     static_assert(
108
     static_assert(
109
       COUNT(stepper_xy_init) == NUM_Z_STEPPER_DRIVERS,
109
       COUNT(stepper_xy_init) == NUM_Z_STEPPER_DRIVERS,

+ 1
- 1
Marlin/src/feature/z_stepper_align.h View File

31
   public:
31
   public:
32
     static xy_pos_t xy[NUM_Z_STEPPER_DRIVERS];
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
       static xy_pos_t stepper_xy[NUM_Z_STEPPER_DRIVERS];
35
       static xy_pos_t stepper_xy[NUM_Z_STEPPER_DRIVERS];
36
     #endif
36
     #endif
37
 
37
 

+ 15
- 15
Marlin/src/gcode/calibrate/G34_M422.cpp View File

41
   #include "../../module/tool_change.h"
41
   #include "../../module/tool_change.h"
42
 #endif
42
 #endif
43
 
43
 
44
-#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
44
+#if HAS_Z_STEPPER_ALIGN_STEPPER_XY
45
   #include "../../libs/least_squares_fit.h"
45
   #include "../../libs/least_squares_fit.h"
46
 #endif
46
 #endif
47
 
47
 
122
         break;
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
       if (!WITHIN(ABS(z_auto_align_amplification), 0.5f, 2.0f)) {
126
       if (!WITHIN(ABS(z_auto_align_amplification), 0.5f, 2.0f)) {
127
         SERIAL_ECHOLNPGM("?(A)mplification out of bounds (0.5-2.0).");
127
         SERIAL_ECHOLNPGM("?(A)mplification out of bounds (0.5-2.0).");
128
         break;
128
         break;
179
       // Now, the Z origin lies below the build plate. That allows to probe deeper, before run_z_probe throws an error.
179
       // Now, the Z origin lies below the build plate. That allows to probe deeper, before run_z_probe throws an error.
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.
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
         float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N_1(NUM_Z_STEPPER_DRIVERS, 10000.0f);
183
         float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N_1(NUM_Z_STEPPER_DRIVERS, 10000.0f);
184
       #else
184
       #else
185
         float last_z_align_level_indicator = 10000.0f;
185
         float last_z_align_level_indicator = 10000.0f;
188
             z_maxdiff = 0.0f,
188
             z_maxdiff = 0.0f,
189
             amplification = z_auto_align_amplification;
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
         bool adjustment_reverse = false;
192
         bool adjustment_reverse = false;
193
       #endif
193
       #endif
194
 
194
 
256
         z_maxdiff = z_measured_max - z_measured_min;
256
         z_maxdiff = z_measured_max - z_measured_min;
257
         z_probe = Z_BASIC_CLEARANCE + z_measured_max + z_maxdiff;
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
           // Replace the initial values in z_measured with calculated heights at
260
           // Replace the initial values in z_measured with calculated heights at
261
           // each stepper position. This allows the adjustment algorithm to be
261
           // each stepper position. This allows the adjustment algorithm to be
262
           // shared between both possible probing mechanisms.
262
           // shared between both possible probing mechanisms.
338
           return false;
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
           // Check if the applied corrections go in the correct direction.
342
           // Check if the applied corrections go in the correct direction.
343
           // Calculate the sum of the absolute deviations from the mean of the probe measurements.
343
           // Calculate the sum of the absolute deviations from the mean of the probe measurements.
344
           // Compare to the last iteration to ensure it's getting better.
344
           // Compare to the last iteration to ensure it's getting better.
370
           float z_align_move = z_measured[zstepper] - z_measured_min;
370
           float z_align_move = z_measured[zstepper] - z_measured_min;
371
           const float z_align_abs = ABS(z_align_move);
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
             // Optimize one iteration's correction based on the first measurements
374
             // Optimize one iteration's correction based on the first measurements
375
             if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
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
           // Lock all steppers except one
394
           // Lock all steppers except one
395
           stepper.set_all_z_lock(true, zstepper);
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
             // Decreasing accuracy was detected so move was inverted.
398
             // Decreasing accuracy was detected so move was inverted.
399
             // Will match reversed Z steppers on dual steppers. Triple will need more work to map.
399
             // Will match reversed Z steppers on dual steppers. Triple will need more work to map.
400
             if (adjustment_reverse) {
400
             if (adjustment_reverse) {
467
  *
467
  *
468
  *   S<index> : Index of the probe point to set
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
  *   W<index> : Index of the Z stepper position to set
471
  *   W<index> : Index of the Z stepper position to set
472
  *              The W and S parameters may not be combined.
472
  *              The W and S parameters may not be combined.
473
  *
473
  *
488
 
488
 
489
   const bool is_probe_point = parser.seen('S');
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
     SERIAL_ECHOLNPGM("?(S) and (W) may not be combined.");
492
     SERIAL_ECHOLNPGM("?(S) and (W) may not be combined.");
493
     return;
493
     return;
494
   }
494
   }
495
 
495
 
496
   xy_pos_t *pos_dest = (
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
     z_stepper_align.xy
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
     return;
503
     return;
504
   }
504
   }
505
 
505
 
513
     }
513
     }
514
   }
514
   }
515
   else {
515
   else {
516
-    #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
516
+    #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
517
       position_index = parser.intval('W') - 1;
517
       position_index = parser.intval('W') - 1;
518
       if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) {
518
       if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) {
519
         SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid.");
519
         SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid.");
551
       SP_Y_STR, z_stepper_align.xy[i].y
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
     LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) {
555
     LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) {
556
       report_echo_start(forReplay);
556
       report_echo_start(forReplay);
557
       SERIAL_ECHOLNPGM_P(
557
       SERIAL_ECHOLNPGM_P(

+ 3
- 2
Marlin/src/inc/Conditionals_adv.h View File

630
 #endif
630
 #endif
631
 
631
 
632
 #if ENABLED(Z_STEPPER_AUTO_ALIGN)
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
     #undef Z_STEPPER_ALIGN_AMP
635
     #undef Z_STEPPER_ALIGN_AMP
635
   #endif
636
   #endif
636
   #ifndef Z_STEPPER_ALIGN_AMP
637
   #ifndef Z_STEPPER_ALIGN_AMP
986
 #endif
987
 #endif
987
 
988
 
988
 // Flag whether least_squares_fit.cpp is used
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
   #define NEED_LSF 1
991
   #define NEED_LSF 1
991
 #endif
992
 #endif
992
 
993
 

+ 4
- 2
Marlin/src/inc/SanityCheck.h View File

613
   #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 1."
613
   #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 1."
614
 #elif defined(NOZZLE_PARK_Y_ONLY)
614
 #elif defined(NOZZLE_PARK_Y_ONLY)
615
   #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 2."
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
 #endif
618
 #endif
617
 
619
 
618
 constexpr float arm[] = AXIS_RELATIVE_MODES;
620
 constexpr float arm[] = AXIS_RELATIVE_MODES;
3479
     #error "Z_STEPPER_AUTO_ALIGN requires NUM_Z_STEPPER_DRIVERS greater than 1."
3481
     #error "Z_STEPPER_AUTO_ALIGN requires NUM_Z_STEPPER_DRIVERS greater than 1."
3480
   #elif !HAS_BED_PROBE
3482
   #elif !HAS_BED_PROBE
3481
     #error "Z_STEPPER_AUTO_ALIGN requires a Z-bed probe."
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
     static_assert(WITHIN(Z_STEPPER_ALIGN_AMP, 0.5, 2.0), "Z_STEPPER_ALIGN_AMP must be between 0.5 and 2.0.");
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
     #if NUM_Z_STEPPER_DRIVERS < 3
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
     #endif
3488
     #endif
3487
   #endif
3489
   #endif
3488
 #endif
3490
 #endif

+ 4
- 4
Marlin/src/module/settings.cpp View File

341
   #endif
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
   #if ENABLED(Z_STEPPER_AUTO_ALIGN)
346
   #if ENABLED(Z_STEPPER_AUTO_ALIGN)
347
     xy_pos_t z_stepper_align_xy[NUM_Z_STEPPER_DRIVERS];             // M422 S X Y
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
       xy_pos_t z_stepper_align_stepper_xy[NUM_Z_STEPPER_DRIVERS];   // M422 W X Y
349
       xy_pos_t z_stepper_align_stepper_xy[NUM_Z_STEPPER_DRIVERS];   // M422 W X Y
350
     #endif
350
     #endif
351
   #endif
351
   #endif
1005
 
1005
 
1006
     #if ENABLED(Z_STEPPER_AUTO_ALIGN)
1006
     #if ENABLED(Z_STEPPER_AUTO_ALIGN)
1007
       EEPROM_WRITE(z_stepper_align.xy);
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
         EEPROM_WRITE(z_stepper_align.stepper_xy);
1009
         EEPROM_WRITE(z_stepper_align.stepper_xy);
1010
       #endif
1010
       #endif
1011
     #endif
1011
     #endif
1924
 
1924
 
1925
       #if ENABLED(Z_STEPPER_AUTO_ALIGN)
1925
       #if ENABLED(Z_STEPPER_AUTO_ALIGN)
1926
         EEPROM_READ(z_stepper_align.xy);
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
           EEPROM_READ(z_stepper_align.stepper_xy);
1928
           EEPROM_READ(z_stepper_align.stepper_xy);
1929
         #endif
1929
         #endif
1930
       #endif
1930
       #endif

+ 1
- 1
buildroot/tests/DUE View File

37
 restore_configs
37
 restore_configs
38
 opt_set MOTHERBOARD BOARD_RADDS NUM_Z_STEPPER_DRIVERS 3
38
 opt_set MOTHERBOARD BOARD_RADDS NUM_Z_STEPPER_DRIVERS 3
39
 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \
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
 pins_set ramps/RAMPS X_MAX_PIN -1
41
 pins_set ramps/RAMPS X_MAX_PIN -1
42
 pins_set ramps/RAMPS Y_MAX_PIN -1
42
 pins_set ramps/RAMPS Y_MAX_PIN -1
43
 exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3"
43
 exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3"

Loading…
Cancel
Save