Entry type: FAQ, Entry ID: 23751257, Entry date: 08/17/2006
(0)
Rate

How do you use WinCC flexible to synchronize the data and time between a SIMATIC HMI panel and a SIMOTION controller?

  • Entry
  • Associated product(s)
Date and time synchronization between WinCC flexible and a SIMOTION controller takes place via external tags. The SIMOTION system time is read out cyclically in a SIMOTION program and transferred into WinCC flexible via the configured tags. Synchronization takes place via script functions in both directions.

Proceed as follows.
 

No. Procedure
1

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

  


Fig. 01
  

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

2

Create/import a structured program in SIMOTION Scout
In the project tree, add a new ST program in the "Programs" folder for the device created or added.

  


Fig. 02
  

Note
Alternatively, you can also download the file "Uhr.zip" (see below) 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 communication between WinCC flexible 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
  

Note
The ReadClock and SetClock functions are of the 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 Bool Set time; default FALSE
READ Input Bool Read time; default FALSE
PDT Input DT Value to which the real-time clock should be set; default 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 ( (for example, in the case of C320-2: DT#1994-01-01-00:00:00).
CDT Output DT Current system time


Example
With 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;

Remark
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.

Transfer 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" in the project tree 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 WinCC flexible

In the project tree, under "Communication > Connections" you create a new connection and select the "SIMOTION" communication driver.

  


Fig. 06
  

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

6 Add tags for time synchronization
In the project tree, under "Tags" you create all the tags required:
  • 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 (for example, 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 Windows "Date" and "Time" operating system functions. The Windows console is called via the script functions "Call" and "StartProgram".

Script - SetPanelClk

  


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

Description of the "StartProgram" function
The instructions of functions are displayed in red in the Script Editor. The structure of the "StartProgram" function is defined as follows:

StartProgram( <ProgName>, <Param>, <Layout>, <Wait> )
 

Parameter Meaning Description
ProgName Name of the program Name and path of the program that is to be started.
Param Program parameter The parameters that you transfer when the program starts, for example a file that opens after program start.
Layout Display Defines how the program window is displayed on the operator panel:
0 (hmiShowNormal) =Normal
1 (hmiShowMinimized) =Minimized
2 (hmiShowMaximized) =Maximized
3 (ShowMinimizedAndInactive) =Minimized and inactive
Wait Wait for the end Defines whether there is to be return to the project after the called program has ended:
0 (hmiNo) = No:
No return to project
1 (hmiYes) = Yes:
Return to project

  
Remark
You can check the script for syntax errors by selecting the toolbar icon (see below) or selecting the "Script" menu (only available when the Script Editor is open).
Check syntax

8

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.

Script - Clk_sys_in_var

  


Fig. 09
9 Create screens 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 screen.

  


Fig. 10
  
Note
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 "Display 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" under "Events > Click".
  • Also create the "SetBit" 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 V4.0.

 Registration required Uhr.zip (1 KB)

Download the sample project
The packed file contains the SIMOTION WinCC flexible project which is described in the instructions. The WinCC flexible project requires WinCC flexible 2005 SP1.  

 Registration required Simotion_WinCC_flexible.zip (2.8 MB)

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

Component Product and version designation
PC operating system Microsoft Windows XP SP2
Standard Tools
Engineering Tools SIMOTION Scout V 4.0
HMI Software WinCC flexible 2005 SP1
HMI System -
SIMOTION device C230

Additional Keywords
Date synchronization, Time synchronization