|
@ -74,17 +74,6 @@ |
|
|
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
#include "../core/debug_out.h" |
|
|
#include "../core/debug_out.h" |
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* axis_homed |
|
|
|
|
|
* Flags that each linear axis was homed. |
|
|
|
|
|
* XYZ on cartesian, ABC on delta, ABZ on SCARA. |
|
|
|
|
|
* |
|
|
|
|
|
* axis_trusted |
|
|
|
|
|
* Flags that the position is trusted in each linear axis. Set when homed. |
|
|
|
|
|
* Cleared whenever a stepper powers off, potentially losing its position. |
|
|
|
|
|
*/ |
|
|
|
|
|
uint8_t axis_homed, axis_trusted; // = 0
|
|
|
|
|
|
|
|
|
|
|
|
// Relative Mode. Enable with G91, disable with G90.
|
|
|
// Relative Mode. Enable with G91, disable with G90.
|
|
|
bool relative_mode; // = false;
|
|
|
bool relative_mode; // = false;
|
|
|
|
|
|
|
|
@ -1122,6 +1111,10 @@ void prepare_line_to_destination() { |
|
|
current_position = destination; |
|
|
current_position = destination; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if HAS_ENDSTOPS |
|
|
|
|
|
|
|
|
|
|
|
uint8_t axis_homed, axis_trusted; // = 0
|
|
|
|
|
|
|
|
|
uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) { |
|
|
uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) { |
|
|
#define SHOULD_HOME(A) TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(A) |
|
|
#define SHOULD_HOME(A) TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(A) |
|
|
// Clear test bits that are trusted
|
|
|
// Clear test bits that are trusted
|
|
@ -1380,83 +1373,9 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Set an axis' current position to its home position (after homing). |
|
|
* Set an axis to be unhomed. (Unless we are on a machine - e.g. a cheap Chinese CNC machine - |
|
|
* |
|
|
* that has no endstops. Such machines should always be considered to be in a "known" and |
|
|
* For Core and Cartesian robots this applies one-to-one when an |
|
|
* "trusted" position). |
|
|
* individual axis has been homed. |
|
|
|
|
|
* |
|
|
|
|
|
* DELTA should wait until all homing is done before setting the XYZ |
|
|
|
|
|
* current_position to home, because homing is a single operation. |
|
|
|
|
|
* In the case where the axis positions are trusted and previously |
|
|
|
|
|
* homed, DELTA could home to X or Y individually by moving either one |
|
|
|
|
|
* to the center. However, homing Z always homes XY and Z. |
|
|
|
|
|
* |
|
|
|
|
|
* SCARA should wait until all XY homing is done before setting the XY |
|
|
|
|
|
* current_position to home, because neither X nor Y is at home until |
|
|
|
|
|
* both are at home. Z can however be homed individually. |
|
|
|
|
|
* |
|
|
|
|
|
* Callers must sync the planner position after calling this! |
|
|
|
|
|
*/ |
|
|
|
|
|
void set_axis_is_at_home(const AxisEnum axis) { |
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")"); |
|
|
|
|
|
|
|
|
|
|
|
set_axis_trusted(axis); |
|
|
|
|
|
set_axis_homed(axis); |
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) |
|
|
|
|
|
if (axis == X_AXIS && (active_extruder == 1 || dual_x_carriage_mode == DXC_DUPLICATION_MODE)) { |
|
|
|
|
|
current_position.x = x_home_pos(active_extruder); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(MORGAN_SCARA) |
|
|
|
|
|
scara_set_axis_is_at_home(axis); |
|
|
|
|
|
#elif ENABLED(DELTA) |
|
|
|
|
|
current_position[axis] = (axis == Z_AXIS) ? delta_height - TERN0(HAS_BED_PROBE, probe.offset.z) : base_home_pos(axis); |
|
|
|
|
|
#else |
|
|
|
|
|
current_position[axis] = base_home_pos(axis); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Z Probe Z Homing? Account for the probe's Z offset. |
|
|
|
|
|
*/ |
|
|
|
|
|
#if HAS_BED_PROBE && Z_HOME_DIR < 0 |
|
|
|
|
|
if (axis == Z_AXIS) { |
|
|
|
|
|
#if HOMING_Z_WITH_PROBE |
|
|
|
|
|
|
|
|
|
|
|
current_position.z -= probe.offset.z; |
|
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe.offset.z = ", probe.offset.z); |
|
|
|
|
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***"); |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
TERN_(I2C_POSITION_ENCODERS, I2CPEM.homed(axis)); |
|
|
|
|
|
|
|
|
|
|
|
TERN_(BABYSTEP_DISPLAY_TOTAL, babystep.reset_total(axis)); |
|
|
|
|
|
|
|
|
|
|
|
#if HAS_POSITION_SHIFT |
|
|
|
|
|
position_shift[axis] = 0; |
|
|
|
|
|
update_workspace_offset(axis); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
|
|
#if HAS_HOME_OFFSET |
|
|
|
|
|
DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(axis_codes[axis]), "] = ", home_offset[axis]); |
|
|
|
|
|
#endif |
|
|
|
|
|
DEBUG_POS("", current_position); |
|
|
|
|
|
DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", axis_codes[axis], ")"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Set an axis to be unhomed. |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
void set_axis_never_homed(const AxisEnum axis) { |
|
|
void set_axis_never_homed(const AxisEnum axis) { |
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", axis_codes[axis], ")"); |
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", axis_codes[axis], ")"); |
|
@ -1469,7 +1388,7 @@ void set_axis_never_homed(const AxisEnum axis) { |
|
|
TERN_(I2C_POSITION_ENCODERS, I2CPEM.unhomed(axis)); |
|
|
TERN_(I2C_POSITION_ENCODERS, I2CPEM.unhomed(axis)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifdef TMC_HOME_PHASE |
|
|
#if ENABLED(TMC_HOME_PHASE) |
|
|
/**
|
|
|
/**
|
|
|
* Move the axis back to its home_phase if set and driver is capable (TMC) |
|
|
* Move the axis back to its home_phase if set and driver is capable (TMC) |
|
|
* |
|
|
* |
|
@ -1877,6 +1796,84 @@ void homeaxis(const AxisEnum axis) { |
|
|
|
|
|
|
|
|
} // homeaxis()
|
|
|
} // homeaxis()
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HAS_ENDSTOPS
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Set an axis' current position to its home position (after homing). |
|
|
|
|
|
* |
|
|
|
|
|
* For Core and Cartesian robots this applies one-to-one when an |
|
|
|
|
|
* individual axis has been homed. |
|
|
|
|
|
* |
|
|
|
|
|
* DELTA should wait until all homing is done before setting the XYZ |
|
|
|
|
|
* current_position to home, because homing is a single operation. |
|
|
|
|
|
* In the case where the axis positions are trusted and previously |
|
|
|
|
|
* homed, DELTA could home to X or Y individually by moving either one |
|
|
|
|
|
* to the center. However, homing Z always homes XY and Z. |
|
|
|
|
|
* |
|
|
|
|
|
* SCARA should wait until all XY homing is done before setting the XY |
|
|
|
|
|
* current_position to home, because neither X nor Y is at home until |
|
|
|
|
|
* both are at home. Z can however be homed individually. |
|
|
|
|
|
* |
|
|
|
|
|
* Callers must sync the planner position after calling this! |
|
|
|
|
|
*/ |
|
|
|
|
|
void set_axis_is_at_home(const AxisEnum axis) { |
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")"); |
|
|
|
|
|
|
|
|
|
|
|
set_axis_trusted(axis); |
|
|
|
|
|
set_axis_homed(axis); |
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) |
|
|
|
|
|
if (axis == X_AXIS && (active_extruder == 1 || dual_x_carriage_mode == DXC_DUPLICATION_MODE)) { |
|
|
|
|
|
current_position.x = x_home_pos(active_extruder); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(MORGAN_SCARA) |
|
|
|
|
|
scara_set_axis_is_at_home(axis); |
|
|
|
|
|
#elif ENABLED(DELTA) |
|
|
|
|
|
current_position[axis] = (axis == Z_AXIS) ? delta_height - TERN0(HAS_BED_PROBE, probe.offset.z) : base_home_pos(axis); |
|
|
|
|
|
#else |
|
|
|
|
|
current_position[axis] = base_home_pos(axis); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Z Probe Z Homing? Account for the probe's Z offset. |
|
|
|
|
|
*/ |
|
|
|
|
|
#if HAS_BED_PROBE && Z_HOME_DIR < 0 |
|
|
|
|
|
if (axis == Z_AXIS) { |
|
|
|
|
|
#if HOMING_Z_WITH_PROBE |
|
|
|
|
|
|
|
|
|
|
|
current_position.z -= probe.offset.z; |
|
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe.offset.z = ", probe.offset.z); |
|
|
|
|
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***"); |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
TERN_(I2C_POSITION_ENCODERS, I2CPEM.homed(axis)); |
|
|
|
|
|
|
|
|
|
|
|
TERN_(BABYSTEP_DISPLAY_TOTAL, babystep.reset_total(axis)); |
|
|
|
|
|
|
|
|
|
|
|
#if HAS_POSITION_SHIFT |
|
|
|
|
|
position_shift[axis] = 0; |
|
|
|
|
|
update_workspace_offset(axis); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) { |
|
|
|
|
|
#if HAS_HOME_OFFSET |
|
|
|
|
|
DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(axis_codes[axis]), "] = ", home_offset[axis]); |
|
|
|
|
|
#endif |
|
|
|
|
|
DEBUG_POS("", current_position); |
|
|
|
|
|
DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", axis_codes[axis], ")"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#if HAS_WORKSPACE_OFFSET |
|
|
#if HAS_WORKSPACE_OFFSET |
|
|
void update_workspace_offset(const AxisEnum axis) { |
|
|
void update_workspace_offset(const AxisEnum axis) { |
|
|
workspace_offset[axis] = home_offset[axis] + position_shift[axis]; |
|
|
workspace_offset[axis] = home_offset[axis] + position_shift[axis]; |
|
@ -1893,4 +1890,4 @@ void homeaxis(const AxisEnum axis) { |
|
|
home_offset[axis] = v; |
|
|
home_offset[axis] = v; |
|
|
update_workspace_offset(axis); |
|
|
update_workspace_offset(axis); |
|
|
} |
|
|
} |
|
|
#endif // HAS_M206_COMMAND
|
|
|
#endif |
|
|