Entry type: FAQ, Entry ID: 24079457, Entry date: 07/28/2008
(1)
Rate

How do you synchronize the date and time between a Windows-based operator panel and the S7-300/S7-400 controller with ProTool?

  • 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 ProTool is available in Entry ID 23972509.

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

Contents:

  1. Transfer of the CPU system time to the Windows-based panel
  2. Transfer of a specified system time from the Windows-based 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:
The two methods of transferring date and time between the Windows-based panel and an S7-300/400 controller are available for downloading at the end of this entry implemented in a STEP 7 project.

1. Transfer of the CPU system time to the Windows-based 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 "Date/time PLC" area pointer. 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 Create the data area for the "Date/Time PLC" area pointer in a data block in the controller
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 Install the area pointer "Date/Time PLC" in ProTool
Via the menu item "Insert > Area Pointers..." you insert a pointer of the type "Date/Time PLC". Then you interconnect this area pointer with the defined data area (structure: Date_Time_PLC) 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 CPU. It is recommended to set an acquisition cycle of 10 seconds.


Fig. 03

Note:
The "Date/Time PLC" area pointer is available for all Windows-based operator panels. Through the area pointer the system clock is synchronized automatically according to the acquisition cycle.   

4 Configuring the date/time field
You can enter the system time on a Windows-based panel via a date/time field (display: date and time enabled) with the "System time" data source and the "Editing permitted" field type in a ProTool picture.


Fig. 04

For display of the controller's system clock on the operator panel you must select the property "Tag" instead of the data source "System Time". The "DateTime" tag must also be connected.

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.

2. Transferring a specified system time from the Windows-based panel to the CPU

There are two different procedures for synchronizing between a SIMATIC S7-300/400 controller and a Windows-based operator panel.

It is recommended to use the synchronization procedure with the "Date/Time PLC" (Option 2).

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.

2.1 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 "Job Mailbox" and "Date/Time" for synchronizing the system time between a Windows-based panel and the S7-300/400 controller in ProTool.

  • 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 Windows-based 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 ProTool 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 PLC's system clock with a marker, e.g. M10.0. Synchronization between the controller and the 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 "Job Mailbox" 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 ProTool
The memory area for the "Date/Time PLC" 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 ProTool and to avoid reading the wrong data. The DATE_AND_TIME data type makes the symbolic connection of the area pointer in ProTool possible.


Fig. 06

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


Fig. 07
3 Configuring tags in ProTool
In ProTool 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 use the same memory area that you defined in Point 1 (e.g. M10.0 and M10.1). The memory area of the second variable is already integrated in the instance data 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 ProTool
You can enter the system time on a Windows-based panel via a date/time field (display: date and time enabled) with the "System time" data source and the "Editing permitted" field type in a ProTool picture.


Fig. 09

For display of the controller's system clock on the operator panel you must select the property "Tag" instead of the data source "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 "OnButtonDown" event using the "Set_Bit" 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:
If you implement multiple controller jobs, you must make sure that the controller jobs do not collide with each other.

Note:
This example can be used for all S7-300/400 controllers and all Windows-based systems except the TP170A.

2.2 Option 2 - Synchronization with "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 PLC 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 "Jobs 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 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 ProTool 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 PLC'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 "Job Mailbox" 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 ProTool
As from address 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 ProTool and to avoid reading the wrong data. The DATE_AND_TIME data type makes the symbolic connection of the area pointers in ProTool possible.

Via the menu item "PLC > Area Pointers" you insert a pointer of the type "Date/Time PLC". Then you interconnect this area pointer with the defined data area in the controller.

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


Fig. 13

Via the acquisition cycle of the "Date/Time PLC" area pointer you define the interval at which the system time in the 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 ProTool
In ProTool 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 ProTool
You can enter/display the system time on a Windows-based panel via a date/time field (display: date and time enabled) with the "System time" data source and the "Editing permitted" field type in a ProTool picture.


Fig. 15

For display of the controller's system clock on the operator panel you must select the property "Tag" instead of the data source "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 "OnButtonDown" event using the "Set_Bit" 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.

Downloading the STEP 7 projects with the integrated ProTool project:
Copy the "Time_WinCE_ProTool_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 ProTool project with ProTool V6.0 SP3 and higher.

Download:
The download in Attachment 1 contains the blocks described above for transferring the CPU system time to the Windows-based operator panel.

Attachment 1: Time_WinCE_ProTool_A1.zip ( 431 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 CPU and a Windows-based operator panel.

Attachment 2: Time_WinCE_ProTool_A2.zip ( 493 KB )

The download in Attachment 3 contains the blocks described above for transferring a user-defined system time with the "Date/Time PLC" area pointer to the CPU and a Windows-based operator panel.

Attachment 3: Time_WinCE_ProTool_A3.zip ( 481 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.3
HMI software ProTool V6.0 SP3 HF 3
HMI system -

Keywords:
TP170B, OP170B, , MOBILE PANEL 170, TP270, OP270, MP270, MP370, Set time/date, Synchronize, Windows-based devices, WinCE, Windows CE