forked from Mirrors/Marlin
🎨 Misc. endstop-related tweaks
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
#include "../module/motion.h"
|
||||
#include "../module/planner.h"
|
||||
|
||||
AxisBits Backlash::last_direction_bits;
|
||||
AxisBits Backlash::last_direction;
|
||||
xyz_long_t Backlash::residual_error{0};
|
||||
|
||||
#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) {
|
||||
AxisBits changed_dir = last_direction_bits ^ dm;
|
||||
AxisBits changed_dir = last_direction ^ dm;
|
||||
// Ignore direction change unless steps are taken in that direction
|
||||
#if DISABLED(CORE_BACKLASH) || ANY(MARKFORGED_XY, MARKFORGED_YX)
|
||||
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.a) changed_dir.x = false;
|
||||
#endif
|
||||
last_direction_bits ^= changed_dir;
|
||||
last_direction ^= changed_dir;
|
||||
|
||||
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) {
|
||||
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];
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
static constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
||||
|
||||
private:
|
||||
static AxisBits last_direction_bits;
|
||||
static AxisBits last_direction;
|
||||
static xyz_long_t residual_error;
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
|
||||
@@ -32,14 +32,14 @@
|
||||
/**
|
||||
* M425: Enable and tune backlash correction.
|
||||
*
|
||||
* F<fraction> Enable/disable/fade-out backlash correction (0.0 to 1.0)
|
||||
* S<smoothing_mm> Distance over which backlash correction is spread
|
||||
* X<distance_mm> Set the backlash distance on X (0 to disable)
|
||||
* Y<distance_mm> ... on Y
|
||||
* Z<distance_mm> ... on Z
|
||||
* X If a backlash measurement was done on X, copy that value
|
||||
* Y ... on Y
|
||||
* Z ... on Z
|
||||
* F<fraction> Enable/disable/fade-out backlash correction (0.0 to 1.0)
|
||||
* S<length> Distance over which backlash correction is spread
|
||||
* X<length> Set the backlash distance on X (0 to disable)
|
||||
* Y<length> ... on Y
|
||||
* Z<length> ... on Z
|
||||
* X If a backlash measurement was done on X, copy that value
|
||||
* Y ... on Y
|
||||
* Z ... on Z
|
||||
*
|
||||
* 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;
|
||||
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
|
||||
Endstops::endstop_mask_t Endstops::validated_live_state;
|
||||
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;
|
||||
#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)
|
||||
volatile bool Endstops::calibration_probe_enabled = false;
|
||||
volatile bool Endstops::calibration_stop_state;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Multi-Endstop Alignment
|
||||
//
|
||||
|
||||
// Initialized by settings.load
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
float Endstops::x2_endstop_adj;
|
||||
@@ -119,9 +131,16 @@ Endstops::endstop_mask_t Endstops::live_state = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// SPI Endstops
|
||||
//
|
||||
#if ENABLED(SPI_ENDSTOPS)
|
||||
Endstops::tmc_spi_homing_t Endstops::tmc_spi_homing; // = 0
|
||||
#endif
|
||||
|
||||
//
|
||||
// StallGuard Debounce
|
||||
//
|
||||
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
|
||||
millis_t sg_guard_period; // = 0
|
||||
#endif
|
||||
|
||||
@@ -409,7 +409,7 @@ bool FTMotion::plan_next_block() {
|
||||
const float totalLength = current_block->millimeters;
|
||||
|
||||
startPos = endPos_prevBlock;
|
||||
const xyze_pos_t& moveDist = current_block->dist_mm;
|
||||
const xyze_pos_t &moveDist = current_block->distance_mm;
|
||||
ratio = moveDist / totalLength;
|
||||
|
||||
// Plan the trajectory using the trajectory generator
|
||||
|
||||
@@ -67,8 +67,7 @@ typedef struct Stepping {
|
||||
// ISR part
|
||||
//
|
||||
|
||||
AxisBits dir_bits;
|
||||
AxisBits step_bits;
|
||||
AxisBits dir_bits, step_bits;
|
||||
|
||||
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) };
|
||||
@@ -78,7 +77,7 @@ typedef struct Stepping {
|
||||
// generating the next step pulse. The call is inexpensive:
|
||||
// - no heap, no locks – pure arithmetic on pre-computed data
|
||||
FORCE_INLINE uint32_t advance_until_step() {
|
||||
step_bits = 0;
|
||||
step_bits.reset();
|
||||
uint32_t ticks_to_wait_fp = 0;
|
||||
|
||||
for (;;) {
|
||||
@@ -140,7 +139,7 @@ typedef struct Stepping {
|
||||
}
|
||||
|
||||
FORCE_INLINE void reset() {
|
||||
step_bits = 0;
|
||||
step_bits.reset();
|
||||
axis_interval_fp = FTM_NEVER;
|
||||
ticks_left_per_axis_fp = FTM_NEVER;
|
||||
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_(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);
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ typedef struct PlannerBlock {
|
||||
AxisBits direction_bits; // Direction bits set for this block, where 1 is negative 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
|
||||
|
||||
#if ANY(SMOOTH_LIN_ADVANCE, FTM_HAS_LIN_ADVANCE)
|
||||
|
||||
Reference in New Issue
Block a user