瀏覽代碼

[2.0.x] G33 magic numbers (#8171)

* [2.0.x] G33 magic numbers

* oops

* Comments

* oops

* warning

* better comment section

* remarks

* extra grids
Luc Van Daele 7 年之前
父節點
當前提交
6827e243a0

+ 2
- 2
Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration.h 查看文件

@@ -497,7 +497,7 @@
497 497
     // set the default number of probe points : n*n (1 -> 7)
498 498
     #define DELTA_CALIBRATION_DEFAULT_POINTS 4
499 499
 
500
-    // Enable and set these values based on results of 'G33 A1'
500
+    // Enable and set these values based on results of 'G33 A'
501 501
     //#define H_FACTOR 1.01
502 502
     //#define R_FACTOR 2.61
503 503
     //#define A_FACTOR 0.87
@@ -505,7 +505,7 @@
505 505
   #endif
506 506
 
507 507
   #if ENABLED(DELTA_AUTO_CALIBRATION) || ENABLED(DELTA_CALIBRATION_MENU)
508
-    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS*0.869 for non-eccentric probes
508
+    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS for non-eccentric probes
509 509
     #define DELTA_CALIBRATION_RADIUS 73.5 // mm
510 510
     // Set the steprate for papertest probing
511 511
     #define PROBE_MANUALLY_STEP 0.025

+ 2
- 2
Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration.h 查看文件

@@ -497,7 +497,7 @@
497 497
     // set the default number of probe points : n*n (1 -> 7)
498 498
     #define DELTA_CALIBRATION_DEFAULT_POINTS 4
499 499
 
500
-    // Enable and set these values based on results of 'G33 A1'
500
+    // Enable and set these values based on results of 'G33 A'
501 501
     //#define H_FACTOR 1.01
502 502
     //#define R_FACTOR 2.61
503 503
     //#define A_FACTOR 0.87
@@ -505,7 +505,7 @@
505 505
   #endif
506 506
 
507 507
   #if ENABLED(DELTA_AUTO_CALIBRATION) || ENABLED(DELTA_CALIBRATION_MENU)
508
-    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS*0.869 for non-eccentric probes
508
+    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS for non-eccentric probes
509 509
     #define DELTA_CALIBRATION_RADIUS 73.5 // mm
510 510
     // Set the steprate for papertest probing
511 511
     #define PROBE_MANUALLY_STEP 0.025

+ 2
- 2
Marlin/src/config/examples/delta/generic/Configuration.h 查看文件

@@ -487,7 +487,7 @@
487 487
     // set the default number of probe points : n*n (1 -> 7)
488 488
     #define DELTA_CALIBRATION_DEFAULT_POINTS 4
489 489
 
490
-    // Enable and set these values based on results of 'G33 A1'
490
+    // Enable and set these values based on results of 'G33 A'
491 491
     //#define H_FACTOR 1.01
492 492
     //#define R_FACTOR 2.61
493 493
     //#define A_FACTOR 0.87
@@ -495,7 +495,7 @@
495 495
   #endif
496 496
 
497 497
   #if ENABLED(DELTA_AUTO_CALIBRATION) || ENABLED(DELTA_CALIBRATION_MENU)
498
-    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS*0.869 for non-eccentric probes
498
+    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS for non-eccentric probes
499 499
     #define DELTA_CALIBRATION_RADIUS 121.5 // mm
500 500
     // Set the steprate for papertest probing
501 501
     #define PROBE_MANUALLY_STEP 0.025

+ 2
- 2
Marlin/src/config/examples/delta/kossel_mini/Configuration.h 查看文件

@@ -487,7 +487,7 @@
487 487
     // set the default number of probe points : n*n (1 -> 7)
488 488
     #define DELTA_CALIBRATION_DEFAULT_POINTS 4
489 489
 
490
-    // Enable and set these values based on results of 'G33 A1'
490
+    // Enable and set these values based on results of 'G33 A'
491 491
     //#define H_FACTOR 1.01
492 492
     //#define R_FACTOR 2.61
493 493
     //#define A_FACTOR 0.87
@@ -495,7 +495,7 @@
495 495
   #endif
496 496
 
497 497
   #if ENABLED(DELTA_AUTO_CALIBRATION) || ENABLED(DELTA_CALIBRATION_MENU)
498
-    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS*0.869 for non-eccentric probes
498
+    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS for non-eccentric probes
499 499
     #define DELTA_CALIBRATION_RADIUS 78.0 // mm
500 500
     // Set the steprate for papertest probing
501 501
     #define PROBE_MANUALLY_STEP 0.025

+ 2
- 2
Marlin/src/config/examples/delta/kossel_pro/Configuration.h 查看文件

@@ -473,7 +473,7 @@
473 473
     // set the default number of probe points : n*n (1 -> 7)
474 474
     #define DELTA_CALIBRATION_DEFAULT_POINTS 4
475 475
 
476
-    // Enable and set these values based on results of 'G33 A1'
476
+    // Enable and set these values based on results of 'G33 A'
477 477
     //#define H_FACTOR 1.01
478 478
     //#define R_FACTOR 2.61
479 479
     //#define A_FACTOR 0.87
@@ -481,7 +481,7 @@
481 481
   #endif
482 482
 
483 483
   #if ENABLED(DELTA_AUTO_CALIBRATION) || ENABLED(DELTA_CALIBRATION_MENU)
484
-    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS*0.869 for non-eccentric probes
484
+    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS for non-eccentric probes
485 485
     #define DELTA_CALIBRATION_RADIUS 110.0 // mm
486 486
     // Set the steprate for papertest probing
487 487
     #define PROBE_MANUALLY_STEP 0.025

+ 2
- 2
Marlin/src/config/examples/delta/kossel_xl/Configuration.h 查看文件

@@ -491,7 +491,7 @@
491 491
     // set the default number of probe points : n*n (1 -> 7)
492 492
     #define DELTA_CALIBRATION_DEFAULT_POINTS 4
493 493
 
494
-    // Enable and set these values based on results of 'G33 A1'
494
+    // Enable and set these values based on results of 'G33 A'
495 495
     //#define H_FACTOR 1.01
496 496
     //#define R_FACTOR 2.61
497 497
     //#define A_FACTOR 0.87
@@ -499,7 +499,7 @@
499 499
   #endif
500 500
 
501 501
   #if ENABLED(DELTA_AUTO_CALIBRATION) || ENABLED(DELTA_CALIBRATION_MENU)
502
-    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS*0.869 for non-eccentric probes
502
+    // Set the radius for the calibration probe points - max DELTA_PRINTABLE_RADIUS for non-eccentric probes
503 503
     #define DELTA_CALIBRATION_RADIUS 121.5 // mm
504 504
     // Set the steprate for papertest probing
505 505
     #define PROBE_MANUALLY_STEP 0.025

+ 127
- 86
Marlin/src/gcode/calibrate/G33.cpp 查看文件

@@ -37,6 +37,26 @@
37 37
   #include "../../feature/bedlevel/bedlevel.h"
38 38
 #endif
39 39
 
40
+constexpr uint8_t _7P_STEP = 1,              // 7-point step - to change number of calibration points
41
+                  _4P_STEP = _7P_STEP * 2,   // 4-point step
42
+                  NPP      = _7P_STEP * 6;   // number of calibration points on the radius
43
+enum CalEnum {                               // the 7 main calibration points - add definitions if needed
44
+  CEN      = 0,
45
+  __A      = 1,
46
+  _AB      = __A + _7P_STEP,
47
+  __B      = _AB + _7P_STEP,
48
+  _BC      = __B + _7P_STEP,
49
+  __C      = _BC + _7P_STEP,
50
+  _CA      = __C + _7P_STEP,
51
+};
52
+
53
+#define LOOP_CAL_PT(VAR, S, N) for (uint8_t VAR=S; VAR<=NPP; VAR+=N) 
54
+#define F_LOOP_CAL_PT(VAR, S, N) for (float VAR=S; VAR<NPP+0.9999; VAR+=N) 
55
+#define I_LOOP_CAL_PT(VAR, S, N) for (float VAR=S; VAR>CEN+0.9999; VAR-=N)
56
+#define LOOP_CAL_ALL(VAR) LOOP_CAL_PT(VAR, CEN, 1)
57
+#define LOOP_CAL_RAD(VAR) LOOP_CAL_PT(VAR, __A, _7P_STEP)
58
+#define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP)
59
+
40 60
 static void print_signed_float(const char * const prefix, const float &f) {
41 61
   SERIAL_PROTOCOLPGM("  ");
42 62
   serialprintPGM(prefix);
@@ -69,13 +89,13 @@ static void print_G33_settings(const bool end_stops, const bool tower_angles) {
69 89
   SERIAL_EOL();
70 90
 }
71 91
 
72
-static void print_G33_results(const float z_at_pt[13], const bool tower_points, const bool opposite_points) {
92
+static void print_G33_results(const float z_at_pt[NPP + 1], const bool tower_points, const bool opposite_points) {
73 93
   SERIAL_PROTOCOLPGM(".    ");
74
-  print_signed_float(PSTR("c"), z_at_pt[0]);
94
+  print_signed_float(PSTR("c"), z_at_pt[CEN]);
75 95
   if (tower_points) {
76
-    print_signed_float(PSTR(" x"), z_at_pt[1]);
77
-    print_signed_float(PSTR(" y"), z_at_pt[5]);
78
-    print_signed_float(PSTR(" z"), z_at_pt[9]);
96
+    print_signed_float(PSTR(" x"), z_at_pt[__A]);
97
+    print_signed_float(PSTR(" y"), z_at_pt[__B]);
98
+    print_signed_float(PSTR(" z"), z_at_pt[__C]);
79 99
   }
80 100
   if (tower_points && opposite_points) {
81 101
     SERIAL_EOL();
@@ -83,9 +103,9 @@ static void print_G33_results(const float z_at_pt[13], const bool tower_points,
83 103
     SERIAL_PROTOCOL_SP(13);
84 104
   }
85 105
   if (opposite_points) {
86
-    print_signed_float(PSTR("yz"), z_at_pt[7]);
87
-    print_signed_float(PSTR("zx"), z_at_pt[11]);
88
-    print_signed_float(PSTR("xy"), z_at_pt[3]);
106
+    print_signed_float(PSTR("yz"), z_at_pt[_BC]);
107
+    print_signed_float(PSTR("zx"), z_at_pt[_CA]);
108
+    print_signed_float(PSTR("xy"), z_at_pt[_AB]);
89 109
   }
90 110
   SERIAL_EOL();
91 111
 }
@@ -112,85 +132,111 @@ static void G33_cleanup(
112 132
   #endif
113 133
 }
114 134
 
115
-static float probe_G33_points(float z_at_pt[13], const int8_t probe_points, const bool towers_set, const bool stow_after_each) {
135
+static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points, const bool towers_set, const bool stow_after_each) {
116 136
   const bool _0p_calibration      = probe_points == 0,
117 137
              _1p_calibration      = probe_points == 1,
118 138
              _4p_calibration      = probe_points == 2,
119 139
              _4p_opposite_points  = _4p_calibration && !towers_set,
120 140
              _7p_calibration      = probe_points >= 3 || probe_points == 0,
121
-             _7p_half_circle      = probe_points == 3,
122
-             _7p_double_circle    = probe_points == 5,
123
-             _7p_triple_circle    = probe_points == 6,
124
-             _7p_quadruple_circle = probe_points == 7,
141
+             _7p_no_intermediates = probe_points == 3,
142
+             _7p_1_intermediates  = probe_points == 4,
143
+             _7p_2_intermediates  = probe_points == 5,
144
+             _7p_4_intermediates  = probe_points == 6,
145
+             _7p_6_intermediates  = probe_points == 7,
146
+             _7p_8_intermediates  = probe_points == 8,
147
+             _7p_11_intermediates = probe_points == 9,
148
+             _7p_14_intermediates = probe_points == 10,
125 149
              _7p_intermed_points  = probe_points >= 4,
126
-             _7p_multi_circle     = probe_points >= 5;
150
+             _7p_6_centre         = probe_points >= 5 && probe_points <= 7,
151
+             _7p_9_centre         = probe_points >= 8;
127 152
 
128 153
   #if DISABLED(PROBE_MANUALLY)
129 154
     const float dx = (X_PROBE_OFFSET_FROM_EXTRUDER),
130 155
                 dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
131 156
   #endif
132 157
 
133
-  for (uint8_t i = 0; i <= 12; i++) z_at_pt[i] = 0.0;
158
+      LOOP_CAL_ALL(axis) z_at_pt[axis] = 0.0;
134 159
 
135 160
   if (!_0p_calibration) {
136 161
 
137
-    if (!_7p_half_circle && !_7p_triple_circle) { // probe the center
162
+    if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
138 163
       #if ENABLED(PROBE_MANUALLY)
139
-        z_at_pt[0] += lcd_probe_pt(0, 0);
164
+        z_at_pt[CEN] += lcd_probe_pt(0, 0);
140 165
       #else
141
-        z_at_pt[0] += probe_pt(dx, dy, stow_after_each, 1, false);
166
+        z_at_pt[CEN] += probe_pt(dx, dy, stow_after_each, 1, false);
142 167
       #endif
143 168
     }
144 169
 
145 170
     if (_7p_calibration) { // probe extra center points
146
-      for (int8_t axis = _7p_multi_circle ? 11 : 9; axis > 0; axis -= _7p_multi_circle ? 2 : 4) {
147
-        const float a = RADIANS(180 + 30 * axis), r = delta_calibration_radius * 0.1;
171
+      const float start  = _7p_9_centre ? _CA + _7P_STEP / 3.0 : _7p_6_centre ? _CA : __C,
172
+                  steps  = _7p_9_centre ? _4P_STEP / 3.0 : _7p_6_centre ? _7P_STEP : _4P_STEP;
173
+      I_LOOP_CAL_PT(axis, start, steps) {
174
+        const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
175
+                    r = delta_calibration_radius * 0.1;
148 176
         #if ENABLED(PROBE_MANUALLY)
149
-          z_at_pt[0] += lcd_probe_pt(cos(a) * r, sin(a) * r);
177
+          z_at_pt[CEN] += lcd_probe_pt(cos(a) * r, sin(a) * r);
150 178
         #else
151
-          z_at_pt[0] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
179
+          z_at_pt[CEN] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
152 180
         #endif
153 181
       }
154
-      z_at_pt[0] /= float(_7p_double_circle ? 7 : probe_points);
182
+      z_at_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
155 183
     }
156 184
 
157 185
     if (!_1p_calibration) {  // probe the radius
186
+      const CalEnum start  = _4p_opposite_points ? _AB : __A;
187
+      const float   steps  = _7p_14_intermediates ? _7P_STEP / 15.0 : // 15r * 6 + 10c = 100
188
+                             _7p_11_intermediates ? _7P_STEP / 12.0 : // 12r * 6 +  9c = 81
189
+                             _7p_8_intermediates  ? _7P_STEP /  9.0 : //  9r * 6 + 10c = 64
190
+                             _7p_6_intermediates  ? _7P_STEP /  7.0 : //  7r * 6 +  7c = 49
191
+                             _7p_4_intermediates  ? _7P_STEP /  5.0 : //  5r * 6 +  6c = 36
192
+                             _7p_2_intermediates  ? _7P_STEP /  3.0 : //  3r * 6 +  7c = 25 
193
+                             _7p_1_intermediates  ? _7P_STEP /  2.0 : //  2r * 6 +  4c = 16 
194
+                             _7p_no_intermediates ? _7P_STEP :        //  1r * 6 +  3c = 9
195
+                             _4P_STEP;                                // .5r * 6 +  1c = 4
158 196
       bool zig_zag = true;
159
-      const uint8_t start = _4p_opposite_points ? 3 : 1,
160
-                    step = _4p_calibration ? 4 : _7p_half_circle ? 2 : 1;
161
-      for (uint8_t axis = start; axis <= 12; axis += step) {
162
-        const float zigadd = (zig_zag ? 0.5 : 0.0),
163
-                    offset_circles = _7p_quadruple_circle ? zigadd + 1.0 :
164
-                                     _7p_triple_circle    ? zigadd + 0.5 :
165
-                                     _7p_double_circle    ? zigadd : 0;
166
-        for (float circles = -offset_circles ; circles <= offset_circles; circles++) {
167
-          const float a = RADIANS(180 + 30 * axis),
168
-                      r = delta_calibration_radius * (1 + circles * (zig_zag ? 0.1 : -0.1));
197
+      F_LOOP_CAL_PT(axis, start, _7p_9_centre ? steps * 3 : steps) {
198
+        const int8_t offset = _7p_9_centre ? 1 : 0;
199
+        for (int8_t circle = -offset; circle <= offset; circle++) {
200
+          const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
201
+                      r = delta_calibration_radius * (1 + 0.1 * (zig_zag ? circle : - circle)),
202
+                      interpol = fmod(axis, 1);
169 203
           #if ENABLED(PROBE_MANUALLY)
170
-            z_at_pt[axis] += lcd_probe_pt(cos(a) * r, sin(a) * r);
204
+             float z_temp = lcd_probe_pt(cos(a) * r, sin(a) * r);
171 205
           #else
172
-            z_at_pt[axis] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
206
+            float z_temp = probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
173 207
           #endif
208
+          // split probe point to neighbouring calibration points
209
+          z_at_pt[round(axis - interpol + NPP - 1) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
210
+          z_at_pt[round(axis - interpol) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
174 211
         }
175 212
         zig_zag = !zig_zag;
176
-        z_at_pt[axis] /= (2 * offset_circles + 1);
177 213
       }
214
+      if (_7p_intermed_points)
215
+        LOOP_CAL_RAD(axis) {
216
+/*
217
+        // average intermediate points to towers and opposites - only required with _7P_STEP >= 2
218
+          for (int8_t i = 1; i < _7P_STEP; i++) {
219
+            const float interpol = i * (1.0 / _7P_STEP);
220
+            z_at_pt[axis] += (z_at_pt[(axis + NPP - i - 1) % NPP + 1]
221
+                             + z_at_pt[axis + i]) * sq(cos(RADIANS(interpol * 90)));
222
+          }
223
+*/
224
+          z_at_pt[axis] /= _7P_STEP  / steps;
225
+        }
178 226
     }
179 227
 
180
-    if (_7p_intermed_points) // average intermediates to tower and opposites
181
-      for (uint8_t axis = 1; axis <= 12; axis += 2)
182
-        z_at_pt[axis] = (z_at_pt[axis] + (z_at_pt[axis + 1] + z_at_pt[(axis + 10) % 12 + 1]) / 2.0) / 2.0;
183 228
 
184
-    float S1 = z_at_pt[0],
185
-          S2 = sq(z_at_pt[0]);
229
+    float S1 = z_at_pt[CEN],
230
+          S2 = sq(z_at_pt[CEN]);
186 231
     int16_t N = 1;
187
-    if (!_1p_calibration) // std dev from zero plane
188
-      for (uint8_t axis = (_4p_opposite_points ? 3 : 1); axis <= 12; axis += (_4p_calibration ? 4 : 2)) {
232
+    if (!_1p_calibration) { // std dev from zero plane
233
+      LOOP_CAL_ACT(axis, _4p_calibration, _4p_opposite_points) {
189 234
         S1 += z_at_pt[axis];
190 235
         S2 += sq(z_at_pt[axis]);
191 236
         N++;
192 237
       }
193
-    return round(SQRT(S2 / N) * 1000.0) / 1000.0 + 0.00001;
238
+      return round(SQRT(S2 / N) * 1000.0) / 1000.0 + 0.00001;
239
+    }
194 240
   }
195 241
 
196 242
   return 0.00001;
@@ -199,8 +245,8 @@ static float probe_G33_points(float z_at_pt[13], const int8_t probe_points, cons
199 245
 #if DISABLED(PROBE_MANUALLY)
200 246
 
201 247
   static void G33_auto_tune() {
202
-    float z_at_pt[13]      = { 0.0 },
203
-          z_at_pt_base[13] = { 0.0 },
248
+    float z_at_pt[NPP + 1]      = { 0.0 },
249
+          z_at_pt_base[NPP + 1] = { 0.0 },
204 250
           z_temp, h_fac = 0.0, r_fac = 0.0, a_fac = 0.0, norm = 0.8;
205 251
 
206 252
     #define ZP(N,I) ((N) * z_at_pt[I])
@@ -227,18 +273,18 @@ static float probe_G33_points(float z_at_pt[13], const int8_t probe_points, cons
227 273
       SERIAL_EOL();
228 274
 
229 275
       probe_G33_points(z_at_pt, 3, true, false);
230
-      for (int8_t i = 0; i <= 12; i++) z_at_pt[i] -= z_at_pt_base[i];
276
+      LOOP_CAL_ALL(axis) z_at_pt[axis] -= z_at_pt_base[axis];
231 277
       print_G33_results(z_at_pt, true, true);
232 278
       delta_endstop_adj[axis] += 1.0;
233 279
       switch (axis) {
234 280
         case A_AXIS :
235
-          h_fac += 4.0 / (Z03(0) +Z01(1)                         +Z32(11) +Z32(3)); // Offset by X-tower end-stop
281
+          h_fac += 4.0 / (Z03(CEN) +Z01(__A)                               +Z32(_CA) +Z32(_AB)); // Offset by X-tower end-stop
236 282
           break;
237 283
         case B_AXIS :
238
-          h_fac += 4.0 / (Z03(0)         +Z01(5)         +Z32(7)          +Z32(3)); // Offset by Y-tower end-stop
284
+          h_fac += 4.0 / (Z03(CEN)           +Z01(__B)           +Z32(_BC)           +Z32(_AB)); // Offset by Y-tower end-stop
239 285
           break;
240 286
         case C_AXIS :
241
-          h_fac += 4.0 / (Z03(0)                 +Z01(9) +Z32(7) +Z32(11)        ); // Offset by Z-tower end-stop
287
+          h_fac += 4.0 / (Z03(CEN)                     +Z01(__C) +Z32(_BC) +Z32(_CA)          ); // Offset by Z-tower end-stop
242 288
           break;
243 289
       }
244 290
     }
@@ -257,11 +303,11 @@ static float probe_G33_points(float z_at_pt[13], const int8_t probe_points, cons
257 303
       SERIAL_PROTOCOL(zig_zag == -1 ? "-" : "+");
258 304
       SERIAL_EOL();
259 305
       probe_G33_points(z_at_pt, 3, true, false);
260
-      for (int8_t i = 0; i <= 12; i++) z_at_pt[i] -= z_at_pt_base[i];
306
+      LOOP_CAL_ALL(axis) z_at_pt[axis] -= z_at_pt_base[axis];
261 307
       print_G33_results(z_at_pt, true, true);
262 308
       delta_radius -= 1.0 * zig_zag;
263 309
       recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
264
-      r_fac -= zig_zag * 6.0 / (Z03(1) + Z03(5) + Z03(9) + Z03(7) + Z03(11) + Z03(3)); // Offset by delta radius
310
+      r_fac -= zig_zag * 6.0 / (Z03(__A) +Z03(__B) +Z03(__C) +Z03(_BC) +Z03(_CA) +Z03(_AB)); // Offset by delta radius
265 311
     }
266 312
     r_fac /= 2.0;
267 313
     r_fac *= 3 * norm; // Normalize to 2.25 for Kossel mini
@@ -284,7 +330,7 @@ static float probe_G33_points(float z_at_pt[13], const int8_t probe_points, cons
284 330
       SERIAL_EOL();
285 331
 
286 332
       probe_G33_points(z_at_pt, 3, true, false);
287
-      for (int8_t i = 0; i <= 12; i++) z_at_pt[i] -= z_at_pt_base[i];
333
+      LOOP_CAL_ALL(axis) z_at_pt[axis] -= z_at_pt_base[axis];
288 334
       print_G33_results(z_at_pt, true, true);
289 335
 
290 336
       delta_tower_angle_trim[axis] -= 1.0;
@@ -296,13 +342,13 @@ static float probe_G33_points(float z_at_pt[13], const int8_t probe_points, cons
296 342
       recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
297 343
       switch (axis) {
298 344
         case A_AXIS :
299
-        a_fac += 4.0 / (       Z06(5) -Z06(9)         +Z06(11) -Z06(3)); // Offset by alpha tower angle
345
+        a_fac += 4.0 / (          Z06(__B) -Z06(__C)           +Z06(_CA) -Z06(_AB)); // Offset by alpha tower angle
300 346
         break;
301 347
         case B_AXIS :
302
-        a_fac += 4.0 / (-Z06(1)       +Z06(9) -Z06(7)          +Z06(3)); // Offset by beta tower angle
348
+        a_fac += 4.0 / (-Z06(__A)          +Z06(__C) -Z06(_BC)           +Z06(_AB)); // Offset by beta tower angle
303 349
         break;
304 350
         case C_AXIS :
305
-        a_fac += 4.0 / (Z06(1) -Z06(5)        +Z06(7) -Z06(11)        ); // Offset by gamma tower angle
351
+        a_fac += 4.0 / (Z06(__A) -Z06(__B)           +Z06(_BC) -Z06(_CA)          ); // Offset by gamma tower angle
306 352
         break;
307 353
       }
308 354
     }
@@ -333,7 +379,7 @@ static float probe_G33_points(float z_at_pt[13], const int8_t probe_points, cons
333 379
  *      P1     Probe center and set height only.
334 380
  *      P2     Probe center and towers. Set height, endstops and delta radius.
335 381
  *      P3     Probe all positions: center, towers and opposite towers. Set all.
336
- *      P4-P7  Probe all positions at different locations and average them.
382
+ *      P4-P10 Probe all positions + at different itermediate locations and average them.
337 383
  *
338 384
  *   T   Don't calibrate tower angle corrections
339 385
  *
@@ -353,8 +399,8 @@ static float probe_G33_points(float z_at_pt[13], const int8_t probe_points, cons
353 399
 void GcodeSuite::G33() {
354 400
 
355 401
   const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
356
-  if (!WITHIN(probe_points, 0, 7)) {
357
-    SERIAL_PROTOCOLLNPGM("?(P)oints is implausible (0-7).");
402
+  if (!WITHIN(probe_points, 0, 10)) {
403
+    SERIAL_PROTOCOLLNPGM("?(P)oints is implausible (0-10).");
358 404
     return;
359 405
   }
360 406
 
@@ -382,15 +428,13 @@ void GcodeSuite::G33() {
382 428
              _0p_calibration      = probe_points == 0,
383 429
              _1p_calibration      = probe_points == 1,
384 430
              _4p_calibration      = probe_points == 2,
431
+             _7p_9_centre         = probe_points >= 8,
385 432
              _tower_results       = (_4p_calibration && towers_set)
386 433
                                     || probe_points >= 3 || probe_points == 0,
387 434
              _opposite_results    = (_4p_calibration && !towers_set)
388 435
                                     || probe_points >= 3 || probe_points == 0,
389 436
              _endstop_results     = probe_points != 1,
390
-             _angle_results       = (probe_points >= 3 || probe_points == 0) && towers_set,
391
-             _7p_double_circle    = probe_points == 5,
392
-             _7p_triple_circle    = probe_points == 6,
393
-             _7p_quadruple_circle = probe_points == 7;
437
+             _angle_results       = (probe_points >= 3 || probe_points == 0) && towers_set;
394 438
   const static char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
395 439
   int8_t iterations = 0;
396 440
   float test_precision,
@@ -412,12 +456,9 @@ void GcodeSuite::G33() {
412 456
   SERIAL_PROTOCOLLNPGM("G33 Auto Calibrate");
413 457
 
414 458
   if (!_1p_calibration && !_0p_calibration) {  // test if the outer radius is reachable
415
-    const float circles = (_7p_quadruple_circle ? 1.5 :
416
-                           _7p_triple_circle    ? 1.0 :
417
-                           _7p_double_circle    ? 0.5 : 0),
418
-                r = (1 + circles * 0.1) * delta_calibration_radius;
419
-    for (uint8_t axis = 1; axis <= 12; ++axis) {
420
-      const float a = RADIANS(180 + 30 * axis);
459
+    LOOP_CAL_RAD(axis) {
460
+      const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
461
+                  r = delta_calibration_radius * (1 + (_7p_9_centre ? 0.1 : 0.0));
421 462
       if (!position_is_reachable_xy(cos(a) * r, sin(a) * r)) {
422 463
         SERIAL_PROTOCOLLNPGM("?(M665 B)ed radius is implausible.");
423 464
         return;
@@ -468,7 +509,7 @@ void GcodeSuite::G33() {
468 509
 
469 510
   do {
470 511
 
471
-    float z_at_pt[13] = { 0.0 };
512
+    float z_at_pt[NPP + 1] = { 0.0 };
472 513
 
473 514
     test_precision = zero_std_dev;
474 515
 
@@ -526,34 +567,34 @@ void GcodeSuite::G33() {
526 567
 
527 568
         case 1:
528 569
           test_precision = 0.00; // forced end
529
-          LOOP_XYZ(axis) e_delta[axis] = Z1(0);
570
+          LOOP_XYZ(axis) e_delta[axis] = Z1(CEN);
530 571
           break;
531 572
 
532 573
         case 2:
533 574
           if (towers_set) {
534
-            e_delta[A_AXIS] = (Z6(0) + Z4(1) - Z2(5) - Z2(9)) * h_factor;
535
-            e_delta[B_AXIS] = (Z6(0) - Z2(1) + Z4(5) - Z2(9)) * h_factor;
536
-            e_delta[C_AXIS] = (Z6(0) - Z2(1) - Z2(5) + Z4(9)) * h_factor;
537
-            r_delta         = (Z6(0) - Z2(1) - Z2(5) - Z2(9)) * r_factor;
575
+            e_delta[A_AXIS] = (Z6(CEN) +Z4(__A) -Z2(__B) -Z2(__C)) * h_factor;
576
+            e_delta[B_AXIS] = (Z6(CEN) -Z2(__A) +Z4(__B) -Z2(__C)) * h_factor;
577
+            e_delta[C_AXIS] = (Z6(CEN) -Z2(__A) -Z2(__B) +Z4(__C)) * h_factor;
578
+            r_delta         = (Z6(CEN) -Z2(__A) -Z2(__B) -Z2(__C)) * r_factor;
538 579
           }
539 580
           else {
540
-            e_delta[A_AXIS] = (Z6(0) - Z4(7) + Z2(11) + Z2(3)) * h_factor;
541
-            e_delta[B_AXIS] = (Z6(0) + Z2(7) - Z4(11) + Z2(3)) * h_factor;
542
-            e_delta[C_AXIS] = (Z6(0) + Z2(7) + Z2(11) - Z4(3)) * h_factor;
543
-            r_delta         = (Z6(0) - Z2(7) - Z2(11) - Z2(3)) * r_factor;
581
+            e_delta[A_AXIS] = (Z6(CEN) -Z4(_BC) +Z2(_CA) +Z2(_AB)) * h_factor;
582
+            e_delta[B_AXIS] = (Z6(CEN) +Z2(_BC) -Z4(_CA) +Z2(_AB)) * h_factor;
583
+            e_delta[C_AXIS] = (Z6(CEN) +Z2(_BC) +Z2(_CA) -Z4(_AB)) * h_factor;
584
+            r_delta         = (Z6(CEN) -Z2(_BC) -Z2(_CA) -Z2(_AB)) * r_factor;
544 585
           }
545 586
           break;
546 587
 
547 588
         default:
548
-          e_delta[A_AXIS] = (Z6(0) + Z2(1) - Z1(5) - Z1(9) - Z2(7) + Z1(11) + Z1(3)) * h_factor;
549
-          e_delta[B_AXIS] = (Z6(0) - Z1(1) + Z2(5) - Z1(9) + Z1(7) - Z2(11) + Z1(3)) * h_factor;
550
-          e_delta[C_AXIS] = (Z6(0) - Z1(1) - Z1(5) + Z2(9) + Z1(7) + Z1(11) - Z2(3)) * h_factor;
551
-          r_delta         = (Z6(0) - Z1(1) - Z1(5) - Z1(9) - Z1(7) - Z1(11) - Z1(3)) * r_factor;
589
+          e_delta[A_AXIS] = (Z6(CEN) +Z2(__A) -Z1(__B) -Z1(__C) -Z2(_BC) +Z1(_CA) +Z1(_AB)) * h_factor;
590
+          e_delta[B_AXIS] = (Z6(CEN) -Z1(__A) +Z2(__B) -Z1(__C) +Z1(_BC) -Z2(_CA) +Z1(_AB)) * h_factor;
591
+          e_delta[C_AXIS] = (Z6(CEN) -Z1(__A) -Z1(__B) +Z2(__C) +Z1(_BC) +Z1(_CA) -Z2(_AB)) * h_factor;
592
+          r_delta         = (Z6(CEN) -Z1(__A) -Z1(__B) -Z1(__C) -Z1(_BC) -Z1(_CA) -Z1(_AB)) * r_factor;
552 593
 
553 594
           if (towers_set) {
554
-            t_delta[A_AXIS] = (       - Z4(5) + Z4(9)         - Z4(11) + Z4(3)) * a_factor;
555
-            t_delta[B_AXIS] = ( Z4(1)         - Z4(9) + Z4(7)          - Z4(3)) * a_factor;
556
-            t_delta[C_AXIS] = (-Z4(1) + Z4(5)         - Z4(7) + Z4(11)        ) * a_factor;
595
+            t_delta[A_AXIS] = (         -Z4(__B) +Z4(__C)          -Z4(_CA) +Z4(_AB)) * a_factor;
596
+            t_delta[B_AXIS] = ( Z4(__A)          -Z4(__C) +Z4(_BC)          -Z4(_AB)) * a_factor;
597
+            t_delta[C_AXIS] = (-Z4(__A) +Z4(__B)          -Z4(_BC) +Z4(_CA)         ) * a_factor;
557 598
             e_delta[A_AXIS] += (t_delta[B_AXIS] - t_delta[C_AXIS]) / 4.5;
558 599
             e_delta[B_AXIS] += (t_delta[C_AXIS] - t_delta[A_AXIS]) / 4.5;
559 600
             e_delta[C_AXIS] += (t_delta[A_AXIS] - t_delta[B_AXIS]) / 4.5;

Loading…
取消
儲存