here you go.
using the feedback concept the process variable (PV) is regulated according to the difference between its current value and the value
of the set point (SP) (i.e. what it should be). The output is the action required on the system
to keep the regulation.
The PID calculation is achieved by a method of sampling; Ts specifies the minimum sample period.
If Ts is less than the application scan time, the effective sample interval will be the application scan time.
The maximum effective sample period is Ts plus the application scan time. The outputs are recalculated
only if a new sample is made.
The input Auto determines whether the function block is to operate in AUTO or MANUAL mode:
AUTO Mode Operation
==================
If a new sample is made and Auto = TRUE, the output Xout is calculated as follows:
Xout = Kp * ( E[t] + I[t]/Ti + D[t] * Td)
where
E[t] = SP - PV (error)
I[t] = I[t-1] + ( E[t] * T ) (integral term)
D[t] = ( E[t] - E[t-1] ) / T (derivative term)
E[t-1] is the stored error value (i.e. value on last sample)
I[t-1] is the stored integral term (i.e. value on last sample)
T is the elapsed time in milliseconds since the last sample
On initialisation (i.e. first application program scan), the stored integral term is set to zero, and the
action is calculated using proportional action only (i.e. Xout = Kp * E[t]).
If Ti = 0, the stored integral term is set to zero and Xout is calculated using proportional and derivative
action only (i.e. Xout = Kp * (E[t] + D[t] * Td) ).
Once Xout has been calculated, the increment stop (INCstop), decrement stop (DECstop) and the clamp
(Xmax and Xmin) are applied. If INCstop = TRUE and Xout has increased since the last sample or if
DECstop = TRUE and Xout has decreased since the last sample, Xout is set to its previous value. If
Xout > Xmax or Xout < Xmin, Xout is clamped to the range Xmin to Xmax, LIMIThi is set to Xout > Xmax,
and LIMITlo to Xout < Xmin.
If INCstop, DECstop or the clamp are active, the previous integral term is retained (i.e. the stored
integral term is not set to the current integral term). On initialisation, INCstop and DECstop have no
effect.
MANUAL mode operation
====================
If a new sample is made and Auto = FALSE, the output Xout immediately follows the adjustment
value (XO) clamped to the range Xmin to Xmax. LIMIThi is set to XO > Xmax and LIMITlo to XO < Xmin.
The stored error term is set to (SP - PV) and the stored integral term is set to zero. The increment
and decrement stop (INCstop and DECstop) have no effect.
Parameter Summary
=================
Parameter Type Description
--- --- ---
Auto BOOLEAN TRUE for AUTO mode, FALSE for MANUAL mode
PV REAL Process variable
SP REAL Set point
XO REAL Adjustment value (in MANUAL mode, Xout = XO)
Kp REAL Proportionality constant
Ti TIMER Integral time constant
Td TIMER Derivative time constant
Ts TIMER Sampling period
Xmax REAL Maximum value of Xout
Xmin REAL Minimum value of Xout
INCstop REAL Increment stop
DECstop REAL Decrement stop
Xout REAL PID_II function output
LIMIThi REAL TRUE if Xout is clamped at its maximum value (Xmax)
LIMITlo REAL TRUE if Xout is clamped at its minimum value (Xmin)
N.B. Parameters PV, SP, XO, Kp, Xmax, and Xmin must be finite (i.e. not +/- infinities or NaNs).
call: PV, SP, XO, Kp, Xmax, Xmin (REAL); Auto, INCstop, DECstop (BOOLEAN); Ts, Ti, Td (TIMER)
return: Xout (REAL); LIMIThi, LIMITlo (BOOLEAN)
prototype: PID_II(PV, SP, Auto, XO, Kp, Ti, Td, Ts, Xmax, Xmin, INCstop, DECstop);
Xout := PID_II.Xout;
LIMIThi := PID_II.LIMIThi;
LIMITlo := PID_II.LIMITlo;
notes:
Loss of precision and underflow may occur.
Due to the limitations of ISaGRAF TIMER data type, Ti, Td and Ts cannot have a value of 24 hours or greater.
If Xmax < Xmin, the function assumes that the values have been reversed and 'swaps' the
values. The 'Reversed' error counter is incremented for every application program scan that the
values are reversed.
Either the following behaviour will occur *TBD*:
EITHER:
If overflow occurs during the execution of the function, the stored integral and error terms are set to
zero. In AUTO mode, if SP > PV, Xout is set to Xmax, LIMIThi to TRUE and LIMITlo to FALSE. If
SP < PV, Xout is set to Xmin, LIMIThi to FALSE and LIMITlo to TRUE. In MANUAL mode Xout is set
to XO clamped to the range Xmin to Xmax, LIMIThi is set to XO > Xmax and LIMITlo is set to XO < Xmin.
OR:
If overflow occurs during the execution of the function, the stored integral and error terms are set to
zero. In AUTO mode, Xout is set to zero, and LIMIThi and LIMITlo to FALSE. In MANUAL mode, Xout is
set to XO clamped to the range Xmin to Xmax, LIMIThi is set to XO > Xmax and LIMITlo is set to XO < Xmin.
example: