diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-07-20 23:41:10 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-07-20 23:41:10 +0300 |
commit | b4195213437de0fb2868c0390cf63e0dafeb728f (patch) | |
tree | dd98f0864640999145b0c8d87977e3664f92420a /src | |
parent | b2b00b36ffe92a4e74b9fc4d302ee63da94b3c92 (diff) |
Improved the recording of clock sync jitter when in CAN slave mode
Diffstat (limited to 'src')
-rw-r--r-- | src/Movement/StepTimer.cpp | 10 | ||||
-rw-r--r-- | src/Movement/StepTimer.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/Movement/StepTimer.cpp b/src/Movement/StepTimer.cpp index 5fd0d366..5edb2b00 100644 --- a/src/Movement/StepTimer.cpp +++ b/src/Movement/StepTimer.cpp @@ -41,6 +41,7 @@ uint32_t StepTimer::prevMasterTime; // the previous master time recei uint32_t StepTimer::prevLocalTime; // the previous local time when the master time was received, corrected for receive processing delay int32_t StepTimer::peakPosJitter = 0; int32_t StepTimer::peakNegJitter = 0; +bool StepTimer::gotJitter = false; uint32_t StepTimer::peakReceiveDelay = 0; volatile unsigned int StepTimer::syncCount = 0; unsigned int StepTimer::numJitterResyncs = 0; @@ -318,7 +319,12 @@ void StepTimer::DisableTimerInterrupt() noexcept whenLastSynced = millis(); if (locSyncCount == MaxSyncCount) { - if (diff > peakPosJitter) + if (!gotJitter) + { + peakPosJitter = peakNegJitter = diff; + gotJitter = true; + } + else if (diff > peakPosJitter) { peakPosJitter = diff; } @@ -515,7 +521,7 @@ extern "C" uint32_t StepTimerGetTimerTicks() noexcept /*static*/ void StepTimer::Diagnostics(const StringRef& reply) noexcept { reply.lcatf("Peak sync jitter %" PRIi32 "/%" PRIi32 ", peak Rx sync delay %" PRIu32 ", resyncs %u/%u, ", peakNegJitter, peakPosJitter, peakReceiveDelay, numTimeoutResyncs, numJitterResyncs); - peakNegJitter = peakPosJitter = 0; + gotJitter = false; numTimeoutResyncs = numJitterResyncs = 0; peakReceiveDelay = 0; diff --git a/src/Movement/StepTimer.h b/src/Movement/StepTimer.h index d3f3b550..8a2fcda6 100644 --- a/src/Movement/StepTimer.h +++ b/src/Movement/StepTimer.h @@ -115,6 +115,7 @@ private: static uint32_t prevMasterTime; // the previous master time received static uint32_t prevLocalTime; // the previous local time when the master time was received, corrected for receive processing delay static int32_t peakPosJitter, peakNegJitter; // the max and min corrections we made to local time offset while synced + static bool gotJitter; // true if we have recorded the jitter static uint32_t peakReceiveDelay; // the maximum receive delay we measured by using the receive time stamp static volatile unsigned int syncCount; // the number of messages we have received since starting sync static unsigned int numJitterResyncs, numTimeoutResyncs; |