×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 24104104, Entry date: 07/28/2008
(5)
Rate

How do you synchronize the date and time between an operator panel and an S7-300/S7-400 controller with WinCC flexible?

  • Entry
  • Associated product(s)

Instructions
This entry cannot be used for the TP170A. Information on time synchronization between a TP170A and the S7-300/400 with WinCC flexible is available in Entry ID 24106357.

There are the following options for synchronizing the system time between an operator panel (except TP170A) and an S7-300 or S7-400.

Contents

  1. Transfer of the CPU system time to an operator panel
  2. Transfer of a specified system time from the operator panel to the CPU
    2.1  Option 1 - Synchronization without "Date/Time PLC" area pointer
    2.2  Option 2 - Synchronization via the "Date/time PLC" area pointer
  3. Download

Note
Three sample projects are available for downloading at the end of this entry, in which both methods of transferring date and time are realized.

1. Transfer of the CPU system time to the operator panel
You can synchronize the system time on the operator panel, which is used for time stamping incoming operation and error messages among other things, to the system time of the controller using the area pointer "Date/time PLC". The project for this example is in Attachment 1 at the end of this entry.

In this example, synchronization is unidirectional from the controller to the operator panel.
 

No. Procedure
1 Creating the data area for the "Date/time PLC" area pointer in a data block in the controller (DB1)
In the controller you define a data area consisting of one "DATE_AND_TIME" tag and four tags of the "BYTE" type. For later configuration of the area pointer in the operator panel it is useful to organize this data area in a structure.


Fig. 01
 
2 Cyclic transfer of the controller's system time to the data area defined
You transfer the controller's system time in a one-second cycle to the "DATE_AND_TIME" tag already defined. You can do this in a cyclic interrupt OB such as OB35 or OB32 using the system function SFC1 "READ_CLK".


Fig. 02

Note
Connection of a DB pointer, for example, to the "CDT" parameter is possible only symbolically.

3 Installing the "Date/time PLC" area pointer in WinCC flexible
Insert the "Date/time PLC" area pointer and then interconnect it with the structure created in the controller. Via the Acquisition Cycle you define the interval at which the system time in the operator panel is updated with the current system time of the S7 CPU. It is recommended to set an acquisition cycle of at least 10 seconds.


Fig. 03

Note
The "Date/time PLC" area pointer is available for all operator panels that can be configured in WinCC flexible. Through the area pointer the system clock is synchronized automatically according to the acquisition cycle.  

4 Configuring the date/time field
You can have the current system time of the operator panel displayed in a WinCC flexible picture via the date/time field (display: Display date / Display time activated) with the "Display system time" property and "Output" mode.


Fig. 04

Note
Note that in the case of changing the system clock via the panel the update time can take several seconds. This depends on the baud rate and the acquisition cycle among other things.

Note
More information on time synchronization between operator panel and S7 CPU is available in the manual "WinCC flexible Communication Part 1" in Entry ID: 18797552.

2. Transfer of a specified system time from the operator panel to the CPU
There are two different procedures for synchronizing between a SIMATIC S7-300/400 controller and an operator panel.

In these two examples, synchronization is bidirectional from the controller to the operator panel optionally transfer of the specified system time from the panel to the controller.

Option 1 - Synchronization without "Date/time PLC" area pointer
With this synchronization option without "Date/time PLC" area pointer synchronization is done by controller jobs.

For this synchronization option between operator panel and S7-300/400 controller you can use the "** SYS_CLK_WinCE_V1" block that is available for downloading in Attachment 2 at the end of this entry.

This synchronization option requires the two area pointers "Controller Job" and "Date/Time" for synchronizing the system time between an operator panel and the S7-300/400 controller in WinCC flexible.

  • Area pointer "Job mailbox"
    The "Job mailbox" area pointer is for executing controller jobs. The controller job is specified via the the job number that is entered in the first data word of the "Job mailbox" area pointer. You can specify up to three parameters per job. Transfer of the CPU system time to the operator panel is done with controller job 14 (set time) and controller job 15 (set date). Controller job 40 or 41 transfers the date/time from the operator panel to the controller.
  • Area pointer "Date/time"
    The "Date/time" area pointer is required for executing controller job 40 or 41. Controller job 40/41 reads the current date/time from the operator panel and writes the data to the "Date/Time" data area in the controller.

Below is an explanation of how to synchronize between the controller and WinCC flexible using the "** SYS_CLK_WinCE_V1" block.
 

No. Procedure
1 Import the "** SYS_CLK_WinCE_V1" block into the STEP 7 project
Once you have imported the block in the cyclic program (e.g. OB1) you generate the associated instance data block of the function block. Connect the "IO_SetTime" block parameter for setting the S7 CPU's system clock with a marker, e.g. M10.0. Synchronization between controller and operator panel is done via the "IO_ReadTime" block parameter. The other four parameters are required by the controller job to transfer the system time of the panel to the controller. For this you create a global data block, e.g. DB20 and interconnect the relevant data areas of the "Controller Job" area pointer with the four parameters of the function block.

Note
Since there are different controller jobs, e.g. "No. 51 - Screen selection", the data management of the controller job is not performed in the function block.


Fig. 05

Note
You can also use this block if you are implementing multiple controller jobs in your STEP 7 project. For this you only have to make sure that two or more controller jobs are not started in parallel or overwritten.

2 Configuring the area pointer in WinCC flexible
The memory area for the "Date/Time" area pointer is reserved as from address 10.0 of the instance data block. The area pointer contains at least 6 words so that you need another four bytes in addition to the DATE_AND_TIME data type.

Note
The last four bytes of the area pointers must be in the data area to ensure a data format match with WinCC flexible and to avoid reading the wrong data. The DATE_AND_TIME data type makes the symbolic connection of the area pointer in WinCC flexible possible.


Fig. 06

Also enable the "Date/Time" and "Controller Job" area pointers. For the "Date/Time" area pointer use the same data area defined in the generated instance data block.
For the "Controller Job" area pointer you specify the address area of the global data block, e.g. "DB20 DBW 0".


Fig. 07
3 Configuring tags in WinCC flexible
In WinCC flexible you create the "SetTime" and "ReadTime" tags of the BOOL type and the "DateTime" tag of the DATE_AND_TIME type. For the first tag you use the same memory area that you defined in Point 1 (e.g. M10.0 and M10.1). The memory area of the second tag is already integrated in the instance block as from address 22.0 (see Fig. 06).


Fig. 08

Optionally you can create the "Day of week" tag to display the day of the week in a text list, for example.

4 Configuring the date/time field in WinCC flexible
You can enter/display the current system time of the operator panel in a WinCC flexible picture via a date/time field (display: Display date / Display time activated) with the "Display system time" properties and the "Input / Output" mode.


Fig. 09

For display of the controller's system clock on the operator panel you must select the property "Tag" instead of the property "System time" and link the "DateTime" tag.

5 Adding the button for setting the system clock
You can realize setting of the system clock via a button under the "Press" event using the "SetBit" system function.


Fig. 10

For the "SetTime" you use the control tag that you have already created in the tag editor for synchronizing the operator panel's system clock with the controller's system clock. For synchronizing the system clock between the controller and the panel you link the "ReadTime" tag to a separate button.

To realize automatic and periodic synchronization between controller and panel you use the job planner in which you have the "ReadTime" tag called every minute.

Note
This example can be used for all S7-300/400 controllers and all operator panels that can be configured in WinCC flexible, except the TP170A.

Note
More information on time synchronization between operator panel and S7 CPU is available in the manual "WinCC flexible Communication Part 1" in Entry ID 18797552.

2.2 Option 2 - Synchronization via the "Date/time PLC" area pointer
When synchronizing time with an area pointer, synchronization is done periodically without having to do much configuration.

The function block "** SYS_CLK_WinCE_V2" in Attachment 3 at the end of this entry synchronizes the controller's system clock periodically with the display device. The panel's and the controller's system clocks can also be set.

  • Area pointer "Date/time PLC"
    The "Date/time PLC" area pointer is for synchronizing the system clock in the S7 CPU and the system clock in the operator panel. Synchronization is periodic depending on the acquisition cycle.
  • Area pointer "Date/time"
    The "Date/time" area pointer is required for executing controller job 40/41. Controller job 40/41 reads the current date/time from the operator panel and writes the data to the "Date/time" data area in the controller. 
  • Area pointer "Job mailbox"
    The "Job mailbox" area pointer is for executing the controller jobs. The controller job is specified via the the job number that is entered in the first data word of the "Job mailbox" area pointer. You can specify up to three parameters per job in addition. Only controller job 40 is required to transfer the system time of the operator panel to the controller.

Below is an explanation of how to synchronize between the controller and WinCC flexible using the "** SYS_CLK_WinCE_V2" block.
 

No. Procedure
1 Importing the "** SYS_CLK_WinCE_V2" block into the STEP 7 project
Once you have imported the block in the cyclic program (e.g. OB1) you generate the associated instance data block of the function block. Connect the "IO_SetTime" block parameter for setting the S7 CPU's system clock with a marker, e.g. M10.0.
The other four parameters are required by the controller job to transfer the system time of the panel to the controller. For this you create a global data block, e.g. DB20 and interconnect the relevant data areas of the "Controller Job" area pointer with the four parameters of the function block.

Note
Since there are different controller jobs, e.g. "No. 51 - Screen selection", the data management of the controller job is not performed in the function block.


Fig. 11

Note
You can also use this block if you are implementing multiple controller jobs in your STEP 7 project. For this you only have to make sure that two or more controller jobs are not started in parallel or overwritten.

2 Configuring area pointers in WinCC flexible
As from addresses 10.0 and 22.0 of the instance data block the memory areas are reserved for the "Date/Time PLC" and the "Date/Time" area pointers. The two area pointers contain a total of 6 words so that you need another four bytes in addition to the DATE_AND_TIME data type.


Fig. 12

Note
The last four bytes of the area pointers must be in the data area to ensure a data format match with WinCC flexible and to avoid reading the wrong data. The DATE_AND_TIME data type makes the symbolic connection of the area pointers in WinCC flexible possible.

For the "Controller Job" area pointer you specify the address area of the global data block, e.g. "DB20 DBW 0".

Insert the "Date/time PLC" area pointer in your WinCC flexible project by defining the connection and the address. Also enable the "Date/Time" and "Controller Job" area pointers. For the area pointers use the same data area defined in the global data block and in the generated instance data block.


Fig. 13

Via the Acquisition Cycle of the "Date/time PLC" area pointer you define the interval at which the system time in the operator panel is updated with the current system time of the controller. It is recommended to set an acquisition cycle of at least 10 seconds.

3 Configuring tags in WinCC flexible
In WinCC flexible you create the "SetTime" tag of the BOOL type and the "DateTime" tag of the DATE_AND_TIME type. For the first tag use the same memory area that you defined in Point 1 (e.g. M10.0). The memory area of the second variable is already integrated in the instance data block as from address 10.0 (see Fig. 12).


Fig. 14

Optionally you can create the "Day of week" tag to display the day of the week in a text list, for example.

4 Configuring the date/time field in WinCC flexible
You can enter/display the current system time of the operator panel in a WinCC flexible picture via a date/time field (display: Display date / Display time activated) with the "Display system time" properties and the "Output" or "Input / Output" mode.


Fig. 15

For display of the controller's system clock on the operator panel you must select the property "Tag" instead of the property "System time" and link the "DateTime" tag.

5 Adding the button for setting the system clock
You can realize setting of the system clock via a button under the "Press" event using the "SetBit" system function.


Fig. 16

Use the "SetTime" control tag that you have already created in the tag editor. The control tag is reset in the block after the system clock has been set. Periodic synchronization of the panel's system clock is done automatically by integrating the "Date/time PLC" area pointer.

Note
Note that in the case of changing the system clock via the panel the update time can take several seconds. This depends on the baud rate and the acquisition cycle among other things.

Note
More information on time synchronization between operator panel and S7 CPU is available in the manual "WinCC flexible Communication Part 1" in Entry ID: 18797552.

Downloading the STEP 7 projects with the integrated WinCC flexible project:
Copy the "Time_WinCE_flexible_Ax.zip" file into a separate directory and unpack it. Then you can use the SIMATIC Manager to open and if necessary edit the STEP 7 project with integrated HMI station. You can open the integrated WinCC flexible project with WinCC flexible 2007 HF4 (from the Compact Edition onwards).

Note
Hotfix 4 for WinCC flexible 2007 is available for free downloading in Entry ID: 28882233 .

Downloads
The download in Attachment 1 contains the blocks described above for transferring the S7 CPU system time to an operator panel (TP170B color).

Attachment 1: Time_WinCE_flexible_A1.zip ( 2449 KB )

The download in Attachment 2 contains the blocks described above for transferring a user-defined system time without the "Date/time PLC" area pointer to the S7 CPU and an operator panel (MP277 10").

Attachment 2: Time_WinCE_flexible_A2.zip ( 2966 KB )

The download in Attachment 3 contains the blocks described above for transferring a user-defined system time via the "Date/time PLC" area pointer to the S7 CPU and an operator panel (MP277 10").

Attachment 3: Time_WinCE_flexible_A3.zip ( 2854 KB )

Runnability and test environment
The following table lists the components that have been used to create this entry and verify the functions described.
 

Components Product and version designation
PC operating system Microsoft Windows XP SP2
Standard tools -
Engineering tool STEP 7 V5.4 SP3 HF1
HMI software WinCC flexible 2007 HF4
HMI system TP170 6" & MP277 10"

Keywords
OP73, OP77A, OP77B, TP177B, C7-635, C7-636, TP170B, TP177, OP170B, OP177, MOBILE PANEL 170, MOBILE PANEL TP177, MOBILE PANEL TP277, TP270, TP277, OP270, OP277, MP270, MP277, MP370, MP377, Set date/time, Synchronize, Windows-based devices, WinCE, Windows CE, GMP, Pharma, Life Science, Validation, FDA 21 CFR Part 11

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.