millis() overflow problem.
qnxsgwy opened this issue · 2 comments
qnxsgwy commented
"if (msNow > nextSwitchTime) { nextSwitchTime = msNow + debounce;"
is used in the PID_RelayOutput example,
When nextSwitchTime overflows, the comparison results for the next cycle will be wrong.
//should use
if(millis() - lastMillis >= interval){
//and NOT like
if(millis() >= lastMillis + interval){
Dlloydev commented
Thank you for pointing this out. Even though the effect is very minimal on the output, I'll take a look at updating the function to prevent the overflow issue.
Dlloydev commented
Converting this to discussion. Will do some additional testing and possible update for a future release.