Skip to content

millis() overflow problem. #52

Closed
Closed

Description

@qnxsgwy

"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){

Activity

  1. Dlloydev commented on Jun 16, 2022

    @Dlloydev
    Owner

    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.

  2. Dlloydev commented on Jan 6, 2023

    @Dlloydev
    Owner

    Converting this to discussion. Will do some additional testing and possible update for a future release.

  3. Repository owner locked and limited conversation to collaborators on Jan 6, 2023
  4. converted this issue into a discussion #58 on Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions