Browse Source

Merge pull request #7157 from thinkyhead/bf_g33_f_parameter

G33 F and Height bug fix
Scott Lahteine 8 years ago
parent
commit
c2c8aafda2
1 changed files with 37 additions and 20 deletions
  1. 37
    20
      Marlin/Marlin_main.cpp

+ 37
- 20
Marlin/Marlin_main.cpp View File

1772
 
1772
 
1773
     float z_dest = LOGICAL_Z_POSITION(z_raise);
1773
     float z_dest = LOGICAL_Z_POSITION(z_raise);
1774
     if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
1774
     if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
1775
+
1775
     #if ENABLED(DELTA)
1776
     #if ENABLED(DELTA)
1776
-      z_dest -= home_offset[Z_AXIS];
1777
+      z_dest -= home_offset[Z_AXIS]; // Account for delta height adjustment
1777
     #endif
1778
     #endif
1778
 
1779
 
1779
     if (z_dest > current_position[Z_AXIS])
1780
     if (z_dest > current_position[Z_AXIS])
2263
       // move down quickly before doing the slow probe
2264
       // move down quickly before doing the slow probe
2264
       float z = LOGICAL_Z_POSITION(Z_CLEARANCE_BETWEEN_PROBES);
2265
       float z = LOGICAL_Z_POSITION(Z_CLEARANCE_BETWEEN_PROBES);
2265
       if (zprobe_zoffset < 0) z -= zprobe_zoffset;
2266
       if (zprobe_zoffset < 0) z -= zprobe_zoffset;
2267
+
2266
       #if ENABLED(DELTA)
2268
       #if ENABLED(DELTA)
2267
-        z -= home_offset[Z_AXIS];
2269
+        z -= home_offset[Z_AXIS]; // Account for delta height adjustment
2268
       #endif
2270
       #endif
2271
+
2269
       if (z < current_position[Z_AXIS])
2272
       if (z < current_position[Z_AXIS])
2270
         do_blocking_move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2273
         do_blocking_move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2271
 
2274
 
2285
         SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
2288
         SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
2286
       }
2289
       }
2287
     #endif
2290
     #endif
2288
-    return RAW_CURRENT_POSITION(Z) + zprobe_zoffset;
2291
+    return RAW_CURRENT_POSITION(Z) + zprobe_zoffset
2292
+      #if ENABLED(DELTA)
2293
+        + home_offset[Z_AXIS] // Account for delta height adjustment
2294
+      #endif
2295
+    ;
2289
   }
2296
   }
2290
 
2297
 
2291
   /**
2298
   /**
5134
      *   T   Don't calibrate tower angle corrections
5141
      *   T   Don't calibrate tower angle corrections
5135
      *
5142
      *
5136
      *   Cn.nn Calibration precision; when omitted calibrates to maximum precision
5143
      *   Cn.nn Calibration precision; when omitted calibrates to maximum precision
5144
+     *   
5145
+     *   Fn  Force to run at least n iterations and takes the best result
5137
      *
5146
      *
5138
      *   Vn  Verbose level:
5147
      *   Vn  Verbose level:
5139
      *
5148
      *
5172
         return;
5181
         return;
5173
       }
5182
       }
5174
 
5183
 
5175
-      const bool towers_set = !parser.seen('T'),
5184
+      const int8_t force_iterations = parser.seen('F') ? parser.value_int() : 1;
5185
+      if (!WITHIN(force_iterations, 1, 30)) {
5186
+        SERIAL_PROTOCOLLNPGM("?(F)orce iteration is implausible (1-30).");
5187
+        return;
5188
+      }
5189
+
5190
+      const bool towers_set           = !parser.seen('T'),
5176
                  stow_after_each      = parser.seen('E') && parser.value_bool(),
5191
                  stow_after_each      = parser.seen('E') && parser.value_bool(),
5177
                  _1p_calibration      = probe_points == 1,
5192
                  _1p_calibration      = probe_points == 1,
5178
                  _4p_calibration      = probe_points == 2,
5193
                  _4p_calibration      = probe_points == 2,
5206
       float test_precision,
5221
       float test_precision,
5207
             zero_std_dev = (verbose_level ? 999.0 : 0.0), // 0.0 in dry-run mode : forced end
5222
             zero_std_dev = (verbose_level ? 999.0 : 0.0), // 0.0 in dry-run mode : forced end
5208
             zero_std_dev_old = zero_std_dev,
5223
             zero_std_dev_old = zero_std_dev,
5224
+            zero_std_dev_min = zero_std_dev,
5209
             e_old[XYZ] = {
5225
             e_old[XYZ] = {
5210
               endstop_adj[A_AXIS],
5226
               endstop_adj[A_AXIS],
5211
               endstop_adj[B_AXIS],
5227
               endstop_adj[B_AXIS],
5284
           const uint8_t start = _4p_opposite_points ? 3 : 1,
5300
           const uint8_t start = _4p_opposite_points ? 3 : 1,
5285
                          step = _4p_calibration ? 4 : _7p_half_circle ? 2 : 1;
5301
                          step = _4p_calibration ? 4 : _7p_half_circle ? 2 : 1;
5286
           for (uint8_t axis = start; axis < 13; axis += step) {
5302
           for (uint8_t axis = start; axis < 13; axis += step) {
5287
-            const float offset_circles = _7p_quadruple_circle ? (zig_zag ? 1.5 : 1.0) :
5288
-                                         _7p_triple_circle    ? (zig_zag ? 1.0 : 0.5) :
5289
-                                         _7p_double_circle    ? (zig_zag ? 0.5 : 0.0) : 0;
5303
+            const float zigadd = (zig_zag ? 0.5 : 0.0),
5304
+                        offset_circles = _7p_quadruple_circle ? zigadd + 1.0 :
5305
+                                         _7p_triple_circle    ? zigadd + 0.5 :
5306
+                                         _7p_double_circle    ? zigadd : 0;
5290
             for (float circles = -offset_circles ; circles <= offset_circles; circles++) {
5307
             for (float circles = -offset_circles ; circles <= offset_circles; circles++) {
5291
               const float a = RADIANS(180 + 30 * axis),
5308
               const float a = RADIANS(180 + 30 * axis),
5292
                           r = delta_calibration_radius * (1 + circles * (zig_zag ? 0.1 : -0.1));
5309
                           r = delta_calibration_radius * (1 + circles * (zig_zag ? 0.1 : -0.1));
5310
             N++;
5327
             N++;
5311
           }
5328
           }
5312
         zero_std_dev_old = zero_std_dev;
5329
         zero_std_dev_old = zero_std_dev;
5313
-        zero_std_dev = round(SQRT(S2 / N) * 1000.0) / 1000.0 + 0.00001;
5314
-
5315
-        if (iterations == 1) home_offset[Z_AXIS] = zh_old; // reset height after 1st probe change
5330
+        NOMORE(zero_std_dev_min, zero_std_dev);
5331
+        zero_std_dev = round(sqrt(S2 / N) * 1000.0) / 1000.0 + 0.00001;
5316
 
5332
 
5317
         // Solve matrices
5333
         // Solve matrices
5318
 
5334
 
5319
-        if (zero_std_dev < test_precision && zero_std_dev > calibration_precision) {
5320
-          COPY(e_old, endstop_adj);
5321
-          dr_old = delta_radius;
5322
-          zh_old = home_offset[Z_AXIS];
5323
-          alpha_old = delta_tower_angle_trim[A_AXIS];
5324
-          beta_old = delta_tower_angle_trim[B_AXIS];
5335
+        if ((zero_std_dev < test_precision && zero_std_dev > calibration_precision) || iterations <= force_iterations) {
5336
+          if (zero_std_dev < zero_std_dev_min) {
5337
+            COPY(e_old, endstop_adj);
5338
+            dr_old = delta_radius;
5339
+            zh_old = home_offset[Z_AXIS];
5340
+            alpha_old = delta_tower_angle_trim[A_AXIS];
5341
+            beta_old = delta_tower_angle_trim[B_AXIS];
5342
+          }
5325
 
5343
 
5326
           float e_delta[XYZ] = { 0.0 }, r_delta = 0.0, t_alpha = 0.0, t_beta = 0.0;
5344
           float e_delta[XYZ] = { 0.0 }, r_delta = 0.0, t_alpha = 0.0, t_beta = 0.0;
5327
           const float r_diff = delta_radius - delta_calibration_radius,
5345
           const float r_diff = delta_radius - delta_calibration_radius,
5420
           }
5438
           }
5421
         }
5439
         }
5422
         if (test_precision != 0.0) {                                 // !forced end
5440
         if (test_precision != 0.0) {                                 // !forced end
5423
-          if (zero_std_dev >= test_precision || zero_std_dev <= calibration_precision) {  // end iterations
5441
+          if ((zero_std_dev >= test_precision || zero_std_dev <= calibration_precision) && iterations > force_iterations) {  // end iterations
5424
             SERIAL_PROTOCOLPGM("Calibration OK");
5442
             SERIAL_PROTOCOLPGM("Calibration OK");
5425
             SERIAL_PROTOCOL_SP(36);
5443
             SERIAL_PROTOCOL_SP(36);
5426
             if (zero_std_dev >= test_precision)
5444
             if (zero_std_dev >= test_precision)
5458
             SERIAL_PROTOCOLPGM("  Tz:+0.00");
5476
             SERIAL_PROTOCOLPGM("  Tz:+0.00");
5459
             SERIAL_EOL();
5477
             SERIAL_EOL();
5460
           }
5478
           }
5461
-          if (zero_std_dev >= test_precision || zero_std_dev <= calibration_precision)
5479
+          if ((zero_std_dev >= test_precision || zero_std_dev <= calibration_precision) && iterations > force_iterations)
5462
             serialprintPGM(save_message);
5480
             serialprintPGM(save_message);
5463
             SERIAL_EOL();
5481
             SERIAL_EOL();
5464
         }
5482
         }
5485
         endstops.not_homing();
5503
         endstops.not_homing();
5486
 
5504
 
5487
       }
5505
       }
5488
-      while (zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31);
5506
+      while ((zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31) || iterations <= force_iterations);
5489
 
5507
 
5490
       #if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
5508
       #if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
5491
         do_blocking_move_to_z(delta_clip_start_height);
5509
         do_blocking_move_to_z(delta_clip_start_height);
8248
   inline void gcode_M665() {
8266
   inline void gcode_M665() {
8249
     if (parser.seen('H')) {
8267
     if (parser.seen('H')) {
8250
       home_offset[Z_AXIS] = parser.value_linear_units() - DELTA_HEIGHT;
8268
       home_offset[Z_AXIS] = parser.value_linear_units() - DELTA_HEIGHT;
8251
-      current_position[Z_AXIS] += parser.value_linear_units() - DELTA_HEIGHT - home_offset[Z_AXIS];
8252
       update_software_endstops(Z_AXIS);
8269
       update_software_endstops(Z_AXIS);
8253
     }
8270
     }
8254
     if (parser.seen('L')) delta_diagonal_rod = parser.value_linear_units();
8271
     if (parser.seen('L')) delta_diagonal_rod = parser.value_linear_units();

Loading…
Cancel
Save