Well, which do you want - Basics in PID, or PID the Allen-Bradley way?
There's a book,
PID Without the Math, By David St. Clare, that does an excellent job of explaining the principles. Here's a link:
http://members.aol.com/pidcontrol/booklet.html
Now for my spin (I hope I've got this right):
The key to PID is the
Error. That's just the difference between Where-you-are (Process Variable) and Where-you-want-to-be (Setpoint). This is either calculated as E=PV-SP or E=SP-PV depending on whether the response (say, valve position) should increase (open more) or decrease (close more) on a positive error.
In a PLC, the PID block is updated at a specific frequency. (In the AB - there are two ways of doing that, STI and Timed). Anyway, at an even time interval, the PID block wakes up and calculates the new Error. It also remembers the last Error that it had, and the Error before that (you'll see why below)
First, the Proportional part. If there was only a P term, then the equation would be simply:
<center>
New_Output = Old_Output + P*(New_Error - Old_Error) </center>
That is, each time the PID block wakes up, it adjusts the output by an amount
Proportional to the change in the error. Eventually, the system will overshoot, creating a negative error, the Output will be reduced, and it will oscillate as it settles in on the new "sweet spot" of the output.
The Proportional is sometimes called GAIN (as in how much has the system GAINed since last time)
Next for the Integral part. In most systems, the system may stablize at a particular output, but still leave an error. Or, the system may go into oscillation, overshooting (which causes a negative error, which in turn drops the output) and then undershooting (positive error => increased output), etc. Sometimes the oscillations dampen out. Sometimes not.
To prevent that, we take a look, not at the change in error, but at the absolute Error. If you are looking at a plot of Error over time, what you are interested in is the area under the curve for that last time period.
You are no doubt familiar with integration (calculating the area under the curve) when converting Flow Rate into a Totalized Quantity. The intergral term does the same thing. But we don't want all of it, just some fraction (the I, or K<sub>I</sub>)
Adding that to the equation, we get:
<center>
New_Output = Old_Output + P*(New_Error - Old_Error) + I*(New_Error * Update_Time) </center>
The integral term is also RESET because of those cases where the system has stablized (unchanging error) but is still short of the goal. The I term "Resets" the system to produce a zero error.
As you can see, it is possible, if the integral term were to get too big, that the New_Output would "wind up" being larger than 100% or less than 0%. The PID block allows calculated New_Output to be larger than 100% (it has to, since it may be desirable NOT to lower the CV at the begining of a negative error), but of course it only drives the CV to 100%. However, this can also cause big problems, and to solve it, you need "anti-reset windup".
To enable "anti-reset windup" in the SLC, you just set the Output Limits to 0 and 100%, and enable Output Limiting (the .OL bit). Then, no matter what the integral term says to do, New_Output won't be more than 100%.
Now for the Derivative. That's tougher to explain (meaning I'm not clear on it myself). But the basic idea is that as the error is changing rapidly, that means that the system needs to back off now, otherwise it will overshoot. So you look at the slope (or Derivative, if you remember your calculus) of the
CHANGE in Error. The slope of a line is Rise/Run or
<center>
{Y<sub>2</sub> - Y<sub>1</sub>} / {X<sub>2</sub> X<sub>1</sub>}</center>
But each point represents a change in Error, so this becomes
<center>
{(New_Error - Old_Error) - (Old_Old_Error - Old_Error) } / {Time<sub>1</sub> - Time<sub>2</sub>}</center>
or
<center>
{New_Error - 2* Old_Error + Old_Old_Error} / {Update_Time}</center>
The Derivative is also called RATE because it is examining the Rate at which the Error is changing.
I'm not going to roll that part into the PID equation, just to say that that whole mess gets multiplied by D and added to the end.
<hr>
Now, that's the easy theory. Implementation gets tricky, because each PLC/DCS manufacturer does it differently. Some have the P term multiplied by the whole thing (so that doubling P doubles the effect of I as well). Others use K<sub>I</sub>= 1/I (and you'll know this because the units will be in seconds per reset (or think of it as seconds between each reset) instead of resets per second (which my description has). Others don't use seconds, but minutes, which throws things off, too. Some allow you to do all the above, not on error, but the raw PV (why? dunno - I've had it explained to me, but I'm no expert).
Now to the SLC, for a specific. I think you can see why it's important that the PID block not have any conditions on the branch. If it does, and those cause the PID block to be "disabled", then all those numbers stored in it, for what should be the "last" value/error are wrong, and so when the PID finally does "wake up", it's looking at bad data and produces bad results. To turn off a PID, set the Auto/Manual bit (bit 1 of word 0 of the control block), and then the PID is in manual, and it knows it's not driving anymore. But the info is still being updated.
You can also see how critical the Update Time number is. I can't tell you how many times I've seen it set to 0.01 sec (faster than PLC scan). The SLC doesn't care (or at least, doesn't bother timing) what the time between updates really is, it just checks to see if the elapsed timer has expired, and updates the data if it has. That's why in one post on the old forum I said that it doesn't matter. And it doesn't. But the PID block will be updating faster than perhaps it should. You want the update time to be about 1/4 of that P-only oscilation I mentioned earlier. This should be the first tuning parameter set. If it's wrong, all the others will be wrong, too.
Well, I think that this is enough to get you started. Thanks for the opportunity to put this down - I actually learned something in preparing this.
Feel free to ask anything else about the care and feeding of SLC PID blocks.