toolhead: Ensure full kin_flush_delay after flush_step_generation()

Commit b7b13588 made it possible that the kinematic code could be
restarted after a flush_step_generation() call without a sufficient
delay.

Rename last_sg_flush_time to min_restart_time and use that to ensure
_calc_print_time() always pauses kin_flush_delay time since the last
flush_step_generation() call.

Also, update force_move to invoke flush_step_generation() after any
movements.  This is needed to ensure there is a sufficient delay
should force_move be called on a stepper motor that is part of the
toolhead kinematics and is using a step generation "scan time".

This fixes possible "internal error in stepcompress" reports when
using FORCE_MOVE.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2024-01-16 20:40:55 -05:00
parent 447a88eb08
commit 3d3b87f97f
2 changed files with 5 additions and 4 deletions

View File

@ -90,8 +90,8 @@ class ForceMove:
print_time + 99999.9) print_time + 99999.9)
stepper.set_trapq(prev_trapq) stepper.set_trapq(prev_trapq)
stepper.set_stepper_kinematics(prev_sk) stepper.set_stepper_kinematics(prev_sk)
toolhead.note_kinematic_activity(print_time)
toolhead.dwell(accel_t + cruise_t + accel_t) toolhead.dwell(accel_t + cruise_t + accel_t)
toolhead.flush_step_generation()
def _lookup_stepper(self, gcmd): def _lookup_stepper(self, gcmd):
name = gcmd.get('STEPPER') name = gcmd.get('STEPPER')
if name not in self.steppers: if name not in self.steppers:

View File

@ -239,7 +239,7 @@ class ToolHead:
# Flush tracking # Flush tracking
self.flush_timer = self.reactor.register_timer(self._flush_handler) self.flush_timer = self.reactor.register_timer(self._flush_handler)
self.do_kick_flush_timer = True self.do_kick_flush_timer = True
self.last_flush_time = self.last_sg_flush_time = 0. self.last_flush_time = self.min_restart_time = 0.
self.need_flush_time = self.step_gen_time = self.clear_history_time = 0. self.need_flush_time = self.step_gen_time = self.clear_history_time = 0.
# Kinematic step generation scan window time tracking # Kinematic step generation scan window time tracking
self.kin_flush_delay = SDS_CHECK_TIME self.kin_flush_delay = SDS_CHECK_TIME
@ -289,7 +289,7 @@ class ToolHead:
sg_flush_time = max(sg_flush_want, flush_time) sg_flush_time = max(sg_flush_want, flush_time)
for sg in self.step_generators: for sg in self.step_generators:
sg(sg_flush_time) sg(sg_flush_time)
self.last_sg_flush_time = sg_flush_time self.min_restart_time = max(self.min_restart_time, sg_flush_time)
# Free trapq entries that are no longer needed # Free trapq entries that are no longer needed
clear_history_time = self.clear_history_time clear_history_time = self.clear_history_time
if not self.can_pause: if not self.can_pause:
@ -314,7 +314,7 @@ class ToolHead:
def _calc_print_time(self): def _calc_print_time(self):
curtime = self.reactor.monotonic() curtime = self.reactor.monotonic()
est_print_time = self.mcu.estimated_print_time(curtime) est_print_time = self.mcu.estimated_print_time(curtime)
kin_time = max(est_print_time + MIN_KIN_TIME, self.last_sg_flush_time) kin_time = max(est_print_time + MIN_KIN_TIME, self.min_restart_time)
kin_time += self.kin_flush_delay kin_time += self.kin_flush_delay
min_print_time = max(est_print_time + BUFFER_TIME_START, kin_time) min_print_time = max(est_print_time + BUFFER_TIME_START, kin_time)
if min_print_time > self.print_time: if min_print_time > self.print_time:
@ -361,6 +361,7 @@ class ToolHead:
def flush_step_generation(self): def flush_step_generation(self):
self._flush_lookahead() self._flush_lookahead()
self._advance_flush_time(self.step_gen_time) self._advance_flush_time(self.step_gen_time)
self.min_restart_time = max(self.min_restart_time, self.print_time)
def get_last_move_time(self): def get_last_move_time(self):
if self.special_queuing_state: if self.special_queuing_state:
self._flush_lookahead() self._flush_lookahead()