forked from Mirrors/Marlin
🎨 Misc. endstop-related tweaks
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
#include "../module/motion.h"
|
#include "../module/motion.h"
|
||||||
#include "../module/planner.h"
|
#include "../module/planner.h"
|
||||||
|
|
||||||
AxisBits Backlash::last_direction_bits;
|
AxisBits Backlash::last_direction;
|
||||||
xyz_long_t Backlash::residual_error{0};
|
xyz_long_t Backlash::residual_error{0};
|
||||||
|
|
||||||
#ifdef BACKLASH_DISTANCE_MM
|
#ifdef BACKLASH_DISTANCE_MM
|
||||||
@@ -64,7 +64,7 @@ Backlash backlash;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void Backlash::add_correction_steps(const xyze_long_t &dist, const AxisBits dm, block_t * const block) {
|
void Backlash::add_correction_steps(const xyze_long_t &dist, const AxisBits dm, block_t * const block) {
|
||||||
AxisBits changed_dir = last_direction_bits ^ dm;
|
AxisBits changed_dir = last_direction ^ dm;
|
||||||
// Ignore direction change unless steps are taken in that direction
|
// Ignore direction change unless steps are taken in that direction
|
||||||
#if DISABLED(CORE_BACKLASH) || ANY(MARKFORGED_XY, MARKFORGED_YX)
|
#if DISABLED(CORE_BACKLASH) || ANY(MARKFORGED_XY, MARKFORGED_YX)
|
||||||
if (!dist.a) changed_dir.x = false;
|
if (!dist.a) changed_dir.x = false;
|
||||||
@@ -83,7 +83,7 @@ void Backlash::add_correction_steps(const xyze_long_t &dist, const AxisBits dm,
|
|||||||
if (!(dist.b - dist.c)) changed_dir.z = false;
|
if (!(dist.b - dist.c)) changed_dir.z = false;
|
||||||
if (!dist.a) changed_dir.x = false;
|
if (!dist.a) changed_dir.x = false;
|
||||||
#endif
|
#endif
|
||||||
last_direction_bits ^= changed_dir;
|
last_direction ^= changed_dir;
|
||||||
|
|
||||||
if (!correction && !residual_error) return;
|
if (!correction && !residual_error) return;
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ void Backlash::add_correction_steps(const xyze_long_t &dist, const AxisBits dm,
|
|||||||
int32_t Backlash::get_applied_steps(const AxisEnum axis) {
|
int32_t Backlash::get_applied_steps(const AxisEnum axis) {
|
||||||
if (axis >= NUM_AXES) return 0;
|
if (axis >= NUM_AXES) return 0;
|
||||||
|
|
||||||
const bool forward = last_direction_bits[axis];
|
const bool forward = last_direction[axis];
|
||||||
|
|
||||||
const int32_t residual_error_axis = residual_error[axis];
|
const int32_t residual_error_axis = residual_error[axis];
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
static constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
static constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static AxisBits last_direction_bits;
|
static AxisBits last_direction;
|
||||||
static xyz_long_t residual_error;
|
static xyz_long_t residual_error;
|
||||||
|
|
||||||
#if ENABLED(BACKLASH_GCODE)
|
#if ENABLED(BACKLASH_GCODE)
|
||||||
|
|||||||
@@ -32,14 +32,14 @@
|
|||||||
/**
|
/**
|
||||||
* M425: Enable and tune backlash correction.
|
* M425: Enable and tune backlash correction.
|
||||||
*
|
*
|
||||||
* F<fraction> Enable/disable/fade-out backlash correction (0.0 to 1.0)
|
* F<fraction> Enable/disable/fade-out backlash correction (0.0 to 1.0)
|
||||||
* S<smoothing_mm> Distance over which backlash correction is spread
|
* S<length> Distance over which backlash correction is spread
|
||||||
* X<distance_mm> Set the backlash distance on X (0 to disable)
|
* X<length> Set the backlash distance on X (0 to disable)
|
||||||
* Y<distance_mm> ... on Y
|
* Y<length> ... on Y
|
||||||
* Z<distance_mm> ... on Z
|
* Z<length> ... on Z
|
||||||
* X If a backlash measurement was done on X, copy that value
|
* X If a backlash measurement was done on X, copy that value
|
||||||
* Y ... on Y
|
* Y ... on Y
|
||||||
* Z ... on Z
|
* Z ... on Z
|
||||||
*
|
*
|
||||||
* Type M425 without any arguments to show active values.
|
* Type M425 without any arguments to show active values.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -77,17 +77,6 @@ bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.l
|
|||||||
volatile Endstops::endstop_mask_t Endstops::hit_state;
|
volatile Endstops::endstop_mask_t Endstops::hit_state;
|
||||||
Endstops::endstop_mask_t Endstops::live_state = 0;
|
Endstops::endstop_mask_t Endstops::live_state = 0;
|
||||||
|
|
||||||
#if ENABLED(BD_SENSOR)
|
|
||||||
bool Endstops::bdp_state; // = false
|
|
||||||
#if HOMING_Z_WITH_PROBE
|
|
||||||
#define READ_ENDSTOP(P) ((P == TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN_PIN, Z_MIN_PROBE_PIN)) ? bdp_state : READ(P))
|
|
||||||
#else
|
|
||||||
#define READ_ENDSTOP(P) READ(P)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define READ_ENDSTOP(P) READ(P)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENDSTOP_NOISE_THRESHOLD
|
#if ENDSTOP_NOISE_THRESHOLD
|
||||||
Endstops::endstop_mask_t Endstops::validated_live_state;
|
Endstops::endstop_mask_t Endstops::validated_live_state;
|
||||||
uint8_t Endstops::endstop_poll_count;
|
uint8_t Endstops::endstop_poll_count;
|
||||||
@@ -97,11 +86,34 @@ Endstops::endstop_mask_t Endstops::live_state = 0;
|
|||||||
volatile bool Endstops::z_probe_enabled = false;
|
volatile bool Endstops::z_probe_enabled = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Standard Endstop READ
|
||||||
|
//
|
||||||
|
#define READ_ENDSTOP(P) READ(P)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bed Distance Sensor
|
||||||
|
//
|
||||||
|
#if ENABLED(BD_SENSOR)
|
||||||
|
bool Endstops::bdp_state; // = false
|
||||||
|
#if HOMING_Z_WITH_PROBE
|
||||||
|
#undef READ_ENDSTOP
|
||||||
|
#define READ_ENDSTOP(P) ((P == TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN_PIN, Z_MIN_PROBE_PIN)) ? bdp_state : READ(P))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calibration Probe
|
||||||
|
//
|
||||||
#if ENABLED(CALIBRATION_GCODE)
|
#if ENABLED(CALIBRATION_GCODE)
|
||||||
volatile bool Endstops::calibration_probe_enabled = false;
|
volatile bool Endstops::calibration_probe_enabled = false;
|
||||||
volatile bool Endstops::calibration_stop_state;
|
volatile bool Endstops::calibration_stop_state;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Multi-Endstop Alignment
|
||||||
|
//
|
||||||
|
|
||||||
// Initialized by settings.load
|
// Initialized by settings.load
|
||||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||||
float Endstops::x2_endstop_adj;
|
float Endstops::x2_endstop_adj;
|
||||||
@@ -119,9 +131,16 @@ Endstops::endstop_mask_t Endstops::live_state = 0;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// SPI Endstops
|
||||||
|
//
|
||||||
#if ENABLED(SPI_ENDSTOPS)
|
#if ENABLED(SPI_ENDSTOPS)
|
||||||
Endstops::tmc_spi_homing_t Endstops::tmc_spi_homing; // = 0
|
Endstops::tmc_spi_homing_t Endstops::tmc_spi_homing; // = 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// StallGuard Debounce
|
||||||
|
//
|
||||||
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
|
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
|
||||||
millis_t sg_guard_period; // = 0
|
millis_t sg_guard_period; // = 0
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -409,7 +409,7 @@ bool FTMotion::plan_next_block() {
|
|||||||
const float totalLength = current_block->millimeters;
|
const float totalLength = current_block->millimeters;
|
||||||
|
|
||||||
startPos = endPos_prevBlock;
|
startPos = endPos_prevBlock;
|
||||||
const xyze_pos_t& moveDist = current_block->dist_mm;
|
const xyze_pos_t &moveDist = current_block->distance_mm;
|
||||||
ratio = moveDist / totalLength;
|
ratio = moveDist / totalLength;
|
||||||
|
|
||||||
// Plan the trajectory using the trajectory generator
|
// Plan the trajectory using the trajectory generator
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ typedef struct Stepping {
|
|||||||
// ISR part
|
// ISR part
|
||||||
//
|
//
|
||||||
|
|
||||||
AxisBits dir_bits;
|
AxisBits dir_bits, step_bits;
|
||||||
AxisBits step_bits;
|
|
||||||
|
|
||||||
xyze_ulong_t axis_interval_fp{ LOGICAL_AXIS_LIST_1(FTM_NEVER) };
|
xyze_ulong_t axis_interval_fp{ LOGICAL_AXIS_LIST_1(FTM_NEVER) };
|
||||||
xyze_ulong_t ticks_left_per_axis_fp{ LOGICAL_AXIS_LIST_1(FTM_NEVER) };
|
xyze_ulong_t ticks_left_per_axis_fp{ LOGICAL_AXIS_LIST_1(FTM_NEVER) };
|
||||||
@@ -78,7 +77,7 @@ typedef struct Stepping {
|
|||||||
// generating the next step pulse. The call is inexpensive:
|
// generating the next step pulse. The call is inexpensive:
|
||||||
// - no heap, no locks – pure arithmetic on pre-computed data
|
// - no heap, no locks – pure arithmetic on pre-computed data
|
||||||
FORCE_INLINE uint32_t advance_until_step() {
|
FORCE_INLINE uint32_t advance_until_step() {
|
||||||
step_bits = 0;
|
step_bits.reset();
|
||||||
uint32_t ticks_to_wait_fp = 0;
|
uint32_t ticks_to_wait_fp = 0;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -140,7 +139,7 @@ typedef struct Stepping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE void reset() {
|
FORCE_INLINE void reset() {
|
||||||
step_bits = 0;
|
step_bits.reset();
|
||||||
axis_interval_fp = FTM_NEVER;
|
axis_interval_fp = FTM_NEVER;
|
||||||
ticks_left_per_axis_fp = FTM_NEVER;
|
ticks_left_per_axis_fp = FTM_NEVER;
|
||||||
ticks_left_in_frame_fp = 0;
|
ticks_left_in_frame_fp = 0;
|
||||||
|
|||||||
@@ -2060,7 +2060,7 @@ bool Planner::_populate_block(
|
|||||||
TERN_(BACKLASH_COMPENSATION, backlash.add_correction_steps(dist, dm, block));
|
TERN_(BACKLASH_COMPENSATION, backlash.add_correction_steps(dist, dm, block));
|
||||||
}
|
}
|
||||||
|
|
||||||
TERN_(FT_MOTION, block->dist_mm = dist_mm); // Store the distance for all axes in mm for this block
|
TERN_(FT_MOTION, block->distance_mm = dist_mm); // Store the distance for all axes in mm for this block
|
||||||
|
|
||||||
TERN_(HAS_EXTRUDERS, block->steps.e = esteps);
|
TERN_(HAS_EXTRUDERS, block->steps.e = esteps);
|
||||||
|
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ typedef struct PlannerBlock {
|
|||||||
AxisBits direction_bits; // Direction bits set for this block, where 1 is negative motion
|
AxisBits direction_bits; // Direction bits set for this block, where 1 is negative motion
|
||||||
|
|
||||||
#if ENABLED(FT_MOTION)
|
#if ENABLED(FT_MOTION)
|
||||||
xyze_pos_t dist_mm; // The distance traveled in mm along each axis
|
xyze_pos_t distance_mm; // The distance traveled in mm along each axis
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ANY(SMOOTH_LIN_ADVANCE, FTM_HAS_LIN_ADVANCE)
|
#if ANY(SMOOTH_LIN_ADVANCE, FTM_HAS_LIN_ADVANCE)
|
||||||
|
|||||||
Reference in New Issue
Block a user