extruder: Don't assume start_v matches last end_v in pressure advance
Due to minor differences in the extrude ratio, the last end velocity of the filament may not exactly match the next move's start velocity of the filament. Implement more precise calculations for pressure advance to take this into account. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
a201385008
commit
93dd310add
|
@ -44,38 +44,45 @@ class PrinterExtruder:
|
||||||
decel_v = cruise_v
|
decel_v = cruise_v
|
||||||
|
|
||||||
# Update for pressure advance
|
# Update for pressure advance
|
||||||
|
start_pos = self.extrude_pos
|
||||||
if (axis_d >= 0. and (move.axes_d[0] or move.axes_d[1])
|
if (axis_d >= 0. and (move.axes_d[0] or move.axes_d[1])
|
||||||
and self.pressure_advance):
|
and self.pressure_advance):
|
||||||
# Increase accel_d and start_v when accelerating
|
# Increase accel_d and start_v when accelerating
|
||||||
extra_accel_d = (cruise_v - start_v) * self.pressure_advance
|
move_extrude_r = move.extrude_r
|
||||||
accel_d += extra_accel_d
|
prev_pressure_d = start_pos - move.start_pos[3]
|
||||||
if accel_t:
|
if accel_t:
|
||||||
start_v += extra_accel_d / accel_t
|
npd = move.cruise_v * move_extrude_r * self.pressure_advance
|
||||||
|
extra_accel_d = npd - prev_pressure_d
|
||||||
|
if extra_accel_d > 0.:
|
||||||
|
accel_d += extra_accel_d
|
||||||
|
start_v += extra_accel_d / accel_t
|
||||||
|
prev_pressure_d += extra_accel_d
|
||||||
# Update decel and retract parameters when decelerating
|
# Update decel and retract parameters when decelerating
|
||||||
if decel_t:
|
if decel_t:
|
||||||
extra_decel_d = (cruise_v - end_v) * self.pressure_advance
|
npd = move.end_v * move_extrude_r * self.pressure_advance
|
||||||
extra_decel_v = extra_decel_d / decel_t
|
extra_decel_d = prev_pressure_d - npd
|
||||||
decel_v -= extra_decel_v
|
if extra_decel_d > 0.:
|
||||||
end_v -= extra_decel_v
|
extra_decel_v = extra_decel_d / decel_t
|
||||||
if decel_v <= 0.:
|
decel_v -= extra_decel_v
|
||||||
# The entire decel phase is replaced with retraction
|
end_v -= extra_decel_v
|
||||||
retract_t = decel_t
|
if decel_v <= 0.:
|
||||||
retract_d = -(end_v + decel_v) * 0.5 * decel_t
|
# The entire decel phase is replaced with retraction
|
||||||
retract_v = -decel_v
|
retract_t = decel_t
|
||||||
decel_t = decel_d = 0.
|
retract_d = -(end_v + decel_v) * 0.5 * decel_t
|
||||||
elif end_v < 0.:
|
retract_v = -decel_v
|
||||||
# Split decel phase into decel and retraction
|
decel_t = decel_d = 0.
|
||||||
retract_t = -end_v * inv_accel
|
elif end_v < 0.:
|
||||||
retract_d = -end_v * 0.5 * retract_t
|
# Split decel phase into decel and retraction
|
||||||
decel_t -= retract_t
|
retract_t = -end_v * inv_accel
|
||||||
decel_d = decel_v * 0.5 * decel_t
|
retract_d = -end_v * 0.5 * retract_t
|
||||||
else:
|
decel_t -= retract_t
|
||||||
# There is still only a decel phase (no retraction)
|
decel_d = decel_v * 0.5 * decel_t
|
||||||
decel_d -= extra_decel_d
|
else:
|
||||||
|
# There is still only a decel phase (no retraction)
|
||||||
|
decel_d -= extra_decel_d
|
||||||
|
|
||||||
# Determine regular steps
|
# Determine regular steps
|
||||||
forward_d = accel_d + cruise_d + decel_d
|
forward_d = accel_d + cruise_d + decel_d
|
||||||
start_pos = self.extrude_pos
|
|
||||||
end_pos = start_pos + forward_d
|
end_pos = start_pos + forward_d
|
||||||
inv_step_dist = self.stepper.inv_step_dist
|
inv_step_dist = self.stepper.inv_step_dist
|
||||||
new_step_pos = int(end_pos*inv_step_dist + 0.5)
|
new_step_pos = int(end_pos*inv_step_dist + 0.5)
|
||||||
|
|
Loading…
Reference in New Issue