
VAR_INPUT L0 : REAL; (* Initial tank level, 0-100% *) FEED : REAL; (* Liquid Feed Rate, % per clock interval *) DRAW : REAL; (* Liquid Drain Rate, % per clock interval *) N : UINT := 25; (* # of clock cycles for full fill/drain at 100% FEED/DRAW rate *) END_VAR VAR_OUTPUT LEVEL : REAL := 0; (* Liquid Level, 0-100% *) END_VAR
An instance of this function block type provides a Model for the filling and draining of liquid in a cylindrical tank. Its interface variables are defined as shown above, and its operation is defined by the ECC (Execution Control Chart) and algorithms shown below.
See the TANK_MVL
System
configuration for an example of the use of an instance of this
function block type.

ALGORITHM INIT IN ST : (* Initialize tank level *) LEVEL := L0; END_ALGORITHM ALGORITHM REQ IN Java : (* Tank level update *) LEVEL.value = Math.max(0.0f, Math.min(100.0f,LEVEL.value + (FEED.value-DRAW.value)/N.value)); END_ALGORITHM