You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the sum of the value in the windowStartTime variable occurs, but it seems to me that it is not restarted, so in a moment it seems to overflow.
if (millis() - windowStartTime > WindowSize)
{ //time to shift the Relay Window
windowStartTime += WindowSize;
}
Based on the Blink code, the variable can be set using the value of millis(), this way it must always have a value within the operating range:
if (millis() - windowStartTime > WindowSize)
{ //time to shift the Relay Window
windowStartTime = millis();
}
Ref.:
unsignedlong currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
[...]
}
The math for differencing unsigned longs works well for intervals.
Using the windowStartTime += windowSize; form makes it so any jitter in the window getting triggered is absorbed by the following window. The triggers will stay synchronized with every 5000ms for as long as the code runs. If you use the windowStartTime = millis(); form, if a window starts a little late, it pushes all the following windows later too.
Hello,
I noticed that the sum of the value in the windowStartTime variable occurs, but it seems to me that it is not restarted, so in a moment it seems to overflow.
PID_RelayOutput.ino:
Based on the Blink code, the variable can be set using the value of millis(), this way it must always have a value within the operating range:
Ref.:
https://docs.arduino.cc/built-in-examples/digital/BlinkWithoutDelay
The text was updated successfully, but these errors were encountered: