The objective of this tutorial is to explain how to use special variables 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
Special variables are variables automatically created by the system, used to provide internal PLC information or ready-to-use signals in the logic, such as periodic pulses and time and date data.
These variables:
- Are predefined by the system
- Are global
- Can be used anywhere in the project
- Are organized in the project tree
Where to find the Special Variables
Special variables are located in the project tree in:
System GVLs - (System Global Variable Lists)
Within this folder, the user will find:
- Pulsating variables (clock/pulse)
- Variables related to the RTC (Real Time Clock)
Because they are global, it is not necessary to declare them in any POU or in UserPrg; simply use them directly in the logic.
Figure 2. Special Variables Menu
Pulsating Variables
Pulsating variables are signals automatically generated by the PLC, with periodic behavior, very useful for:
- Signaling flashes
- Simple timings
- Logic tests
- Generation of cyclical events without the use of timers
Example: Pulse_2s variable
Despite the name Pulse_2s, it is important to understand its operation correctly.
This variable does not stay on for 2 seconds and then off for 2 seconds.
It generates a square wave, that is:
- 1 second at TRUE level (on)
- 1 second at FALSE level (off)
Totaling a period of 2 seconds.
This behavior is typical of a square wave, where the on time is equal to the off time.
RTC (Real-Time Clock) Variables
The variables related to the RTC (Real-Time Clock) provide information such as:
- Year
- Month
- Day
- Hour
- Minute
- Second
- Day of the week
Important note about the RTC
RTC variables only function correctly when used in physical equipment.
In simulation mode:
- There is no real synchronization with an internal clock
- The values may not reflect the actual time behavior
Correct synchronization depends on the PLC's internal clock, which exists only in the physical hardware.
Typical Applications of RTC Variables
- Time-based logic
- Scheduling
- Daily counters
- Event logging
- Date and time-dependent systems
Figure 3. Operation of special variables
Practical example in UserPrg
In UserPrg, a pulsed variable can be used directly as a contact:
- Insert a normally open contact
- Assign the variable pulse2s
- Connect this contact to a coil
Operation:
- Every 1 second the coil turns on
- In the following second the coil turns off
- The cycle repeats continuously while the PLC is in RUN
This feature eliminates the need to use a TON block just to blink an output.
Figure 4. Use of special variables in UserPrg logic
Advantages of using Special Variables
- They do not require declaration
- They are global
- They reduce the use of timers and counters
- They facilitate testing and diagnostics
- They increase the clarity of the logic
Final observation
Whenever possible:
- Use pulsed variables for simple timing logic
- Use RTC only in environments with a physical PLC
- Avoid recreating solutions that the system itself already provides in an optimized way
This feature makes the code cleaner, more efficient, and easier to maintain.
Comments
0 comments
Please sign in to leave a comment.