You are here: Core Reference > Coding > Logic > TOF

TOF

Function Block Name

TOF

Description

Sets an output to False after a specified time delay. This is useful when the input signals are unreliable due to interference etc. By having a delay, you can stop fluctuating input values from affecting the output—a True input will set the Q output to True immediately, but a False input will have to remain False for a set time before it causes the Q output to become False.

Arguments

IN {BOOL}

When the IN input changes to False, the timer ET begins to increase. The output remains True until the ET time reaches the time limit defined by the PT input. When the ET time reaches the PT time, the output changes to False (only if the IN input is still False).

PT {TIME}

The PT input defines the amount of time for the delay. The output cannot change to False unless the IN input is False for the PT time.

Returns

Q {BOOL}

The Q Boolean output is True whenever the IN input is True. If the IN input changes to False, the Q output remains True until the ET time has reached the limit defined by the PT time. If the IN input is still False then the ET time reaches the PT time, the Q output changes to False.

ET {TIME}

The ET time counter begins when the IN input changes from True to False. It increases toward the time limit defined by the PT input. When it reaches the PT limit, the ET counter stops and the output either changes or remains the same (depending on whether the IN input is still False).

Example - TOF Function Block Diagram:

The POWER Boolean provides the input for IN. It begins as False and then changes to True which causes the Q output to change to True. The IN input then changes to False, and the ET counter begins to count up to the amount of time defined by the PT input (in this case, 30 seconds). After 15 seconds, the IN input changes back to True. When the ET counter reaches 30 seconds, the Q output remains True as the IN input was not continuously False for 30 seconds.

The IN input changes from True to False again. As before, the ET counter starts to increase from 1s upwards toward 30 seconds. During this time, the IN input remains False. When the ET counter reaches 30s, the Q output changes to False as the IN input has been False for over 30 seconds.

Example - TOF ST Program:

The syntax for entering a TOF function block in an ST program is:

  • VAR
    • IN_IN AT %M(.Digital Point1): BOOL;
  • END_VAR
  • VAR
    • PT_IN: TIME;
    • Q_OUT: BOOL;
    • ET_OUT: TIME;
    • FB : TOF;
  • END_VAR
  • FB( IN := IN_IN, PT := PT_IN, Q => Q_OUT, ET => ET_OUT );

The direct variable is declared in a separate VAR block to the indirect variables. The input and output variables for the TOF function block are also allocated names that are different to the names of the inputs and outputs in the function block as this makes it easier to understand the ST program (for example, the PT input variable is named PT_IN). In this example, the direct variable for the IN input (IN_IN) references a digital point (the Boolean value for the input is taken from a digital point in the database).

In the second VAR block, the internal variables are declared, including an FB variable that defines the type of function block.

The ST Program can then reference the variables as inputs and outputs for the function block:

  • FB( IN := IN_IN, PT := PT_IN, Q => Q_OUT, ET => ET_OUT );

ClearSCADA 2015 R2