Clock synchronization

The substation can be synchronized with the time of the central station. The settings necessary for this are made in the System Parameters:

     fbSlave.sysPara.bSyncTime        := TRUE;    // sync IEC system time after reception of C_CS_NA_1 commmando
     fbSlave.sysPara.bSyncPCTime := TRUE; // sync local PC system time from master
     fbSlave.sysPara.tSyncToPCTime := T#30S;

A detailed description:

bSyncTime: if TRUE, activate IEC system time synchronization on receiving the C_CS_NA_1 command. Default: TRUE.

bSyncPCTime: If TRUE, synchronize the IEC system time and the system time of the TwinCAT PC (the Windows system time in the taskbar). Default: FALSE.

bUsePCTime: If TRUE, synchronize the IEC system time with the system time of the PC. Following the initialization of the substation, the IEC system time is first synchronized with the system time of the TwinCAT PC (Windows system time). Default: TRUE.

tSyncToPCTime: controls the cyclic synchronization of the IEC system time with the system time of the TwinCAT PC (in online and offline mode). The time is determined by the cycle time in which the synchronization is executed. A value of T#0s deactivates the cyclic synchronization. Default: T#0s.

sPCTimeNetID: TwinCAT network address of the PC whose system time is to be used for the synchronization. If it is to be run on the local computer, an empty string can be entered. Default: empty string = local PC.

bTimeCOT3: If TRUE, send the system time to the central station with the cause of transmission <3> spontaneous on the hour. Default: FALSE

The associated PLC example tutorial can be downloaded here.