TP
Function Block Name |
TP |
---|---|
Description |
Sets an output to True for a defined time duration. This is useful when a change in state needs to be indicated for a set amount of time, for example, a pulse timer could be used to activate alarm sirens on site for 10 minutes. |
Arguments |
IN {BOOL} When the IN input changes from False to True, the timer ET begins to increase. The Q 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 even if the IN input remains True. PT {TIME} The PT input defines the amount of time for the delay. The output changes to True for the PT time and then reverts to False. |
Returns |
Q {BOOL} The Q output is True whenever the IN input changes from False to True. The output remains True until the ET counter reaches the time specified by the PT input (at which point it reverts to False). The Q output can be False even if the IN input is True—the output will only be True for the PT time. When the PT time has expired, the Q output reverts to False even if the IN input remains True. In this situation, the Q output would not become True again unless the IN input changes from True to False and then back to True again. 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 reverts to False. The ET counter then resets to 0. |
NOTE: When using TP, you should have the execution set to an interval so that the program re-executes and re-evaluates the condition of the timer. TP timers do not function as a SLEEP or WAIT type command.
Example - TP Function Block Diagram:
The ShutDown Boolean provides the input for IN. It begins as False and then changes to True which causes the Q output to change to True. This starts the ET counter which begins to count up to the amount of time defined by the PT input (in this case, 30 seconds). After 30 seconds, the Q output changes back to False and the ET counter resets to 0. The Q output will not change from False to True again until the IN input changes from True to False and then back to True (the output only changes when the IN input changes from False to True).
Example - TP ST Program:
The syntax for entering a TP 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 : TP;
- 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 TP 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 );