@@ -1706,7 +1706,8 @@ void Planner::endstop_triggered(const AxisEnum axis) {
1706
1706
}
1707
1707
1708
1708
float Planner::triggered_position_mm (const AxisEnum axis) {
1709
- return stepper.triggered_position (axis) * mm_per_step[axis];
1709
+ const float result = DIFF_TERN (BACKLASH_COMPENSATION, stepper.triggered_position (axis), backlash.applied_steps (axis));
1710
+ return result * mm_per_step[axis];
1710
1711
}
1711
1712
1712
1713
void Planner::finish_and_disable () {
@@ -1728,8 +1729,8 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
1728
1729
// Protect the access to the position.
1729
1730
const bool was_enabled = stepper.suspend ();
1730
1731
1731
- const int32_t p1 = stepper.position (CORE_AXIS_1),
1732
- p2 = stepper.position (CORE_AXIS_2);
1732
+ const int32_t p1 = DIFF_TERN (BACKLASH_COMPENSATION, stepper.position (CORE_AXIS_1), backlash. applied_steps (CORE_AXIS_1) ),
1733
+ p2 = DIFF_TERN (BACKLASH_COMPENSATION, stepper.position (CORE_AXIS_2), backlash. applied_steps (CORE_AXIS_2) );
1733
1734
1734
1735
if (was_enabled) stepper.wake_up ();
1735
1736
@@ -1738,7 +1739,7 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
1738
1739
axis_steps = (axis == CORE_AXIS_2 ? CORESIGN (p1 - p2) : p1 + p2) * 0 .5f ;
1739
1740
}
1740
1741
else
1741
- axis_steps = stepper.position (axis);
1742
+ axis_steps = DIFF_TERN (BACKLASH_COMPENSATION, stepper.position (axis), backlash. applied_steps (axis) );
1742
1743
1743
1744
#elif EITHER(MARKFORGED_XY, MARKFORGED_YX)
1744
1745
@@ -1755,11 +1756,12 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
1755
1756
axis_steps = ((axis == CORE_AXIS_1) ? p1 - p2 : p2);
1756
1757
}
1757
1758
else
1758
- axis_steps = stepper.position (axis);
1759
+ axis_steps = DIFF_TERN (BACKLASH_COMPENSATION, stepper.position (axis), backlash. applied_steps (axis) );
1759
1760
1760
1761
#else
1761
1762
1762
1763
axis_steps = stepper.position (axis);
1764
+ TERN_ (BACKLASH_COMPENSATION, axis_steps -= backlash.applied_steps (axis));
1763
1765
1764
1766
#endif
1765
1767
@@ -2841,6 +2843,9 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_
2841
2843
block->flag = sync_flag;
2842
2844
2843
2845
block->position = position;
2846
+ #if ENABLED(BACKLASH_COMPENSATION)
2847
+ LOOP_LINEAR_AXES (axis) block->position [axis] += backlash.applied_steps ((AxisEnum)axis);
2848
+ #endif
2844
2849
2845
2850
#if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107)
2846
2851
FANS_LOOP (i) block->fan_speed [i] = thermalManager.fan_speed [i];
@@ -3108,13 +3113,21 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) {
3108
3113
LROUND (abce.k * settings.axis_steps_per_mm [K_AXIS])
3109
3114
)
3110
3115
);
3116
+
3111
3117
if (has_blocks_queued ()) {
3112
3118
// previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest.
3113
3119
// previous_speed.reset();
3114
3120
buffer_sync_block ();
3115
3121
}
3116
- else
3117
- stepper.set_position (position);
3122
+ else {
3123
+ #if ENABLED(BACKLASH_COMPENSATION)
3124
+ abce_long_t stepper_pos = position;
3125
+ LOOP_LINEAR_AXES (axis) stepper_pos[axis] += backlash.applied_steps ((AxisEnum)axis);
3126
+ stepper.set_position (stepper_pos);
3127
+ #else
3128
+ stepper.set_position (position);
3129
+ #endif
3130
+ }
3118
3131
}
3119
3132
3120
3133
void Planner::set_position_mm (const xyze_pos_t &xyze) {
0 commit comments