Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Time.monotonic()
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Time.monotonic()

by gordona23 on Wed Jun 17, 2020 6:29 pm

Can you tell me the resolution of the time.monotonic() function on an ItsyBitsy M4? What's the shortest elapsed time that I can reliably measure ? I'm using this to measure pulses from a hall effect sensor on a slowly (300 rpm) spinning motor shaft. Thanks for any help with this.

gordona23
 
Posts: 1
Joined: Wed Jun 17, 2020 6:21 pm

Re: Time.monotonic()

by mikeysklar on Wed Jun 17, 2020 7:20 pm

time.monotonic() is limited to millisecond accuracy.

There should be a time.monotonic_ns() available on Express boards available since CircuitPython 4.x release.

time.monotonic_ns() → int¶
Similar to monotonic(), but return time as nanoseconds.


Good thread on the topic.

https://github.com/adafruit/circuitpython/issues/519

mikeysklar
 
Posts: 1243
Joined: Mon Aug 01, 2016 8:10 pm

Re: Time.monotonic()

by kevinjwalters on Wed Jun 17, 2020 7:37 pm

The way that time.monotonic() degrades over time is also described in CLUE Sensor Plotter in CircuitPython: Time in CircuitPython.

kevinjwalters
 
Posts: 634
Joined: Sun Oct 01, 2017 3:15 pm

Re: Time.monotonic()

by tannewt on Thu Jun 18, 2020 1:56 pm

gordona23 wrote:Can you tell me the resolution of the time.monotonic() function on an ItsyBitsy M4? What's the shortest elapsed time that I can reliably measure ? I'm using this to measure pulses from a hall effect sensor on a slowly (300 rpm) spinning motor shaft. Thanks for any help with this.


There are a couple better options than DIY. If you care about pulse length, then pulseio.PulseIn will get down to microseconds or so. If you care about counting pulses then the new `countio` would be your best bet. Note that it's only in the 5.4.0 Beta.

tannewt
 
Posts: 1685
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.