Skip to content

Commit d023f09

Browse files
tombrazierimp67
authored andcommitted
🩹 Arc/Planner optimization followup (MarlinFirmware#24509)
1 parent b3e3654 commit d023f09

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Marlin/src/gcode/motion/G2_G3.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,12 @@ void plan_arc(
294294
// An arc can always complete within limits from a speed which...
295295
// a) is <= any configured maximum speed,
296296
// b) does not require centripetal force greater than any configured maximum acceleration,
297-
// c) allows the print head to stop in the remining length of the curve within all configured maximum accelerations.
297+
// c) is <= nominal speed,
298+
// d) allows the print head to stop in the remining length of the curve within all configured maximum accelerations.
298299
// The last has to be calculated every time through the loop.
299300
const float limiting_accel = _MIN(planner.settings.max_acceleration_mm_per_s2[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]),
300301
limiting_speed = _MIN(planner.settings.max_feedrate_mm_s[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]),
301-
limiting_speed_sqr = _MIN(sq(limiting_speed), limiting_accel * radius);
302+
limiting_speed_sqr = _MIN(sq(limiting_speed), limiting_accel * radius, sq(scaled_fr_mm_s));
302303
float arc_mm_remaining = flat_mm;
303304

304305
for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times
@@ -357,12 +358,12 @@ void plan_arc(
357358

358359
// calculate safe speed for stopping by the end of the arc
359360
arc_mm_remaining -= segment_mm;
360-
361-
hints.curve_radius = i > 1 ? radius : 0;
362361
hints.safe_exit_speed_sqr = _MIN(limiting_speed_sqr, 2 * limiting_accel * arc_mm_remaining);
363362

364363
if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints))
365364
break;
365+
366+
hints.curve_radius = radius;
366367
}
367368
}
368369

@@ -383,6 +384,7 @@ void plan_arc(
383384
#endif
384385

385386
hints.curve_radius = 0;
387+
hints.safe_exit_speed_sqr = 0.0f;
386388
planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints);
387389

388390
#if ENABLED(AUTO_BED_LEVELING_UBL)

Marlin/src/module/planner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t
806806
float accelerate_steps_float = (nominal_rate_sq - sq(float(initial_rate))) * (0.5f / accel);
807807
accelerate_steps = CEIL(accelerate_steps_float);
808808
const float decelerate_steps_float = (nominal_rate_sq - sq(float(final_rate))) * (0.5f / accel);
809-
decelerate_steps = decelerate_steps_float;
809+
decelerate_steps = FLOOR(decelerate_steps_float);
810810

811811
// Steps between acceleration and deceleration, if any
812812
plateau_steps -= accelerate_steps + decelerate_steps;

0 commit comments

Comments
 (0)