The purpose of this tutorial is to explain how to adjust the XF real-time clock using a function block via MasterTool X.
Components
Equipment: 1 computer/laptop.
Software: MasterTool X
Tutorial Sections
- ARCHITECTURE
- DEVELOPMENT
1. ARCHITECTURE
A computer/laptop will be required to use MasterTool X.
Figure 1. Computer running MasterTool X
2. DEVELOPMENT
The adjustment of RTC (Real Time Clock) variables can also be performed via programming logic, using function blocks, which is very useful in applications where date and time need to be updated automatically by the system.
Concept
The setDateAndTime block allows writing new values directly to the PLC's internal clock from the logic.
This method is used when you want to:
- Automatically adjust date/time
- Synchronize via supervisory system
- Programmed control of the RTC
Inserting the block into the logic
To use the block:
- Create a new network
- Insert an empty box (EN/ENO)
- Inside the box, type:
setDateAndTime
Figure 2. Adding the RTC adjustment function block
Main inputs
Request (BOOL)
- Responsible for executing the command
- Must make a transition from FALSE to TRUE
DateAndTime (structure)
- Set of variables representing:
- Year
- Month
- Day
- Hour
- Minutes
- Seconds
- These values must be pre-configured by the user
Operation
The block works as follows:
- The user sets the desired values in the DateAndTime structure
- While Request = FALSE, no action is taken
- When the transition from FALSE → TRUE occurs:
- The configured values are sent to the PLC's RTC
- The internal clock is updated
Figure 3. Configuring the RTC variables adjustment block
Important note about the Request
- The sending occurs only on the rising edge
- Keeping Request always TRUE does not generate new sends
- It is necessary to switch to FALSE and then TRUE again to update
Figure 4. RTC variables adjustment via function block
Practical application
Example of use:
- Automatically adjust the time when starting the system
- Receive date/time from a supervisory system
- Synchronize multiple devices
Important notes
- Works only with physical PLC
- Requires correct logic for triggering the Request
- Values must be correctly filled before sending
- May impact time-dependent systems
Comments
0 comments
Please sign in to leave a comment.