Browse Source

UBL G29 T current position fix

Counterpart to #12845
Scott Lahteine 5 years ago
parent
commit
f37df28d17
2 changed files with 13 additions and 4 deletions
  1. 5
    2
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  2. 8
    2
      Marlin/src/inc/Conditionals_post.h

+ 5
- 2
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

198
       serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
198
       serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
199
     }
199
     }
200
 
200
 
201
-    const float current_xi = get_cell_index_x(current_position[X_AXIS] + (MESH_X_DIST) / 2.0),
202
-                current_yi = get_cell_index_y(current_position[Y_AXIS] + (MESH_Y_DIST) / 2.0);
201
+    // Add XY_PROBE_OFFSET_FROM_EXTRUDER because probe_pt() subtracts these when
202
+    // moving to the xy position to be measured. This ensures better agreement between
203
+    // the current Z position after G28 and the mesh values.
204
+    const float current_xi = find_closest_x_index(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER),
205
+                current_yi = find_closest_y_index(current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER);
203
 
206
 
204
     if (!lcd) SERIAL_EOL();
207
     if (!lcd) SERIAL_EOL();
205
     for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {
208
     for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {

+ 8
- 2
Marlin/src/inc/Conditionals_post.h View File

203
  * Safe Homing Options
203
  * Safe Homing Options
204
  */
204
  */
205
 #if ENABLED(Z_SAFE_HOMING)
205
 #if ENABLED(Z_SAFE_HOMING)
206
+  #if ENABLED(AUTO_BED_LEVELING_UBL)
207
+    // Home close to center so grid points have z heights very close to 0
208
+    #define _SAFE_POINT(A) (((GRID_MAX_POINTS_##A) / 2) * (A##_BED_SIZE - 2 * (MESH_INSET)) / (GRID_MAX_POINTS_##A - 1) + MESH_INSET)
209
+  #else
210
+    #define _SAFE_POINT(A) A##_CENTER
211
+  #endif
206
   #ifndef Z_SAFE_HOMING_X_POINT
212
   #ifndef Z_SAFE_HOMING_X_POINT
207
-    #define Z_SAFE_HOMING_X_POINT X_CENTER
213
+    #define Z_SAFE_HOMING_X_POINT _SAFE_POINT(X)
208
   #endif
214
   #endif
209
   #ifndef Z_SAFE_HOMING_Y_POINT
215
   #ifndef Z_SAFE_HOMING_Y_POINT
210
-    #define Z_SAFE_HOMING_Y_POINT Y_CENTER
216
+    #define Z_SAFE_HOMING_Y_POINT _SAFE_POINT(Y)
211
   #endif
217
   #endif
212
   #define X_TILT_FULCRUM Z_SAFE_HOMING_X_POINT
218
   #define X_TILT_FULCRUM Z_SAFE_HOMING_X_POINT
213
   #define Y_TILT_FULCRUM Z_SAFE_HOMING_Y_POINT
219
   #define Y_TILT_FULCRUM Z_SAFE_HOMING_Y_POINT

Loading…
Cancel
Save