Browse Source

Adjust M48 raise / move handling

Scott Lahteine 9 years ago
parent
commit
1dad912b03
1 changed files with 17 additions and 15 deletions
  1. 17
    15
      Marlin/Marlin_main.cpp

+ 17
- 15
Marlin/Marlin_main.cpp View File

@@ -4274,17 +4274,18 @@ inline void gcode_M42() {
4274 4274
      */
4275 4275
     setup_for_endstop_move();
4276 4276
 
4277
+    // Height before each probe (except the first)
4278
+    float z_before = current_position[Z_AXIS] + (deploy_probe_for_each_reading ? Z_RAISE_BEFORE_PROBING : Z_RAISE_BETWEEN_PROBINGS);
4279
+
4280
+    // Deploy the probe and probe the first point
4277 4281
     probe_pt(X_probe_location, Y_probe_location, Z_RAISE_BEFORE_PROBING,
4278 4282
       deploy_probe_for_each_reading ? ProbeDeployAndStow : ProbeDeploy,
4279 4283
       verbose_level);
4280 4284
 
4281
-    raise_z_after_probing();
4282
-
4283 4285
     randomSeed(millis());
4284 4286
 
4285 4287
     double mean, sigma, sample_set[n_samples];
4286 4288
     for (uint8_t n = 0; n < n_samples; n++) {
4287
-      delay(500);
4288 4289
       if (n_legs) {
4289 4290
         int dir = (random(0, 10) > 5.0) ? -1 : 1;  // clockwise or counter clockwise
4290 4291
         float angle = random(0.0, 360.0),
@@ -4359,18 +4360,13 @@ inline void gcode_M42() {
4359 4360
         } // n_legs loop
4360 4361
       } // n_legs
4361 4362
 
4362
-      /**
4363
-       * We don't really have to do this move, but if we don't we can see a
4364
-       * funny shift in the Z Height because the user might not have the
4365
-       * Z_RAISE_BEFORE_PROBING height identical to the Z_RAISE_BETWEEN_PROBINGS
4366
-       * height. This gets us back to the probe location at the same height that
4367
-       * we have been running around the circle at.
4368
-       */
4363
+      // The last probe will differ
4369 4364
       bool last_probe = (n == n_samples - 1);
4370
-      do_blocking_move_to_xy(X_probe_location - (X_PROBE_OFFSET_FROM_EXTRUDER), Y_probe_location - (Y_PROBE_OFFSET_FROM_EXTRUDER));
4365
+
4366
+      // Probe a single point
4371 4367
       sample_set[n] = probe_pt(
4372 4368
         X_probe_location, Y_probe_location,
4373
-        Z_RAISE_BEFORE_PROBING,
4369
+        z_before,
4374 4370
         deploy_probe_for_each_reading ? ProbeDeployAndStow : last_probe ? ProbeStow : ProbeStay,
4375 4371
         verbose_level
4376 4372
       );
@@ -4392,6 +4388,7 @@ inline void gcode_M42() {
4392 4388
         sum += ss * ss;
4393 4389
       }
4394 4390
       sigma = sqrt(sum / (n + 1));
4391
+
4395 4392
       if (verbose_level > 1) {
4396 4393
         SERIAL_PROTOCOL(n + 1);
4397 4394
         SERIAL_PROTOCOLPGM(" of ");
@@ -4407,9 +4404,14 @@ inline void gcode_M42() {
4407 4404
         }
4408 4405
       }
4409 4406
       if (verbose_level > 0) SERIAL_EOL;
4410
-      delay(50);
4411
-      do_blocking_move_to_z(current_position[Z_AXIS] + (last_probe ? Z_RAISE_AFTER_PROBING : Z_RAISE_BETWEEN_PROBINGS));
4412
-    }  // End of probe loop code
4407
+
4408
+      // Raise before the next loop for the legs
4409
+      if (n_legs || last_probe) {
4410
+        do_blocking_move_to_z(last_probe ? Z_RAISE_AFTER_PROBING : z_before);
4411
+        if (!last_probe) delay(500);
4412
+      }
4413
+
4414
+    } // End of probe loop
4413 4415
 
4414 4416
     if (verbose_level > 0) {
4415 4417
       SERIAL_PROTOCOLPGM("Mean: ");

Loading…
Cancel
Save