The objective of this tutorial is to explain how to create a global variable list 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 GVL (Global Variable List) is used to declare global variables, that is, variables that can be accessed and used anywhere in the project, regardless of the POU (UserPrg, subroutines, functional blocks, or functions).
This feature is essential for sharing information between different logics, standardizing signals, and improving project organization.
Best Practices for Using GVLs
- Use GVLs for:
- Shared signals
- Global states
- Configuration parameters
- Avoid unnecessary global variables
- Use clear and standardized names
- Separate GVLs by purpose as the project grows
Accessing the GVL creation location
To create a GVL in the project:
- In the project tree, locate the UserGVLs item.
- Right-click on UserGVLs.
- Select the Add Object option.
- Choose Global Variable List.
Optionally, you can create folders for organization, but in this example the GVL will be created directly in UserGVLs.
Creating the global variable list
After selecting Global Variable List:
- Define a name for the GVL
Example: gvl_signals, gvl_control, gvl_io - Confirm the creation.
The software will automatically open the global variable declaration field.
Figure 2. Creating a GVL
Declaration of global variables
Within the GVL, variables must be declared in the same way as local variables:
start_button : BOOL;
tank_level : INT;
alarm_level : BOOL;All variables declared in this list become global, meaning:
- They do not need to be redeclared in other POUs
- They can be used directly in any project logic
Difference between global and local variables
| Local Variable | Global Variable |
| Visible only in the POU | Visible throughout the project |
| Specific use | Shared use |
| Declared in the POU | Declared in the GVL |
Figure 3. Creation of global variables
Use of global variables in the project
After creation, GVL variables can be:
- Used in UserPrg
- Used in subroutines
- Used in functional blocks
- Used in functions
- Associated with inputs and outputs
- Monitored and enforced during simulation
Simply reference the variable name normally in the logic.
The GVL (Global Variable List) is a fundamental tool for organizing and sharing data in the project, allowing different parts of the application to communicate clearly, in a standardized and efficient way.
Figure 4. Calling global variables via UserPrg
Comments
0 comments
Please sign in to leave a comment.