Skip to content

Commit 7b349ca

Browse files
committed
Jerk correction for advance.
1 parent 294d3c2 commit 7b349ca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Marlin/src/module/planner.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,13 +2805,30 @@ bool Planner::_populate_block(
28052805
speed_diff = v_entry - previous_speed;
28062806
}
28072807

2808+
#if ENABLED(LIN_ADVANCE)
2809+
// Advance affects E_AXIS speed therefore its jerk. Add a speed correction whenever we stop
2810+
// using advance. There's no correction when we start using advance because it didn't
2811+
// perform well as it takes more time/effort to push/melt filament than the reverse.
2812+
static float previous_advance_speed_mm_s = 0.0f;
2813+
float advance_correction_mm_s = 0.0f;
2814+
if (dist.e < 0 && previous_advance_speed_mm_s != 0.0f) {
2815+
// Retract move after a segment with advance, which ends with an E speed decrease.
2816+
// Correct for this to allow a faster junction speed. Since the decrease always helps to
2817+
// get E to nominal retract speed, the equation simplifies to an increase in max jerk.
2818+
advance_correction_mm_s = previous_advance_speed_mm_s;
2819+
}
2820+
// Prepare for next segment.
2821+
previous_advance_speed_mm_s = block->la_advance_rate * mm_per_step[E_AXIS_N(extruder)];
2822+
#endif
2823+
28082824
// Now limit the jerk in all axes.
28092825
float v_factor = 1.0f;
28102826
LOOP_LOGICAL_AXES(i) {
28112827
// Jerk is the per-axis velocity difference.
28122828
const float jerk = ABS(speed_diff[i]);
28132829
float maxj = max_jerk[i];
28142830
TERN_(HAS_TRAVEL_EXTRA_XYJERK, if (i == X_AXIS || i == Y_AXIS) maxj += extra_xyjerk);
2831+
TERN_(LIN_ADVANCE, if (i == E_AXIS) maxj += advance_correction_mm_s);
28152832
if (jerk * v_factor > maxj) v_factor = maxj / jerk;
28162833
}
28172834
vmax_junction_sqr = sq(vmax_junction * v_factor);

0 commit comments

Comments
 (0)