-
Notifications
You must be signed in to change notification settings - Fork 29
Slow time on micro:bit V1 and V2 #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I wasn't expecting this but just tried on a V1 and same thing.
That's 100.679, 100.749, 100.703, 100.726, 100.692, 100.738 seconds. |
For comparison, MakeCode on V2:
That's 99.979, 100.019, 100.020, 100.039, 100.044, 100.009 seconds. |
That's really interesting, thanks for the report @kevinjwalters. I believe the internal RC clock might be used unless BLE or radio is running. Could you turn on the radio and test again to see if that makes a difference? |
My V2 is busy at the moment testing a trimmed MCP7940N. The same V1 is still slow with this code
produces
on |
I think this was discovered back in 2016 too on the V1 in REUK.co.uk: Testing Accuracy of micro:bit Internal Clock, that one was out by |
An alternative method to monitor micro:bit's time: millis.zip Install millis-python.hex in micro:bit V2. Run millis.py on PC. The PC periodically asks micro:bit for it's millis clock and compares it's elapsed time. Disconnect WebUSB or it will corrupt the python serial. It's clear within a minute that the micro:bit V2 is not quite 1% out. Edit millis-python.hex to #import radio, and test again. Radio enables the HFCLK in V2, and the micro:bit times seem to match the PC to the millisecond, though I haven't run the test for more than a few minutes, I think micropython is using a version of CODAL before the HFCLK was always enabled: |
I've observed that time is slow in micropython on the micro:bit V1 and V2 using v1.18 from https://python.microbit.org/v/3
This program using
sleep
runs for longer than 100 seconds.It produces this output (borrowed the Arduino IDE as it has timestamping, running on Windows 11)
On
v1.18
The 100 second sleep (plus a tiny bit of processing for format/print/increment) is 100.680, 100.744, 100.666, 100.753, 100.715, 100.671. The clock appears to be running about 0.7% slow (at 23C). It's easy to dismiss this as poor time keeping on a microcontroller but the micro:bit V2 has a crystal (listed in BOM) and all is fine in CircuitPython on same board.
I first noticed this when checking the performance of the MCP7940N rtc on a ZIP Halo HD vs MicroPython
utime.ticks_us()
. Across 24 hours the RTC is running about 18 seconds fast (I think this has a trim feature which I may explore to get it spot on), MicroPython is 552 seconds slow (about 0.64%) and CircuitPython (time.monotonic_ns()
) is just 2 seconds slow (extrapolated, I only had time to run the test for ~90 mins).@JackAtKitronik might be interested in this.
The text was updated successfully, but these errors were encountered: