The objective of this tutorial is to explain how to use the TOF function block, which is a timer with a delay on de-energization, in a MasterTool X project.
Components
Equipment: 1 computer/notebook.
Software: MasterTool X
Tutorial Sections
- ARCHITECTURE
- DEVELOPMENT
1. ARCHITECTURE
A computer/notebook will be required to use MasterTool X.
Figure 1. Computer running MasterTool X
2. DEVELOPMENT
TOF Timer (Timer Off Delay)
The TOF is a timer with a delay on de-energization. It is used when you want an output or logic condition to remain activated for a certain time after the input is turned off.
TOF Functionality
The TOF works as follows:
- When the IN input changes from FALSE to TRUE, the Q output is activated immediately, without delay.
- When the IN input changes from TRUE to FALSE, the timer starts counting.
- After the set time (PT – Preset Time) is reached:
- The Q output is deactivated.
- If the IN input returns to TRUE during counting:
- The timer is interrupted.
- The Q output remains TRUE.
That is, the delay occurs on shutdown, not on power-up.
TOF Insertion in Logic
The TOF block is a function block, therefore it cannot be inserted directly as a contact or coil.
To add it to the logic:
- Open the Toolbox.
- Access Function Blocks.
- Select TOF.
- Drag the block to the Ladder logic.
Figure 2. Inserting the TOF block
Timer variable declaration (required)
Because it is a function block, TOF requires an instance variable to store its internal state.
Example of naming:
tof_0 : TOF;Important:
This rule applies to all function blocks in MasterTool IEC XE.
Without this variable, the timer will not function correctly.
Figure 3. TOF block variable declaration
TOF inputs and outputs
The TOF block has the following variables:
Inputs
- IN (BOOL): Enables the timer. When TRUE, output Q remains active.
- PT (TIME): Delay time applied after the input is turned off.
Outputs
- Q (BOOL): Remains TRUE while IN is TRUE and during the time PT after IN goes to FALSE.
- ET (TIME): Indicates the elapsed time since the start of the shutdown countdown.
Use of variables in TOF parameters
- The input parameters (IN and PT) must be instantiated, as they feed the timer's operation.
- The output parameters (Q and ET) do not necessarily require the creation of variables, since their values can be viewed directly in the block itself during the logic execution.
Creating variables for the outputs is optional and only indicated when you want to reuse or monitor these values at other points in the program.
Time syntax (PT and ET)
Time can be configured using the IEC 61131-3 syntax, in the format:
- T#3s → 3 seconds
- T#500ms → 500 milliseconds
- T#1m → 1 minute
Important notes:
- Both T# and t# are accepted.
- The use of uppercase or lowercase letters does not alter the operation.
Figure 4. TOF Parameterization
Use of a time variable
If the programmer chooses not to use a constant value but a variable in the PT field:
- The time base used by the controller will be milliseconds (ms).
- That is, the value 1000 corresponds to 1 second.
To maintain clarity and avoid errors, it is recommended:
- Always use the T# syntax when the time is fixed
- Use variables only when the time needs to be adjustable at runtime
Figure 5. Use of a time variable directly in the TOF Block
Practical application
After assembling the logic with TOF:
- Download the application.
- Put the CPU in RUN mode.
- Activate the IN input.
- Observe:
- The Q output turns on immediately.
- When IN is turned off, the ET value starts counting.
- The Q output will only turn off after the PT time.
The TOF timer is essential in applications that require a delay in shutdown, such as post-process ventilation, safety timing, and controlled load shutdown.
Figure 6. TOF Block Operation
Comments
0 comments
Please sign in to leave a comment.