Configuring S7-1200 NTP Time Synchronization with DST in TIA

David Krause11 min read
S7-1200SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

1. Overview

Reading the real-time clock from a SIMATIC S7-1200 CPU is not as trivial as calling a single instruction. The PLC maintains two distinct notions of time: a system time (UTC, monotonically referenced) and a local time (wall-clock time adjusted for the configured time zone and daylight saving rules). Without an external time reference, the on-board hardware RTC drifts at a rate of typically ±2.5 s/day, which accumulates to several minutes per month. For applications that log events at roughly 100 transitions per day with second-level accuracy, the RTC alone is not adequate.

This reference describes how to:

  • Distinguish RD_SYS_T from RD_LOC_T and select the correct block for a given use case.
  • Configure NTP synchronization on a CPU 1214C DC/DC/DC (6ES7 214-1AG40-0XB0) under TIA Portal V16.
  • Set the local time zone and DST rules in the device configuration.
  • Verify synchronization through the diagnostic buffer and online watch tables.
  • Resolve the most common NTP/DST faults (firewall blocks, wrong UTC offset, mixed-protocol networks).
Operational rule: "Set the time once with a laptop" is not a viable long-term strategy. The drift, plus DST transitions handled manually every six months, inevitably produces out-of-order or duplicated event timestamps. Always plan for an NTP source during commissioning.

2. Prerequisites

Item Requirement Notes
PLC model CPU 1214C DC/DC/DC Order number 6ES7 214-1AG40-0XB0
Firmware V4.2 or later NTP client is supported in firmware V4.0+; V4.2 is the minimum recommended for TIA Portal V16 stability
Engineering software TIA Portal V16 (or V16 Update 7+) Matches the firmware V4.2 CPU family
NTP server Any RFC 5905 compliant NTP or SNTP server Windows Time service, ntpd, chrony, Siemens SICLOCK, or a router-integrated NTP daemon
Network reachability UDP/123 from the PLC to the NTP server Industrial firewalls (Fortinet, Palo Alto, Siemens SCALANCE) must allow outbound NTP
Project access Online connection to the PLC Required for hardware configuration download and online diagnostics

3. S7-1200 Time Architecture

The S7-1200 keeps three coordinated concepts of time that engineers routinely confuse:

Concept Storage Time zone offset DST applied? Drift source
Hardware RTC Battery-backed, on the CPU None - monotonic UTC-like counter No Crystal tolerance, ±2.5 s/day typical, ±10 s/day worst case across full temperature range
System time (UTC) Soft-synchronized to RTC, updated by NTP when configured Always 0 (UTC reference) No Drift of underlying RTC; NTP corrects it
Local time Computed from system time + time zone + DST rules Configurable (e.g., UTC-05:00 / UTC-04:00) Yes, per configured DST start/stop Inherits system-time drift; DST rules read from project

The PLC evaluates system time whenever RD_SYS_T is executed. Local time is evaluated only at the moment RD_LOC_T (SFC 19) runs; it does not change the underlying system clock.

4. Time and Date Data Types

All S7-1200 time instructions return a DTL (Date_Time_Long) structure, which is the only data type that fully captures year-to-nanosecond resolution. Auxiliary types are used in arithmetic.

Type Size Range / Resolution Typical Use
DTL 12 bytes 1970-01-01 00:00:00.000000000 to 2554-12-31 23:59:59.999999999 Wall-clock timestamps, event logs
DATE 2 bytes D#1990-01-01 to D#2168-12-31 (days since 1990-01-01) Date-only calculations
TIME_OF_DAY (TOD) 4 bytes TOD#00:00:00.000 to TOD#23:59:59.999 Time-of-day only, no date
DT (DATE_AND_TIME) 8 bytes DT#1990-01-01 00:00:00.000 to DT#2089-12-31 23:59:59.999 Legacy legacy STEP 7 type
TIME 4 bytes T#-24d20h31m23s648ms to T#+24d20h31m23s647ms (signed ms) Timers, durations, IEC counter math

Per the TIA Portal S7-1200 manual, TIME data is stored as a signed double integer interpreted as milliseconds, and the editor display uses d, h, m, s, ms, ns tokens. Conversion to DTL uses DT_TO_DTL; arithmetic uses T_ADD for adding durations or T_SUB for differences.

Reference: S7-1200 Programmable Controller - System Manual (chapter on basic PLC concepts, data types)

5. RD_SYS_T vs RD_LOC_T - Block-by-Block Comparison

Aspect RD_SYS_T (SFC 1) - Read System Clock RD_LOC_T (SFC 19) - Read Local Time
Returns System (UTC) time as DTL Local time as DTL, DST-corrected
Time zone Always UTC; no offset applied Applies the configured local time zone
DST handling None Yes - reads the configured DST rules and inserts/withdraws one hour at the configured transitions
Use when Sequencing scheduled events regardless of geography, comparing logs from multiple plants, post-processing timestamps in UTC Displaying wall-clock time to operators, scheduling work shifts, applying DST-aware tariff logic
Companion write WR_SYS_T (SFC 0) WR_LOC_T (SFC 18)
Input None None (uses configured rules)
Output OUT : DTL RET_VAL : INT (status) + OUT : DTL

In SCL, declare a tag tEventTime : DTL; at the rising edge of the input, then call RD_LOC_T(OUT => tEventTime);. The block reads the configuration that was downloaded as part of the hardware setup (Properties > Time of day > Local time zone > DST rules), so the program code never has to be modified for DST transitions.

Common mistake: engineers call RD_SYS_T believing they will receive "the time the operator sees." The system time is unaffected by the DST tick, so the wall-clock display drifts one hour twice a year for the entire DST season. Use RD_LOC_T when the resulting value is shown to a person.

6. Configuring NTP Synchronization in TIA Portal V16

  1. Open the project in TIA Portal and select the CPU in the project tree.
  2. Open Device Configuration and switch to Properties > General > Time of day.
  3. Tick "Synchronize the time of day via NTP server". This is a single checkbox; everything below becomes available.
  4. Click Add NTP server and enter:
    • IP address: the IPv4 address of the NTP source (e.g., a Windows domain controller at 10.20.30.5, or a SICLOCK at 10.20.30.10).
    • Port: default 123 (only change if the server is non-standard).
    • Update interval: 10 s is a reasonable starting point. Smaller intervals increase CPU utilization marginally; larger intervals tolerate more network loss.
  5. Compile and download the hardware configuration.

The PLC behaves as an NTP client in symmetric mode. On every interval it sends a request, calculates the round-trip delay and offset, and slews the system clock by slewing rather than stepping for offsets under 1 second. Larger offsets trigger a step. Every accepted update is logged into the diagnostic buffer as event ID 0xE0FE0001 ("Time successfully synchronized"); each rejection or timeout is logged as 0xE0FE0002.

Reference: NTP Time Synchronization with S7-1200 / S7-1500 - Siemens FAQ

7. Configuring Time Zone and DST in the PLC

Even with NTP, local-time arithmetic still requires time-zone and DST rules. Without them, RD_LOC_T returns a value that is offset by the wrong number of hours and DST transitions are silently skipped.

  1. Device Configuration > Properties > Time of day.
  2. Set Local time zone: e.g., (UTC-05:00) Eastern Standard Time (US & Canada).
  3. Under Daylight saving time settings, tick Activate daylight saving time.
  4. Enter the DST start rule (e.g., Second Sunday of March, 02:00 local standard time).
  5. Enter the DST end rule (e.g., First Sunday of November, 02:00 local standard time).
  6. Enter the time offset (typically 60 minutes = 1 hour).

Download the hardware configuration to the PLC. The rule set is stored in non-volatile configuration memory and survives power cycle.

EU vs US rules: Europe uses the last Sunday of March / October; the United States uses the second Sunday of March / first Sunday of November. The PLC will not automatically detect which country you are in. Wrong rules mean your operators see a 1-hour error in spring or autumn that no NTP update will ever fix.

8. Application Example: Event Time Stamping

The following SCL snippet produces a 12-byte DTL log each time a discrete input rises. It is engineered for an OB (e.g., OB1 or OB200) that runs cyclically and uses edge detection on an input tag iEvent : BOOL;.

// SCL example for rising-edge time stamping using RD_LOC_T
VAR
    tEventTime : DTL;       // wall-clock timestamp
    bPrevEvent : BOOL;      // edge memory
    arrLog : ARRAY[1..500] OF DTL;
    nIdx    : INT := 1;
END_VAR

IF iEvent AND NOT bPrevEvent THEN
    RD_LOC_T(RET_VAL := _dummy_ret_, OUT => tEventTime);
    arrLog[nIdx] := tEventTime;
    nIdx := nIdx + 1;
    IF nIdx > 500 THEN nIdx := 1; END_IF;
END_IF;
bPrevEvent := iEvent;

The complementary block uses RD_SYS_T when logs from multiple sites are consolidated in UTC:

RD_SYS_T(OUT => tEventTimeUtc);

9. Verification and Diagnostics

After downloading the configuration:

  1. Go Online and force the diagnostic buffer view (Project tree > right-click CPU > Online & Diagnostics > Diagnostic buffer).
  2. Look for 0xE0FE0001 with a recent timestamp. Absence of this event means NTP is not working.
  3. Open a watch table and observe the system time tag. Compare it to an authoritative UTC source (e.g., time.is). Drift between updates should be <1 s on a stable network.
  4. Verify DST behavior at the seasonal crossover - the clock should step at exactly 02:00 local on the configured date. TIA Portal does not provide a built-in DST simulator; the test must wait for the real transition or be forced by an NTP server with a fictional time.

Reference: How to Evaluate the Diagnostic Buffer Entries of S7-1200/S7-1500 Regarding NTP Synchronization - Siemens FAQ

10. Troubleshooting Matrix

Symptom Diagnostic Buffer Event Likely Cause Fix
Clock drifts several seconds per day No NTP events at all NTP not enabled in device configuration Re-check the checkbox under Time of day, recompile, and download
Updates intermittently appear, mostly fail 0xE0FE0002 "NTP error" UDP/123 blocked by firewall Add an outbound rule on the network firewall permitting UDP source 123 from PLC to NTP server, or temporarily disable the PC firewall for verification
Time is exactly 1 h off 0xE0FE0001 OK Time zone set incorrectly, or DST rules not active Open Time of day and switch the local time zone; tick "Activate daylight saving time" if your region observes DST
Time jumps at wrong date 0xE0FE0001 OK Wrong start/end rule (e.g., EU rules on a US plant) Re-enter DST rules matching your region's legislation
Time is exactly 4 minutes off on every poll 0xE0FE0001 OK but with offset Network round-trip-time asymmetry, server under load Move to a closer NTP server or increase the polling interval to dampen jitter
Programs cannot read time RET_VAL of RD_LOC_T non-zero Time not yet synchronized after cold start Delay reads by 60 s after PLC boot, or poll the status output of the NTP block
Time shows year 1970 or 2000 Often coincident with battery alarm Empty RTC backup capacitor or no battery installed Install / replace the BB 1297 battery; on cold-start, RTC may be set to default date 01.01.2000 until NTP arrives

11. Best Practices

  • Two-tier time strategy: keep one RD_LOC_T tag for operator-facing displays and one RD_SYS_T tag for event logs destined for cross-plant aggregation.
  • Use NTP, not SNTP, when the network is congested; SNTP is a stripped-down subset and can be fooled by jittery links.
  • Quarantine the NTP source from production traffic: place the NTP server in a small VLAN shared with the PLCs and route nothing else across it.
  • Document the DST rules in the project documentation: if the PLC ever has its configuration reloaded at a customer's site, the engineer will need to know which rules to enter.
  • Track RTC battery health: a depleted battery is the only hardware-level cause of time loss; nothing in the software can protect against it.
  • Consider a Siemens SICLOCK TM or SICLOCK TC for plants with many controllers - the SICLOCK can synchronize to GPS and emit NTP from a single source for dozens of PLCs.
Safety note: If the timestamp is used as legal evidence (e.g., FDA 21 CFR Part 11 or similar regulatory frameworks), the NTP server itself must be synchronized to a traceable source such as GPS or a national time authority. A stand-alone PC without traceable sync does not satisfy regulatory traceability.

FAQ

Is setting the clock once with the laptop a sustainable strategy?

No. The S7-1200 hardware RTC drifts by typically ±2.5 s/day, accumulating to minutes per month. After a year, the wall clock will be wrong by 10-20 minutes, and a manual correction would still be required twice per year for DST. Use an NTP server.

Which block should I use, RD_SYS_T or RD_LOC_T?

Use RD_LOC_T (SFC 19) when the time is shown to operators or used for DST-aware tariff logic - it applies the configured time zone and DST rules. Use RD_SYS_T (SFC 1) when you need a stable UTC reference for logs that will be merged from multiple plants or systems in different time zones.

What firewall rules do I need for the NTP server?

Allow outbound UDP source port 123 from the PLC's IP address to the NTP server's IP, destination port 123. If the NTP server is on a Windows PC with the firewall enabled, the firewall is deny-by-default, so an explicit Allow rule must be created or NTP will silently fail.

How do I confirm NTP synchronization is working?

Open Online & Diagnostics > Diagnostic buffer and look for event ID 0xE0FE0001 ("Time successfully synchronized"). Its presence and recency prove that the PLC is reaching the server and accepting updates. A pattern of only 0xE0FE0002 indicates the server is being contacted but rejects the response, usually due to a firewall or asymmetric routing.

How does the PLC handle DST transitions?

At exactly the configured local switchover time, the local clock displayed by RD_LOC_T steps by the configured DST offset (typically +1 h in spring, -1 h in autumn). The underlying UTC system time is unaffected. Spring-forward events may produce a 1-hour gap with no events; fall-back may produce one hour of duplicated local timestamps - this is normal ISO 8601 behavior and must be accounted for in any business logic that compares local timestamps.

Back to blog