Bläddra i källkod

Implement Dry-Run mode in G29

It just probe all the bed without appliying the matrix.
Useful after a first G29 to check the topology.
alexborro 9 år sedan
förälder
incheckning
55025558dc
1 ändrade filer med 47 tillägg och 31 borttagningar
  1. 47
    31
      Marlin/Marlin_main.cpp

+ 47
- 31
Marlin/Marlin_main.cpp Visa fil

@@ -1168,6 +1168,7 @@ static void run_z_probe() {
1168 1168
     zPosition += home_retract_mm(Z_AXIS);
1169 1169
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1170 1170
     st_synchronize();
1171
+    endstops_hit_on_purpose();
1171 1172
 
1172 1173
     // move back down slowly to find bed
1173 1174
     
@@ -1185,6 +1186,7 @@ static void run_z_probe() {
1185 1186
     zPosition -= home_retract_mm(Z_AXIS) * 2;
1186 1187
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1187 1188
     st_synchronize();
1189
+    endstops_hit_on_purpose();
1188 1190
 
1189 1191
     current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
1190 1192
     // make sure the planner knows where we are as it may be a bit different than we last said to move to
@@ -1389,11 +1391,11 @@ static float probe_pt(float x, float y, float z_before, ProbeAction retract_acti
1389 1391
   if (verbose_level > 2) {
1390 1392
     SERIAL_PROTOCOLPGM(MSG_BED);
1391 1393
     SERIAL_PROTOCOLPGM(" X: ");
1392
-    SERIAL_PROTOCOL(x + 0.0001);
1394
+    SERIAL_PROTOCOL_F(x, 3);
1393 1395
     SERIAL_PROTOCOLPGM(" Y: ");
1394
-    SERIAL_PROTOCOL(y + 0.0001);
1396
+    SERIAL_PROTOCOL_F(y, 3);
1395 1397
     SERIAL_PROTOCOLPGM(" Z: ");
1396
-    SERIAL_PROTOCOL(measured_z + 0.0001);
1398
+    SERIAL_PROTOCOL_F(measured_z, 3);
1397 1399
     SERIAL_EOL;
1398 1400
   }
1399 1401
   return measured_z;
@@ -2109,6 +2111,9 @@ inline void gcode_G28() {
2109 2111
    *
2110 2112
    *  S  Set the XY travel speed between probe points (in mm/min)
2111 2113
    *
2114
+   *  D  Dry-Run mode. Just evaluate the bed Topology - It does not apply or clean the rotation Matrix
2115
+   *     Useful to check the topology after a first run of G29.
2116
+   *
2112 2117
    *  V  Set the verbose level (0-4). Example: "G29 V3"
2113 2118
    *
2114 2119
    *  T  Generate a Bed Topology Report. Example: "G29 P5 T" for a detailed report.
@@ -2150,6 +2155,7 @@ inline void gcode_G28() {
2150 2155
       }
2151 2156
     }
2152 2157
 
2158
+    bool dryrun = code_seen('D') || code_seen('d');
2153 2159
     bool enhanced_g29 = code_seen('E') || code_seen('e');
2154 2160
 
2155 2161
     #ifdef AUTO_BED_LEVELING_GRID
@@ -2159,7 +2165,10 @@ inline void gcode_G28() {
2159 2165
     #endif
2160 2166
 
2161 2167
       if (verbose_level > 0)
2168
+      {
2162 2169
         SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
2170
+        if (dryrun) SERIAL_ECHOLN("Running in DRY-RUN mode");
2171
+      }
2163 2172
 
2164 2173
       int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
2165 2174
       #ifndef DELTA
@@ -2216,22 +2225,27 @@ inline void gcode_G28() {
2216 2225
 
2217 2226
     st_synchronize();
2218 2227
 
2219
-    #ifdef DELTA
2220
-      reset_bed_level();
2221
-    #else
2228
+    if (!dryrun)
2229
+    {
2230
+      #ifdef DELTA
2231
+        reset_bed_level();
2232
+      #else
2222 2233
 
2223
-    // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
2224
-    //vector_3 corrected_position = plan_get_position_mm();
2225
-    //corrected_position.debug("position before G29");
2226
-    plan_bed_level_matrix.set_to_identity();
2227
-    vector_3 uncorrected_position = plan_get_position();
2228
-    //uncorrected_position.debug("position during G29");
2229
-    current_position[X_AXIS] = uncorrected_position.x;
2230
-    current_position[Y_AXIS] = uncorrected_position.y;
2231
-    current_position[Z_AXIS] = uncorrected_position.z;
2232
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2233
-  #endif
2234
+      // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
2235
+      //vector_3 corrected_position = plan_get_position_mm();
2236
+      //corrected_position.debug("position before G29");
2237
+      plan_bed_level_matrix.set_to_identity();
2238
+      vector_3 uncorrected_position = plan_get_position();
2239
+//    uncorrected_position.debug("position during G29");
2240
+
2241
+      current_position[X_AXIS] = uncorrected_position.x;
2242
+      current_position[Y_AXIS] = uncorrected_position.y;
2243
+      current_position[Z_AXIS] = uncorrected_position.z;
2244
+      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2234 2245
 
2246
+      #endif
2247
+    }
2248
+    
2235 2249
     setup_for_endstop_move();
2236 2250
 
2237 2251
     feedrate = homing_feedrate[Z_AXIS];
@@ -2381,12 +2395,12 @@ inline void gcode_G28() {
2381 2395
       } //do_topography_map
2382 2396
 
2383 2397
 
2384
-      set_bed_level_equation_lsq(plane_equation_coefficients);
2398
+      if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients);
2385 2399
       free(plane_equation_coefficients);
2386
-    #else
2387
-      extrapolate_unprobed_bed_level();
2400
+    #else //Delta
2401
+      if (!dryrun) extrapolate_unprobed_bed_level();
2388 2402
       print_bed_level();
2389
-    #endif
2403
+    #endif //Delta
2390 2404
 
2391 2405
     #else // !AUTO_BED_LEVELING_GRID
2392 2406
 
@@ -2405,25 +2419,27 @@ inline void gcode_G28() {
2405 2419
         z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeEngageAndRetract, verbose_level);
2406 2420
       }
2407 2421
       clean_up_after_endstop_move();
2408
-      set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
2422
+      if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
2409 2423
 
2410 2424
     #endif // !AUTO_BED_LEVELING_GRID
2411 2425
 
2412 2426
   #ifndef DELTA
2413
-    if (verbose_level > 0)
2414
-      plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
2427
+    if (verbose_level > 0) plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
2415 2428
 
2416 2429
     // Correct the Z height difference from z-probe position and hotend tip position.
2417 2430
     // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
2418 2431
     // When the bed is uneven, this height must be corrected.
2419
-    real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
2420
-    x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
2421
-    y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
2422
-    z_tmp = current_position[Z_AXIS];
2432
+    if (!dryrun)
2433
+    {
2434
+      real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
2435
+      x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
2436
+      y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
2437
+      z_tmp = current_position[Z_AXIS];
2423 2438
 
2424
-    apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2425
-    current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2426
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2439
+      apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2440
+      current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2441
+      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2442
+    }
2427 2443
   #endif
2428 2444
 
2429 2445
   #ifdef Z_PROBE_SLED

Laddar…
Avbryt
Spara