|
@@ -63,10 +63,24 @@ Backlash backlash;
|
63
|
63
|
void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const uint8_t dm, block_t * const block) {
|
64
|
64
|
static uint8_t last_direction_bits;
|
65
|
65
|
uint8_t changed_dir = last_direction_bits ^ dm;
|
66
|
|
- // Ignore direction change if no steps are taken in that direction
|
67
|
|
- if (da == 0) CBI(changed_dir, X_AXIS);
|
68
|
|
- if (db == 0) CBI(changed_dir, Y_AXIS);
|
69
|
|
- if (dc == 0) CBI(changed_dir, Z_AXIS);
|
|
66
|
+ // Ignore direction change unless steps are taken in that direction
|
|
67
|
+ #if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
|
|
68
|
+ if (!da) CBI(changed_dir, X_AXIS);
|
|
69
|
+ if (!db) CBI(changed_dir, Y_AXIS);
|
|
70
|
+ if (!dc) CBI(changed_dir, Z_AXIS);
|
|
71
|
+ #elif CORE_IS_XY
|
|
72
|
+ if (!(da + db)) CBI(changed_dir, X_AXIS);
|
|
73
|
+ if (!(da - db)) CBI(changed_dir, Y_AXIS);
|
|
74
|
+ if (!dc) CBI(changed_dir, Z_AXIS);
|
|
75
|
+ #elif CORE_IS_XZ
|
|
76
|
+ if (!(da + dc)) CBI(changed_dir, X_AXIS);
|
|
77
|
+ if (!(da - dc)) CBI(changed_dir, Z_AXIS);
|
|
78
|
+ if (!db) CBI(changed_dir, Y_AXIS);
|
|
79
|
+ #elif CORE_IS_YZ
|
|
80
|
+ if (!(db + dc)) CBI(changed_dir, Y_AXIS);
|
|
81
|
+ if (!(db - dc)) CBI(changed_dir, Z_AXIS);
|
|
82
|
+ if (!da) CBI(changed_dir, X_AXIS);
|
|
83
|
+ #endif
|
70
|
84
|
last_direction_bits ^= changed_dir;
|
71
|
85
|
|
72
|
86
|
if (correction == 0) return;
|
|
@@ -105,18 +119,35 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
105
|
119
|
// Take up a portion of the residual_error in this segment, but only when
|
106
|
120
|
// the current segment travels in the same direction as the correction
|
107
|
121
|
if (reversing == (error_correction < 0)) {
|
108
|
|
- if (segment_proportion == 0)
|
109
|
|
- segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm);
|
|
122
|
+ if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm);
|
110
|
123
|
error_correction = CEIL(segment_proportion * error_correction);
|
111
|
124
|
}
|
112
|
125
|
else
|
113
|
126
|
error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps
|
114
|
127
|
}
|
115
|
128
|
#endif
|
116
|
|
- // Making a correction reduces the residual error and adds block steps
|
|
129
|
+
|
|
130
|
+ // This correction reduces the residual error and adds block steps
|
117
|
131
|
if (error_correction) {
|
118
|
132
|
block->steps[axis] += ABS(error_correction);
|
119
|
|
- residual_error[axis] -= error_correction;
|
|
133
|
+ #if ENABLED(CORE_BACKLASH)
|
|
134
|
+ switch (axis) {
|
|
135
|
+ case CORE_AXIS_1:
|
|
136
|
+ //block->steps[CORE_AXIS_2] += influence_distance_mm[axis] * planner.settings.axis_steps_per_mm[CORE_AXIS_2];
|
|
137
|
+ //SERIAL_ECHOLNPAIR("CORE_AXIS_1 dir change. distance=", distance_mm[axis], " r.err=", residual_error[axis],
|
|
138
|
+ // " da=", da, " db=", db, " block->steps[axis]=", block->steps[axis], " err_corr=", error_correction);
|
|
139
|
+ break;
|
|
140
|
+ case CORE_AXIS_2:
|
|
141
|
+ //block->steps[CORE_AXIS_1] += influence_distance_mm[axis] * planner.settings.axis_steps_per_mm[CORE_AXIS_1];;
|
|
142
|
+ //SERIAL_ECHOLNPAIR("CORE_AXIS_2 dir change. distance=", distance_mm[axis], " r.err=", residual_error[axis],
|
|
143
|
+ // " da=", da, " db=", db, " block->steps[axis]=", block->steps[axis], " err_corr=", error_correction);
|
|
144
|
+ break;
|
|
145
|
+ case NORMAL_AXIS: break;
|
|
146
|
+ }
|
|
147
|
+ residual_error[axis] = 0; // No residual_error needed for next CORE block, I think...
|
|
148
|
+ #else
|
|
149
|
+ residual_error[axis] -= error_correction;
|
|
150
|
+ #endif
|
120
|
151
|
}
|
121
|
152
|
}
|
122
|
153
|
}
|