The objective of this tutorial is to explain how to enable MasterTool X in simulation mode and write/force
values to variables declared in the logic.
Components
Equipment: 1 computer/notebook.
Software: MasterTool X
Tutorial Sections
1. ARCHITECTURE
2. DEVELOPMENT
1. ARCHITECTURE
A computer/notebook will be required to use MasterTool X.
Figure 1. Computer running MasterTool X
2. DEVELOPMENT
With the project already created and the logic implemented, the next step is to enable simulation mode, which allows you to run and test the program on a virtual PLC, without the need for physical hardware.
In the software's top menu, click on Online.
- Then, select the Simulation option to enable simulation mode.
- After activation, check the lower right field of the screen.
- An indicator with the word “Simulation” in red will be displayed, signaling that the software is operating in Simulation mode.
Figure 2. Enabling simulation mode in MasterTool X
With simulation mode enabled, return to the Online menu and click Login. This command downloads the application to the virtual PLC.
At this point, MasterTool IEC XE will compile the code, checking for syntax or logic errors. If any errors are found, the software will display messages indicating the problem for correction.
Figure 3. Downloading the application to the virtual PLC
During the login process, MasterTool IEC XE may display a message related to the source code.
The source code can be understood as a copy of the project, functioning as a backup of the code developed by the programmer. This source code is stored within the PLC, allowing the project to be recovered later directly from the equipment if the original file is lost. In simulation mode, this copy of the source code will not be sent, as the application is running on a virtual PLC, eliminating the need for permanent project storage.
Figure 4. Pop-up confirming the submission of the project source code
After compilation and login, the software will start with the CPU in STOP mode, which is the default safety state.
There are three ways to start the program execution:
- Access the Debug menu and select RUN
- Use the shortcut located in the upper corner of the software to put the CPU in RUN mode.
- Press the F5 key on the keyboard
From this moment on, the program will run cyclically on the virtual PLC, allowing simulation tests to be performed.
Figure 5. Menu to enable the CPU in RUN mode
Writing and forcing values in the Ladder logic
During program execution in simulation mode, it is possible to change the state of variables directly in the Ladder logic, allowing testing of the system's behavior.
To prepare the value to be applied, double-click on the contact in the logic. With each double-click, the software will alternate the value assigned to the contact in the following sequence:
- TRUE
- FALSE
- Empty value (no value assigned)
After selecting the desired value to be applied in the logic, the user has two operation possibilities: write value or force value.
Figure 6. Preparing value to write or force in the PLC logic
Difference between writing and forcing a value
Write value:
- The value is momentarily applied to the variable, but it continues to be controlled by the program logic. That is, the PLC can change this value in the next scan cycle, according to the implemented logic.
Force value:
- The value is imposed on the variable in a fixed way, regardless of the program logic. While the variable is forced, the program will not be able to modify it, making it ideal for specific tests.
Applying the Value to the Variable
After preparing the value in the contact, the operation can be performed in two ways:
- Access the Debug menu and select:
- Force Value or Write Value
- Or use the keyboard shortcuts:
- Force value: F7
- Write value: Ctrl + F7
The value will be applied immediately to the logic, allowing you to observe the behavior of the contacts and coils during the simulation.
Figure 7. Write/Force values command in the PLC in Simulation mode
To release a forced value, the user can use one of the options below:
- Access the Debug menu and click on Release Values.
- Use the keyboard shortcut Alt + F7.
After the release, the variable returns to being controlled normally by the program logic, respecting the conditions defined in the contacts and coils.
Attention: Always check that there are no forced values before starting a new simulation or before transferring the program to a real PLC.
Figure 8. Command to release forced values in the PLC in Simulation mode
Comments
0 comments
Please sign in to leave a comment.