瀏覽代碼

Apply G33 updates

Adapted from #7865
Scott Lahteine 7 年之前
父節點
當前提交
b220bc7521
共有 1 個檔案被更改,包括 53 行新增28 行删除
  1. 53
    28
      Marlin/src/gcode/calibrate/G33.cpp

+ 53
- 28
Marlin/src/gcode/calibrate/G33.cpp 查看文件

@@ -107,6 +107,34 @@ static void G33_cleanup(
107 107
   #endif
108 108
 }
109 109
 
110
+/**
111
+ * G33 - Delta '1-4-7-point' Auto-Calibration
112
+ *       Calibrate height, endstops, delta radius, and tower angles.
113
+ *
114
+ * Parameters:
115
+ *
116
+ *   Pn  Number of probe points:
117
+ *
118
+ *      P0     No probe. Normalize only.
119
+ *      P1     Probe center and set height only.
120
+ *      P2     Probe center and towers. Set height, endstops, and delta radius.
121
+ *      P3     Probe all positions: center, towers and opposite towers. Set all.
122
+ *      P4-P7  Probe all positions at different locations and average them.
123
+ *
124
+ *   T0  Don't calibrate tower angle corrections
125
+ *
126
+ *   Cn.nn Calibration precision; when omitted calibrates to maximum precision
127
+ *
128
+ *   Fn  Force to run at least n iterations and takes the best result
129
+ *
130
+ *   Vn  Verbose level:
131
+ *
132
+ *      V0  Dry-run mode. Report settings and probe results. No calibration.
133
+ *      V1  Report settings
134
+ *      V2  Report settings and probe results
135
+ *
136
+ *   E   Engage the probe for each point
137
+ */
110 138
 void GcodeSuite::G33() {
111 139
 
112 140
   const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
@@ -134,6 +162,7 @@ void GcodeSuite::G33() {
134 162
   }
135 163
 
136 164
   const bool towers_set           = parser.boolval('T', true),
165
+             stow_after_each      = parser.boolval('E'),
137 166
              _0p_calibration      = probe_points == 0,
138 167
              _1p_calibration      = probe_points == 1,
139 168
              _4p_calibration      = probe_points == 2,
@@ -146,15 +175,9 @@ void GcodeSuite::G33() {
146 175
              _7p_quadruple_circle = probe_points == 7,
147 176
              _7p_multi_circle     = _7p_double_circle || _7p_triple_circle || _7p_quadruple_circle,
148 177
              _7p_intermed_points  = _7p_calibration && !_7p_half_circle;
149
-
150
-  #if DISABLED(PROBE_MANUALLY)
151
-    const bool stow_after_each    = parser.boolval('E');
152
-    const float dx = (X_PROBE_OFFSET_FROM_EXTRUDER),
153
-                dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
154
-  #endif
155
-
156 178
   const static char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
157
-
179
+  const float dx = (X_PROBE_OFFSET_FROM_EXTRUDER),
180
+              dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
158 181
   int8_t iterations = 0;
159 182
   float test_precision,
160 183
         zero_std_dev = (verbose_level ? 999.0 : 0.0), // 0.0 in dry-run mode : forced end
@@ -189,7 +212,6 @@ void GcodeSuite::G33() {
189 212
   SERIAL_PROTOCOLLNPGM("G33 Auto Calibrate");
190 213
 
191 214
   stepper.synchronize();
192
-
193 215
   #if HAS_LEVELING
194 216
     reset_bed_level(); // After calibration bed-level data is no longer valid
195 217
   #endif
@@ -220,19 +242,11 @@ void GcodeSuite::G33() {
220 242
 
221 243
   print_G33_settings(!_1p_calibration, _7p_calibration && towers_set);
222 244
 
223
-  #if DISABLED(PROBE_MANUALLY)
224
-    if (!_0p_calibration) {
225
-      const float measured_z = probe_pt(dx, dy, stow_after_each, 1, false); // 1st probe to set height
226
-      if (isnan(measured_z)) return G33_CLEANUP();
227
-      home_offset[Z_AXIS] -= measured_z;
228
-    }
229
-  #endif
230
-
231 245
   do {
232 246
 
233 247
     float z_at_pt[13] = { 0.0 };
234 248
 
235
-    test_precision = _0p_calibration ? 0.00 : zero_std_dev_old != 999.0 ? (zero_std_dev + zero_std_dev_old) / 2 : zero_std_dev;
249
+    test_precision = zero_std_dev_old != 999.0 ? (zero_std_dev + zero_std_dev_old) / 2 : zero_std_dev;
236 250
 
237 251
     iterations++;
238 252
 
@@ -301,7 +315,7 @@ void GcodeSuite::G33() {
301 315
 
302 316
     // Solve matrices
303 317
 
304
-    if ((zero_std_dev < test_precision && zero_std_dev > calibration_precision) || iterations <= force_iterations) {
318
+    if ((zero_std_dev < test_precision || iterations <= force_iterations) && zero_std_dev > calibration_precision) {
305 319
       if (zero_std_dev < zero_std_dev_min) {
306 320
         COPY(e_old, delta_endstop_adj);
307 321
         dr_old = delta_radius;
@@ -311,9 +325,9 @@ void GcodeSuite::G33() {
311 325
 
312 326
       float e_delta[ABC] = { 0.0 }, r_delta = 0.0, t_delta[ABC] = { 0.0 };
313 327
       const float r_diff = delta_radius - delta_calibration_radius,
314
-                  h_factor = (1.00 + r_diff * 0.001) / 6.0,                        //1.02 / 6 for r_diff = 20mm
315
-                  r_factor = -(1.75 + 0.005 * r_diff + 0.001 * sq(r_diff)) / 6.0,  //2.25 / 6 for r_diff = 20mm
316
-                  a_factor = 66.66 / delta_calibration_radius;                     //1.25 for cal_rd = 80mm
328
+                  h_factor = (1.00 + r_diff * 0.001) / 6.0,                                       // 1.02 for r_diff = 20mm
329
+                  r_factor = (-(1.75 + 0.005 * r_diff + 0.001 * sq(r_diff))) / 6.0,               // 2.25 for r_diff = 20mm
330
+                  a_factor = (66.66 / delta_calibration_radius) / (iterations == 1 ? 16.0 : 2.0); // 0.83 for cal_rd = 80mm
317 331
 
318 332
       #define ZP(N,I) ((N) * z_at_pt[I])
319 333
       #define Z6(I) ZP(6, I)
@@ -326,8 +340,16 @@ void GcodeSuite::G33() {
326 340
       #endif
327 341
 
328 342
       switch (probe_points) {
343
+        case 0:
344
+          #if DISABLED(PROBE_MANUALLY)
345
+            test_precision = 0.00; // forced end
346
+          #endif
347
+          break;
348
+
329 349
         case 1:
330
-          test_precision = 0.00; // forced end
350
+          #if DISABLED(PROBE_MANUALLY)
351
+            test_precision = 0.00; // forced end
352
+          #endif
331 353
           LOOP_XYZ(axis) e_delta[axis] = Z1(0);
332 354
           break;
333 355
 
@@ -353,9 +375,12 @@ void GcodeSuite::G33() {
353 375
           r_delta         = (Z6(0) - Z1(1) - Z1(5) - Z1(9) - Z1(7) - Z1(11) - Z1(3)) * r_factor;
354 376
 
355 377
           if (towers_set) {
356
-            t_delta[A_AXIS] = (            - Z2(5) + Z1(9)         - Z2(11) + Z1(3)) * a_factor;
357
-            t_delta[B_AXIS] = (      Z2(1)         - Z1(9) + Z2(7)          - Z1(3)) * a_factor;
358
-            t_delta[C_AXIS] = (     -Z2(1) + Z1(5)         - Z2(7) + Z1(11)        ) * a_factor;
378
+            t_delta[A_AXIS] = (       - Z2(5) + Z2(9)         - Z2(11) + Z2(3)) * a_factor;
379
+            t_delta[B_AXIS] = ( Z2(1)         - Z2(9) + Z2(7)          - Z2(3)) * a_factor;
380
+            t_delta[C_AXIS] = (-Z2(1) + Z2(5)         - Z2(7) + Z2(11)        ) * a_factor;
381
+            e_delta[A_AXIS] += (t_delta[B_AXIS] - t_delta[C_AXIS]) / 4.5;
382
+            e_delta[B_AXIS] += (t_delta[C_AXIS] - t_delta[A_AXIS]) / 4.5;
383
+            e_delta[C_AXIS] += (t_delta[A_AXIS] - t_delta[B_AXIS]) / 4.5;
359 384
           }
360 385
           break;
361 386
       }
@@ -407,7 +432,7 @@ void GcodeSuite::G33() {
407 432
       }
408 433
     }
409 434
     if (verbose_level != 0) {                                    // !dry run
410
-      if ((zero_std_dev >= test_precision || zero_std_dev <= calibration_precision) && iterations > force_iterations) {  // end iterations
435
+      if ((zero_std_dev >= test_precision && iterations > force_iterations) || zero_std_dev <= calibration_precision) {  // end iterations
411 436
         SERIAL_PROTOCOLPGM("Calibration OK");
412 437
         SERIAL_PROTOCOL_SP(36);
413 438
         #if DISABLED(PROBE_MANUALLY)
@@ -469,7 +494,7 @@ void GcodeSuite::G33() {
469 494
     endstops.not_homing();
470 495
 
471 496
   }
472
-  while ((zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31) || iterations <= force_iterations);
497
+  while (((zero_std_dev < test_precision && iterations < 31) || iterations <= force_iterations) && zero_std_dev > calibration_precision);
473 498
 
474 499
   G33_CLEANUP();
475 500
 }

Loading…
取消
儲存