The PLC clock is not a small detail. It is used in diagnostics, alarms, event logs, historical data and traceability. If each OT device has a different time, reconstructing what happened and in which order becomes painful.
In this example we will create a local Windows NTP server, point a Siemens S7-1500 PLC to it from TIA Portal, and verify the traffic with Wireshark.
1. What the PLC clock is
The PLC keeps an internal clock used as the timestamp reference for events. In TIA Portal we can set that clock from the PG/PC, for example when commissioning a CPU or after downloading a configuration.
Setting the time once from the PG/PC is useful for startup, but it is not continuous synchronization. If the PLC does not query a time source again, its clock runs on its own.
2. Why it drifts over time
The CPU keeps time with an internal oscillator. That oscillator is never mathematically perfect, and its frequency can vary because of manufacturing tolerance, temperature, aging and power conditions.
A small drift already matters when correlating diagnostics.
After one month, events can be almost one minute out of place.
Without resynchronization, the error accumulates during the life of the installation.
3. Synchronize with a time server
The right solution is for the PLC to periodically query an NTP time server. This keeps the important devices in the network aligned to the same reference.
Common options:
- Internal network server: for example, a domain controller or a central OT server. This is the usual plant approach.
- Dedicated NTP/PTP device: used when more precision or a GPS reference is required.
- External Internet server: fine for labs, but less common in isolated OT networks.
In TIA Portal V20, the setting path is:
- Open Device configuration.
- Select the CPU, in this example a CPU 1515-2 PN.
- Go to Properties > General > Time of day.
- Under Time-of-day synchronization, select Set NTP server in the project.
- Enter the NTP server IP, set the update interval, compile and download the hardware configuration.
4. Example: Windows as a local NTP server
For a lab test we will turn a Windows PC on the network into the time server. In production, the usual choice is a central OT or domain server.
Prepare Windows
Run PowerShell as administrator. First, check where the PC gets its time from:
w32tm /query /source
w32tm /query /status
Enable Windows as an NTP server and announce it as a valid time source:
Set-ItemProperty `
-Path "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer" `
-Name "Enabled" `
-Value 1
Set-ItemProperty `
-Path "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config" `
-Name "AnnounceFlags" `
-Value 5
Then keep the service available, restart it and open UDP port 123 for the local subnet only:
sc.exe triggerinfo w32time delete
Set-Service -Name W32Time -StartupType Automatic
Stop-Service -Name W32Time -Force
Start-Service -Name W32Time
New-NetFirewallRule `
-DisplayName "Servidor NTP para PLC" `
-Direction Inbound `
-Protocol UDP `
-LocalPort 123 `
-RemoteAddress LocalSubnet `
-Action Allow
Check that the service is running:
Get-Service W32Time
Test from another PC
From another machine on the same network, for example the TIA Portal machine, test against the server PC IP. In this example it is 192.168.1.134:
w32tm /stripchart /computer:192.168.1.134 /samples:5 /dataonly
Configure the PLC
Now the PLC must point to that time server. The PLC and the server must be on the same network, or routing to UDP 123 must be allowed.
In this example the server is defined directly in the TIA Portal project. Depending on the installation, it could also be provided by DHCP or configured from the display.
Download the configuration to the PLC. To confirm that the PLC follows the server, change the Windows server time manually and compare it with the module time in TIA Portal.
Validate with Wireshark
The final check is the traffic itself. In Wireshark, filter by ntp or udp.port == 123. You should see the PLC queries to the server and the NTP response from the PC.
The capture confirms that the PLC is querying the local NTP server over UDP 123.
Practical summary: do not leave the PLC clock depending only on a PG/PC download. Define a common NTP source for the OT network and validate that the traffic is arriving before considering it done.