Introduction
NTP time synchronization can be crucial to automation systems if the system uses time stamps between PLCs or the PLC and the IT systems.
However, NTP time synchronization error normally is silent and people may have to spend hours trying to troubleshoot the issue only to find out that the PLC’s NTP synchronization is not properly configured or the NTP server is not available.
To help avoid such time waste, I’m introducing a way to check the NTP time sync status in the SIMATIC PLCs.
Check it out.
What is NTP
The NTP (Network Time Protocol) is a networking protocol for clock synchronization between computer systems. It is one of the oldest Internet protocols in current use.

NTP sync time in UTC and the PLC will automatically calculate the local time using the time zone configuration and the day light saving settings.
How to Check SIMATIC Controller’s NTP Sync Status
Manually Check the NTP Sync Status
One of the simplest ways to check the PLC’s NTP sync status is to access the PLC online and manually change the PLC’s time to a completely wrong time following the below screenshot.

If the NTP time sync is working properly, the PLC should automatically change its time sync back in a few seconds.
Though easy and practical, we have to first realize that we need to check the time sync status which is actually the hardest part.
The good news is we can program to get the information and make the time sync status always available.
Check Sync Status with User Program
The below program is an example of how to program to get the NTP time sync status.
FUNCTION_BLOCK "FB_NTP_Diag"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR
s_ClockStatus : Word;
s_Sync_Missed : Bool;
s_Sync_Enabled : Bool;
s_DaylightSaving_Enabled : Bool;
s_GetClockStatus_Ret { ExternalAccessible := 'False'; ExternalVisible := 'False'; ExternalWritable := 'False'} : Int;
END_VAR
BEGIN
#s_GetClockStatus_Ret := GetClockStatus(#s_ClockStatus);
#s_Sync_Missed := #s_ClockStatus.%X0;
#s_Sync_Enabled := #s_ClockStatus.%X1;
#s_DaylightSaving_Enabled := #s_ClockStatus.%X2;
END_FUNCTION_BLOCK
The program uses a SIEMENS library function GetClockStatus. The function returns a word with the lowest three bits bearing meanings.
| Bit | Diagnosis Meaning |
|---|---|
| 0 | TRUE: Time sync is missing, FALSE: Time Sync is working |
| 1 | TRUE: Time sync is enabled, FALSE: Time sync is disabled |
| 2 | TRUE: Daylight saving is enabled, FALSE: Daylight saving is disabled |
With the above program, we can easily create indications to tell us if the PLC’s time synchronization with the NTP server is working or not.
One Important Note
If the PLC’s NTP sync just failed, the diagnose use program will take some time to flag the time sync missing bit.
Don’t expect the time sync missing bit to instantly become TRUE unless in some special cases.
Conclusion
The PLC Time synchronization can be very important but when it fails there is no clear indication for it. This article introduces a programming way to get the time synchronization status with the SIEMENS library function and offers the possibility to generate diagnostic information.