Browse Source

Some probe_pt error-handling

Scott Lahteine 7 years ago
parent
commit
6c064bb7d6
2 changed files with 33 additions and 24 deletions
  1. 16
    13
      Marlin/Marlin_main.cpp
  2. 17
    11
      Marlin/ubl_G29.cpp

+ 16
- 13
Marlin/Marlin_main.cpp View File

@@ -4743,12 +4743,12 @@ void home_all_axes() { gcode_G28(true); }
4743 4743
           // Retain the last probe position
4744 4744
           xProbe = LOGICAL_X_POSITION(points[i].x);
4745 4745
           yProbe = LOGICAL_Y_POSITION(points[i].y);
4746
-          measured_z = points[i].z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
4747
-        }
4748
-
4749
-        if (isnan(measured_z)) {
4750
-          planner.abl_enabled = abl_should_enable;
4751
-          return;
4746
+          measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
4747
+          if (isnan(measured_z)) {
4748
+            planner.abl_enabled = abl_should_enable;
4749
+            return;
4750
+          }
4751
+          points[i].z = measured_z;
4752 4752
         }
4753 4753
 
4754 4754
         if (!dryrun) {
@@ -5021,9 +5021,11 @@ void home_all_axes() { gcode_G28(true); }
5021 5021
 
5022 5022
     const float measured_z = probe_pt(xpos, ypos, !code_seen('S') || code_value_bool(), 1);
5023 5023
 
5024
-    SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
5025
-    SERIAL_PROTOCOLPAIR(" Y: ", FIXFLOAT(ypos));
5026
-    SERIAL_PROTOCOLLNPAIR(" Z: ", FIXFLOAT(measured_z));
5024
+    if (!isnan(measured_z)) {
5025
+      SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
5026
+      SERIAL_PROTOCOLPAIR(" Y: ", FIXFLOAT(ypos));
5027
+      SERIAL_PROTOCOLLNPAIR(" Z: ", FIXFLOAT(measured_z));
5028
+    }
5027 5029
 
5028 5030
     clean_up_after_endstop_or_probe_move();
5029 5031
 
@@ -5170,13 +5172,13 @@ void home_all_axes() { gcode_G28(true); }
5170 5172
 
5171 5173
         if (!do_all_positions && !do_circle_x3) { // probe the center
5172 5174
           setup_for_endstop_or_probe_move();
5173
-          z_at_pt[0] += probe_pt(0.0, 0.0 , true, 1);
5175
+          z_at_pt[0] += probe_pt(0.0, 0.0 , true, 1);   // TODO: Needs error handling
5174 5176
           clean_up_after_endstop_or_probe_move();
5175 5177
         }
5176 5178
         if (probe_center_plus_3) { // probe extra center points
5177 5179
           for (int8_t axis = probe_center_plus_6 ? 11 : 9; axis > 0; axis -= probe_center_plus_6 ? 2 : 4) {
5178 5180
             setup_for_endstop_or_probe_move();
5179
-            z_at_pt[0] += probe_pt(
5181
+            z_at_pt[0] += probe_pt(                     // TODO: Needs error handling
5180 5182
               cos(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius),
5181 5183
               sin(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius), true, 1);
5182 5184
             clean_up_after_endstop_or_probe_move();
@@ -5192,7 +5194,7 @@ void home_all_axes() { gcode_G28(true); }
5192 5194
                                     do_circle_x2 ? (zig_zag ? 0.5 : 0.0) : 0);
5193 5195
             for (float circles = -offset_circles ; circles <= offset_circles; circles++) {
5194 5196
               setup_for_endstop_or_probe_move();
5195
-              z_at_pt[axis] += probe_pt(
5197
+              z_at_pt[axis] += probe_pt(                // TODO: Needs error handling
5196 5198
                 cos(RADIANS(180 + 30 * axis)) * delta_calibration_radius *
5197 5199
                 (1 + circles * 0.1 * (zig_zag ? 1 : -1)),
5198 5200
                 sin(RADIANS(180 + 30 * axis)) * delta_calibration_radius *
@@ -6372,7 +6374,8 @@ inline void gcode_M42() {
6372 6374
     setup_for_endstop_or_probe_move();
6373 6375
 
6374 6376
     // Move to the first point, deploy, and probe
6375
-    probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
6377
+    const float t = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
6378
+    if (isnan(t)) return;
6376 6379
 
6377 6380
     randomSeed(millis());
6378 6381
 

+ 17
- 11
Marlin/ubl_G29.cpp View File

@@ -393,19 +393,24 @@
393 393
         ubl.save_ubl_active_state_and_disable();
394 394
         ubl.tilt_mesh_based_on_probed_grid(code_seen('T'));
395 395
         ubl.restore_ubl_active_state_and_leave();
396
-      } else { // grid_size==0 which means a 3-Point leveling has been requested
397
-        float z1 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y), false, g29_verbose_level),
398
-              z2 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y), false, g29_verbose_level),
399
-              z3 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y), true, g29_verbose_level);
396
+      }
397
+      else { // grid_size == 0 : A 3-Point leveling has been requested
398
+        float z3, z2, z1 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y), false, g29_verbose_level);
399
+        if (!isnan(z1)) {
400
+          z2 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y), false, g29_verbose_level);
401
+          if (!isnan(z2))
402
+            z3 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y), true, g29_verbose_level);
403
+        }
400 404
 
401
-        if ( isnan(z1) || isnan(z2) || isnan(z3)) {   // probe_pt will return NAN if unreachable
405
+        if (isnan(z1) || isnan(z2) || isnan(z3)) { // probe_pt will return NAN if unreachable
402 406
           SERIAL_ERROR_START;
403 407
           SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
404 408
           goto LEAVE;
405 409
         }
406 410
 
407
-      //  We need to adjust z1, z2, z3 by the Mesh Height at these points. Just because they are non-zero doesn't mean
408
-      //  the Mesh is tilted!  (We need to compensate each probe point by what the Mesh says that location's height is)
411
+        // Adjust z1, z2, z3 by the Mesh Height at these points. Just because they're non-zero
412
+        // doesn't mean the Mesh is tilted! (Compensate each probe point by what the Mesh says
413
+        // its height is.)
409 414
 
410 415
         ubl.save_ubl_active_state_and_disable();
411 416
         z1 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y)) /* + zprobe_zoffset */ ;
@@ -706,7 +711,7 @@
706 711
     const float mean = sum / n;
707 712
 
708 713
     //
709
-    // Now do the sumation of the squares of difference from mean
714
+    // Sum the squares of difference from mean
710 715
     //
711 716
     float sum_of_diff_squared = 0.0;
712 717
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
@@ -769,12 +774,13 @@
769 774
         const float rawx = pgm_read_float(&ubl.mesh_index_to_xpos[location.x_index]),
770 775
                     rawy = pgm_read_float(&ubl.mesh_index_to_ypos[location.y_index]);
771 776
 
772
-        const float measured_z = probe_pt(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy), stow_probe, g29_verbose_level);
777
+        const float measured_z = probe_pt(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy), stow_probe, g29_verbose_level); // TODO: Needs error handling
773 778
         ubl.z_values[location.x_index][location.y_index] = measured_z;
774 779
       }
775 780
 
776 781
       if (do_ubl_mesh_map) ubl.display_map(map_type);
777
-    } while ((location.x_index >= 0) && (--max_iterations));
782
+
783
+    } while (location.x_index >= 0 && --max_iterations);
778 784
 
779 785
     STOW_PROBE();
780 786
     ubl.restore_ubl_active_state_and_leave();
@@ -1548,7 +1554,7 @@
1548 1554
       const float x = float(x_min) + ix * dx;
1549 1555
       for (int8_t iy = 0; iy < grid_size; iy++) {
1550 1556
         const float y = float(y_min) + dy * (zig_zag ? grid_size - 1 - iy : iy);
1551
-        float measured_z = probe_pt(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y), code_seen('E'), g29_verbose_level);
1557
+        float measured_z = probe_pt(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y), code_seen('E'), g29_verbose_level); // TODO: Needs error handling
1552 1558
         #if ENABLED(DEBUG_LEVELING_FEATURE)
1553 1559
           if (DEBUGGING(LEVELING)) {
1554 1560
             SERIAL_CHAR('(');

Loading…
Cancel
Save