br3ttb/Arduino-PID-Library — pull request #6 by jamesprior (2013-01-24 01:49:07+00:00)
Title: Altered RelayOutput example behavior

I recently made a mechanical relay based PID with time proportioning control but I noticed some behavior in the sample that was unexpected, and this pull request is an attempt to address those.

First, is that given a window size of 5000 and a PID output of say, 2000 I would expect the PID to be on for 2000 out of 5000 milliseconds. The call to myPID.Compute(); inside the main loop changed the output each loop so out of a 5000 millisecond slice of time, the output could vary between 2000 and 0. I am not an expert in PIDs but it seems like it would make it hard to maintain a consistent temperature when the response depended on more than just the output state.

The other change I made was to put in a floor so that the relay would be on for a minimum amount of time. My assumption is that mechanical relays have a response time, and anything below the response time is not useful.

Finally, thank you for writing the PID library and contributing, I find it very useful and I'm glad you made it.