@@ -82,14 +82,17 @@ void plan_arc(
82
82
rt_X = cart[axis_p] - center_P,
83
83
rt_Y = cart[axis_q] - center_Q;
84
84
85
- ARC_LIJKUVW_CODE (
86
- const float start_L = current_position[axis_l],
87
- const float start_I = current_position.i ,
88
- const float start_J = current_position.j ,
89
- const float start_K = current_position.k ,
90
- const float start_U = current_position.u ,
91
- const float start_V = current_position.v ,
92
- const float start_W = current_position.w
85
+ // Starting position of the move for all non-arc axes
86
+ // i.e., only one of X, Y, or Z, plus the rest.
87
+ ARC_LIJKUVWE_CODE (
88
+ float start_L = current_position[axis_l],
89
+ float start_I = current_position.i ,
90
+ float start_J = current_position.j ,
91
+ float start_K = current_position.k ,
92
+ float start_U = current_position.u ,
93
+ float start_V = current_position.v ,
94
+ float start_W = current_position.w ,
95
+ float start_E = current_position.e
93
96
);
94
97
95
98
// Angle of rotation between position and target from the circle center.
@@ -125,6 +128,7 @@ void plan_arc(
125
128
min_segments = CEIL ((MIN_CIRCLE_SEGMENTS) * portion_of_circle); // Minimum segments for the arc
126
129
}
127
130
131
+ // Total travel on all the non-arc axes
128
132
ARC_LIJKUVWE_CODE (
129
133
float travel_L = cart[axis_l] - start_L,
130
134
float travel_I = cart.i - start_I,
@@ -133,7 +137,7 @@ void plan_arc(
133
137
float travel_U = cart.u - start_U,
134
138
float travel_V = cart.v - start_V,
135
139
float travel_W = cart.w - start_W,
136
- float travel_E = cart.e - current_position. e
140
+ float travel_E = cart.e - start_E
137
141
);
138
142
139
143
// If "P" specified circles, call plan_arc recursively then continue with the rest of the arc
@@ -166,15 +170,29 @@ void plan_arc(
166
170
);
167
171
plan_arc (temp_position, offset, clockwise, 0 ); // Plan a single whole circle
168
172
}
173
+
174
+ // Get starting coordinates for the remainder from the current position
175
+ ARC_LIJKUVWE_CODE (
176
+ start_L = current_position[axis_l],
177
+ start_I = current_position.i ,
178
+ start_J = current_position.j ,
179
+ start_K = current_position.k ,
180
+ start_U = current_position.u ,
181
+ start_V = current_position.v ,
182
+ start_W = current_position.w ,
183
+ start_E = current_position.e
184
+ );
185
+
186
+ // Update travel distance for the remainder
169
187
ARC_LIJKUVWE_CODE (
170
- travel_L = cart[axis_l] - current_position[axis_l], // Linear X, Y, or Z
171
- travel_I = cart.i - current_position. i , // The rest are also non-arc
172
- travel_J = cart.j - current_position. j ,
173
- travel_K = cart.k - current_position. k ,
174
- travel_U = cart.u - current_position. u ,
175
- travel_V = cart.v - current_position. v ,
176
- travel_W = cart.w - current_position. w ,
177
- travel_E = cart.e - current_position. e
188
+ travel_L = cart[axis_l] - start_L, // Linear X, Y, or Z
189
+ travel_I = cart.i - start_I, // The rest are also non-arc
190
+ travel_J = cart.j - start_J ,
191
+ travel_K = cart.k - start_K ,
192
+ travel_U = cart.u - start_U ,
193
+ travel_V = cart.v - start_V ,
194
+ travel_W = cart.w - start_W ,
195
+ travel_E = cart.e - start_E
178
196
);
179
197
}
180
198
@@ -256,38 +274,35 @@ void plan_arc(
256
274
257
275
xyze_pos_t raw;
258
276
259
- // do not calculate rotation parameters for trivial single-segment arcs
277
+ // Don't calculate rotation parameters for trivial single-segment arcs
260
278
if (segments > 1 ) {
261
279
// Vector rotation matrix values
262
280
const float theta_per_segment = angular_travel / segments,
263
281
sq_theta_per_segment = sq (theta_per_segment),
264
282
sin_T = theta_per_segment - sq_theta_per_segment * theta_per_segment / 6 ,
265
283
cos_T = 1 - 0 .5f * sq_theta_per_segment; // Small angle approximation
266
284
267
- #if DISABLED(AUTO_BED_LEVELING_UBL)
268
- ARC_LIJKUVW_CODE (
269
- const float per_segment_L = travel_L / segments,
270
- const float per_segment_I = travel_I / segments,
271
- const float per_segment_J = travel_J / segments,
272
- const float per_segment_K = travel_K / segments,
273
- const float per_segment_U = travel_U / segments,
274
- const float per_segment_V = travel_V / segments,
275
- const float per_segment_W = travel_W / segments
276
- );
277
- #endif
278
-
279
- CODE_ITEM_E (const float extruder_per_segment = travel_E / segments);
285
+ ARC_LIJKUVWE_CODE (
286
+ const float per_segment_L = travel_L / segments,
287
+ const float per_segment_I = travel_I / segments,
288
+ const float per_segment_J = travel_J / segments,
289
+ const float per_segment_K = travel_K / segments,
290
+ const float per_segment_U = travel_U / segments,
291
+ const float per_segment_V = travel_V / segments,
292
+ const float per_segment_W = travel_W / segments,
293
+ const float per_segment_E = travel_E / segments
294
+ );
280
295
281
296
// Initialize all linear axes and E
282
297
ARC_LIJKUVWE_CODE (
283
- raw[axis_l] = current_position[axis_l] ,
284
- raw.i = current_position. i ,
285
- raw.j = current_position. j ,
286
- raw.k = current_position. k ,
287
- raw.u = current_position. u ,
288
- raw.v = current_position. v ,
289
- raw.w = current_position. w ,
290
- raw.e = current_position. e
298
+ raw[axis_l] = start_L ,
299
+ raw.i = start_I ,
300
+ raw.j = start_J ,
301
+ raw.k = start_K ,
302
+ raw.u = start_U ,
303
+ raw.v = start_V ,
304
+ raw.w = start_W ,
305
+ raw.e = start_E
291
306
);
292
307
293
308
millis_t next_idle_ms = millis () + 200UL ;
@@ -305,7 +320,6 @@ void plan_arc(
305
320
const float limiting_accel = _MIN (planner.settings .max_acceleration_mm_per_s2 [axis_p], planner.settings .max_acceleration_mm_per_s2 [axis_q]),
306
321
limiting_speed = _MIN (planner.settings .max_feedrate_mm_s [axis_p], planner.settings .max_feedrate_mm_s [axis_q]),
307
322
limiting_speed_sqr = _MIN (sq (limiting_speed), limiting_accel * radius, sq (scaled_fr_mm_s));
308
- float arc_mm_remaining = flat_mm;
309
323
310
324
for (uint16_t i = 1 ; i < segments; i++) { // Iterate (segments-1) times
311
325
@@ -343,16 +357,14 @@ void plan_arc(
343
357
raw[axis_p] = center_P + rvec.a ;
344
358
raw[axis_q] = center_Q + rvec.b ;
345
359
ARC_LIJKUVWE_CODE (
346
- #if ENABLED(AUTO_BED_LEVELING_UBL)
347
- raw[axis_l] = start_L,
348
- raw.i = start_I, raw.j = start_J, raw.k = start_K,
349
- raw.u = start_U, raw.v = start_V, raw.w = start_V
350
- #else
351
- raw[axis_l] += per_segment_L,
352
- raw.i += per_segment_I, raw.j += per_segment_J, raw.k += per_segment_K,
353
- raw.u += per_segment_U, raw.v += per_segment_V, raw.w += per_segment_W
354
- #endif
355
- , raw.e += extruder_per_segment
360
+ raw[axis_l] = start_L + per_segment_L * i,
361
+ raw.i = start_I + per_segment_I * i,
362
+ raw.j = start_J + per_segment_J * i,
363
+ raw.k = start_K + per_segment_K * i,
364
+ raw.u = start_U + per_segment_U * i,
365
+ raw.v = start_V + per_segment_V * i,
366
+ raw.w = start_W + per_segment_W * i,
367
+ raw.e = start_E + per_segment_E * i
356
368
);
357
369
358
370
apply_motion_limits (raw);
@@ -362,7 +374,7 @@ void plan_arc(
362
374
#endif
363
375
364
376
// calculate safe speed for stopping by the end of the arc
365
- arc_mm_remaining -= segment_mm;
377
+ const float arc_mm_remaining = flat_mm - segment_mm * i ;
366
378
hints.safe_exit_speed_sqr = _MIN (limiting_speed_sqr, 2 * limiting_accel * arc_mm_remaining);
367
379
368
380
if (!planner.buffer_line (raw, scaled_fr_mm_s, active_extruder, hints))
@@ -374,13 +386,6 @@ void plan_arc(
374
386
375
387
// Ensure last segment arrives at target location.
376
388
raw = cart;
377
- #if ENABLED(AUTO_BED_LEVELING_UBL)
378
- ARC_LIJKUVW_CODE (
379
- raw[axis_l] = start_L,
380
- raw.i = start_I, raw.j = start_J, raw.k = start_K,
381
- raw.u = start_U, raw.v = start_V, raw.w = start_W
382
- );
383
- #endif
384
389
385
390
apply_motion_limits (raw);
386
391
@@ -392,14 +397,7 @@ void plan_arc(
392
397
hints.safe_exit_speed_sqr = 0 .0f ;
393
398
planner.buffer_line (raw, scaled_fr_mm_s, active_extruder, hints);
394
399
395
- #if ENABLED(AUTO_BED_LEVELING_UBL)
396
- ARC_LIJKUVW_CODE (
397
- raw[axis_l] = start_L,
398
- raw.i = start_I, raw.j = start_J, raw.k = start_K,
399
- raw.u = start_U, raw.v = start_V, raw.w = start_W
400
- );
401
- #endif
402
- current_position = raw;
400
+ current_position = cart;
403
401
404
402
} // plan_arc
405
403
0 commit comments