Voting resources, early voting, and poll worker information - VOTE. ... 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: 8
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: 2069
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: 772
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: 1849
Joined: Thu Oct 06, 2016 8:48 pm

Re: Time.monotonic()

by alpierce on Wed Oct 07, 2020 1:36 pm

Is the countio function still only available in 5.4.0 Beta?

alpierce
 
Posts: 41
Joined: Mon May 13, 2013 2:44 am

Re: Time.monotonic()

by tannewt on Wed Oct 07, 2020 8:56 pm

Yup, it's only in the 6.0.0 Beta. Give it a try. It's working well and we're hoping to stabilize soon.

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

Re: Time.monotonic()

by westfw on Thu Oct 08, 2020 6:18 am

time.monotonic_ns()

This wraps in about 4 seconds ?

westfw
 
Posts: 1735
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Time.monotonic()

by tannewt on Thu Oct 08, 2020 2:04 pm

westfw wrote:
time.monotonic_ns()

This wraps in about 4 seconds ?


No, it uses long integer support so it can be more than 32 bits. It does mean that it won't work on boards without long integer support such as non-Express M0s.

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

Please be positive and constructive with your questions and comments.


cron