Arduino-PID-Library
Arduino-PID-Library copied to clipboard
Error in PID_RelayOutput Example
On line 58, there is a an error which makes the program useless.
Line 58: if (Output < millis() - windowStartTime) digitalWrite(RELAY_PIN, HIGH);
The output should be greater than not less than millis() - windowStartTime.
When warming up to the SetPoint, the output is 5000, which is the whole windowTime, so the relay would never turn on.
+1.
It depends on whether the relay is on when input is HIGH
or when input is LOW
. Indeed the example is unclear. Assuming that HIGH
turns the relay on, then the code should check when output is greater than the current window, and set HIGH
when it is. Think about it as "What percentage of time should the relay be on?"
As stated here, this means that the comparison would be incorrect in PID_RelayOutput.ino when HIGH
turns the relay on. It should be:
if (Output > millis() - windowStartTime) digitalWrite(RELAY_PIN, HIGH);
else digitalWrite(RELAY_PIN, LOW);
This is a duplicate of #10.