scan time’s possible effect on PID performance ...
Greetings to all,
in various posts above, Contr_Conn said (in part):
Take a look at the program to make sure PID is triggered by a timer and preset is exactly equal to the loop update time.
As far as I know the trigger rate must exactly match loop update time.
If this is not true than PID will never do calculations correctly, but within the same program will give you consistently incorrect results and error can be compensated by tuning. Technically if timing is set correctly gains will depend on the process only and should be same.
all of this is technically correct and is good sound advice ... but then in post #8, Contr_Conn went on to say (in part):
This is not a scan time influence ...
Scan time ... has nothing to do with PID calculations.
unfortunately this is incorrect ... specifically, if the PID is not correctly programmed, then the program scan time CAN indeed influence the PID’s operation ...
now let me begin by saying that if taken in the ongoing context of the current thread, then Contr_Conn’s statement might certainly be acceptably on target ... specifically, IF all of the sound advice he had already given in his previous posts had been followed, then the “scan time” effect might well be considered a “non-issue” ... but that’s a big “if” ... I have a strong suspicion that the program that Derek has been working on does NOT incorporate Contr_Conn’s excellent advice ... still if Contr_Conn did have this “ongoing context” in mind when he made that troublesome statement, then I hereby apologize for having misinterpreted what he actually meant to say ...
and so now on to discussing how the program scan time actually CAN affect the PID tuning after all ...
preview of the following discussion: the PID’s Integral action and its Derivative action are both mathematically related to time ... if the PID is not correctly executed on an accurately timed schedule, then the output of the PID will be skewed from the “expected” results ... while it is not recommended practice, it is POSSIBLE to alter the PID’s tuning to “compensate” for the inaccurately timed execution and thus obtain satisfactory control of the process ... BUT ... if the timed execution is INCONSISTENT, then the PID will, in effect, become “detuned” whenever the execution rate becomes either significantly faster or significantly slower ... I suspect that Derek’s problem is being caused by this “scan-time-related-detuning” effect ...
the discussion below focuses entirely on the PID’s Integral action ... if anyone wants to also explore the Derivative action, please post your request ... it might take a few days for me to respond but I’ll try to answer your questions as soon as I can ...
the figure below shows an experimental test of a PID in an Allen-Bradley PLC-5/20E ... the PID was programmed using an N-type (integer) control block ... the standard “ISA” or “Dependent Gains” equation was selected ... the PID rung was placed in an STI (Selectable Timed Interrupt) routine as detailed on pages 14-30 and 14-31 of the
PLC-5 Instruction Set Reference Manual
... using this STI programming method allows us to easily and accurately change the PID’s execution (or “trigger”) rate by simply altering the STI setpoint ... this way we can simulate the effects that a “faster” or “slower” scan time would have on the PID’s output ...
the values for “STI” given in the figure below are in units of “seconds” ... the values for “LUT” (Loop Update Time) given in the figure below are also in units of “seconds” ... the values for Ti (Integral Time) given in the figure below are in units of “minutes per repeat” ... the X-axis of the graph is 10 minutes long ... a grid line is displayed at each 2-minute interval ...
[attachment]
the test begins at “0” minutes with the process in a condition of “steady-state" control ...
from point “A” to point “B” the PV is accurately tracking the SP at 20% ... since the PV is “on target” the Error is 0% ...
from point “F” to point “G” the PID is driving the CV at a constant 5% ... since the Error is 0% there is no change in the CV due to Integral action ...
from point “B” to point “C” the SP is suddenly increased from 20% to 40% ... this generates a new Error of 20% ...
from point “C” the SP is kept at 40% all the way to point “D” ... from point “B” the PV is kept at 20% all the way to point “E” ... the constant SP and the constant PV result in a constant Error of 20% throughout the duration of the test ... in a real-world system the PV would be expected to change as the test proceeds ... by holding the PV constant throughout our test, we can concentrate on how the PID’s Integral action responds to differences in tuning and in scan time ...
from point “G” to point “H” the CV responds to the sudden new 20% Error with a 10% rise due to the Proportional action ... (E*Kc so 20*0.50 = 10) ...
from 2 minutes to 4 minutes the Integral action has ramped the CV to a 20% increase from point “H” to point “I” ... the Ti setting of 1.00 minute/repeat gives 2 repeats of the Proportional action after 2 minutes ... thus 2*10=20 ... note that the STI “trigger” time of 0.50 seconds is exactly equal to the PID’s “Loop Update Time” of 0.50 seconds ... specifically, the PID is being executed on an accurately timed schedule ... this test period represents “normal” operation ...
from 4 minutes to 6 minutes the Integral action has ramped the CV to a 10% increase from point “I” to point “J” ... the unchanged Ti setting of 1.00 minute/repeat SHOULD HAVE given 2 repeats of the Proportional action after 2 minutes ... thus 2*10=20 ... BUT ... note that the new STI “trigger” time of 1.00 second is double the PID’s “Loop Update Time” of 0.50 seconds ... specifically, the PID is being executed only half as often during this test period as during the last 2 minutes ... more specifically, the loop tuning has been ALTERED by the inaccurately timed execution of the PID ...
from 6 minutes to 8 minutes the Integral action has ramped the CV to a 20% increase from point “J” to point “K” ... here the Ti setting has been altered to “compensate” for the inaccurately timed execution of the PID ... the new Ti setting of 0.50 minute/repeat SHOULD give 1 repeat of the Proportional action after 2 minutes ... thus 1*10=10 ... BUT ... note that the STI “trigger” time of 1.00 seconds is still double the PID’s “Loop Update Time” of 0.50 seconds ... specifically, the PID is still being executed only half as often as it should be ... more specifically, note that the 20% rise from point “J” to point “K” is exactly equal to the 20% rise from point “H” to point “I” ... DESPITE the change in the Ti setting from 1.00 minute/repeat to 0.50 minutes/repeat ...
from 8 minutes to 10 minutes the Integral action has ramped the CV to a 40% increase from point “K” to point “L” ... note that the new STI “trigger” time of 0.50 seconds is now exactly equal to the PID’s “Loop Update Time” of 0.50 seconds ... specifically, the PID is once again being correctly executed on an accurately timed schedule ... and so the Ti setting of 0.50 minutes/repeat gives the expected 4 repeats of the Proportional action after 2 minutes ... thus 4*10=40 ... also note that the 40% rise from point “K” to point “L” is double the 20% rise from point “J” to point “K” ... DESPITE the identical Ti settings of 0.50 minutes/repeat between the two test periods ...
the main point of all of this is that the response of the PID’s Integral action CAN indeed be influenced by the processor’s scan time ...
specifically, if we execute the PID at a “slower” rate, then the Integral action will be DECREASED ... on the other hand, if we execute the PID at a “faster” rate, then the Integral action will be INCREASED ...
discussion continued in next post ...