javos65 / WDTZero

Allows to use the WatchDog functionality for Arduino Zero, MKRZero and MKR1000 only
15 stars 12 forks source link

Clock Drift with RTCZero Library #2

Closed AndrewCarterUK closed 4 years ago

AndrewCarterUK commented 5 years ago

We're using the RTCZero library.

We've done an experiment, as we noticed that we were getting unacceptable clock drift:

watchdog.setup(WDT_SOFTCYCLE32S);

Every 15 seconds:

watchdog.clear()

Doing this resulted in the RTC gaining about 24 seconds per hour.

Happy to help investigate this - but not sure where to start!

Thanks

javos65 commented 4 years ago

The watchdog is not build to keep track of time, us a RealtimeClock for this purpose. Purpose of the Watchdog is to guard your process, and take an action incl reset in case something fails to update the timer. (ie never ending loops of stalled process).

Precision of longer WTD-times are not relevant in this case.

AndrewCarterUK commented 4 years ago

Hello, to be clear, we are using the RTC to keep track of time and not the watchdog.

The problem is that using the watchdog appears to interfere with the time retrieved from the RTC using the RTCZero library.

salvq commented 4 years ago

@javos65 @AndrewCarterUK same here, I am getting delay of my RTC when using watchdog, my short term workaround is that I update RTC time from internet every 10 min

Is there any better solution for this ?

javos65 commented 4 years ago

Again: this is a watchdog timer, not an RTC. Precise timing is not the target, system stability is. If you need a time tick ie every 10.00234 seconds, use an RTC, not a watchdog... Sorry

salvq commented 4 years ago

@javos65 Hi, watchdog works just fine and thanks for that.

Rtc works fine and accuarately when not using watchdog. Once i start using watchdog i am seeing that my time taken from the rtc i use for other purpose start getting clock drift. So watchdog works but my time got from rtc is not accuarate anymore. When not using watchdog time from rtc is accurate anytime i read the time from rtc. Looks like there is a clock drift when using watchdog clear routine and watchdog is slowing down rtc.

miqbatalla commented 4 years ago

Hi! I am currently experiencing the same problem, when trying to use the RTC while a watchdog is operating and being cleared. This problem appears to happen on both an Arduino MKR GSM and MKR WiFi. I don't know how to fix this issue either. Did you find a workaround for it? Thanks!

salvq commented 4 years ago

@miqbatalla No, I have not found any other than refreshing time from internet every X minutes.