Add M851 X Y probe offsets (#15202)

This commit is contained in:
InsanityAutomation
2019-09-24 22:29:21 -04:00
committed by Scott Lahteine
parent ebc9a8a0b0
commit df1e51258a
151 changed files with 1009 additions and 1878 deletions

View File

@ -177,11 +177,11 @@
serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
}
// Add XY_PROBE_OFFSET_FROM_EXTRUDER because probe_pt() subtracts these when
// Add XY probe offset from extruder because probe_pt() subtracts them when
// moving to the xy position to be measured. This ensures better agreement between
// the current Z position after G28 and the mesh values.
const float current_xi = find_closest_x_index(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER),
current_yi = find_closest_y_index(current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER);
const float current_xi = find_closest_x_index(current_position[X_AXIS] + zprobe_offset[X_AXIS]),
current_yi = find_closest_y_index(current_position[Y_AXIS] + zprobe_offset[Y_AXIS]);
if (!lcd) SERIAL_EOL();
for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {

View File

@ -290,7 +290,7 @@
* especially better for Delta printers, since it populates the center of the mesh first, allowing for
* a quicker test print to verify settings. You don't need to populate the entire mesh to use it.
* After all, you don't want to spend a lot of time generating a mesh only to realize the resolution
* or zprobe_zoffset are incorrect. Mesh-generation gathers points starting closest to the nozzle unless
* or probe offsets are incorrect. Mesh-generation gathers points starting closest to the nozzle unless
* an (X,Y) coordinate pair is given.
*
* Unified Bed Leveling uses a lot of EEPROM storage to hold its data, and it takes some effort to get
@ -453,7 +453,7 @@
SERIAL_ECHO(g29_y_pos);
SERIAL_ECHOLNPGM(").\n");
}
probe_entire_mesh(g29_x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, g29_y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER,
probe_entire_mesh(g29_x_pos + zprobe_offset[X_AXIS], g29_y_pos + zprobe_offset[Y_AXIS],
parser.seen('T'), parser.seen('E'), parser.seen('U'));
report_current_position();
@ -482,8 +482,8 @@
g29_x_pos = X_HOME_POS;
g29_y_pos = Y_HOME_POS;
#else // cartesian
g29_x_pos = X_PROBE_OFFSET_FROM_EXTRUDER > 0 ? X_BED_SIZE : 0;
g29_y_pos = Y_PROBE_OFFSET_FROM_EXTRUDER < 0 ? Y_BED_SIZE : 0;
g29_x_pos = zprobe_offset[X_AXIS] > 0 ? X_BED_SIZE : 0;
g29_y_pos = zprobe_offset[Y_AXIS] < 0 ? Y_BED_SIZE : 0;
#endif
}
@ -800,8 +800,8 @@
restore_ubl_active_state_and_leave();
do_blocking_move_to_xy(
constrain(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), MESH_MIN_X, MESH_MAX_X),
constrain(ry - (Y_PROBE_OFFSET_FROM_EXTRUDER), MESH_MIN_Y, MESH_MAX_Y)
constrain(rx - zprobe_offset[X_AXIS], MESH_MIN_X, MESH_MAX_X),
constrain(ry - zprobe_offset[Y_AXIS], MESH_MIN_Y, MESH_MAX_Y)
);
}
@ -1281,8 +1281,8 @@
out_mesh.distance = -99999.9f;
// Get our reference position. Either the nozzle or probe location.
const float px = rx + (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
py = ry + (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
const float px = rx + (probe_as_reference == USE_PROBE_AS_REFERENCE ? zprobe_offset[X_AXIS] : 0),
py = ry + (probe_as_reference == USE_PROBE_AS_REFERENCE ? zprobe_offset[Y_AXIS] : 0);
float best_so_far = 99999.99f;
@ -1384,22 +1384,17 @@
#include "../../../libs/vector_3.h"
void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) {
constexpr int16_t x_min = _MAX(MIN_PROBE_X, MESH_MIN_X),
x_max = _MIN(MAX_PROBE_X, MESH_MAX_X),
y_min = _MAX(MIN_PROBE_Y, MESH_MIN_Y),
y_max = _MIN(MAX_PROBE_Y, MESH_MAX_Y);
bool abort_flag = false;
const float x_min = probe_min_x(), x_max = probe_max_x(),
y_min = probe_min_y(), y_max = probe_max_y(),
dx = (x_max - x_min) / (g29_grid_size - 1),
dy = (y_max - y_min) / (g29_grid_size - 1);
float measured_z;
bool abort_flag = false;
const float dx = float(x_max - x_min) / (g29_grid_size - 1),
dy = float(y_max - y_min) / (g29_grid_size - 1);
//float z1, z2, z3; // Needed for algorithm validation below
struct linear_fit_data lsf_results;
//float z1, z2, z3; // Needed for algorithm validation down below.
incremental_LSF_reset(&lsf_results);
if (do_3_pt_leveling) {
@ -1478,9 +1473,9 @@
uint16_t total_points = g29_grid_size * g29_grid_size, point_num = 1;
for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
const float rx = float(x_min) + ix * dx;
const float rx = x_min + ix * dx;
for (int8_t iy = 0; iy < g29_grid_size; iy++) {
const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
const float ry = y_min + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
if (!abort_flag) {
SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
@ -1505,7 +1500,7 @@
DEBUG_ECHOPAIR_F(" correction: ", get_z_correction(rx, ry), 7);
}
measured_z -= get_z_correction(rx, ry) /* + zprobe_zoffset */ ;
measured_z -= get_z_correction(rx, ry) /* + zprobe_offset[Z_AXIS] */ ;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F(" final >>>---> ", measured_z, 7);
@ -1711,13 +1706,13 @@
serial_delay(50);
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
SERIAL_ECHOLNPAIR_F("planner.z_fade_height : ", planner.z_fade_height, 4);
SERIAL_ECHOLNPAIR_F("Fade Height M420 Z", planner.z_fade_height, 4);
#endif
adjust_mesh_to_mean(g29_c_flag, g29_constant);
#if HAS_BED_PROBE
SERIAL_ECHOLNPAIR_F("zprobe_zoffset: ", zprobe_zoffset, 7);
SERIAL_ECHOLNPAIR_F("Probe Offset M851 Z", zprobe_offset[Z_AXIS], 7);
#endif
SERIAL_ECHOLNPAIR("MESH_MIN_X " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); serial_delay(50);