The objective of this tutorial is to explain how to use Boolean operators with XOR and NOT functionality 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 Boolean operators XOR and NOT are used to create specific logical conditions, being very useful in situations where it is necessary to detect differences between signals or invert logical states.
Both operate exclusively with variables of type BOOL.
XOR Operator (2 Inputs)
Operating Concept
The XOR (Exclusive OR) operator returns:
- TRUE → when only one of the inputs is TRUE
- FALSE → when both inputs are equal (both TRUE or both FALSE)
Simplified logic table:
| A | B | XOR |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
This operator is widely used for:
Detecting different states
Logical alternation
Exclusive comparisons
Inserting XOR into logic
To add the XOR operator (2 inputs):
Open the Toolbox.
Access Boolean Operators.
Select XOR (2 inputs).
Click and drag the block to the Ladder logic.
After insertion, simply parameterize the two inputs and connect the output to a coil or BOOL variable.
Figure 2. Insertion of the Boolean XOR operator
NOT Operator
Operating Concept
The NOT operator performs the logical negation of an input:
- Input TRUE → output FALSE
- Input FALSE → output TRUE
It is used when you want to invert the logical state of a signal.
Correct way to insert NOT in logic
The NOT operator does not appear directly in the Toolbox as an individual block. Therefore, it must be inserted inside an empty box with EN/ENO.
Inserting the empty box with EN/ENO
There are two ways to add the empty box:
Option 1 – Right-click
- Create a new network.
- Right-click on the line.
- Select Insert Empty Box with EN/ENO.
Option 2 – Toolbox
- Open the Toolbox.
- Access the General tab.
- Select Box with EN/ENO.
- Drag to logic.
Calling the NOT operator inside the box
After inserting the box with EN/ENO:
- Click inside the box.
- Type the name of the NOT operator.
- The software will recognize the operator and associate it with the box.
- Parameterize:
- Input: BOOL variable
- Output: BOOL variable or coil
Figure 3. Insertion of the Boolean operator NOT
Parameterization of inputs and outputs
Inputs
- The operator inputs (IN1, IN2, IN3) must be of type BOOL
- They can receive:
- Boolean variables
- TRUE or FALSE constants
- Outputs from contacts or logic blocks
Output
- The output (Q) is of type BOOL
- Because it is not a function block, the output must be connected:
- To a BOOL variable
- Or directly to a coil
Unlike function blocks, these operators do not maintain an internal state, functioning only as instantaneous logic processing.
Use in Ladder Logic
The AND and OR operators are used to:
- Group multiple conditions into a single point
- Reduce excessive parallel and series connections
- Improve logic readability
- Centralize complex logical decisions
They can be connected:
- In series with other blocks
- In parallel
- Directly to coils
Figure 4. Parameterization of the Boolean XOR and NOT operators
Practical use in logic
- XOR:
- When two signals cannot be active at the same time
- Detection of the difference between two states
- NOT:
- Inversion of sensors
- Denial of permissions
- Simplification of logic with normally closed contacts
Practical application
After assembling the logic:
- Download the application.
- Put the CPU in RUN mode.
- Change the input values.
- Note:
- On the XOR: the output is only active when an input is TRUE
- On the NOT: the output will always be the inverse of the input
The XOR and NOT operators are essential features for advanced logic control, allowing greater flexibility, clarity, and precision in Ladder programming.
Figure 5. Boolean XOR and NOT operators in operation
Comments
0 comments
Please sign in to leave a comment.