The objective of this tutorial is to explain how to use the R_Trig and F_Trig function blocks 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
The R_TRIG and F_TRIG blocks are used to detect changes in the state of a digital signal, generating a pulse of only one sweep cycle when the desired transition occurs. They are widely used to avoid multiple triggers in button commands.
Block Operation
R_TRIG (Rising Trigger)
- Detects the transition from FALSE to TRUE.
- Generates a TRUE logic pulse for only one PLC cycle.
- Even if the signal remains TRUE, the output returns to FALSE in the next cycle.
Typical use: generating a single command when pressing a button.
Figure 2. R_Trig Block
F_TRIG (Falling Trigger)
- Detects the transition from TRUE to FALSE.
- Generates a TRUE pulse for only one cycle.
- Used when the action should occur when the signal is released.
Figure 3. F_Trig Block
Inserting blocks into the logic
The R_TRIG and F_TRIG blocks are not inserted as contacts or coils.
To add them:
- Open the Toolbox.
- Access Function Blocks.
- Select R_TRIG or F_TRIG.
- Drag the block to the Ladder logic.
- Associate the block with the previously declared instance variable.
In this tutorial:
- Use one line (network) for each block.
- Insert a contact connected to the block's input, facilitating visualization and testing.
Figure 4. Insertion of function blocks in the logic
Declaration of the block variable (mandatory)
Because it is a function block, R_TRIG and F_TRIG must have a variable to reference their instance.
- This variable represents the block's internal memory.
- It must be declared before use, in the variables area.
- The variable type must be exactly the block name.
Conceptual example:
- For an R_TRIG → variable of type R_TRIG
- For an F_TRIG → variable of type F_TRIG
Important:
This rule applies to all function blocks in MasterTool IEC XE.
Without the instance variable, the block does not function correctly because it cannot store its internal state.
Figure 5. Declaration of variables in the function block
Basic structure of the block
- CLK (input): signal to be monitored.
- Q (output): pulse generated by only one scan cycle.
Download and testing
After assembling the logic:
- Download the application.
- Put the CPU in RUN mode.
- Activate the contact connected to the block.
- Observe:
- R_TRIG generates a pulse only on the rising edge.
- F_TRIG generates a pulse only on the falling edge.
Figure 6. Operation of the R_Trig and F_Trig blocks
Final observation
Even if the contact remains activated, the block output:
- Does not remain continuously on
- Acts only at the instant of the state chang
The R_TRIG and F_TRIG blocks are fundamental for creating robust, predictable, and professional logic, avoiding repeated activations and unwanted behaviors.
Comments
0 comments
Please sign in to leave a comment.