-
Notifications
You must be signed in to change notification settings - Fork 20
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
micros() Rollover? #11
Comments
Interesting request, I haven't come across this kind thing before but yes I can make it have precision which will give you more days. I come up with something. Sent from my iPhone
|
Wow. That was a quick reply. Yeah, there's something going on with the rollover. I ran your count up timer example code and commented out the 30 second stop. I just let it sit since I last commented, and here's the output from the serial monitor at the 71.6 minute mark: 1:11:34:4294030:4294029577 I understand that it has to rollover micros() because of the nature of unsigned long, but here it is also rolling over the milliseconds as well. I wonder if implementing some sort of overflow similar to what you did with hours, minutes, seconds in the code for microseconds to milliseconds will do the trick. That way it can roll over the microseconds before the limitation of the variable type at some defined point (1000000, say) and bump that number up to the microseconds. It will still run into the rollover of milliseconds at 49.7 days again because of the limitations of unsigned long, but for most applications this will work. Although, it should be possible to do the same thing with milliseconds to seconds. I will let it keep running. |
Additionally, my sketch is using ShowTotalSeconds() as a way to do stuff based on the time. Full code is below. I'm running your example again and printing the total seconds to serial monitor to see if it's rolling this over as well.
|
Updated the code, give it try. |
Awesome, I have similar uses running 1-2 weeks. Thanks Andrew~ |
??? Uses or issues? Sent from my iPhone
|
First off, thank you Andrew for making this helpful library. I'm trying to use this library for a sketch that involves keeping time over the course of 2-3 days. Everything in the sketch works properly when I test it on short timescales (less than an hour), but when I try to bump up to longer time periods it's acting like there's a rollover going on that is not handled.
Looking at the master code, it seems like you are accounting for the microsecond rollover period of 71.6 minutes. Has anyone tried using this code for anything on longer timescales and encountered the same issue? Since I don't need microsecond resolution or care at all about high accuracy in timekeeping, would changing the part of the library that uses microseconds for tracking time (boolean Timer() ) over to milliseconds work? Then I'd get a rollover period of 49.7 days, which shouldn't be an issue.
I'm currently running the timer on my Arduino with the serial monitor for a couple of days to see if this is indeed the case. Any help is appreciated.
The text was updated successfully, but these errors were encountered: