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.
Create a SIMOTION project:
The requirement for date and time synchronization is an opened project with a SIMOTION device set up.
A new device or further devices can be added in the project menu via "Create new device".
Creating/importing a structured program in SIMOTION Scout:
In the project menu, add a new ST program in the "Programs" folder for the device created or added.
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.
||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.
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.
||Setting the time, default is FALSE|
||Reading the time, default is FALSE|
||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).|
||Current system time|
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;
The structured program can be tested for syntax errors via the menu selection "ST source file > Accept and compile" or by clicking the following icon on the toolbar.
Accept and compile
||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 on the "Execution System" menu in the project navigation and selecting "Execution levels > Operation levels > BackgroundTask".
- Select the "Uhr.clock( )" program and add it by clicking the "Add" button.
You can then compile your SIMOTION configuration and transfer it to the SIMOTION device.
||Create a SIMOTION connection in WinCC flexible:|
The connection with the SIMOTION device must be created in WinCC flexible.
In the project tree, under "Communication > Connections" you create a new connection and select the communication driver "SIMOTION".
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 to the SIMOTION data type.
||Add tags for time synchronization:|
In the project tree, under "Communication > Tags" you create all the tags required:
||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 "StartProgram".
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 "StartProgram" function
The statements 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> )
||Name of the program
||Name and path of the program that is to be started.|
||The parameters that you transfer when the program starts, for example a file that opens after program start.|
||Defines how the program window is displayed on the operator panel:|
||=Minimized and inactive|
||Wait for the end
||Defines whether there is to be return to the project after the called program has ended:|
|0 (hmiNo) =
No return to project
|1 (hmiYes) =
Return to project
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).
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
||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.
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.
Then connect the upper date/time field to the "Uhr.time_plc" tag which you created previously. Select the "Display system time" in the lower date/time field.
||Link the script to the buttons:
- Link the "Clk_sys_in_var" script in the Properties of the "Time Panel > CPU" button 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.
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.
Uhr.zip ( 508 bytes )
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.
Simotion_WinCC_flexible.zip ( 2837 KB )
Runnability and test environment:
The following table lists the components that have been used to create this entry and verify the functions described.
||Product and version|
|PC operating system
||Microsoft Windows XP SP2|
||SIMOTION Scout V 4.0|
||WinCC flexible 2005 SP1|
Date synchronization, Time synchronization