Technical Differences Between READ_CLK (SFC1) and LOC_TIME (FC1) in SIMATIC S7 Controllers
In SIMATIC S7 controllers (S7-300, S7-400, and PCS 7 AS 410), READ_CLK (SFC1) and LOC_TIME (FC1) read the real-time clock but serve distinct temporal purposes. READ_CLK (SFC1) reads the raw system clock of the CPU, which in PCS 7 is strictly synchronized to Coordinated Universal Time (UTC), outputting a monotonic DATE_AND_TIME (DT) structure without timezone or daylight saving bias. LOC_TIME (FC1) reads the system clock via SFC1 and mathematically applies the configured local time zone bias and daylight saving time (DST) offset, outputting the local DATE_AND_TIME and a boolean flag SUMMER indicating whether summer time is active.
Table of Contents
- Executive Summary
- Architecture and Fundamental Mechanics
- Step-by-Step Implementation Procedure
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Executive Summary
Time-dependent logic in industrial controllers—such as batch report generation, shift change accounting, energy totalization, and alarm time-stamping—requires accurate clock management. S7-SCL and CFC programmers frequently ask whether to use READ_CLK (SFC1) or LOC_TIME (FC1) when interrogating controller time. In SIMATIC PCS 7, the controller internal clock is always synchronized in UTC to maintain global monotonicity and prevent archive overwrites during daylight saving changes. Using the wrong block results in time offsets between controller logic and local wall-clock events. This guide compares their internal architectures, execution performance, and engineering application rules.
Architecture and Fundamental Mechanics
The clock architecture of SIMATIC S7 CPUs separates internal system time from localized display time:
1. READ_CLK (SFC1 - System Function 1):
- Functionality: Reads the hardware real-time clock (RTC) maintained by the CPU operating system.
- Output Format: DATE_AND_TIME (DT) structure (8 bytes encoding Year, Month, Day, Hour, Minute, Second, Millisecond, and Day of Week in BCD format).
- Time Base: In SIMATIC PCS 7, the CPU clock is synchronized via NTP or SICLOCK in UTC. Therefore, READ_CLK outputs pure UTC time ($T_{UTC}$).
- Key Characteristic: Monotonic and continuous. It never jumps backward or repeats an hour during autumn daylight saving fall-back.
2. LOC_TIME (FC1 - Standard Library / System Function):
- Functionality: Calls READ_CLK internally, queries the CPU configuration for Time Zone bias (e.g., UTC+1) and Daylight Saving parameters, and adds the offset to calculate local wall-clock time:
$$T_{Local} = T_{UTC} + Bias_{TimeZone} + Bias_{DaylightSaving}$$
- Outputs: Returns local DATE_AND_TIME (LT) and a boolean output SUMMER (TRUE if daylight saving time is active, FALSE during standard winter time).
- Key Characteristic: Non-monotonic. During the transition from summer to standard time, the local clock jumps backward by one hour (e.g., 03:00 becomes 02:00), causing local time to repeat.
Step-by-Step Implementation Procedure
-
Selecting the Correct Function for Your Application:
a. ChooseREAD_CLK(SFC1) for: historical data logging, message generation, sequence-of-events recording, interval measurement, and inter-controller communication.
b. ChooseLOC_TIME(FC1) for: displaying human-readable time on local operator panels, triggering daily production shifts (e.g., starting a batch at 06:00 local time), or evaluating seasonal shift changes. -
Implementing READ_CLK (SFC1) in CFC or SCL:
a. In CFC, dragREAD_CLK(SFC1) from theSTEP 7 Standard Library -> System Function Blocks.
b. Connect outputCDT(Current Date and Time) to your timestamping block or custom function.
c. In SCL:
pascal VAR RetVal : INT; CurrentUTC : DATE_AND_TIME; END_VAR RetVal := READ_CLK(CDT := CurrentUTC); -
Implementing LOC_TIME (FC1) in CFC or SCL:
a. In CFC, dragLOC_TIME(FC1) from theSTEP 7 Standard Library -> Time Functions.
b. Parameterize inputs:LOC_TIMEevaluates the local time zone configured in HW Config (CPU Properties -> Diagnostics/Clock -> Time Zone).
c. Monitor outputs:LT(Local Date and Time) andSUMMER(Daylight Saving Active flag).
d. In SCL:
pascal VAR RetVal : INT; CurrentLocal : DATE_AND_TIME; IsSummer : BOOL; END_VAR RetVal := LOC_TIME(LT := CurrentLocal, SUMMER := IsSummer); -
Configure Daylight Saving Rules in HW Config (If Using LOC_TIME):
a. Open STEP 7 HW Config, double-click the CPU, and select the 'Diagnostics/Clock' tab.
b. Enable 'Daylight saving time' and select the applicable international rule (e.g., EU: Last Sunday in March to Last Sunday in October).
c. Save, compile, and download HW Config.
Verification
- Monitor both blocks simultaneously in CFC Test Mode at a known local time (e.g., 14:00 local time in a UTC+2 summer zone).
- Verify that
READ_CLK.CDToutputs12:00(UTC). - Verify that
LOC_TIME.LToutputs14:00(Local Time). - Confirm that
LOC_TIME.SUMMERreadsTRUEduring summer months and transitions toFALSEduring standard winter time.
Limitations and Operational Precautions
Never use LOC_TIME for calculating process elapsed times (e.g., duration between two timestamps); if a duration spans an autumn daylight saving transition, calculating $\Delta t$ with local time will produce an erroneous negative or 1-hour inflated result.
Engineer FAQ
Why does READ_CLK output a different time than my wristwatch?
Because in PCS 7, the CPU system clock is synchronized to UTC. READ_CLK outputs UTC, which differs from local time by your regional timezone and summer time offset.
What does the SUMMER output on LOC_TIME indicate?
SUMMER is a boolean flag that is TRUE when daylight saving time (summer time) is actively applied to the calculated local time.
Can LOC_TIME cause negative time calculation errors?
Yes. During the autumn 1-hour fall-back transition, the local clock repeats an hour. Calculating elapsed durations using local time can result in negative intervals.
Where is the time zone offset configured for LOC_TIME?
In STEP 7 HW Config under CPU Properties -> Diagnostics/Clock tab.
Is READ_CLK faster to execute than LOC_TIME?
Yes. READ_CLK is a native operating system syscall (SFC), whereas LOC_TIME is a function (FC) that calls SFC1 and executes additional arithmetic and calendar comparison algorithms.
Technical References
- SIMATIC System Software for S7-300/400 System and Standard Functions Manual
- SIMATIC PCS 7 Time Synchronization System Manual
- IEC 61131-3 Programmable Controllers Standard
Related Articles
- Resolving Two-Hour Time Axis Offsets in WinCC Online Trend Control and CEMAT Faceplates
- Resolving WinCC Alarm Logging 1-Hour UTC Timestamp Discrepancies During Daylight Saving Transitions
- Implementing Conditional Daily Real Value Accumulation and Triggered Summation in CFC
Related Tags
- READ_CLK
- LOC_TIME
- SFC1
- FC1
- Time Synchronization
- UTC vs Local