Browse Source

Merge pull request #7157 from thinkyhead/bf_g33_f_parameter

G33 F and Height bug fix
Scott Lahteine 7 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,8 +1772,9 @@ static void clean_up_after_endstop_or_probe_move() {
1772 1772
 
1773 1773
     float z_dest = LOGICAL_Z_POSITION(z_raise);
1774 1774
     if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
1775
+
1775 1776
     #if ENABLED(DELTA)
1776
-      z_dest -= home_offset[Z_AXIS];
1777
+      z_dest -= home_offset[Z_AXIS]; // Account for delta height adjustment
1777 1778
     #endif
1778 1779
 
1779 1780
     if (z_dest > current_position[Z_AXIS])
@@ -2263,9 +2264,11 @@ static void clean_up_after_endstop_or_probe_move() {
2263 2264
       // move down quickly before doing the slow probe
2264 2265
       float z = LOGICAL_Z_POSITION(Z_CLEARANCE_BETWEEN_PROBES);
2265 2266
       if (zprobe_zoffset < 0) z -= zprobe_zoffset;
2267
+
2266 2268
       #if ENABLED(DELTA)
2267
-        z -= home_offset[Z_AXIS];
2269
+        z -= home_offset[Z_AXIS]; // Account for delta height adjustment
2268 2270
       #endif
2271
+
2269 2272
       if (z < current_position[Z_AXIS])
2270 2273
         do_blocking_move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2271 2274
 
@@ -2285,7 +2288,11 @@ static void clean_up_after_endstop_or_probe_move() {
2285 2288
         SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
2286 2289
       }
2287 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,6 +5141,8 @@ void home_all_axes() { gcode_G28(true); }
5134 5141
      *   T   Don't calibrate tower angle corrections
5135 5142
      *
5136 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 5147
      *   Vn  Verbose level:
5139 5148
      *
@@ -5172,7 +5181,13 @@ void home_all_axes() { gcode_G28(true); }
5172 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 5191
                  stow_after_each      = parser.seen('E') && parser.value_bool(),
5177 5192
                  _1p_calibration      = probe_points == 1,
5178 5193
                  _4p_calibration      = probe_points == 2,
@@ -5206,6 +5221,7 @@ void home_all_axes() { gcode_G28(true); }
5206 5221
       float test_precision,
5207 5222
             zero_std_dev = (verbose_level ? 999.0 : 0.0), // 0.0 in dry-run mode : forced end
5208 5223
             zero_std_dev_old = zero_std_dev,
5224
+            zero_std_dev_min = zero_std_dev,
5209 5225
             e_old[XYZ] = {
5210 5226
               endstop_adj[A_AXIS],
5211 5227
               endstop_adj[B_AXIS],
@@ -5284,9 +5300,10 @@ void home_all_axes() { gcode_G28(true); }
5284 5300
           const uint8_t start = _4p_opposite_points ? 3 : 1,
5285 5301
                          step = _4p_calibration ? 4 : _7p_half_circle ? 2 : 1;
5286 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 5307
             for (float circles = -offset_circles ; circles <= offset_circles; circles++) {
5291 5308
               const float a = RADIANS(180 + 30 * axis),
5292 5309
                           r = delta_calibration_radius * (1 + circles * (zig_zag ? 0.1 : -0.1));
@@ -5310,18 +5327,19 @@ void home_all_axes() { gcode_G28(true); }
5310 5327
             N++;
5311 5328
           }
5312 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 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 5344
           float e_delta[XYZ] = { 0.0 }, r_delta = 0.0, t_alpha = 0.0, t_beta = 0.0;
5327 5345
           const float r_diff = delta_radius - delta_calibration_radius,
@@ -5420,7 +5438,7 @@ void home_all_axes() { gcode_G28(true); }
5420 5438
           }
5421 5439
         }
5422 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 5442
             SERIAL_PROTOCOLPGM("Calibration OK");
5425 5443
             SERIAL_PROTOCOL_SP(36);
5426 5444
             if (zero_std_dev >= test_precision)
@@ -5458,7 +5476,7 @@ void home_all_axes() { gcode_G28(true); }
5458 5476
             SERIAL_PROTOCOLPGM("  Tz:+0.00");
5459 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 5480
             serialprintPGM(save_message);
5463 5481
             SERIAL_EOL();
5464 5482
         }
@@ -5485,7 +5503,7 @@ void home_all_axes() { gcode_G28(true); }
5485 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 5508
       #if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
5491 5509
         do_blocking_move_to_z(delta_clip_start_height);
@@ -8248,7 +8266,6 @@ inline void gcode_M205() {
8248 8266
   inline void gcode_M665() {
8249 8267
     if (parser.seen('H')) {
8250 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 8269
       update_software_endstops(Z_AXIS);
8253 8270
     }
8254 8271
     if (parser.seen('L')) delta_diagonal_rod = parser.value_linear_units();

Loading…
Cancel
Save