The objective of this tutorial is to explain how to use the TON function block, which is a timer with a delay on 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
TON is a timer with a delay on energization. It is used when you want an output or logical condition to be activated only after a certain time, counted from the moment the input is activated.
TON Functionality
The operation of TON is as follows:
- When the IN input changes from FALSE to TRUE, the timer starts counting the time.
- After the set time (PT – Preset Time) is reached, the Q output is activated.
- If the IN input returns to FALSE before the time expires:
- The count is canceled
- The Q output remains FALSE
- Turning off the IN input resets the timer.
Inserting the TON into the logic
The TON 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 TON.
- Drag the block to the Ladder logic.
Figure 2. Inserting the TON block
Timer variable declaration (required)
Because it is a function block, TON requires an instance variable to store its internal state.
Example of naming:
ton_0 : TON;Important:
This rule applies to all function blocks in MasterTool IEC XE.
Without this variable, the timer will not function correctly.
Figure 3. Declaration of the TON block variable
TON Inputs and Outputs
The TON block has the following variables:
- Inputs
- IN (BOOL): Enables the timer. When TRUE, it starts counting.
- PT (TIME): Preset time, i.e., the time that must be counted before activating the output.
- Outputs
- Q (BOOL): Becomes TRUE after the PT time is reached.
- ET (TIME): Elapsed time since the start of the count.
The input parameters (IN and PT) must be instantiated, that is, they need to receive an existing variable or a valid value, as they are what power the timer's operation.
Output parameters (Q and ET) do not necessarily require the creation of variables, as their values can be viewed directly in the block itself during logic execution.
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. TON Parameterization
Use of a variable in time
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 to:
- Always use T# syntax when the time is fixed.
- Use variables only when the time needs to be adjustable at runtime.
Figure 5. Direct use of a time variable in the TON Block
Practical Application
After assembling the logic with TON:
- Download the application.
- Put the CPU in RUN mode.
- Activate the IN input.
- Observe:
- The value of ET increasing until it reaches PT.
- The output Q being activated only after the configured time.
The TON timer is essential for creating controlled delays, ensuring correct sequencing, safety, and predictability in the operation of the logic.
Figure 6. Operation of the TON Block
Comments
0 comments
Please sign in to leave a comment.