...
In this mode, the "Current Position", "Recalibrate", "Set # of Turns Open (Man)" controls and the "Motor Enabled" bool are all disabled and grayed out, but the "Min Open" and "Max Open" controls are enabled. The Min and Max Open values are set by the user, and represent the minimum position that the valve can close to and the maximum position it can open to while running. These values can be changed while the PID loop is active.
...
The Proportional-Integral-Derivative (PID) Response
The PID response operates by calculating an error from the designated target level and corrects that by using proportional, integral and derivative terms.
...
The above picture shows the code which creates the PID response.
In short, the PID loop takes the current level and the target level and compares them to determine what the new valve position should be. It also takes into account the min and max open positions, and converts them to steps. It uses these positions to edit the new position created by the PID loop to ensure its validity.
If you want to change the PID gains or are interested in the mathematics behind the PID response, visit my page on Creating the PID Response.
The image above (from top to bottom) shows how the current level is subtracted from the target level for each iteration, and this data is then used to produce the error graph, which plots the current error from the target level with respect to time.
...