From dcf6c2d18a0483111bffb2dc86f7080e75cb84e6 Mon Sep 17 00:00:00 2001 From: Hakan Bastedt Date: Thu, 4 Apr 2024 10:38:27 +0200 Subject: [PATCH] jitter flawed, removed --- Firmware/src/main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Firmware/src/main.cpp b/Firmware/src/main.cpp index 3006a2d..9f10981 100755 --- a/Firmware/src/main.cpp +++ b/Firmware/src/main.cpp @@ -85,7 +85,7 @@ uint64_t reallyNowTime = 0, reallyThenTime = 0; // Times in microseconds uint64_t timeDiff; // Timediff in microseconds int32_t delayT; uint16_t avgCycleTime, thisCycleTime; // In usecs -int16_t jitterThisCycle = 0, maxCycleTime = 0; +int16_t maxCycleTime = 0; volatile uint64_t oldIrqTime = 0; @@ -98,10 +98,9 @@ void handleStepper(void) } oldIrqTime = irqTime; - if (cycleTimes.bufferIsFull()) // Do max and jitter calcs, just waiting a second + if (cycleTimes.bufferIsFull()) // Do max calcs, just waiting a second { avgCycleTime = cycleTimes.getFastAverage(); - jitterThisCycle = irqTime - avgCycleTime; uint16_t maxInBuffer = cycleTimes.getMaxInBuffer(); if (maxCycleTime < maxInBuffer) maxCycleTime = maxInBuffer; @@ -118,7 +117,7 @@ void handleStepper(void) Obj.ActualPosition1 = Step->stepgen_array[0].pos_fb; Obj.ActualPosition2 = Step->stepgen_array[1].pos_fb; uint32_t diffT = longTime.extendTime(micros()) - irqTime; - delayT = maxCycleTime + 50 - diffT - jitterThisCycle; // Add 50 as some saftey margin + delayT = maxCycleTime + 50 - diffT; // Add 50 as some saftey margin if (delayT > 0 && delayT < 900) { syncTimer->setOverflow(delayT, MICROSEC_FORMAT); // Work in flawed units, its ok