Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4914

MicroPython • Re: Timing Various Events

$
0
0
In micropython, ticks_ms() is rolling over every 298 hours (*) which is not good for 'a few weeks'.
You could write some code which keeps an internal counter every hour or so to mitigate the rollover.

I never checked the accuracy of the on board oscillator. Especially temperature change could offset frequency. When timing intervals over weeks this could sum up. If you aim for high accuracy, then look for a DS3231 RTC which provides a temperature controlled oscillator. Use the square wave output of this chip to synchronize the rp2's millisecond ticks. (**)
Using an external RTC also mitigates the risk of power outage (coin cell needed for the RTC) which could happen when measuring for many weeks.
Using a GPS receiver with its pulse output also provides a precise time reference, but needs antenna with a clear view to the sky.
Another option is wifi with NTP.

(*) https://forum.micropython.org/viewtopic.php?t=12783
(**) DS3231 provides accuracy ±3.5ppm from -40°C to +85°C

Statistics: Posted by ghp — Tue Jan 16, 2024 7:08 am



Viewing all articles
Browse latest Browse all 4914

Trending Articles