View Single Post
Old February 20th, 2003, 05:53 PM   #6
Allen Nelson
United States

Allen Nelson is offline
Join Date: Apr 2002
Location: West Chester, PA
Posts: 1,368
Thrown for a loop

Ron. Thanks for this. It's cleared up some more concepts/misconceptions. I think I almost get it now. (qualified statement.

The PLC cannot, of course, perform calculus. What it does is approximate, just like the rest of us.

When we are totalizing a flow through a flow meter, we are integrating the flow rate over time. Do we use calculus (Integral of Fdt from zero to End)? No - we just do a time sampling of the current flow (F), multiply that to the length of time (dt), and add that to the previous result.

When we scale a linear temperature reading based on the scale of the raw input, do we use calculus (dT/dr)? NO, we just use the calculate the differnce between the values relative to full scale (or an SCP, which does the math for you).

In short, in those equations that I posted above, the integral sign gets changed to a sigma, representing summation of all the previous terms. The derivate 'd' gets changed to a delta, the differnce between the current value and the last recorded value.

So the fancy equation becomes (for independent, derivative on PV):

CV = Kp*E + Ki*(Totalized{E*LoopUpdateTime}) + Kd*(Current PV - Last PV)/LoopUpdateTime + Bias

It's easy enough to roll your own (although a bit more than 3 multiplies, unless you are willing to combine constants, (LoopUpdateTime is a constant, and SUM(E*k) = k*SUM(E), from the distubive principle that you should have learned in 4th grade)

So the equation becomes:

CV = P*E + I*(Totalized{E}) + D*(Current PV - Last PV) + Bias

P = Kp ;
I = Ki * LoopUpdateTime;
D = Kd / LoopUpdateTime

When I saw that you were changing the LoopUpdateTime three-fold, I thought that you'd have to do the inverse to Ki in order to keep the 'I' term the same.

But since you changed the trigger time as well, there was only 1/3 as many values of 'E' in the totalized(E), which is why you say you didn't de-tune the loop.

But that doesn't take the derivative portion into account. There, there is no historical sampling of E, and so (I think) that you effectively divided the derivative portion by 3. I doubt that derivative by itself would produce the drastic changes in your graphs (that's due, as you point out, to the CV not being adjusted frequently enough to control the PV adequately) but it might explain the detuning that happened when you updated even more frequently (Fig 6).

Again, thanks for pointing out yet another mistake in the Rockwell manuals, about the 1/5 to 1/10 update time.

Here's a question. "How long is too long?". I had a PID a few years ago where the natural period was about 40 minutes (really big cooling tower basin (think olymipc-size swimming pool, 3 feet deep)- the theory was to refill it at the rate of evaporation). The problem was that the when a tower was turned off, all of the water that was in transit would stay in the basin, raising the level dramatically, so that the loop had to respond quickly to that change, but slowly to evaporative changes. I finally got fed up with trying to put in PID control and did a simple OFF-LOW-MED-HI-FULL control based on level (is this "fuzzy logic"? - I don't know). Was this loop tunable? We had some numbers that worked (although still tended to oscillate quite a bit). I think I had the update time around 3 seconds (400 updates per period, if I had the period right)
  Reply With Quote