Weihenstephan Standards
for S7-1200 / S7-1500
Communication Protocol
https://support.industry.siemens.com/cs/ww/en/view/109475571
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,
Siemens AG 2016 All rights reserved
Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, solutions, machines, equipment and/or
tion networks. They are important components in a holistic industrial security
concept. With this in mind, Siemens’ products and solutions undergo continuous
development. Siemens recommends strongly that you regularly check for
product updates.
For the secure operation of Siemens products and solutions, it is necessary to
take suitable preventive action (e.g. cell protection concept) and integrate each
component into a holistic, state-of-the-art industrial security concept. Third-party
products that may be in use should also be considered. For more information
about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a product-
specific newsletter. For more information, visit
http://support.industry.siemens.com.
Table of contents
Warranty and liability ............................................................................................... 2
1 Library Overview ............................................................................................ 4
1.1 Different user scenarios ..................................................................... 5
1.2 Hardware and software requirements................................................. 8
1.3 Library resources ............................................................................... 9
2 Blocks of the Library .................................................................................... 10
2.1 List of the blocks .............................................................................. 10
2.2 Explanation of the blocks ................................................................. 11
2.2.1 LWeihStd_Server (FB 30400) .......................................................... 11
2.2.2 LWeihStd_ServerBasic (FB 30401).................................................. 15
2.2.3 LWeihStd_Client (FB 30402) ........................................................... 17
2.2.4 LWeihStd_ComWriteDiagBuffer (FB 30403) .................................... 30
2.2.5 LWeihStd_ComSearchTag (FC 30400) ............................................ 31
2.2.6 PLC data types ................................................................................ 32
2.2.7 PLC tags ......................................................................................... 36
3 Working with the Library .............................................................................. 39
3.1 Integrating the library into STEP 7.................................................... 39
3.2 Integrating the library blocks into STEP 7......................................... 39
4 Notes and Support ....................................................................................... 41
Siemens AG 2016 All rights reserved
1 Library Overview
What you get
This document describes the 'Communication Protocol' part of the LWeihStd block
library. The block library provides you with the tested code with clearly defined
interfaces. They can be used as a basis for your task to be implemented.
A key concern of the document is to describe
all blocks of the block library
the functionality implemented through these blocks.
Furthermore, this documentation shows possible fields of application and helps you
integrate the library into your STEP 7 project using step-by-step instructions.
Scope of application
STEP 7 Professional V13 SP1
S7-1200 CPU as of firmware 4.1.1
S7-1500 CPU as of firmware 1.8.0
Siemens AG 2016 All rights reserved
The connection between server and client can be realized with standard Ethernet
interface. This allows a data evaluation which results in an efficiency analysis, a
batch tracing of data and of course a quality assurance. For an explicit definition of
the data, the content is described in a description file with a unique tag number, tag
name and data type.
More information on the Weihenstephan Standards for the food and beverage
packaging industry can be found at the according homepage
(http://www.weihenstephaner-standards.de/index.php?id=2&L=1).
The following section shows a scenario for a possible application of the LWeihStd
library:
Scenario
Machine PLCs are using the Weihenstephan Server application to provide their
production data. The Weihenstephan server application is available for SIMATIC
S7-300/400, S7-1200/S7-1500 and SIMOTION devices.
The Master PLC concentrates data from different machine PLCs or other
compatible devices that offer a Weihenstephan Server communication. It
exchanges the data between the Weihenstephan Client application and the
Weihenstephan Server (partner). The Weihenstephan Client application is
available for S7-300/400 devices and S7-1500 devices.
The Master PLC itself contains a Weihenstephan Server application to provide the
concentrated data of the line to the MES system that acts as a Weihenstephan
Client.
The supported commands and data points (tags) are described in an XML file
(PDACONF.xml). The data blocks containing the tags and administrative
information (tag number, access rights, data type) are created automatically based
on this XML file.
Weihenstephan Client
Command:
• NOOP
• READ_SVALUE
Answer according • WRITE_SVALUE
to Weihenstephan • READ_LIST
Standard • WRITE_LIST
• READ_STRING
• WRITE_STRING
+ Tag number
Weihenstephan Server
Hardware
Table 1-2 Hardware components
No. Component Article number Alternative
1. CPU 1513-1 PN 6ES7513-1AL00-0AB0 Other S7-1500 CPU with FW V1.8.0
2. Or CPU 1215C 6ES7215-1AG40-0XB0 Other S7-1200 CPU with FW V4.1.1
Software
Table 1-3 Software components
No. Component Article number Quantity
3. Step7 Professional V13 SP1 6ES7822-1..03-.. 1
4. Or Step7 Basic V13 SP1 6ES7822-0..03-.. 1
Siemens AG 2016 All rights reserved
Overall size
The overall size of the blocks used for a Weihenstephan Server application of the
LWeihStd library in the main memory is 23 Kbytes and 226 Kbytes in the load
memory.
The overall size of the blocks used for a Weihenstephan ServerBasic application of
the LWeihStd library in the main memory is 11 Kbytes and 124 Kbytes in the load
memory.
The overall size of the blocks used for a Weihenstephan Client application of the
LWeihStd library in the main memory is 25 Kbytes and 252 Kbytes in the load
memory.
The <MachineID> attached at the symbol name of the WS_Data_ and WS_Config_
data block depends on the unique name you choose while generating the source
files from the PDACONF.xml description file.
The total memory of WS_Data and WS_Config depends on the configuration and
data (PDACONF.xml) you choose.
How to generate the source files from the PDACONF.xml and to implement them in
your application can be found in chapter 4.
1
Instance data blocks (prefix instLWeihStd_) are not delivered with the library. They will be
generated automatically with the call of a function block.
Figure
LWeihStd_Server
LWeihStd_typeServer
configuration status Word
Configuration
LWeihStd_typeServer
diagnostics
Diagnostics
Siemens AG 2016 All rights reserved
Principle of operation
The FB LWeihStd_Server expects the required TCP parameterization (e.g. local
port number of the TCP server, unique connection ID) and the parameterization of
the Weihenstephan data as input. Furthermore it is necessary to define the tag
information and the list information to establish a successful connection according
to Weihenstephan Standards. The tagInfo consists of a unique tag number, the
data offset, data type and read/write access of each variable. The listInfo consists
of all lists and the contained tags in the lists.
The establishment of a connection, the status and the error information is provided
as outputs.
The output diagnostics provides further error information, e.g. values of runtime
measurement or a diagnostic buffer which contains detailed entries of occurred
errors.
Note The upper limit of the internal send buffer of the FB can be adapted by changing
the constant LWEIHSTD_SERVER_SEND_BUFFER_LEN. The value has a
minimal length of 8 and must be divisible by 4.
Note The upper limit of the internal receive buffer of the FB can be adapted by
changing the constant LWEIHSTD_SERVER_RECEIVE_BUFFER_LEN. The
value has a minimal length of 8 and must be divisible by 4.
Note The upper limit of diagnostic buffer array can be adapted by changing the
constant LWEIHSTD_SERVER_DIAG_BUFFER_UPPER_LIM.
Function characteristics
Figure 2-1: Timing diagram of FB LWeihStd_Server
1. After enabling the function block the TCP port is opened so that the client can
connect. As long as the client is not connected the output connected is not set
and the outputs busy and valid are set if no error occurs.
2. If the client is connected to the server the output connected is set.
Siemens AG 2016 All rights reserved
3. An error occurred that is cleared by the function block on its own, e.g. the
connection to the client is lost, while the FB was sending data. If this type of
error occurs, the outputs connected and valid are reset and the outputs error
and busy are set. After solving the error reason, e.g. by reconnecting, the FB
continues with normal workflow. The output error is reset and the output valid
is set.
4. An error occurred, that can only be cleared by the user. For example the data
DB or the configuration DB is incompatible. Then the outputs busy, valid and
connected are reset. The output error is set.
The output error can only be reset by resetting the input enable.
Input parameters
Table 2-2 LWeihStd_Server input parameters
Parameter Data type Description
enable Bool TRUE: Enable functionality of FB
(default: FALSE)
tagInfo Variant Array with Weihenstephan tag information
listInfo Variant Array with Weihenstephan list information
data DB_ANY Weihenstephan data DB number
configuration LWeihStd_typeServerConfiguration FB configuration
Output parameters
Table 2-3 LWeihStd_Server output parameters
Parameter Data type Description
connected Bool TRUE: Connection established
(default: FALSE)
valid Bool TRUE: Valid set of outputs available at the FB
(default: FALSE)
busy Bool TRUE: FB is working and new output values
can be expected
(default: FALSE)
error Bool Rising edge informs that an error occurred
during the execution of FB
(default: FALSE)
status Word Current status of FB
(default: STATUS_NO_CALL)
diagnostics LWeihStd_typeServerDiagnostics Diagnostic values of FB
Figure
LWeihStd_ServerBasic
LWeihStd_type
configuration error Bool
ServerConfiguration
status Word
subfunction
Word
Status
Principle of operation
The FB LWeihStd_Server expects the required TCP parameterization (e.g. local
port number of the TCP server, unique connection ID) and the parameterization of
Siemens AG 2016 All rights reserved
Note The upper limit of the internal send buffer of the FB can be adapted by changing
the constant LWEIHSTD_SERVER_SEND_BUFFER_LEN. The value has a
minimal length of 8 and must be divisible by 4.
Note The upper limit of the internal receive buffer of the FB can be adapted by
changing the constant LWEIHSTD_SERVER_RECEIVE_BUFFER_LEN. The
value has a minimal length of 8 and must be divisible by 4.
Note The upper limit of diagnostic buffer array can be adapted by changing the
constant LWEIHSTD_SERVER_DIAG_BUFFER_UPPER_LIM.
Function characteristics
Identically with LWeihStd_Server (FB30400), see chapter 2.2.1
Input parameters
Table 2-8 LWeihStd_ServerBasic input parameters
Parameter Data type Description
enable Bool TRUE: Enable functionality of FB
(default: FALSE)
tagInfo Variant Array with Weihenstephan tag information
data DB_ANY Weihenstephan data DB number
configuration LWeihStd_typeServerConfiguration FB configuration
Output parameters
Table 2-9 LWeihStd_ServerBasic output parameters
Parameter Data type Description
connected Bool TRUE: Connection established
(default: FALSE)
valid Bool TRUE: Valid set of outputs available at the
FB
(default: FALSE)
busy Bool TRUE: FB is working and new output values
Siemens AG 2016 All rights reserved
can be expected
(default: FALSE)
error Bool Rising edge informs that an error occurred
during the execution of FB
(default: FALSE)
status Word Current status of FB
(default: STATUS_NO_CALL)
subfunctionStatus Word Status of subsequent called function
Figure
LWeihStd_Client
LWeihStd_typeClient LWeihStd_typeClient
configuration diagnostics
Configuration Diagnostics
commands
Variant Variant
Siemens AG 2016 All rights reserved
Principle of operation
The FB LWeihStd_Client expects the required TCP parameterization (e.g. local
port number of the TCP client, unique connection ID, IP address and remote port of
Weihenstephan server) and the parameterization of the Weihenstephan data as
input. Furthermore it is necessary to define the tag information and the list
information to establish a successful connection according to Weihenstephan
Standards. . The tagInfo consists of a unique tag number, the data offset, data type
and read/write access of each variable. The listInfo consists of all lists and the
contained tags in the lists. The InOut parameter commands must be connected to
an array of the data type LWeihStd_typeClientCommand. The commands array
contains information about the sent commands. Every command in the commands
array can be set inactive.
Commands are sent cyclically (requestCycle) or by trigger input (executeRequest).
According to the chosen mode, all commands are sent in one block or only one
command is sent to the server and the client waits for acknowledgement.
The establishment of a connection, the status or error information is provided as
outputs.
The output diagnostics provides further error information, e.g. values of runtime
measurement or a diagnostic buffer which contains detailed entries of occurred
errors.
Note The upper limit of the internal send buffer of the FB can be adapted by changing
the constant LWEIHSTD_CLIENT_SEND_BUFFER_LEN. The value has a
minimal length of 8 and must be divisible by 4.
Note The upper limit of the internal receive buffer of the FB can be adapted by
changing the constant LWEIHSTD_CLIENT_RECEIVE_BUFFER_LEN. The
value has a minimal length of 8 and must be divisible by 4.
Note The upper limit of diagnostic buffer array can be adapted by changing the
constant LWEIHSTD_CLIENT_DIAG_BUFFER_UPPER_LIM.
Function characteristics
Figure 2-2: Timing diagram of FB LWeihStd_Client
Siemens AG 2016 All rights reserved
1. After enabling the function block a connection is established via TCP to the
server IP address and port. As long as the client is not connected the outputs
valid and connected are not set and the output busy is set if no error occurs. If
the client is connected via TCP, the output valid is set.
2. After the client is connected to the server via TCP, a NOOP command is sent
to the server to check its ability to communicate via Weihenstephan protocol. If
the response on the NOOP command is correct and arriving in the specified
time (configuration.cmdTimeout), the output connected is set.
3. An error occurred that is cleared by the FB on its own, e.g. the connection to
the client is lost, while the FB was sending data. If this type of error occurs, the
outputs connected and valid are reset and the outputs error and busy are set.
After solving the error reason, e.g. by reconnecting, the FB continues with
normal workflow. The output error is reset and the output valid is set.
4. An error occurred that can only be cleared by the user. For example the data
DB and the configuration DB is incompatible. Then the outputs busy, valid and
connected are reset. The output error is set.
The output error can only be reset by resetting the input enable.
Figure 2-3: Timing diagram for WSConnTest mechanism with triggered requesting
Siemens AG 2016 All rights reserved
1. The timer for sending a test request is started when the Weihenstephan
connection is established. A communication request (sending commands from
the commands array) stops the timer.
2. When receiving the response from the WS Server the test timer is restarted.
3. A NOOP command is sent when the timer is elapsed. The ping time can be
configured via configuration.WSConnTestCycleTime. The timer is restarted
when the response of the WS Server is received.
4. No request was sent since the last test, so a new NOOP command is sent.
5. If the WS Server does not respond on a configured number of retries
(configuration.maxNoOfFailedWSConnTests) an automatically cleared error is
set. The WS Client application reacts on automatically cleared errors by
closing the connection and reconnecting to the WS Server.
6. The WS connection is reestablished by sending a NOOP command to the
server and receiving a correct response. This clears automatically the error
and a new request can be triggered.
Request modes
The Weihenstephan client supports different modes of data exchange. The
decision which mode is best relates to the possibilities of the connected WS server.
The LWeihStd Server is able to communicate with the LWeihStd Client in each of
these modes.
Table 2-10: Supported request modes
Value Constant Triggered Cyclic Sequential Block Single
LWEIHSTD_REQUEST_
0 x x
MODE_SEQ_TRIG
LWEIHSTD_REQUEST_
1 x x
MODE_SEQ_CYCLIC
LWEIHSTD_REQUEST_
2 x x
MODE_BLOCK_TRIG
LWEIHSTD_REQUEST_
3 x x
MODE_BLOCK_CYCLIC
LWEIHSTD_REQUEST_
4 x x
MODE_SINGLE_TRIG
Siemens AG 2016 All rights reserved
Triggered requesting
If triggered requesting is selected (suffix _TRIG), the request is sent if no other
request is busy at the same time and the executeRequest input is set.
All active commands
Input of WS Client FB
executeRequest
PLC Runtime
Cyclic requesting
If cyclic requesting is chosen (suffix _CYCLIC), the request is sent the first time
when the client FB is enabled and a connection is established. At the same time
the first request is sent, a timer is started with the requestCycle time. After the timer
is elapsed, the next request is triggered automatically. The timer is restarted
immediately before the commands are sent to the server. If the requestCycle is
less than the roundtrip time of the commands (from client to server and back to the
client), a new request is sent immediately after receiving the response to the
request sent before.
Multiple of
0 1 2 3
requestCycle
requestCycle
The second difference is the type of sending the commands to the server:
WS Client WS Server
A request is triggered
Wait for telegram receive
Build telegram(s) with first
command of commands
array and send it to server Command received
Check response
… …
Request finished
Set requestDone
WS Client WS Server
A request is triggered;
deactivate receive Wait for receive of
message(s)
Add first command of
commands array to
message(s)
Enable receiving
Check responses
Request finished
Set requestDone
Single sending
Figure 2-8: Schema single sending
WS Client WS Server
A request is triggered
Wait for telegram receive
Build telegram(s) with first
command of commands
array and send it to server Command received
Request finished
Set requestDone
Siemens AG 2016 All rights reserved
Check response
Request finished
Set requestDone
… …
If single sending is selected, only one command is sent per trigger. If the last active
command in commands array is reached, the first active command in commands
array is sent. The advantage of this method is that a WS Server has to process
only one command at the same time and between each command a defined action
in client can take place before a new command is sent. All modes using single
sending have a _SINGLE_ in the name of the constant.
Input parameters
Table 2-11 LWeihStd_Client input parameters
Parameter Data type Description
enable Bool TRUE: Enable functionality of FB
(default: FALSE)
executeRequest Bool Rising edge triggers FB to execute a
request
requestMode USInt Mode for sending and receiving request
(see Request modes)
(default: LWEIHSTD_REQUEST_MODE_
SEQ_TRIG)
requestCycle Time Interval of sending requests for all
commands; T#0ms means triggered by
executeRequest
tagInfo Variant Array with Weihenstephan tag information
listInfo Variant Array with Weihenstephan list information
data DB_ANY Weihenstephan data DB number
configuration LWeihStd_typeClient FB configuration
Configuration
Output parameters
Siemens AG 2016 All rights reserved
InOut parameters
Table 2-13 LWeihStd_Client InOut parameters
Parameter Data type Description
commands Variant Array with commands
Server.
2. WS Client tries to reconnect to WS
Server. This empties the TCP stack
of the WS Client.
3. Send a NOOP command to WS
Server and wait for correct answer
for a specified time
(configuration.cmdTimeout).
Figure
LWeihStd_ComWriteDiagBuffer
LWeihStd_typeCom
entry entryIndex Int
DiagnosticEntry
diagnosticBuffer
Variant Variant
Principle of operation
This function block is called by the LWeihStd_Server FB and manages the
diagnostic buffer. In case of error LWeihStd_ComWriteDiagBuffer is called and
input entry will be written in the diagnostic buffer array. If input reset is TRUE, the
diagnostic buffer array will be initialized.
Siemens AG 2016 All rights reserved
Input parameters
Table 2-19: LWeihStd_ComWriteDiagBuffer input parameters
Parameter Data type Description
entry LWeihStd_typeComDiagnosticEntry Entry to be written into diagnostic buffer
reset Bool Reset/Initialize diagnostic buffer
Output parameters
Table 2-20: LWeihStd_ComWriteDiagBuffer output parameters
Parameter Data type Description
entryIndex Int Index of written entry in diagnostic buffer
(default: -1)
status Word FB Status
InOut parameters
Table 2-21: LWeihStd_ComWriteDiagBuffer InOut parameters
Parameter Data type Description
diagnosticBuffer Variant Diagnostic buffer array
Figure
LWeihStd_ComSearchTag
subfunction
Variant tagInfoArray Word
Status
Principle of operation
This function provides information about the requested tag number. The
tagNumber is searched in the tagInfoArray. The type of output tagInfo is a PLC
datatype which contains the address (data offset in data DB), the access rights
(read, write or read/write) and the datatype of the tag.
Input parameters
Table 2-22: LWeihStd_ComSearchTag input parameters
Siemens AG 2016 All rights reserved
Output parameters
Table 2-23: LWeihStd_ComSearchTag output parameters
Parameter Data type Description
tagInfo LWeihStd_typeComTagInfo Complete information of tag
subfunctionStatus Word Status of sub functions
LWeihStd_typeComDiagnosticEntry
An entry in the diagnostic buffer will be made when a message occurs.
LWeihStd_typeComTagInfo
The tagInfo contains a unique tag number, the data offset (address in data DB),
data type and access authorization of each variable.
LWeihStd_typeServerDiagnostics
This type contains diagnostics information for Server FB.
LWeihStd_typeServerConfiguration
The type configuration data contains information to establish a TCP
communication.
LWeihStd_typeClientDiagnostics
This type contains diagnostic information of the client FB.
LWeihStd_typeClientCommand
The type contains information about the used command with according tag
number. With the Boolean parameter isInactive commands can be set inactive.
LWeihStd_typeClientConfiguration
The type configuration data contains the information about the connection and
other configuration parameters like timeout detection for the client FB.
(default: 64)
cmdTimeout Time Timeout for receiving response for
previously sent command
(default: T#10s)
reconnectDelay Time Time to wait before reconnecting after
temporary error
(default: T#5s)
WSConnTestCycleTime Time Cycle time for sending NOOP
command if no other command is sent
(WS connection test), T#0ms means
cyclic test is disabled
(default: T#10s)
maxNoOfFailed USInt Maximum number of failed WS
WSConnTests connection tests before error is set that
can only be solved by user
(default: 3)
LWEIHSTD_COM_DATA_TYPE_ USInt 253 Internal data type mixed list with tag
MIXED_LIST numbers
LWEIHSTD_COM_DATA_TYPE_ USInt 254 Internal data type list with offset of first
CONT_LIST tag and number of tags (Continuous
list)
LWEIHSTD_COM_DATA_TYPE_ USInt 255 Internal data type list with offsets of all
NON_CONT_LIST tags (Non continuous list)
2. In TIA Portal select “Options” -> “Global libraries” -> “Open library…”
3. Browse to the file LWeihStd.al13.
It can be found in the subfolder LWeihStd of the extracted zip file.
4. Open the global library in read-only mode.
5. The LWeihStd library is now available in the task card “Global libraries”
Note The standard Weihenstephan port number 50000 cannot be used for an S7 with
PN interface because this number is in the range of the dynamically assigned
port numbers (49152 to 65535).
For a successful TCP connection we recommend to use user ports (1024-
49151), e.g. the port number 5000.
See: http://www.iana.org/assignments/service-names-port-numbers/service-
names-port-numbers.xhtml.
2. Browse to the appropriate description file (PDACONF.xml) via clicking the Browse button.
3. Choose a destination path to save the generated source file (WS_Source).
4. In the section MachineID type in a unique name for the accompanying application.
5. When you are finished, click Generate to create the source files for your TIA project.
6. The following source files have been added to your destination path:
WS_Source_<MachineID>.scl
Note Such machine description files (PDACONF.xml) can be generated with the
WS_Edit program.
See http://www.weihenstephaner-standards.de/index.php?id=29&L=1).
The tag “WS_Error” is defined as a HEX32 variable, which is read only tag with the
unique tag number “000000”.
Note The data in the tagInfo array must be sorted according to the tag number in
ascending order. The sorting is automatically done by the WS_TIA_GenTool.
Each element of the tagInfo array contains the tag number, the data offset, the
data type and the access rights of one data point
Note To avoid any incompatibility, invalid data or connection errors it is important not
to modify, add or delete any entries in the WS_Config DB.
5 Related literature
Table 5-1
Topic Title / Link
\1\ Siemens Industry http://support.automation.siemens.com
Online Support
\2\ Download page of http://support.automation.siemens.com/ww/view/en/109475571
this entry
\3\ Weihenstephan http://www.weihenstephaner-standards.de/index.php?id=2&L=1
Standards
6 Contact
Siemens AG
Digital Factory Division
Factory Automation
Production Machines
Siemens AG 2016 All rights reserved
DF FA PMA APC
Frauenauracher Str. 80
91056 Erlangen,Germany
mailto: tech.team.motioncontrol@siemens.com
7 History
Table 7-1
Version Date Modifications
V1.0 01/2016 First version