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

TON

Function Block Name

TON

Description

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

Arguments

IN {BOOL}

When the IN input changes to True, the timer ET begins to increase. The output remains False 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 True (only if the IN input is still True).

PT {TIME}

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

Returns

Q {BOOL}

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

ET {TIME}

The ET time counter begins when the IN input changes from False to True. 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 True).

NOTE: When using TON, you should have the execution set to an interval so that the program re-executes and re-evaluates the condition of the timer. TON timers do not function as a SLEEP or WAIT type command.

Example - TON Function Block Diagram:

The ShutDown Boolean provides the input for IN. It begins as True and then changes to False which causes the Q output to change to False. The IN input then changes to True, 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 False. When the ET counter reaches 30 seconds, the Q output remains False as the IN input was not continuously True for 30 seconds.

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

Example - TON ST Program:

The syntax for entering a TON 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 : TON;
  • 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 TON 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 );

So, the ST Program uses the IN_IN input as the IN input for the FB function block (which has already been declared as a TON type). The PT input is provided by the PT_IN variable, the Q output is stored by the Q_OUT variable, and the ET output is stored by the ET_OUT variable.


ClearSCADA 2015 R2