mirror of
https://github.com/andreili/klipper.git
synced 2025-08-23 19:34:06 +02:00
stepper: Also ensure minimum time after dir change and next step
In practice the host will not schedule any steps immediately after a direction change (due to acceleration limits and the host "step+dir+step filter"). However, there is also no harm in enforcing a minimum duration in the mcu. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
885f63cff0
commit
fd55dd9e9d
@ -109,10 +109,18 @@ stepper_load_next(struct stepper *s)
|
||||
shutdown("Stepper too far in past");
|
||||
s->time.waketime = min_next_time;
|
||||
}
|
||||
if (was_active && need_dir_change && s->flags & SF_SINGLE_SCHED)
|
||||
if (was_active && need_dir_change) {
|
||||
// Must ensure minimum time between step change and dir change
|
||||
while (timer_is_before(timer_read_time(), min_next_time))
|
||||
;
|
||||
if (s->flags & SF_SINGLE_SCHED)
|
||||
while (timer_is_before(timer_read_time(), min_next_time))
|
||||
;
|
||||
gpio_out_toggle_noirq(s->dir_pin);
|
||||
uint32_t curtime = timer_read_time();
|
||||
min_next_time = curtime + s->step_pulse_ticks;
|
||||
if (timer_is_before(s->time.waketime, min_next_time))
|
||||
s->time.waketime = min_next_time;
|
||||
return SF_RESCHEDULE;
|
||||
}
|
||||
}
|
||||
|
||||
// Set new direction (if needed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user