Skip to content

Prevent 32-bit micros() timestamp rollover#1

Open
Gronemeyer wants to merge 2 commits into
janelia-experimental-technology:mainfrom
Gronemeyer:main
Open

Prevent 32-bit micros() timestamp rollover#1
Gronemeyer wants to merge 2 commits into
janelia-experimental-technology:mainfrom
Gronemeyer:main

Conversation

@Gronemeyer

Copy link
Copy Markdown

Introduce a 64-bit monotonic microseconds counter to avoid timer rollover in output when recording data for more than 17 minutes.

Timekeeping improvements:

  • Added a monoUsecs 64-bit monotonic microseconds variable to track elapsed time without rollover issues.
  • Updated speed calculation and output logic to use monoUsecs instead of the raw micros() value to ensure time values remain accurate across timer wraparounds. [1] [2]
  • Modified all relevant time difference calculations to use unsigned arithmetic for proper wraparound handling.

Output changes:

  • Changed serial output to print the monotonic time (monoUsecs) rather than the raw microsecond timer to increase reliability of logged timestamps. [1] [2]

…ds tracking

Added a 64-bit monotonic microseconds variable and updated calculations to use it for speed and distance tracking.
Updated speed calculation to use monotonic time and fixed type casting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant