This is a problem that would hardly ever happen but is easily fixed.
If Focuser Pro 2 were to be used in an application where the Arduino is powered on for more than 49 days the timer functions will fail.
I don’t expect that anyone using Focuser Pro 2 for astronomy would every leave the system powered up for 49 days, but someone using the system for time-lapse photography (which I assume could be a possibility) would encounter the problem.
The fix is pretty easy; by adding an “or” statement to the “if” statement used to compare the timer variable and millis(). The “or” triggers the event when the timer variable is greater than millis() due to millis() rolling over.
The firmware I am using, "Focuserv256_DRV8825_HW203_OLED_RE_F" , has three timed events that would be susceptible to this problem.
Below shows the line number, current code and suggested code changes:
The millis() command returns the number of milliseconds the Arduino has been running (powered on) and is used for timing functions in programs.
For timing functions millis() is compared to other variables, to measure elapsed time, and then used to trigger timed events.
Millis() is stored as an unsigned long number, a 32 bit number, with a maximum value of 4,294,967,295.
Once the millis() counter reaches 4,294,967,295, it rolls back over to 0.
4,294,967,295 milliseconds is a little more than 49 days.
A variable is compared to millis(), which will be greater than the variable, to determine the number of milliseconds that have passed. When the required number of milliseconds have past, the event is triggered and the variable is reset to the current millis() value. When millis() rolls back over the 0 the variable will now be greater than millis(), never trigger the event and never be reset. This will cause timed events to never trigger again until the Arduino is reset.
Regards,
Mike W
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a problem that would hardly ever happen but is easily fixed.
If Focuser Pro 2 were to be used in an application where the Arduino is powered on for more than 49 days the timer functions will fail.
I don’t expect that anyone using Focuser Pro 2 for astronomy would every leave the system powered up for 49 days, but someone using the system for time-lapse photography (which I assume could be a possibility) would encounter the problem.
The fix is pretty easy; by adding an “or” statement to the “if” statement used to compare the timer variable and millis(). The “or” triggers the event when the timer variable is greater than millis() due to millis() rolling over.
The firmware I am using, "Focuserv256_DRV8825_HW203_OLED_RE_F" , has three timed events that would be susceptible to this problem.
Below shows the line number, current code and suggested code changes:
Line 1553 (update display)
Line 1564 (get current temperature)
Line 1615 (save settings to flash)
This is why it fails:
The millis() command returns the number of milliseconds the Arduino has been running (powered on) and is used for timing functions in programs.
For timing functions millis() is compared to other variables, to measure elapsed time, and then used to trigger timed events.
Millis() is stored as an unsigned long number, a 32 bit number, with a maximum value of 4,294,967,295.
Once the millis() counter reaches 4,294,967,295, it rolls back over to 0.
4,294,967,295 milliseconds is a little more than 49 days.
A variable is compared to millis(), which will be greater than the variable, to determine the number of milliseconds that have passed. When the required number of milliseconds have past, the event is triggered and the variable is reset to the current millis() value. When millis() rolls back over the 0 the variable will now be greater than millis(), never trigger the event and never be reset. This will cause timed events to never trigger again until the Arduino is reset.
Regards,
Mike W
Many thanks Mike
I will work this into v258 release
Mike, could I have your email please?
Robert, thank you for V258. I will test it.
Miloš