You are on page 1of 44

Communication:

Performant Data Synchronization


Between Several Field and One Head
PLC

S7-1200 Set 17

Application Example March 2016

Siemens Industry Online Support


Answers for industry.
Warranty and liability

Warranty and liability

Note The Application Examples are not binding and do not claim to be complete
regarding the circuits shown, equipping and any eventuality. The Application
Examples do not represent customer-specific solutions. They are only intended
to provide support for typical applications. You are responsible for ensuring that
the described products are used correctly. These Application Examples do not
relieve you of the responsibility to use safe practices in application, installation,
operation and maintenance. When using these Application Examples, you
recognize that we cannot be made liable for any damage/claims beyond the
liability clause described. We reserve the right to make changes to these
Application Examples at any time without prior notice.
If there are any deviations between the recommendations provided in these
Application Examples and other Siemens publications – e.g. Catalogs – the
contents of the other documents have priority.

We do not accept any liability for the information contained in this document.
Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life,
body or health, guarantee for the quality of a product, fraudulent concealment of a
 Siemens AG 2016 All rights reserved

deficiency or breach of a condition which goes to the root of the contract


(“wesentliche Vertragspflichten”). The damages for a breach of a substantial
contractual obligation are, however, limited to the foreseeable damage, typical for
the type of contract, except in the event of intent or gross negligence or injury to
life, body or health. The above provisions do not imply a change of the burden of
proof to your detriment.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the expressed consent of the Siemens AG.

Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, systems, machines and networks.
tion In order to protect plants, systems, machines and networks against cyber
threats, it is necessary to implement – and continuously maintain – a holistic,
state-of-the-art industrial security concept. Siemens’ products and solutions only
form one element of such a concept.
Customer is responsible to prevent unauthorized access to its plants, systems,
machines and networks. Systems, machines and components should only be
connected to the enterprise network or the internet if and to the extent necessary
and with appropriate security measures (e.g. use of firewalls and network
segmentation) in place.
Additionally, Siemens’ guidance on appropriate security measures should be
taken into account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them
more secure. Siemens strongly recommends to apply product updates as soon
as available and to always use the latest product versions. Use of product
versions that are no longer supported, and failure to apply latest updates may
increase customer’s exposure to cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial
Security RSS Feed under http://www.siemens.com/industrialsecurity.

Datasync
Entry-ID: 39040038, V3.1, 21.03.2016 2
Table of contents

Datasync 39040038

Table of contents
Warranty and liability ................................................................................................... 2
1 Task ..................................................................................................................... 4
2 Solution overview .............................................................................................. 5
2.1 Description of the core functionality ..................................................... 7
2.1.1 Overview and description of the user interface .................................... 7
2.1.2 Synchronization of the data .................................................................. 9
2.1.3 Simulation of the data in the field PLCs ............................................. 11
2.1.4 Time synchronization ......................................................................... 12
2.2 Hardware and software components used......................................... 12
3 The blocks of the data synchronization ........................................................ 14
3.1 Complete overview of the program blocks ......................................... 14
3.1.1 Program overview of the head PLC ................................................... 14
3.1.2 Program sequence in the field PLC ................................................... 15
3.2 Data blocks ......................................................................................... 16
3.2.1 The data block of the head PLC ......................................................... 16
3.2.2 The data block of the field PLC .......................................................... 20
39040038_DATASYNC_DOKU_V31_en.docx

3.3 The data block “DATASYNC_X” ........................................................ 22


 Siemens AG 2016 All rights reserved

4 Mechanisms of data synchronization ............................................................ 25


4.1 Control process in the overview ......................................................... 25
4.2 Functioning of the function block DATASYNC_X .............................. 26
4.3 Behavior in the event of a power failure ............................................. 27
5 Performance Measurement ............................................................................ 28
5.1 Conception of the measurement ........................................................ 28
5.2 Values of the performance measurement .......................................... 30
5.3 Result ................................................................................................. 31
6 Installation ........................................................................................................ 32
6.1 Hardware installation .......................................................................... 32
6.2 Software installation ........................................................................... 33
7 Starting up the Application ............................................................................. 34
7.1 Assigning the IP addresses ................................................................ 34
7.2 Download the PLCs and the panels ................................................... 37
8 Operating the Application ............................................................................... 40
9 Related literature ............................................................................................. 42
10 History............................................................................................................... 42
11 Appendix A: Measured Data ........................................................................... 43
11.1 Head: S7-1200; 6 ms program load ................................................... 43
11.2 Head: S7-1200; 50 ms program load ................................................. 43
11.3 Head: WinAC; 6 ms program load ..................................................... 44
11.4 Head: WinAC; 50 ms program load ................................................... 44

V3.1 21.03.2016 3/44


1 Task

1 Task
Introduction
For synchronization tasks and for the exchange of control and status information
among a head PLC and field PLCs, e.g. for solar trackers in solar parks, a
performant cyclic communication system is needed.
For reducing the data transfer, e.g. to an HMI or when a remote supervision is
used, the data are to be exchanged in bundles by means of a data concentrator
(here: head PLC).
The figure below provides an overview of the automation task.
Figure 1-1

Head PLC HMI


Copyright  Siemens AG 2016 All rights reserved

Field PLC 1 Field PLC 2 Field PLC n

Description of the automation problem


A module for the data synchronization and the exchange of control and status
information among the head PLC and several field PLCs is to be developed. It is to
assume the following task independently:
 Supply of all the field PLCs with the same or different sets of data from the
head PLC (down sync).
 Updating the sets of data from all the field PLCs in the head PLC (up sync).

Requirements of the automation task


The following requirements are posed to the block:
 Optimal and performant utilization of the available connection resources of the
head and field PLC.
 Simple adaptation to variable quantities (data volume sent and received).
 To be used with S7-1200 and S7-300/400/IPC with Win AC.
 The programming is to be done mainly with SCL.

V3.1 21.03.2016 4/44


2 Solution overview

2 Solution overview
Display
The following figure gives a schematic overview of the most important components
of the solution:
Figure 2-1

Possible Head PLCs with function block


DATASYNC_HEAD

HMI Panel S7-1200 IPC + WinAC

DATASYNC_ DATASYNC_
HEAD HEAD
Copyright  Siemens AG 2016 All rights reserved

DATASYNC_ DATASYNC_ DATASYNC_ DATASYNC_


SUB SUB SUB SUB

Field PLCs S7-1200 (e.g. in solar trackers) with


function block DATASYNC_SUB

Setup
The application example is demonstrated in a concrete example - controlling solar
trackers.
The expression solar tracker means solar energy systems which can be tracked
according to the position of the sun to ensure the best possible energy yields.
For the field PLC, a CPU S7-1200 is used in this example. For the sake of a better
clarity, the number has been reduced to four.
For the head PLC, this solution uses two types of devices:
 An S7-1200 controller
 An S7-300/400 / IPC with WinAC

V3.1 21.03.2016 5/44


2 Solution overview

Description
With the function block “DATASYNC_X” (X:= HEAD or SUB), a block has been
developed that assumes the control of the data synchronization automatically.
The head PLC sequentially establishes an ISO-on-TCP communication connection
with each field PLC and terminates it again. Data is sent to the field PLCs and data
is received from them. After all field PLCs have been operated, the process is
repeated.
The following figure summarizes the data exchanged between head PLC and field
PLCs.
Figure 2-2

Data structure of the Head-PLC:


• Geographic position (longitude / latitude)
• Requirement time synchronization
• Current time

Field PLC
Head PLC
1..4
Data structure of the Field PLCs:
• Zenith / azimuth angle
• Current weather data (temperature / wind)
Copyright  Siemens AG 2016 All rights reserved

• Production data
It is always the head PLC which takes the initiative.
Since the field PLCs are only passive and wait for the request from the head PLC,
there is a separate “DATASYNC_SUB” block for the field PLC. Its task is the
supply and disposal of the send and receive data.
The data communication among the PLCs is displayed in images by the HMI panel.
For displaying and updating the images, the panel uses the send and receive data
of the head PLC.

Delimitation
This application does not include any
 information concerning the programming language SCL.
 basic information on industrial Ethernet.
 information on astronomic algorithm or solar tracking.
Basic knowledge of these topics is assumed.

V3.1 21.03.2016 6/44


2 Solution overview

2.1 Description of the core functionality


2.1.1 Overview and description of the user interface

For commissioning, operation and monitoring there is


 an overview for operating and configuring the solar trackers.
 an information surface for every field PLC.
The user interface has been realized in a comfort panel TP700.
For updating the images with the current data, an HMI connection between the
panel and the head PLC has been configured.

Overview head PLC


In this overview screen, all the field PLCs can be configured when their geographic
position is entered and the time synchronization can be triggered.
The longitude and the latitude are to be entered in decimal degrees.
Figure 2-3
Copyright  Siemens AG 2016 All rights reserved

V3.1 21.03.2016 7/44


2 Solution overview

Information screen
There is a separate information screen for every field PLC. The calculated zenith
and azimuth angles and simulated weather information and production data are
displayed here.
Figure 2-4
Copyright  Siemens AG 2016 All rights reserved

V3.1 21.03.2016 8/44


2 Solution overview

2.1.2 Synchronization of the data

Schematic layout
The data synchronization between the head PLC and the field PLCs is done
comfortably with the function block “DATASYNC_X”.
This block implements the cyclic and performant data exchange between the head
PLC and the field PLCs.
The defined data structure is sent from the head PLC to the field PLC when the
connection has been built up on both sides. The field PLC waits for reception and
then sends its own data structure to the head PLC
(see Figure 2-2).
As soon as the head PLC has received the data sent from the field PLC, the data
exchange is completed. The connection is disconnected.
The exchanged data structures and the IP addresses of the field PLCs are stored
in different global data blocks.

Increasing the performance by parallel connections


There is the possibility of operating several field PLCs in parallel (multiplexing). The
function block “DATASYNC_HEAD” can be called with a different instance data
Copyright  Siemens AG 2016 All rights reserved

block in the OB1 of the head PLC for every available connection. The maximum
number of calls is limited by the available connection resources of the head PLC.
In the present Application Example, these parallel connections are being used.

Note The maximum admissible number of parallel connections varies depending in the
head PLC.

 S7-1200 supports no more than eight connections.

 S7-300/400 / IPC with WinAC supports up to 32 connections.

V3.1 21.03.2016 9/44


2 Solution overview

The following graphic shows the possibility of increasing the performance by


multiplexing.
Figure 2-5

3
Multiplex z field PLCs
2 …
via several channels
1 z

DATASYNC_ DATASYNC_ DATASYNC_ DATASYNC_


HEAD PLC HEAD HEAD HEAD
… HEAD

n available
connection
Copyright  Siemens AG 2016 All rights reserved

resources

DATASYNC_ DATASYNC_ DATASYNC_ DATASYNC_


FIELD PLCs FIELD FIELD FIELD … FIELD

1 2 3 z

Example:
An S7-1200 CPU is used as the head PLC, and there are 12 field PLCs. This
makes possible the following combinations:
 Number of available connection resources: n = 8
 Number of field PLCs: z = 12
Therefore, the “DATASYNC_HEAD” block can be called in eight instances. There
are eight communication channels for the 12 field PLCs.
In the dynamic multiplex mode, the 12 field PLCs are synchronized through the
eight channels.

V3.1 21.03.2016 10/44


2 Solution overview

Communication blocks
The communication between the head PLC and the field PLCs is done by an ISO-
on-TOP connection.
The connecting and disconnecting process and the sending and receiving of the
data is internally carried out in the “DATASYNC_X” block by means of the following
standard communication blocks:
Table 2-1
Block Description
TCON The TCON command establishes the communication
connection.
TDISCON TDISCON establishes the connection to the partner station.
TSEND TSEND sends data through an existing communication
connection.
TRCV The counterpart to TSEND is TRCV. With this command, data
can be received through an existing communication
connection.

2.1.3 Simulation of the data in the field PLCs


Copyright  Siemens AG 2016 All rights reserved

Determining the position of the sun, using an astronomical algorithm


Depending on the position of the earth, the position of the sun can be calculated
with the aid of an astronomical algorithm, using details on longitude and latitude.
This position of the sun is described with the azimuth angle for the horizontal
alignment and zenith for the vertical alignment. To calculate the position of the sun,
the algorithm needs the Universal Time Coordinated (UTC) to take the earth’s
changing orbital period around its own axis into account.
Table 2-2
Parameters Unit Description
Longitude [°] Longitude from 0° (North) to 360 °
Latitude [°] Latitude from -90° (South pole) to +90° on the North
pole
In this Application Example, the astronomic algorithm is calculated with the function
block SimpleAstroAlgorithm in the cyclic program of the field PLCs.

Simulation of the weather and production data in the field PLCs


The simulation of data that are sent from the field PLCs to the head PLC is done by
time-controlled OBs and a mathematical calculation.

V3.1 21.03.2016 11/44


2 Solution overview

2.1.4 Time synchronization

For the visualization screen the time synchronization of all the CPUs can be
synchronized with the current UTC time in the head PLC. The synchronization
takes place in two steps:
1. With a trigger command, the head PLC reads out the current time and date
head PLC with the button Activate Timesync by means of the function block
RD_SYS_T. This information is stored in the sending reports of the field PLCs
and the time synchronization bit there is set.
2. The field PLCs receive the information with the next data synchronization and
recognize the requirement to carry out a time synchronization. Then they adapt
their real time clocks to the times they received.

2.2 Hardware and software components used


The application was set up with the following components:

Hardware components
Table 2-3
Component No. Order number Note
Copyright  Siemens AG 2016 All rights reserved

CPU 1215C AC/DC/Rly 1 6ES7 215-1BG31-0XB0 Head PLC


IPC 277D PN/IE 1 6ES7 647-8A… Head PLC
Bundle with WinAC RTX (F)
CPU 1214C DC/DC/DC 1 6ES7 214-1AE30-0XB0 Field PLC
Field PLC1
CPU 1212C DC/DC/DC 3 6ES7 212-1AE31-0XB0 Field PLCs
Field PLC2 - 4
HMI panel TP700 Comfort 1 6AV2124-0GC01-0AX0
SCALANCE X208 1 6GK5208-0BA10-2AA3
PG / PC 1 For loading the head
and field PLCs

Standard software components


Table 2-4
Component No. Order number Note
STEP 7 Professional V13 1 6ES7822-0A… Service Pack 1
WinCC Professional V13 1 6AV210… Service Pack 1

V3.1 21.03.2016 12/44


2 Solution overview

Example files and projects


The following list includes all files and projects used in this example.
Table 2-5
Component Note
39040038_DATASYNC_CODE_v22.zip This zip file contains two STEP 7 V13
projects.
 DATASYNC_1200 for the S7-1200
CPU as the head PLC.
 DATASYNC_IPC for the IPC with
WinAC as the head PLC
39040038_DATASYNC_DOKU_v31_d.pdf This document.
Copyright  Siemens AG 2016 All rights reserved

V3.1 21.03.2016 13/44


3 The blocks of the data synchronization

3 The blocks of the data synchronization


3.1 Complete overview of the program blocks
3.1.1 Program overview of the head PLC

Program structure
The following graphic shows the complete user program of the head PLC.
Figure 3-1

DATASYNC_HE iDB
iDB TCON
DATASYNC_HE
AD iDB TRCV
AD
DATASYNC_HE iDB
AD
DATASYNC_ TSEND
HEAD TDISCON
Copyright  Siemens AG 2016 All rights reserved

DB_IPADDRESS DB_MANAGE DB_STATE


OB 1

DB_RCV_ DB_SND_
DATA DATA

RD_SYS_T

Description
Table 3-1
Block Note
DATASYNC_HEAD Function block for data synchronization; to enable a parallel
data synchronization with all the other field PLCs (solar tracker),
the block is called several times - each time with a different
instance data block - cyclically in the application program.
Per field PLC, there is one call of the FB in the OB1 in this
Application Example (4 field PLCs 4 calls).
TCON, TRCV, TSEND Function blocks for the communication (see also chapter 2.1.2);
and TDISCON the enable the data communication.
DB_IPADDRESS Data block; contains the IP addresses of all the field PLCs.
DB_STATE Data block; contains status information of every field PLC.

V3.1 21.03.2016 14/44


3 The blocks of the data synchronization

Block Note
DB_MANAGE Data block; contains information setting up the communication
channels.
DB_RCV_DATA Data block; contains the receive data of the field PLC in
separate structures.
DB_SND_DATA Data block; contains the receive data of the field PLC in
separate structures.
RD_SYS_T Function block; responsible for reading out the current and local
time for the time synchronization.

3.1.2 Program sequence in the field PLC

Program structure
The following graphic shows the complete user program of the field PLCs.
Figure 3-2

iDB TCON
DATASYNC_ TRCV
Copyright  Siemens AG 2016 All rights reserved

SUB
TSEND

DB_SND_RCV
_DATA

OB 1
SimpleAstro
Algorithm

WR_SYS_T

OB 30

OB 31

V3.1 21.03.2016 15/44


3 The blocks of the data synchronization

Description
Table 3-2
Block Note
DATASYNC_SUB Function block for data synchronization
TCON, TRCV, TSEND Function blocks for the communication (see also chapter 2.1.2);
the enable the data communication.
DB_SND_RCV_DATA Data block; contains sending data for and receiving data from
the head PLC.
SimpleAstroAlgorithm Function block; calculates the position of the sun on the basis of
the position data (longitude and latitude) sent.
WR_SYS_T Function block; responsible for reading out the current and local
time for the time synchronization.
OB 30, OB 31 Time-controlled organization block for the simulation of the
weather and production data

3.2 Data blocks


3.2.1 The data block of the head PLC
Copyright  Siemens AG 2016 All rights reserved

Overview
For establishing a communication connection, the data block “DATASYNC_HEAD”
needs more information
 about the field PLC
– IP addresses
– number of project engineers
– feedback concerning the status of the connection
 the maximum number of possible parallel connections
– with an S7-1200 as head PLC: eight connections
– with an S7-300/400 / WinAC as head PLC: 32 connections
 about the sending and receive structure
– size of each structure
– storage location
All these pieces of information are stored in different global data blocks:
Table 3-3
Data block Responsible for...
DB_IPADDRESS IP addresses of the field PLCs used
DB_MANAGE Number of field PLCs, length of the structures, global trigger for
starting the data synchronization
DB_RCV_DATA Storage location for the received data of every field PLCs
DB_SND_DATA Storage for the data to be sent
DB_STATE Communication status of every field PLC
These data blocks are described in the following:

V3.1 21.03.2016 16/44


3 The blocks of the data synchronization

DB_IPADDRESS
In the global data block “DB_IPADDRESS”, the IP addresses for every field PLC
are stored. Every IP address is defined as the data type “Struct”, and divided into
the segments “REM_1”, “REM_2”, “REM_3” and “REM_4” with the data type
“USInt” (S7-1200) or “byte” (WinAC).
Figure 3-3

DB_MANAGE
The global data block “DB_MANAGE” serves for the communication of the
connections.
Copyright  Siemens AG 2016 All rights reserved

Figure 3-4

In the parameter “Act_SubStation”, the “DATASYNC_HEAD” blocks store the


number of the last field PLC they called, or read the number of the next free field
PLC.
The parameter “Nr_of_Substations” contains the number of field PLCs.
“REQ_x” are Bool variables for using (REY_x “True”) or the release (REQ_x
“False”) of a “DATASYNC_HEAD” block and therefore with a connection resource.
For every “DATASYNC_HEAD” one bit is provided.

The parameters “LEN_SNDData” and “LEN_RCVData” each contain the length of


the send and receive structure in number of bytes.

V3.1 21.03.2016 17/44


3 The blocks of the data synchronization

DB_STATE
In this data block, the communication status of each field PLC is listed and updated
and observed while “DATASYNC_HEAD” is running. For every station, one byte is
provided.
Figure 3-5

The value of the status byte is to be interpreted as follows:


Table 3-4
Value Meaning
1 A connection between the head and the field PLCs is being established.
2 The connection between the head and the field PLC was successfully
established.
3 The data exchange between the head and the field PLC is completed and the
communication connection is disconnected.
Copyright  Siemens AG 2016 All rights reserved

4 The first attempt to establish a connection between the head and the field PLC
failed.
5 From the second attempt onwards (the status was “4” before), the system tries to
establish a connection for a certain period of time.
0 Field PLC available for access.

DB_SND_DATA and DB_RCV_DATA


The two data blocks contain the data to be synchronized.
The following rule is applied:
 The structure of the send data of the head PLC must be identical with the
receive structure of the field PLC.
 The structure of the receive data of the head PLC must be identical with the
send structure of the field PLC.
 The send and receive structure is the same for every field PLC.
For every field PLC one structure is stored in the data block.

Since the send and receive structure must be identical for all field PLCs, we
recommend the use of templates (PLC data types).
PLC data types are defined data structures which can be opened several times in
the program. The structure of a PLC data type is composed of several components
which can have different data types. There are the following possibilities of using
PLC data types:
 PLC data types can be used as data types for variables in a variable
declaration of code blocks or in data blocks
 PLC data types can be used as templates for creating global data blocks with
the same data structure.

V3.1 21.03.2016 18/44


3 The blocks of the data synchronization

UDT_HEAD_RCV_STRUCT
As the data type of the receive data, the template “UDT_HEAD_RCV_-STRUCT” is
used:
Figure 3-6

With this template, one sector is defined for every field PLC in the receive data
block “DB_RCV_DATA” of the head PLC.
Figure 3-7
Copyright  Siemens AG 2016 All rights reserved

UDT_HEAD_SND_STRUCT
As the data type of the receive data, the template “UDT_HEAD_RCV_-STRUCT” is
used:
Figure 3-8

With this template, one sector is defined for every field PLC in the send data block
“DB_SND_DATA” of the head PLC.
Figure 3-9

V3.1 21.03.2016 19/44


3 The blocks of the data synchronization

3.2.2 The data block of the field PLC

DB_SND_RCV_DATA
Since this communication connection is always initiated by the head PLC, it is
sufficient to integrate only one data block into the user program of the field PLC.
The global data block “DB_SND_RCV_DATA” contains the send and receive
structure for the data exchange.
The rules for the send and receive structure are also applied here:
 The structure of the send data of the field PLC must be identical with the
receive structure of the head PLC.
 The structure of the receive data of the field PLC must be identical with the
send structure of the head PLC.
Here, the data block template is also created by a template.

UDT_SUB_SND_STRUCT
As the data type of the receive data, the template “UDT_SUB_SND_-STRUCT” is
used:
Figure 3-10
Copyright  Siemens AG 2016 All rights reserved

UDT_SUB_RCV_STRUCT
As the data type of the receive data, the template “UDT_HEAD_RCV_-STRUCT” is
used:
Figure 3-11

V3.1 21.03.2016 20/44


3 The blocks of the data synchronization

With these templates, the data block of the field PLC is defined.
Figure 3-12

Note Since the send and receive structures must be identical for all field PLCs, these
templates can be reused for the other field PLCs.
Copyright  Siemens AG 2016 All rights reserved

V3.1 21.03.2016 21/44


3 The blocks of the data synchronization

3.3 The data block “DATASYNC_X”


Description
The function block “DATASYNC_X” controls the data synchronization between the
head and the field PLC.
For the head and the field PLC, there are different “DATASYNC_X” blocks which
differ as far as their functionalities scope and therefore their interface configuration
are concerned.

Interfaces for the head PLC


Calling the block has been described as follows:
Figure 3-13
Copyright  Siemens AG 2016 All rights reserved

V3.1 21.03.2016 22/44


3 The blocks of the data synchronization

Parameters
The parameters have the following meaning:
Table 3-5
Parameters Type Data Meaning
type
ID WORD A unique number for the communication connection. If
the “DATASYNC_HEAD” is called several times, a
different number must be selected.
REQ BOOL With “True” the data synchronization is triggered and a
supply resource is assigned.
With “False”" the synchronization process is stopped and
the approval of the communication is initiated
NR_SUBSTATIONS INT Number of project field PLCs
DB_NR_IPADDRESS Number of the data block
“DB_IPADDRESS”.
DB_NR_STATE INPUT Number of the data block
“DB_STATE”.
DB_NR_SND_DATA Number of the data block
“DB_SND_DATA”.
LEN_SND_DATA Length of the send structure
Copyright  Siemens AG 2016 All rights reserved

DB_NR_RCV_DATA Number of the data block


“DB_RCV_DATA”.
LEN_RCV_DATA Length of the receive structure
IDB_NR_LOC Number of the instance block of this
“DATASYNC_HEAD” block
ACT_SUBNET_NUM IN/ INT Variable for interim storage of the field PLC used last.
BER OUT
RSC_FREE OUT BOOL With “True”, the connection resource is released, as soon
as REQ has been set to “False”.

V3.1 21.03.2016 23/44


3 The blocks of the data synchronization

Interfaces for the field PLC


Calling the block has been described as follows:
Figure 3-14
Copyright  Siemens AG 2016 All rights reserved

Parameters
The parameters have the following meaning:
Table 3-6
Parameters Type Data type Meaning
ID WORD A unique number for the communication connection.
REM_IP1 First part of the IP address of the head PLC
REM_IP2 INPUT Second part of the IP address of the head PLC
USINT
REM_IP3 Third part of the IP address of the head PLC
REM_IP4 Fourth part of the IP address of the head PLC
SND_DATA Pointer to the send section
IN/ OUT VARIANT
RCV_DATA Pointer to the receive section

V3.1 21.03.2016 24/44


4 Mechanisms of data synchronization

4 Mechanisms of data synchronization


4.1 Control process in the overview
With the block “DTASYNC_X” a possibility of replacing control and status
information between the head PLC and the field PLCs (solar trackers in solar
parks) automatically and effectively and of synchronizing the time has been
realized.
The following diagram shows the process in the head and in a field PLCs:
Figure 4-1
Head PLC with
DATASYNC_HEAD
Initiation of the data
synchronization

Find next free field PLC


Copyright  Siemens AG 2016 All rights reserved

Copy IP address of the field


PLC from the global DB into
the instance DB
Field PLC z with
DATASYNC_SUB

Establish connection Establish connection

Copy send structure from the Receive data from the


global DB to the instance DB head PLC

Copy receive structure from


Send data to the free field PLC the instance DB
into the global DB

Copy send structures from the


Receive data from the field PLC
global DB to the instance DB

Copy receive structure from


the instance DB Send data to the central PLC
to the global DB

Disconnect the connection

V3.1 21.03.2016 25/44


4 Mechanisms of data synchronization

4.2 Functioning of the function block DATASYNC_X


In this chapter, the functioning of the “DATASYNC_X” block is briefly explained.
For more details, please refer to the program code which has good comments.

Establish communication connection


The command “TCON” establishes and builds up the communication connection.
As soon as the connection is working, it is automatically maintained and monitored
by the CPU. “TCON” is carried out in several cycles.
The block receives the required information such as
 the IP address of the connection partner
 the number of the connection
through the input parameters in the “DATASYNC_X” block.

Send data
The command “TSEND” sends data through an existing communication
connection. “TSEND” is carried out in several cycles.
The block receives the required information through the input parameters in the
“DATASYNC_X” block.
Copyright  Siemens AG 2016 All rights reserved

Receive data
The command “TRCV” sends data through an existing communication connection.
“TRCV” is carried out in several cycles.
The received data are buffered in a receive area, and then they are transmitted to
the receive area.
The receive area is defined by the following two dimensions:
 pointer at the beginning of the area
 length of the area in number of bytes.
This information is transmitted by the parameters at the “DATASYNC_X” block.

Establish a communication connection (head PLCs only)


The instruction “TDISCON” disconnects the communication connection of the CPU
to the communication partner. “TDISCON” is a command working over several
cycles.
When the connection has been disconnected successfully, the ID entered in the FB
“TCON” is no longer valid and can therefore be neither used for sending nor for
receiving.

V3.1 21.03.2016 26/44


4 Mechanisms of data synchronization

Copy data
The transmission of the data (IP address, send and receive structure) between a
global data block and an instance data block is done by MOVE commands.
The storage address where the information of the current field PLC is located, is
determined by an Offset calculation.
The following graphic shows the principle with the example of an IP address.
The global data block “DB_IPADDRESS” contains the IP address for all the field
PLCs. The block “DATASYNC-HEAD” calculates the Offset for the storage area of
the IP address of the field PLC to be edited on the basis of the IN/OUT variables
“ACT_SUBNET_Number”.
Figure 4-2
Global DB Instance DB
DB_IPADDRESS DATASYNC-HEAD

ACT_SUBNET_NUMBER:=3
IP address
4- Bytes
Field PLC 1
IP addresse
Field PLC 2
Copyright  Siemens AG 2016 All rights reserved

Offset: 2 * 4-Bytes
IP address
Field PLC 3
IP address
IP address Field PLC 3
Field PLC z

4.3 Behavior in the event of a power failure


If more than one field PLCs are involved in the data synchronization, it must be
made sure that the synchronization mechanism to the intact field PLCs is not
blocked in the event if one or more field PLCs break down (e.g. because the
connection cable is pulled out).
To solve this problem, the status of the communication connection of each field
PLCs is documented in the data block “DB_STATE” (see chapter 3.2.1). These
status values are compiled by means of the status parameters “TCON_Busy” or
“TRCV_Error” of the communication blocks (TCON, TSEND, TRCV, TDISCON).
If an interruption of the communication to a field PLC is detected (status value: 4),
the block “DATASYNC_HEAD” tries to reestablish the connection for a defined
period of time (status value: 5). If it does not succeed, this will be acknowledged
with an error message.
As soon as a connection has been reestablished, the error message is deleted.

V3.1 21.03.2016 27/44


5 Performance Measurement

5 Performance Measurement
Objective
In order to be able to describe the performance of the program, a performance
measurement is carried out.
The following chapter describes:
 the concept of the performance measurement.
 the measurement results.
 an analysis of the values.

5.1 Conception of the measurement


Structure
The following hardware constellation was used for the measurement:
 Constellation 1:
– Head PLC S7-1200-CPU
– Field PLCs: up to 32 S7-1200-CPUs
 Constellation 2:
Copyright  Siemens AG 2016 All rights reserved

– Head PLC IPC


– Field PLCs: up to 32 S7-1200-CPUs
These components were interconnected in accordance with the instructions in
chapter 6.
Figure 5-1
Head PLCs with up to eight function blocks
“DATASYNC_HEAD”

S7-1200 IPC + WinAC

DATASYNC_ DATASYNC_
DATASYNC_
HEAD DATASYNC_
HEAD
DATASYNC_
HEAD DATASYNC_
HEAD
DATASYNC_
HEAD DATASYNC_
HEAD
HEAD HEAD

DATASYNC_ DATASYNC_ DATASYNC_


SUB SUB SUB

...
1, 4, 8, 16, 32 Field-PLCs S7-1200 with function
block DATASYNC_SUB

In the user program of the head PLC, up to eight function blocks


DATASYNCH_HEAD are called in the OB1 (see also chapter 2.1.2).

V3.1 21.03.2016 28/44


5 Performance Measurement

Measuring scenarios
For the performance measurement, several variants were measured that differ in
the following aspects:
 type of head PLC
 number of substations
 data load
 program load.
The following table shows the values:
Table 5-1
Parameters Settings
Type of head PLC S7-1200 (CPU 1215), WinAC (IPC 227D)
Number of substations 1, 4, 8, 16, 32
Size of the area to be synchronized (in 10, 100, 200, 1000
bytes)
Program load (in ms) 6, 50

Measure cycle
The measuring clock is started before the connection to the first substation is built
Copyright  Siemens AG 2016 All rights reserved

up. The end of a measure cycle is the point in time when all the substations have
been synchronized once.

V3.1 21.03.2016 29/44


5 Performance Measurement

5.2 Values of the performance measurement


Data conditioning
To avoid systematic errors, the measuring parameters are determined by repeated
measurement.
100 subsequent measurements are determined and processed as representative
measuring data. All the values and the maximum and the minimum synchronization
time of a measure of a series of measurements are listed in the Annex (see
chapter 11).

Diagrams
The following diagrams show the time for a synchronization cycle the S7-1200
(gray line) needs as compared to the WinAC (blue line) for two measuring
scenarios.

Figure 5-2

4000
200 Byte,6 ms
200 byte, 6 ms Programmlast
program load
3000
Copyright  Siemens AG 2016 All rights reserved

Zeit in ms
Time in ms

2000
S7-1200
1000 WinAC

0
1 4 8 16 32
Anzahl
NumberSubstationen
of substations

Figure 5-3

10000
1000
1000 Byte,
byte, 5050
msms Programmlast
program load
8000
in ms
Time in ms

6000

S7-1200
Zeit

4000
WinAC
2000

0
1 4 8 16 32
Anzahl
NumberSubstationen
of substations

Detailed values
The detailed values of the performance measurement are listed in chapter 11
“Appendix A: Measured Data”.

V3.1 21.03.2016 30/44


5 Performance Measurement

5.3 Result
Overview
These are the results of the individual measurements:
 The WinAC always synchronizes the data fields quicker than the S7-1200.
 The higher the number of substations, the higher is the time difference
between the synchronization for the S7-1200 and the Win AC.
 The synchronization time increases clearly when more than 8 substations are
being used.
 The synchronization time increases with the number of substations and the
volume of the data to be synchronized.

Analysis
The measured values allow the following conclusions:
 The first two observations can be attributed to the increased performance of
the current Intel atomic chip of the IPC as compared to the processor of the
S7-1200 CPU.
 Up to a number of 8 substations there is a call of the FB “DATASYNC_HEAD”
Copyright  Siemens AG 2016 All rights reserved

per substation in the OB1. Accordingly, the computing time increases, but the
synchronization time does not increase proportionally to the number of
substations, since the connection resources can be used in parallel.
From a number of 8 substations or more, the maximum number of connection
resources of the two head PLC is used up, so that the parallel processing is
completed by a serial processing. For more details about the behavior of the
program, please refer to Figure 2-5.

V3.1 21.03.2016 31/44


6 Installation

6 Installation

6.1 Hardware installation


The figure below shows the hardware setup of the application.
Figure 6-1

Possible Head PLCs


TP700 CPU 1215C IPC 277D

PG
192.168.0.50 192.168.0.45 192.168.0.55
24V 24V 24V

X208
Copyright  Siemens AG 2016 All rights reserved

24V

CPU 1214C CPU 1212C CPU 1212C CPU 1212C

192.168.0.1 192.168.0.2 24V 192.168.0.3 192.168.0.4 24V


24V 24V

Connect one head PLC (a CPU 1215C or an IPC277D), the field PLCs, the
SCALANCE X208 and the panel to one 24V power supply each. Connect all the
devices with a SCALANCE X208 by means of a standard Ethernet cable.

Note The installation guidelines for these components must always be observed.

V3.1 21.03.2016 32/44


6 Installation

6.2 Software installation


Development software
Install the TIA V13 SP1 on your configuration computer.
Follow the instructions of the installation program.

Application software
For each head PLC, a sample program is available.
Unpack the zipped code folder 39040038_DATASYNC_CODE_v22.zip from the
download area into a folder you chose.
In this folder, there are the STEP 7 V13 project folders:
 DATASYNC_1200 for the S7-1200 CPU as the head PLC.
 DATASYNC_IPC for the IPC with WinAC as the head PLC
Navigate to the project folder you need and open the TIA project Datasync.ap13
with a double click.
Copyright  Siemens AG 2016 All rights reserved

V3.1 21.03.2016 33/44


7 Starting up the Application

7 Starting up the Application


7.1 Assigning the IP addresses
The following IP addresses are used in this application:
Table 7-1
IP address Component
192.168.0.45 Head PLC S7-1200
192.168.0.55 Head PLC IPC
192.168.0.50 HMI panel
192.168.0.100 PG / PC
192.168.0.1 Field PLC 1
192.168.0.2 Field PLC 2
192.168.0.3 Field PLC 3
192.168.0.4 Field PLC 4
The subnet mask is 255.255.255.0.

PG / PC
Copyright  Siemens AG 2016 All rights reserved

Change the IP addresses of the PG / PC as follows:


Table 7-2
No. Action Note
1. For changing the network
address, open the Internet log
(TCP/IP) settings with “Start >
Control Panel > Network and
Internet > Network Connections”

Enter the IP address according


to the figure.
Then close all dialogs with OK.

V3.1 21.03.2016 34/44


7 Starting up the Application

SIMATIC components
The SIMATIC components are addressed in the TIA portal by means of the online
function “Assign IP address”.
Table 7-3
No. Action Note
1. Open the portal view of the TIA
portal project.
Copyright  Siemens AG 2016 All rights reserved

2. First open the tree for the HEAD


PLC and then double-click on
the function Online &
diagnostic.
Note:
If you use the IPC as the head
PLC, you use the function
Online & diagnostic in the
section of the WinAC.

3. In Functions, select Assign IP


address.
Click on the button Accessible
devices.

V3.1 21.03.2016 35/44


7 Starting up the Application

No. Action Note


4. If necessary, select the PG / PC
interface. The search for
accessible devices is carried out
automatically.
The result is shown in a list.
Identify the PLC you use as
HEAD via the MAC address and
click on Apply.

5. Assign the IP address stored in


the project with the command
Assign IP address.
The HEAD PLC now owns the IP
address stored in the project.
Copyright  Siemens AG 2016 All rights reserved

6. Change the IP addresses of the


field PLCs and of the panel in
the same way.

V3.1 21.03.2016 36/44


7 Starting up the Application

7.2 Download the PLCs and the panels


In the following, the SIMATIC components with the hardware configuration and the
user program are downloaded.

Note Please find a detailed instruction in the FAQ “How is a project downloaded in the
CPU in STEP 7 (TIA portal) V11?” in the Entry ID: 59728694.

Table 7-4
No. Action Note
1. At first, select the first field PLC.

Then download the device


configuration and the program to
the field PLC with the respective
symbol in Online > Download to
Device.
Copyright  Siemens AG 2016 All rights reserved

2. The project is compiled.


Click the “Load” button.

V3.1 21.03.2016 37/44


7 Starting up the Application

No. Action Note


3. Activate “Start all” to start the
block.
Exit the download with “Finish”.

4. Proceed in the same way for the


3 other remaining field PLCs.
Select the stations PLC_2 to
PLC_4 and download the
respective field PLC.
5. Select the head PLC.
Note:
When you use the IPC as the
Copyright  Siemens AG 2016 All rights reserved

head PLC, select the WinAC.

Then download the device


configuration and the program to
the head PLC with the respective
symbol in Online > Download to
Device.
The next download procedure is
carried out according to steps 2
and 3.

V3.1 21.03.2016 38/44


7 Starting up the Application

No. Action Note


6. For transferring the HMI project,
select the HMI station in the TIA
project and download it to the
panel with the respective symbol
or Online > Download to Device.
The next download procedure is
carried out according to step 2.
Note:
Any warning messages
concerning the name of the
objects in the visualization
images can be ignored.
Copyright  Siemens AG 2016 All rights reserved

V3.1 21.03.2016 39/44


8 Operating the Application

8 Operating the Application


To describe the principle of data synchronization clearly, several visualization
images were created for the panel.
 HEAD PLC: This overview serves for entering the positions of the field PLCs
and for activating the time synchronization.
 Field PLC 1…4: These images display the information transmitted by the field
PLCs:
– weather data
– production data
– calculated position of the sun

Note The data synchronization is started automatically.

Table 8-1
No. Action Note
1. In the HMI screen HEAD PLC,
enter the coordinates of every
field PLC. With these data, the
Copyright  Siemens AG 2016 All rights reserved

field PLCs calculate the current


position of the sun.

2. With the button Activate


TimeSync, you initiate the time
synchronization with all the field
PLCs.

V3.1 21.03.2016 40/44


8 Operating the Application

No. Action Note


3. Change to the visualization of
the field PLCs with the
navigation.
Here, the information is
displayed which the field PLCs
transmit to the head PLC.

4. With the HOME button you


change back to the HEAD PLC
overview screen at any time.
Copyright  Siemens AG 2016 All rights reserved

5. With the switch-off symbol, you


exit the runtime.

V3.1 21.03.2016 41/44


Related literature

Datasync 39040038

9 Related literature
This list is not complete and only represents a selection of relevant literature.

Bibliography
Table 9-1
Subject Title
/1/ STEP7 Automating with STEP7 in STL and SCL
SIMATIC S7-300/400 Author: Hans Berger
Publicis MCD Verlag
ISBN: 978-3-89578-397-5
/2/ STEP7 Automating with SIMATIC S7-1200
SIMATIC S7-1200 Author: Hans Berger
Publicis MCD Verlag
ISBN: 978-3-89578-355-5

Internet link specifications


39040038_DATASYNC_DOKU_V31_en.docx

This list is not complete and only represents a selection of relevant information
 Siemens AG 2016 All rights reserved

Table 9-2
Subject Title
/1/ Reference to the http://support.automation.siemens.com/WW/view/en/39040038
document
/2/ Siemens Industry http://support.automation.siemens.com
Online Support
/3/

10 History
Table 10-1
Version Date Modifications
V1.0 10/2009 First version
V2.0 05/2013 Complete review of code and document.
V3.1 03/2016 New warranty, Change V12 to V13 SP1

V3.1 21.03.2016 42/44


Appendix A: Measured Data

Datasync 39040038

11 Appendix A: Measured Data


11.1 Head: S7-1200; 6 ms program load
Number of
substations

Number of bytes 1 in ms 4 in ms 8 in ms 16 in ms 32 in ms
10 min 234 min 443 min 500 min 987 min 1912
max 323 max 3522max 3539max 3009 max 5155
average 280 average 741 average 1752average 2047 average 2334
100 min 357 min 376 min 507 min 1111 min 1923
max 459 max 2673max 3570max 4002 max 4413
average 399 average 725 average 982 average 2100 average 2417
200 min 342 min 411 min 449 min 956 min 2134
max 430 max 3467max 3446max 4052 max 6077
average 392 average 823 average 939 average 1356 average 3526
1000 min 300 min 387 min 470 min 1116 min 2860
max 393 max 3484max 3066max 4004 max 7819
average 351 average 772 average 924 average 2115 average 3395
39040038_DATASYNC_DOKU_V31_en.docx
 Siemens AG 2016 All rights reserved

11.2 Head: S7-1200; 50 ms program load


Number of
substations

Number of bytes 1 in ms 4 in ms 8 in ms 16 in ms 32 in ms
10 min 1637 min 1486min 1739min 3313 min 6944
max 1834 max 4710max 6899max 8053 max 12347
average 1740 average 2781average 3775average 5131 average 8490
100 min 1867 min 1740min 1724min 3494 min 7202
max 2009 max 4793max 6601max 6799 max 12598
average 1975 average 2805average 3230average 4977 average 8854
200 min 1657 min 1611min 1661min 3417 min 7157
max 1857 max 4757max 5743max 7205 max 12065
average 1721 average 2777average 3158average 4726 average 9226
1000 min 1672 min 1484min 1558min 3468 min 7000
max 1952 max 4645max 5010max 8668 max 12709
average 1853 average 2698average 3149average 5168 average 8830

V3.1 21.03.2016 43/44


Appendix A: Measured Data

Datasync 39040038

11.3 Head: WinAC; 6 ms program load


Number of
substations

Number of bytes 1 in ms 4 in ms 8 in ms 16 in ms 32 in ms
10 min 198 min 187 min 192 min 385 min 3108
max 219 max 362 max 536 max 643 max 803
average 209 average 257 average 304 average 479 average 1187
100 min 203 min 187 min 192 min 457 min 785
max 221 max 590 max 402 max 576 max 2617
average 215 average 277 average 280 average 523 average 1189
200 min 204 min 186 min 200 min 378 min 4441
max 222 max 792 max 2188 max 1144 max 789
average 213 average 287 average 463 average 667 average 1850
1000 min 202 min 193 min 202 min 178 min 799
max 221 max 795 max 1833 max 987 max 3062
average 211 average 444 average 475 average 785 average 1834

11.4 Head: WinAC; 50 ms program load


39040038_DATASYNC_DOKU_V31_en.docx
 Siemens AG 2016 All rights reserved

Number of
substations

Number of bytes 1 in ms 4 in ms 8 in ms 16 in ms 32 in ms
10 min 1694min 1550min 1538min 3124min 6223
max 1750max 3260max 2982max 4377max 10534
average 1704average 1812average 1972average 3353average 7537
100 min 1681min 1543min 1749min 3130min 6154
max 1741max 2344max 2649max 4321max 10668
average 1704average 2070average 2286average 3355average 7416
200 min 1681min 1532min 1538min 3128min 6256
max 1740max 3077max 3082max 7341max 11114
average 1703average 2178average 2428average 4182average 7502
1000 min 1678min 1533min 1541min 3134min 6010
max 1790max 3659max 4126max 6807max 10124
average 1707average 2172average 2566average 4065average 7700

V3.1 21.03.2016 44/44