Entry type: FAQ, Entry ID: 23562916, Entry date: 06/28/2006

How do you synchronize time/date between a SIMATIC HMI panel and a SIMOTION controller?

  • Entry
  • Associated product(s)

Date and time synchronization between ProTool and SIMOTION Scout takes place via external tags. The SIMOTION system time is read out cyclically in a SIMOTION program and transferred into ProTool via the configured tags. Synchronization takes place via script functions in both directions.

No. Procedure

Create a SIMOTION project:
The requirement for date and time synchronization is an opened project with a SIMOTION device set up.

Fig. 01


A new device or further devices can be added in the project menu via "Create new device".


Creating/importing a structured program in SIMOTION:
In the project menu, add a new ST program in the "Programs" folder for the created device.

Fig. 02


Alternatively, you can also download the Uhr.zip file and import the unpacked file "Uhr.st" via the pop-up menu (right-click on "Programs"). Select "Import external source" and "ST source file" in the pop-up menu.

Fig. 03

3 Create global tags and program:
Global tags are required for data exchange between ProTool and the SIMOTION Scout. The system time can be read or set with the aid of the ReadClock and SetClock functions which are created.

Fig. 04


The ReadClock and SetClock functions are RTC-type. When these functions are called, explicit parameters must be transferred to enable the corresponding functions to be executed. The current system time can be read by calling the CDT method.

Identifier Parameter Data type Description
SET Input Boolean Setting the time, default is FALSE
READ Input Boolean Reading the time, default is FALSE
PDT Input DT Value to which the real-time clock should be set, default is DT#0001-01-01-00:00:00. If the value is lower than the default for the real-time clock on the SIMOTION device, the real-time clock is set to its default (e.g. in the case of C320-2: DT#1994-01-01-00:00:00).
CDT Output DT Current system time

As a result of the following function call, the system time is read, and the current time is transferred via the CDT method:

ReadClock( FALSE, TRUE, DT#2005-01-01-0:0:0 );
ReturnValue = ReadClock.CDT;

The structured program can be tested for syntax errors via ""ST source file > Accept and compile"" or by clicking the following icon on the toolbar.

Accept and compile

4 Define the program call in the runtime system:
The program which is created in or imported into SIMOTION Scout also has to be defined as a background task in the execution system.
  • This is done by clicking "Execution system" on the project menu and selecting "ExecutionLevels > OperationLevels > BackgroundTask".
  • Select the "Uhr.clock( )" program and add it by clicking the "Add" button.

Fig. 05


You can then compile your SIMOTION configuration and transfer it to the SIMOTION device.

5 Create a SIMOTION connection in ProTool:
The connection with the SIMOTION device must be defined in ProTool.

Create "Controllers" in the project tree (1) by double-clicking a new connection and selecting the "SIMOTION V6.0" driver. Click the "Parameters..." button (2) in the selection window.

The "Connect OP to network" dialog window now opens. In it select the PROFIBUS subnet (3) to which the panel is connected as hardware. The select the SIMOTION device in the selection field (4) "Choose a communication peer/symbol list".

Fig. 06


ProTool does not support using the area pointer "Date/Time PLC" for time synchronization with a SIMOTION device because the ProTool "DATE_AND_TIME" data type is different to the SIMOTION data type.

6 Add variables for time synchronization:
Create all the requisite tags in the project tree under "Tags":
  • Uhr.set
  • Uhr.time_panel
  • Uhr.time_plc 

Fig. 07

7 Create a script:
  • Add a new script named "SetPanelClk".
  • Create six script tags (second, minute, hour, day, month, year) in the Script Editor and, using the appropriate VBS functions (e.g. day, month, etc.), assign the relevant time base via the external tag "Uhr.time_plc".

The system time of the panel can be changed via the (CMD) console with the "Date" and "Time" operating system functions in Windows. The Windows console is called via the script functions "Call" and "Start_PtFct.Program".

Fig. 08: Script - SetPanelClk

Depending on which location has been selected, dots or dashes must be selected as separator characters in the date details.

Description of the "Start_program" function:
The instructions for ProTool functions are indicated in the Script Editor with the identifier "PtFct", separated by a point. The structure of the "Start_program" function is defined as follows:   

PtFct.Start_Program (<ProgName>, <Param>, <Layout>, <Wait>)

Parameter Meaning Description
ProgName Name of the program String constant or tag containing the name of the program
Param Program parameter String constant or tag containing the name of the program parameter(s)
Layout Display options 0 = window
1 = minimized
2 = maximized
3 = minimized and inactive
Wait wait for the end 0 = off
1 = on

The script can be checked for syntax errors by clicking the "Compile" button in the Script Editor.


Create a further script:

  • Create a second script and rename it "Clk_sys_in_var".
  • Use the keyword "Now" to assign the "Uhr.time_panel" tag which has already been created.

The "Now" function delivers the current system date and time for the panel or PC.

Fig. 09: Script - Clk_sys_in_var

9 Create pictures and objects:
Create two buttons, two date-time fields, as well as (optionally) an alarm view with system messages as an alarm event in a new picture.

Fig. 10

The alarm view is merely used as a configuration aid. Among other things, the system message, which must be explicitly configured, appears in this display to indicate whether the SIMOTION device is connected to the panel.
10 Link tags:
Then connect the upper date/time field to the "Uhr.time_plc" tag which you created previously. Select the "System Time" in the lower date/time field.

Fig. 11

11 Link the script to the buttons:
  • Link the "Clk_sys_in_var" script in the Properties of the "Time Panel > CPU" button under "Functions > OnClick".
  • Also create the "Set_Bit" function and link the "Uhr.set" tag.
  • Link the second script "SetPanelClk" to the "Time CPU > Panel" button applying the same principle as with the first button.

Fig. 12


You can now transfer the configuration to the panel or start the PC runtime.

Download the structured SIMOTION program:
This file contains the "Uhr.st" file which can be imported into SIMOTION Scout V3.2.1.

Uhr.zip ( 508 bytes )

Download the sample project:
The packed file contains the SIMOTION ProTool project which is described in the instructions. The ProTool project requires ProTool version V6.0 SP3.  

Simotion_ProTool.zip ( 450 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
PC operating system Microsoft Windows XP SP2
Standard Tools  
Engineering Tools SIMOTION Scout V 3.2.1
HMI Software ProTool V6.0 SP3
HMI system -
SIMOTION device C230

Date synchronization, Time synchronization