Browse Source

Patch for G29 final Z position

Include all the necessary pieces to get the final Z position after
probing the bed, and add commentary about other possible changes.
Scott Lahteine 10 years ago
parent
commit
5a7356b6fc
1 changed files with 20 additions and 3 deletions
  1. 20
    3
      Marlin/Marlin_main.cpp

+ 20
- 3
Marlin/Marlin_main.cpp View File

@@ -2744,11 +2744,28 @@ inline void gcode_G28() {
2744 2744
         float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
2745 2745
               y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
2746 2746
               z_tmp = current_position[Z_AXIS],
2747
-              real_z = st_get_position_mm(Z_AXIS);  //get the real Z (since the auto bed leveling is already correcting the plane)
2747
+              real_z = st_get_position_mm(Z_AXIS);  //get the real Z (since plan_get_position is now correcting the plane)
2748 2748
 
2749 2749
         apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); // Apply the correction sending the probe offset
2750
-        //line below controls z probe offset, zprobe_zoffset is the actual offset that can be modified via m851 or is read from EEPROM
2751
-        current_position[Z_AXIS] = z_tmp - real_z - zprobe_zoffset; // The difference is added to current position and sent to planner.
2750
+
2751
+        // Get the current Z position and send it to the planner.
2752
+        //
2753
+        // >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z (since homing)
2754
+        //
2755
+        // >> zprobe_zoffset : Z distance from nozzle to probe (set by default, M851, EEPROM, or Menu)
2756
+        //
2757
+        // >> Z_RAISE_AFTER_PROBING : The distance the probe will have lifted after the last probe
2758
+        //
2759
+        // >> Should home_offset[Z_AXIS] be included?
2760
+        //
2761
+        //      Discussion: home_offset[Z_AXIS] was applied in G28 to set the starting Z.
2762
+        //      If Z is not tweaked in G29 -and- the Z probe in G29 is not actually "homing" Z...
2763
+        //      then perhaps it should not be included here. The purpose of home_offset[] is to
2764
+        //      adjust for inaccurate endstops, not for reasonably accurate probes. If it were
2765
+        //      added here, it could be seen as a compensating factor for the Z probe.
2766
+        //
2767
+        current_position[Z_AXIS] = -zprobe_zoffset + Z_RAISE_AFTER_PROBING + (z_tmp - real_z);
2768
+        // current_position[Z_AXIS] += home_offset[Z_AXIS]; // The probe determines Z=0, not "Z home"
2752 2769
         sync_plan_position();
2753 2770
       }
2754 2771
     #endif // !DELTA

Loading…
Cancel
Save