Problem Description
On a SIMATIC IPC 477E running WinCC Runtime Advanced V17, an S7-1500 CPU (variant identified by the operator as 2FN03) loses the configured date/time every time the WinCC Runtime is stopped and the PC is rebooted. After the restart, the CPU clock reads one or more hours behind the value previously written by the controller application.
Symptoms reported in the field:
- The controller's time is correct while the Runtime is running.
- As soon as the PC is restarted (or WinCC Runtime is stopped/started), the S7-1500 clock reverts to a value that is typically one or two hours in the past.
- The drift persists even though the application uses
WR_SYS_T(write system time) andRD_SYS_T(read system time) in the PLC program. - No NTP client, no area pointer, and no HMI time synchronization had been configured by the operator.
Root Cause Analysis
The S7-1500 stores and processes time in two parallel representations. Mixing them is the most common source of the drift described above.
System time versus local time on S7-1500
| Function | Meaning | Format | Time base |
|---|---|---|---|
RD_SYS_T / WR_SYS_T
|
Read / Write system time | DTL (DATE_AND_TIME_LOC) without timezone tag | UTC (Coordinated Universal Time) |
RD_LOC_T / WR_LOC_T
|
Read / Write local time | DTL with implicit local-time semantics | Local time including DST offset |
SET_TIMEZONE (SCL FB) |
Sets the timezone rule the CPU uses when converting between UTC and local | Rule table (DST rules, GMT offset) | Local time |
From the S7-1500 System Manual (section "Time functions" in the basic/advanced controller manuals):
"The CPU always operates internally in UTC. The current local time is derived from UTC and the configured timezone rule.WR_SYS_Twrites a UTC timestamp;WR_LOC_Twrites a local timestamp that the CPU then converts to UTC before storing it."
Two conditions have to be true for the runtime clock to stay aligned with wall time across a Runtime/PC restart:
- The value the application writes must be in the same time base (UTC or local) that the application later reads back.
- For local-time operations, the timezone rule on the CPU (and on the Windows side that feeds it) must match the geographic zone, including the active DST state at the moment of write.
What actually drifts on the IPC 477E
The IPC 477E uses Windows IoT / Windows 10 IoT Enterprise as the operating system. WinCC Runtime Advanced uses the Windows system clock as its source of time and, depending on configuration, may also push or pull time into the connected PLC. When the Runtime is stopped and the PC is restarted, the Windows clock is resynchronized with whatever time source is reachable. On an isolated machine with no NTP and no CMOS battery-backed RTC update, the Windows clock can:
- Lose the RTC value (CMOS battery discharged on the IPC's motherboard).
- Fall back to an older time value if the Windows Time service (
w32time) reverts to a previously persisted time after a forced resync. See the Microsoft troubleshooting note Computer clock resets to a previous date and time for the documented mechanism. - Apply a different DST offset than the S7-1500, producing a one or two-hour delta at every Runtime start.
The PLC program only writes once per session with WR_SYS_T. Once the Runtime shuts down, the controller no longer has any way to refresh its clock, so it free-runs on its own hardware RTC. The RTC is reasonably accurate (typically ±20 ppm on the S7-1500), but if it was initialized with a UTC value, the local time that the HMI displays can be off by exactly the timezone offset at the moment of read.
Solution: Switch to Local-Time Functions and Reconcile the Two Clocks
The confirmed fix reported in the field is to replace the time read/write functions in the S7-1500 program with the local-time variants and to keep the timezone configuration in sync between the CPU and the IPC.
Step 1 – Use RD_LOC_T and WR_LOC_T in the PLC program
Inside TIA Portal, locate the blocks that call WR_SYS_T and RD_SYS_T and replace them with their local-time counterparts. The function blocks are in the same library path (Basic Instructions → Date and Time).
| Original (UTC) | Replacement (Local) | Effect |
|---|---|---|
CALL WR_SYS_TRET_VAL := #status LOCTIME := #dtl_utc; // #dtl_utc was filled with a "local-feeling" value |
CALL WR_LOC_TRET_VAL := #status LOCTIME := #dtl_local; |
CPU accepts the timestamp as local time and stores the equivalent UTC internally. No double-offset when read back. |
CALL RD_SYS_TRET_VAL := #status LOCTIME := #dtl_utc; |
CALL RD_LOC_TRET_VAL := #status LOCTIME := #dtl_local; |
HMI receives a value that already includes the DST/zone offset, matching what the operator sees on the panel. |
Both calls return a RET_VAL word. A non-zero value is an error code (for example W#16#0001 = invalid LOCTIME input, W#16#0002 = parameter error). The ladder snippet below shows the corrected pattern in FBD/GRAPH-friendly form:
// Acquire local time once per scan (or on demand)
"RD_LOC_T_DB".RET_VAL := ; // status output
"RD_LOC_T_DB".LOCTIME := #dtl_local;
IF #btn_set_time THEN
// #dtl_local is built from a WinCC tag or from an HMI input
// whose value already represents local time
"WR_LOC_T_DB".LOCTIME := #dtl_local;
"WR_LOC_T_DB".RET_VAL := ; // status output
#btn_set_time := FALSE;
END_IF;
Step 2 – Verify the S7-1500 timezone configuration
Open Device configuration → Properties → General → Time of day for the S7-1500 in TIA Portal and confirm:
- Time zone is set to the operating site's local zone (for example "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna").
- Daylight saving time / standard time conversion is enabled if the country observes DST.
- The Time zone entry actually downloads to the CPU (TIA Portal writes the rule on every download; you can read it back under Online & Diagnostics → Time of day).
For an S7-1500, the timezone rule is held in the CPU's non-volatile memory; however, after a firmware update or an MRES (memory reset) the rule is restored to UTC. Always re-check after an MRES.
Step 3 – Align the Windows timezone on the IPC 477E
The WinCC Runtime reads time from the Windows system clock, so the Windows timezone must match the PLC timezone. On the IPC 477E:
- Open Control Panel → Clock and Region → Date and Time → Change time zone.
- Set the same time zone as the PLC and enable Automatically adjust clock for Daylight Saving Time.
- Disable any Set time automatically Internet time toggle while troubleshooting so the Windows clock is not being pulled from a public NTP source that disagrees with the PLC's rule.
- If the IPC's CMOS battery is end-of-life, replace it; otherwise the Windows clock loses the time when the IPC is unpowered. The Microsoft knowledge base article Computer clock resets to a previous date and time describes how
w32timecan re-apply an old time value when the registry is in a bad state; clear theW32Timeparameters underHKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parametersand force a resync withw32tm /resync /force.
Step 4 – Confirm no conflicting time sync is active
Before declaring the fix complete, rule out any of the mechanisms that can also push the S7-1500 clock without your knowledge:
- Area pointer "Date/Time PLC" in the WinCC RT Advanced connection. If it is enabled, the Runtime writes the Windows clock into the PLC at every Runtime start. Open Connections → [your HMI connection] → Area pointer and disable it unless you want that behavior.
- Time synchronization mode in the HMI connection. Master means the HMI pushes time to the PLC; Slave means the HMI reads time from the PLC. Set the role explicitly and document it.
- NTP client on the PLC (S7-1500 supports NTP from firmware V2.0 onward). If an NTP server is configured in the CPU's PROFINET interface and that server disagrees with the Windows time, the PLC will free-run on the NTP value at the next resync.
-
NTP client on Windows. The
w32timeservice can be configured as an NTP client; if the source time differs from the PLC's timezone rule, you will see the exact one- or two-hour drift described above.
Alternative Solutions
If, for any reason, you cannot modify the PLC program (brownfield machine, validated code base), there are three alternative approaches. Each has trade-offs.
Alternative A – NTP for the S7-1500 only
Configure the CPU as an NTP client and point it at a local NTP server that the operator controls. NTP keeps the CPU's UTC clock aligned at all times, so the drift after a Runtime restart disappears. This is the cleanest solution if you can put a stable NTP source on the plant network. The CPU's NTP configuration lives under Device configuration → PROFINET interface → Time-of-day synchronization and requires that the CPUs NTP client be enabled and that the firewall allow UDP port 123.
Alternative B – NTP for the IPC only
Configure the IPC's w32time service as an NTP client to a local server, leave the area pointer and time sync mode at their defaults, and accept that WinCC pushes the Windows time into the PLC on every Runtime start. This gives you a single source of truth (the NTP server) without touching the PLC program.
Alternative C – Keep the area pointer, fix the Windows side
If business rules require that the PLC is always slaved to the panel clock, enable the area pointer and set the connection time synchronization mode to Master on the HMI side. The PLC then never holds an independent time, eliminating the drift entirely. The catch is that the panel must always be running, so any PLC-side logging in the gap between Runtime restarts will be wrong.
Verification
After applying the local-time function block change and aligning the timezones, perform the following checks. The expected result for every step is a PLC time within ±1 second of the IPC's local time immediately after a Runtime start.
- Online readback of CPU time. In TIA Portal, go to Online → Online & Diagnostics → Time of day. Note the displayed local time.
-
PLC tag readback. Monitor the DTL tag fed by
RD_LOC_Tin the HMI. The value must match the CPU's online view, including DST offset. - Windows clock readback. Open the Windows clock applet on the IPC. The value must match the PLC to the second.
- Restart test. Stop the WinCC Runtime, restart the IPC, log in, and re-read all three values. They must still match.
- DST boundary test (optional but recommended for plants in DST zones). Set the IPC and PLC clock to a date 5 minutes before the next DST transition. Restart the Runtime. After the transition, the local-time tags must advance by exactly one hour with no manual intervention.
- Drift test. Leave the Runtime running for 24 hours. The PLC's local time, the IPC's Windows time, and a reference NTP-displaying client must all agree within ±2 seconds. A deviation larger than ±5 seconds points to a hardware RTC issue on the IPC, not a function-block issue.
Field-Proven Diagnostic Procedure
When a customer reports that "the PLC clock goes back after Runtime restart", walk through this decision tree in order.
| Step | Check | Expected / Acceptable | If failing, action |
|---|---|---|---|
| 1 | Which time block is in the PLC program? |
RD_LOC_T / WR_LOC_T
|
Replace RD_SYS_T / WR_SYS_T with the local-time variants. |
| 2 | PLC timezone rule | Matches the plant zone, DST enabled if applicable | Re-download the device configuration; verify online. |
| 3 | Windows timezone on the IPC | Matches the PLC zone | Reconfigure Windows time zone; reboot. |
| 4 | CMOS battery on the IPC | Voltage within spec (> 2.7 V under load) | Replace the IPC's motherboard battery. |
| 5 | Area pointer "Date/Time PLC" | Disabled, or consciously enabled | Disable unless Master/Slave is intentional. |
| 6 | HMI connection time sync mode | Set to None or to a documented role | Set explicitly; do not leave at the project default. |
| 7 | NTP client on PLC | Either disabled or pointed at a controlled server | Configure or disable per the time architecture. |
| 8 | Windows w32time service |
Reachable NTP source, no stale registry | Reset the W32Time registry; force resync per Microsoft KB. |
| 9 | Re-test after a Runtime restart | All three clocks within ±1 s | If still drifting, capture an online trace of the CPU's time-of-day buffer and open a Siemens Support Request (SR). |
Why the Drift Can Be Exactly One or Two Hours
The "two hours back" symptom is not random. It is almost always a UTC/local mismatch combined with a DST state that is different on the two devices. The most common combinations on a European plant are:
| PLC zone setting | Windows zone setting | Effect after Runtime restart |
|---|---|---|
| UTC+1, DST enabled | UTC+1, DST enabled | No drift. |
| UTC (no offset) | UTC+1, DST enabled | PLC reads 1 hour behind Windows in winter, 2 hours in summer. |
| UTC+1, DST enabled | UTC (no offset) | PLC reads 1 hour ahead of Windows in winter, 2 hours in summer. |
| UTC+1, DST disabled | UTC+1, DST enabled | Drift toggles between 0 and 1 hour at the DST boundary. |
| UTC+1, DST enabled, wrong DST rule (e.g. US dates) | UTC+1, DST enabled (EU rule) | Drift jumps to 0 or 1 hour on the US/EU transition dates and stays off for ~6 months. |
That is why the operator sees the time "go back two hours" when the Runtime is restarted after a DST transition has occurred on the Windows side but not yet on the PLC side (or vice versa).
Safety and Data Integrity Notes
- Time jumps of exactly one hour near a DST boundary are expected and are not a defect. Audit logs that require monotonic timestamps must store UTC, not local time.
- Do not enable both the area pointer and an NTP client that point at different sources. The two writers will race, and the CPU will free-run on whichever wrote last.
- When validating pharmaceutical or food-and-beverage lines, the time base used for batch records must be documented. Mixing UTC and local in a single recipe is a common 21 CFR Part 11 finding.
- After any PLC firmware update, re-verify the timezone rule. Some firmware versions reset the rule on first boot.
FAQ
What is the difference between RD_SYS_T and RD_LOC_T on the S7-1500?
RD_SYS_T returns the CPU's UTC time as a DTL value, while RD_LOC_T returns the local time, which is UTC adjusted by the CPU's configured timezone and DST rule. Use RD_LOC_T / WR_LOC_T when the value will be displayed to an operator or written from a panel that thinks in local time.
Why does my S7-1500 lose the time after every WinCC Runtime restart?
The PLC keeps its own hardware RTC, but its value is only reloaded from the controller program or from a time sync source. If the application uses WR_SYS_T with a UTC value and the HMI later displays that value as if it were local time, the displayed clock will be off by the timezone offset as soon as the Runtime restarts. Switch to WR_LOC_T / RD_LOC_T and align the PLC and Windows timezones.
Do I have to use NTP for WinCC Runtime Advanced on an IPC 477E?
No, NTP is optional. The Runtime can rely on the Windows system clock, on a PLC time pushed via the area pointer, or on an NTP server. The rule is to pick exactly one source of truth and document it. NTP is the most robust choice if a plant-wide time server is available.
How do I disable the area pointer that pushes the Windows time into the PLC?
In TIA Portal, open the HMI device configuration, select the S7 connection, and clear the "Date/Time PLC" area pointer. Also set the connection's time synchronization mode to None unless you specifically want the HMI to act as master or slave. Recompile and download the Runtime project.
What should I check first if the drift is exactly two hours?
Two-hour drift on a European site is a UTC/local mismatch, almost always a missing or stale DST rule on either the CPU or the Windows side. Verify both timezones, verify the DST setting on each device, and replace WR_SYS_T / RD_SYS_T with the local-time function blocks in the PLC program.