FUNCTION_BLOCK FB_PIDR

Hover on a highlighted element
to pop up its description (if any).

ALGORITHM REQ IN ST :
ERROR:=PV-SP;
IF AUTO THEN
 IF WASAUTO AND NOT WASLIMITED THEN
   ITERM:=ITERM+ERROR*DT/TR;
   DTERM:=(3*(PV-X3)+X1-X2)*TD/DT/10;
 ELSE
   ITERM:=-KP*ERROR-XOUT;
   DTERM:=0;
 END_IF;
 XOUT:=-KP*ERROR-ITERM-DTERM;
ELSE XOUT:=X0;
END_IF
X3:=X2;
X2:=X1;
X1:=PV;
WASLIMITED := FALSE;
IF XOUT<0 THEN
 XOUT:=0;
 WASLIMITED := TRUE;
ELSIF XOUT>100 THEN
 XOUT:=100;
 WASLIMITED := TRUE;
END_IF;
WASAUTO:=AUTO;
END_ALGORITHM

Upon the occurrence of an event at the REQ input, an instance of this function block type performs the REQ algorithm shown above, followed by an event at the CNF output.

The REQ algorithm implements the reverse-acting PID (Proportional+Integral+Derivative) control law

XOUT = -(K p * e + ITERM/T R + T D *DTERM),
where
e = PV - SP, ITERM = ∫ e dt , and ETERM = d e /dt.

The manipulated variable XOUT, the process variable PV and the proportionality constant KP are of type REAL , as are the internal terms ERROR , ITERM and ETERM . The reset time TR and derivative time TD are of type TIME . The set point SP and initial output value X0 are of type UINT since they are considered to be manually set, e.g., from an instance of the FACEPLATE type.

The inputs PV,SP and X0 are assumed to be limited to the range 0 to 100 per cent of full scale, and the output XOUT is limited to the same range.

Provision is made for anti-reset windup and bumpless transer from MANUAL to AUTO mode through appropriate initialization of the internal ITERM and ETERM variables.

See the TANK_MVCL system configuration for an example of the usage of an instance of this type.