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

@ -37,7 +37,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V69"
#define EEPROM_VERSION "V70"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@ -60,6 +60,8 @@
#include "../HAL/shared/persistent_store_api.h"
#endif
#include "probe.h"
#if HAS_LEVELING
#include "../feature/bedlevel/bedlevel.h"
#endif
@ -78,10 +80,6 @@
#define EEPROM_NUM_SERVOS NUM_SERVO_PLUGS
#endif
#if HAS_BED_PROBE
#include "probe.h"
#endif
#include "../feature/fwretract.h"
#if ENABLED(POWER_LOSS_RECOVERY)
@ -178,7 +176,7 @@ typedef struct SettingsDataStruct {
// HAS_BED_PROBE
//
float zprobe_zoffset;
float zprobe_offset[XYZ];
//
// ABL_PLANAR
@ -615,12 +613,8 @@ void MarlinSettings::postprocess() {
// Probe Z Offset
//
{
_FIELD_TEST(zprobe_zoffset);
#if !HAS_BED_PROBE
const float zprobe_zoffset = 0;
#endif
EEPROM_WRITE(zprobe_zoffset);
_FIELD_TEST(zprobe_offset[Z_AXIS]);
EEPROM_WRITE(zprobe_offset);
}
//
@ -1421,12 +1415,14 @@ void MarlinSettings::postprocess() {
// Probe Z Offset
//
{
_FIELD_TEST(zprobe_zoffset);
_FIELD_TEST(zprobe_offset[Z_AXIS]);
#if !HAS_BED_PROBE
float zprobe_zoffset;
#if HAS_BED_PROBE
float (&zpo)[XYZ] = zprobe_offset;
#else
float zpo[XYZ];
#endif
EEPROM_READ(zprobe_zoffset);
EEPROM_READ(zpo);
}
//
@ -2321,7 +2317,12 @@ void MarlinSettings::reset() {
#endif
#if HAS_BED_PROBE
zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#ifndef NOZZLE_TO_PROBE_OFFSET
#define NOZZLE_TO_PROBE_OFFSET { 0, 0, 0 }
#endif
constexpr float dpo[XYZ] = NOZZLE_TO_PROBE_OFFSET;
static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
LOOP_XYZ(a) zprobe_offset[a] = dpo[a];
#endif
//
@ -3070,7 +3071,9 @@ void MarlinSettings::reset() {
say_units(true);
}
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M851 Z", LINEAR_UNIT(zprobe_zoffset));
SERIAL_ECHOLNPAIR(" M851 X", LINEAR_UNIT(zprobe_offset[X_AXIS]),
" Y", LINEAR_UNIT(zprobe_offset[Y_AXIS]),
" Z", LINEAR_UNIT(zprobe_offset[Z_AXIS]));
#endif
/**

View File

@ -233,7 +233,7 @@ void home_delta() {
// Move all carriages together linearly until an endstop is hit.
destination[Z_AXIS] = (delta_height
#if HAS_BED_PROBE
- zprobe_zoffset
- zprobe_offset[Z_AXIS]
#endif
+ 10);
buffer_line_to_destination(homing_feedrate(X_AXIS));

View File

@ -505,7 +505,7 @@ void restore_feedrate_and_scaling() {
soft_endstop[axis].min = base_min_pos(axis);
soft_endstop[axis].max = (axis == Z_AXIS ? delta_height
#if HAS_BED_PROBE
- zprobe_zoffset
- zprobe_offset[Z_AXIS]
#endif
: base_max_pos(axis));
@ -1340,7 +1340,7 @@ void set_axis_is_at_home(const AxisEnum axis) {
#elif ENABLED(DELTA)
current_position[axis] = (axis == Z_AXIS ? delta_height
#if HAS_BED_PROBE
- zprobe_zoffset
- zprobe_offset[Z_AXIS]
#endif
: base_home_pos(axis));
#else
@ -1354,9 +1354,9 @@ void set_axis_is_at_home(const AxisEnum axis) {
if (axis == Z_AXIS) {
#if HOMING_Z_WITH_PROBE
current_position[Z_AXIS] -= zprobe_zoffset;
current_position[Z_AXIS] -= zprobe_offset[Z_AXIS];
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> zprobe_zoffset = ", zprobe_zoffset);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> zprobe_offset[Z_AXIS] = ", zprobe_offset[Z_AXIS]);
#else

View File

@ -30,14 +30,14 @@
#include "../inc/MarlinConfig.h"
#if IS_SCARA
#include "scara.h"
#endif
#if HAS_BED_PROBE
#include "probe.h"
#endif
#if IS_SCARA
#include "scara.h"
#endif
// Axis homed and known-position states
extern uint8_t axis_homed, axis_known_position;
constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
@ -284,7 +284,7 @@ void homeaxis(const AxisEnum axis);
// Return true if the both nozzle and the probe can reach the given point.
// Note: This won't work on SCARA since the probe offset rotates with the arm.
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), ry - (Y_PROBE_OFFSET_FROM_EXTRUDER))
return position_is_reachable(rx - zprobe_offset[X_AXIS], ry - zprobe_offset[Y_AXIS])
&& position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
}
#endif
@ -313,9 +313,9 @@ void homeaxis(const AxisEnum axis);
* nozzle must be be able to reach +10,-10.
*/
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), ry - (Y_PROBE_OFFSET_FROM_EXTRUDER))
&& WITHIN(rx, MIN_PROBE_X - slop, MAX_PROBE_X + slop)
&& WITHIN(ry, MIN_PROBE_Y - slop, MAX_PROBE_Y + slop);
return position_is_reachable(rx - zprobe_offset[X_AXIS], ry - zprobe_offset[Y_AXIS])
&& WITHIN(rx, probe_min_x() - slop, probe_max_x() + slop)
&& WITHIN(ry, probe_min_y() - slop, probe_max_y() + slop);
}
#endif

View File

@ -56,7 +56,7 @@
#include "../feature/backlash.h"
#endif
float zprobe_zoffset; // Initialized by settings.load()
float zprobe_offset[XYZ]; // Initialized by settings.load()
#if ENABLED(BLTOUCH)
#include "../feature/bltouch.h"
@ -86,6 +86,43 @@ float zprobe_zoffset; // Initialized by settings.load()
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
float probe_min_x() {
return _MAX(
#if ENABLED(DELTA) || IS_SCARA
PROBE_X_MIN, MESH_MIN_X
#else
(X_MIN_BED) + (MIN_PROBE_EDGE), (X_MIN_POS) + zprobe_offset[X_AXIS]
#endif
);
}
float probe_max_x() {
return _MIN(
#if ENABLED(DELTA) || IS_SCARA
PROBE_X_MAX, MESH_MAX_X
#else
(X_MAX_BED) - (MIN_PROBE_EDGE), (X_MAX_POS) + zprobe_offset[X_AXIS]
#endif
);
}
float probe_min_y() {
return _MAX(
#if ENABLED(DELTA) || IS_SCARA
PROBE_Y_MIN, MESH_MIN_Y
#else
(Y_MIN_BED) + (MIN_PROBE_EDGE), (Y_MIN_POS) + zprobe_offset[Y_AXIS]
#endif
);
}
float probe_max_y() {
return _MIN(
#if ENABLED(DELTA) || IS_SCARA
PROBE_Y_MAX, MESH_MAX_Y
#else
(Y_MAX_BED) - (MIN_PROBE_EDGE), (Y_MAX_POS) + zprobe_offset[Y_AXIS]
#endif
);
}
#if ENABLED(Z_PROBE_SLED)
#ifndef SLED_DOCKING_OFFSET
@ -263,7 +300,7 @@ inline void do_probe_raise(const float z_raise) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("do_probe_raise(", z_raise, ")");
float z_dest = z_raise;
if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
if (zprobe_offset[Z_AXIS] < 0) z_dest -= zprobe_offset[Z_AXIS];
NOMORE(z_dest, Z_MAX_POS);
@ -543,7 +580,7 @@ static float run_z_probe() {
// Stop the probe before it goes too low to prevent damage.
// If Z isn't known then probe to -10mm.
const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -zprobe_zoffset + Z_PROBE_LOW_POINT : -10.0;
const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -zprobe_offset[Z_AXIS] + Z_PROBE_LOW_POINT : -10.0;
// Double-probing does a fast probe followed by a slow probe
#if TOTAL_PROBING == 2
@ -568,7 +605,7 @@ static float run_z_probe() {
// If the nozzle is well over the travel height then
// move down quickly before doing the slow probe
const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (zprobe_zoffset < 0 ? -zprobe_zoffset : 0);
const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (zprobe_offset[Z_AXIS] < 0 ? -zprobe_offset[Z_AXIS] : 0);
if (current_position[Z_AXIS] > z) {
// Probe down fast. If the probe never triggered, raise for probe clearance
if (!do_probe_move(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST)))
@ -698,8 +735,8 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_
float nx = rx, ny = ry;
if (probe_relative) {
if (!position_is_reachable_by_probe(rx, ry)) return NAN; // The given position is in terms of the probe
nx -= (X_PROBE_OFFSET_FROM_EXTRUDER); // Get the nozzle position
ny -= (Y_PROBE_OFFSET_FROM_EXTRUDER);
nx -= zprobe_offset[X_AXIS]; // Get the nozzle position
ny -= zprobe_offset[Y_AXIS];
}
else if (!position_is_reachable(nx, ny)) return NAN; // The given position is in terms of the nozzle
@ -720,7 +757,7 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_
float measured_z = NAN;
if (!DEPLOY_PROBE()) {
measured_z = run_z_probe() + zprobe_zoffset;
measured_z = run_z_probe() + zprobe_offset[Z_AXIS];
const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
if (big_raise || raise_after == PROBE_PT_RAISE)

View File

@ -28,7 +28,8 @@
#include "../inc/MarlinConfig.h"
#if HAS_BED_PROBE
extern float zprobe_zoffset;
extern float zprobe_offset[XYZ];
bool set_probe_deployed(const bool deploy);
#ifdef Z_AFTER_PROBING
void move_z_after_probing();
@ -45,9 +46,15 @@
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
extern const char msg_wait_for_bed_heating[25];
#endif
float probe_min_x(), probe_max_x(), probe_min_y(), probe_max_y();
#else
constexpr float zprobe_offset[XYZ] = { 0 };
#define DEPLOY_PROBE()
#define STOW_PROBE()
#endif
#if HAS_Z_SERVO_PROBE