From 5af7d9a10f0134c2c6f3d37ddc5790edc9ff3d10 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 31 Jan 2022 00:59:42 +0100 Subject: [PATCH] motion: correctly reset residuals of a stopping axes Fixes the motion stutters generally happening as more than a single axis are active and one completes in the middle of the motion. Do not generate a spourious interval as one axis exits the queue. This short interval didn't account for the minimal stepping quantum, potentially causing a timer overflow. --- src/modules/motion.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/motion.h b/src/modules/motion.h index 5bd8e34..e37f43a 100644 --- a/src/modules/motion.h +++ b/src/modules/motion.h @@ -250,11 +250,15 @@ public: timers[i] = axisData[i].residual; if (timers[i] <= config::stepTimerQuantum) { if (timers[i] || !axisData[i].ctrl.QueueEmpty()) { - if (st_timer_t next = axisData[i].ctrl.Step(axisParams[i].params)) { + st_timer_t next = axisData[i].ctrl.Step(axisParams[i].params); + if (next) { timers[i] += next; // axis has been moved, run the tmc2130 Isr for this axis axisData[i].drv.Isr(axisParams[i].params); + } else { + // axis finished, reset residual + timers[i] = 0; } } }