Udp BaseComm V1 en
Udp BaseComm V1 en
User Communication:
UDP
Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG (“Siemens”). They are non-
binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.
Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
© Siemens AG 2019 All rights reserved
foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.
Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use ([Link] shall also apply.
Security information
Siemens provides products and solutions with industrial security functions that support the secure
operation of plants, systems, machines and networks.
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 constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
[Link]
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: [Link]
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 2
Table of contents
Table of contents
Legal information ......................................................................................................... 2
1 Introduction ........................................................................................................ 4
1.1 Overview............................................................................................... 4
1.2 Principle of operation............................................................................ 6
1.3 Components used .............................................................................. 10
2 Engineering ...................................................................................................... 11
2.1 Interface description for S7-1200 and S7-1500 ................................. 11
2.2 Interface description for S7-300 and S7-400 ..................................... 14
2.3 Integration into the user project .......................................................... 17
2.3.1 Open library in STEP 7 (TIA Portal) ................................................... 17
2.3.2 Integrating the "LOpenUserComm_Udp" Function Module into
the User Program ............................................................................... 20
2.4 Determine hardware identification of the CPU or CP/CM
interface .............................................................................................. 22
2.5 Error handling S7-1200 and S7-1500 ................................................ 23
2.5.1 Error when establishing connection ................................................... 23
2.5.2 Error when receiving data .................................................................. 29
2.5.3 Error sending data .............................................................................. 33
2.5.4 Error when disconnecting ................................................................... 36
2.6 Error handling S7-300 and S7-400 .................................................... 38
2.6.1 Error when establishing connection ................................................... 38
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 3
1 Introduction
1 Introduction
1.1 Overview
Content of the application example
TCP/IP-based Open User Communication (OUC) has become the standard for
communication with SIMATIC S7 CPUs.
In the S7 CPU, the OUC is implemented on the basis of statements (for example,
TCON, TUSEND, TURCV, and TDISCON). The user must configure the
instructions in his user program and call them in a fault-tolerant way. Every user
has to rethink this task again and again. To facilitate this, we offer you a function
block (FB) in SCL. The FB calls the OUC instructions in the order and manner
recommended in the manuals. In addition, the FB already contains the following
mechanisms
• Connection management with the instructions "TCON" and "TDISCON".
• Send data to a partner CPU
• Receive data from a partner CPU
You can use the FB as a template for your own communication projects.
The application example provides the following information:
• Library for STEP 7 (TIA Portal) containing the FB
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 4
1 Introduction
Table 1-1
Protocol Telegram Programmed Note
length connections
ISO-on- Dynamic ✓ • Fast data transmission
TCP • Transmission of medium to large
amounts of data You can find
information on the maximum
data volumes of the CPUs in the
FAQ: 18909487.
• Mainly used in SIMATIC
homogeneous structures.
• Acknowledged
• Packet-oriented data
transmission, i.e. length and
information about beginning and
end of a telegram are also
transmitted.
TCP Fixed ✓ • Fast data transmission
• Transmission of medium to large
Dynamic ✓
amounts of data You can find
information on the maximum
data volumes of the CPUs in the
FAQ. 18909487.
• Flexible use with external
systems.
© Siemens AG 2019 All rights reserved
• Acknowledged
• Data is transmitted as a data
stream, i.e. length and
information about beginning and
end of a telegram are not
transmitted. For this reason,
when transmitting dynamic
telegram lengths, the transmitter
must define a message structure
that can be interpreted by the
receiver.
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 5
1 Introduction
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 6
1 Introduction
Figure 1-1
Wait for
external
Trigger
STATE_
IDLE enable=true
Disable Error
Connection Handling
[STATE_DIS Reestablish or [STATE_
1
CONNECT] close connection ERROR]
because of non
correctable error
Establish
3 Communi- Connection
cation partner [STATE_
enable=false disconnected CONNECT]
Wait for
© Siemens AG 2019 All rights reserved
TCON=ok
Connection
established
[STATE_
CONNECTED] Send 4
Received data request
processed
New data
Manage received Wait for
received ndr=1 Event Send Data
data [STATE_
[STATE_ SEND]
RECEIVE]
Wait for
TUSEND=ok
2 Error on disconnect
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 7
1 Introduction
Table 1-2
State Description Transition condition
STATE_IDLE (1) In the idle state The idle state "STATE_IDLE" is
"STATE_IDLE" the FB has only left if a connection is initiated
the following properties: via a parameter (enable).
• No connection is active.
• Status variables are
reset.
STATE_PARAM The UDP connection The FB immediately changes to
(2) parameters are read in and the state "STATE_CONNECT"
assigned to the statement without any transition condition.
TCON.
STATE_CONNECT The UDP connection to the The state "STATE_CONNECT" is
(3) partner is established. left if one of the following
conditions is fulfilled:
• If the connection has not yet
been established after the
watchdog timer (30 s) has
expired, the FB changes to
the "STATE_ERROR" state.
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 8
1 Introduction
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 9
1 Introduction
6GK7542-6VX00-
0XE0)
• CP 1543SP-1
(Item number:
6GK7543-6WX00-0XE0)
CPU 1214C DC/DC/DC 1 6ES7214-1AG40-0AB0 Alternatively, you can
use any S7-1200 CPU
with firmware V4.0 or
higher.
STEP 7 V15 Update 4 1 Package:
6ES7822-1AA05-0YA5
Download:
6ES7822-1AE05-0YA5
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 10
2 Engineering
2 Engineering
2.1 Interface description for S7-1200 and S7-1500
Functional description
The FB "LOpenUserComm_Udp" implements a complete UDP communication
relationship to a partner. It encapsulates all OUC instructions in a user-friendly
shell module to perform the following functions:
• Management of connection establishment and disconnection via the "enable"
input.
• Send user data at input "sendData" with the length "sendLen" to the partner as
soon as the input "sendRequest" detects a positive edge.
• Receiving data from a partner and saving it in the memory area created at
parameter "rcvData".
• Output of the status of the transmission and connection at the output
parameter "status".
Block interface
Figure 2-1
LOpenUserComm_UDP
© Siemens AG 2019 All rights reserved
connectionEs
Bool enable Bool
tablished
Bool sendRequest ndr Bool
status Word
sendData
Variant Variant
rcvData
Variant Variant
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 11
2 Engineering
The following table shows the inputs and outputs of the function block
"LOpenUserComm_Udp" for S7-1200 and S7-1500.
Table 2-1
Name P type Data type Comment
Enable IN Bool Release signal for connection establishment and
data exchange
sendRequest IN Bool Triggering the send request
rcvLen IN UInt Length of the receive area in bytes:
Value range: 0 (recommended) or 1 to 1472
(from firmware version V2.5 of the S7-1500
CPUs with Unicast or Multicast: 1 to 2048)
sendLen IN UInt Number of bytes that are to be sent with the job.
Value range: 1 to 1472 (from firmware version
V2.5 of the S7-1500 CPUs with Unicast or
Multicast: 1 to 2048)
udpConnParam IN TCON_IP_v4 Connection parameters
Detailed information can be found in the
section 3.1.2.
addrTurcv IN TADDR_Param Address information of the communication
partner for the "TURCV" instruction
Detailed information can be found in the
section 3.1.4.
addrTusend IN TADDR_Param Address information of the communication
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 12
2 Engineering
Note When sending more than 1472 bytes, you must ensure that your receiver
supports more than 1472 bytes. If this is not the case, you will not notice the
failed reception on the transmitter side.
© Siemens AG 2019 All rights reserved
Function diagrams
The following function diagram shows how the most important output parameters
are set depending on the input parameters.
Figure 2-2
activates / deactivates
enable
function block
function block
busy
is active
new data
ndr
received
ein Zyklus
aktiv request send data
sendRequest
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 13
2 Engineering
Note The length of the receive area must be at least as large as the length of the
receive data.
© Siemens AG 2019 All rights reserved
Block interface
Figure 2-3
LOpenUserComm_Udp
connectionEs
Bool enable Bool
tablished
Bool sendRequest ndr Bool
status Word
sendData
Any Any
rcvData
Any Any
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 14
2 Engineering
The following table shows the inputs and outputs of the function block
"LOpenUserComm_Udp" for S7-300 and S7-400.
Table 2-2
Name P type Data type Comment
Enable IN Bool Release signal for connection establishment and
data exchange
sendRequest IN Bool Triggering the send request
rcvLen IN Int Length of receiving data (in bytes): 1 to 1472
sendLen IN Int Maximum number of bytes sent with the job
udpConnParam IN TCON_PAR Connection parameters
Detailed information can be found in the
section 3.1.3.
addrTurcv IN TADDR_PAR Address information of the communication partner
for the "TURCV" instruction
Detailed information can be found in the
section 3.1.5.
addrTusend IN TADDR_PAR Address information of the communication partner
for the "TSEND" instruction
Detailed information can be found in the
section 3.1.5.
connectionEstablished OUT Bool Status display:
Connection setup executed
© Siemens AG 2019 All rights reserved
Note
With UDP, there is no feedback
(acknowledgement) from the communication
partner that the connection has actually been
established.
Ndr OUT Bool Status display:
Receive new data
Note
With UDP, no acknowledgement is sent to the
communication partner that the received data has
arrived.
Done OUT Bool Status display
Send job completed
Note
With UDP there is no feedback (acknowledgement)
from the communication partner that the
transmitted data was actually received.
Busy OUT Bool FB in process
Error OUT Bool Error display
rcvdLen OUT Int Length in bytes of the previously received data
statusID OUT Int Parameter indicates which OUC instruction returns
the error.
Status OUT Word Status display of the OUC instruction
sendData IN_OUT Any Send data area (contains address and length)
The address refers to:
• A data block
• A marker
• The process image of inputs
• The process image of outputs
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 15
2 Engineering
Function diagrams
The following function diagram shows how the most important output parameters
are set depending on the input parameters.
Figure 2-4
activates / deactivates
enable
function block
function block
busy
is active
new data
ndr
received
a cycle
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 16
2 Engineering
Requirement
• STEP 7 (TIA Portal) is open.
• You have created a new project in STEP 7 (TIA Portal) or have opened an
existing project.
Instructions
1. Open the "Libraries" task card.
2. In the "Global libraries" palette, click the "Open global library" button.
The "Open global library" dialog is opened.
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 17
2 Engineering
3. Select the library "LOpenUserComm.al15" and click on the button "Open". The
library "LOpenUserComm" is opened in the palette "Global libraries".
S7-300/S7-400") and under "Types > UDP > S7-1200/S7-1500" ("Types >
UDP > S7-1200/S7-1500").
5. Insert the function block "LOpenUserComm_Udp" via drag & drop from the
library into the folder "Program blocks" of your CPU.
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 18
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 19
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 20
2 Engineering
4. Assign the corresponding variables to the inputs and outputs of the function
block "LOpenUserComm_Udp".
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 21
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 22
2 Engineering
Note Since in the event of an error, the values at the output parameters are only
output for one cycle, the values of "status" and "statusId" must be stored if
error = 1.
Job to establish connection with "TCON" could not be executed successfully (watchdog
timer expired)
The watchdog timer is started as soon as a rising edge is detected at the "enable"
input of the FB "LOpenUserComm_Udp".
If the job to establish the connection was successfully executed with "TCON"
(DONE = 1), the watchdog timer is reset, but there is no acknowledgement from
the communication partner that the communication connection has really been
established successfully.
If the job to establish the connection with "TCON" has not been successfully
© Siemens AG 2019 All rights reserved
completed after 30 s, the watchdog timer runs out and the output parameters of the
FB "LOpenUserComm_Udp" are set for one cycle as follows.
Table 2-3
Output Value Description Remedy
parameters
status 16#8102 Connection could Check whether an error occurred when
not be established establishing a connection with "TCON"
(watchdog timer (ERROR = 1): Evaluate the output
(30 s) expired). parameters "statusID" and "status" of
the FB "LOpenUserComm_Udp" and,
statusId 1 Internal error in
if necessary, correct the error when
function module
establishing the connection with
Error 1 Error display: "TCON".
1: Error identified Initiate the connection setup again via
the parameter enable = 1.
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 23
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 24
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 25
2 Engineering
parameters
status 16#80A3 Status display of the Use a separate parameter data
"TCON" instruction set with different connection ID
and port number for each
statusId 2 Error when
establishing a connection.
connection with Initiate the connection setup
"TCON" again via the parameter
enable = 1.
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 26
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 27
2 Engineering
Table 2-15
Output Value Description Remedy
parameters
status 16#80A3 Status display of Since you are trying to re-establish an
the "TCON" existing connection, the connection is
instruction terminated by the FB.
statusId 2 Error when Initiate the connection setup again via
establishing a the parameter enable = 1.
connection with
"TCON"
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 28
2 Engineering
The output parameters of the FB "LOpenUserComm_Udp" are set for one cycle as
in Table 2-17 if the following conditions are given:
• Receive area is too small
• Value at parameter "rcvLen" greater than the receive range specified at
parameter "rcvData"
Table 2-17
Output Value Description Remedy
parameters
status 16#8088 Status display of the The value at parameter "rcvLen" must
"TURCV" instruction not be larger than the receive range
specified at parameter "rcvData".
statusId 3 Error when
receiving data with
"TURCV".
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 29
2 Engineering
Communication error
The output parameters of the FB "LOpenUserComm_Udp" are set for one cycle as
in Table 2-19 if one of the following communication errors occurs:
• The specified connection between user program and communication layer of
the operating system has not yet been established.
• The specified connection between the user program and the communication
© Siemens AG 2019 All rights reserved
layer of the operating system is being disconnected. A receive job over this
connection is not possible.
• The interface is being reconfigured.
Table 2-19
Output Value Description Remedy
parameters
status 16#80A1 Status display of The connection must be established
the "TURCV" to receive data.
instruction In the event of a communication error,
statusId 3 Error when the connection is terminated by the FB
receiving data with so that it can be re-established.
"TURCV".
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 30
2 Engineering
parameters
status 16#80A4 Status display of Check that you have defined the IP
the "TURCV" address of the remote connection
instruction endpoint in the "addrTurcv"
statusId 3 Error when parameter.
receiving data with
"TURCV".
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 31
2 Engineering
Parameter "rcvData" was changed before the current job was finished.
If you change the parameter "rcvData" before the current receive job has been
completed, the output parameters of the FB "LOpenUserComm_Udp" for one cycle
are set as follows.
Table 2-22
Output Value Description Remedy
parameters
status 16#80B1 Status display of Initiate the connection setup again via
the "TURCV" the parameter enable = 1.
instruction
statusId 3 Error when
receiving data with
"TURCV".
Error 1 Error display:
1: Error identified
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 32
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 33
2 Engineering
Communication error
The output parameters of the FB "LOpenUserComm_Udp" are set for one cycle as
in Table 2-25 if one of the following communication errors occurs:
• The specified connection between user program and communication layer of
the operating system has not yet been established.
• The specified connection between the user program and the communication
layer of the operating system is being disconnected. Transmission over this
connection is not possible.
• Reinitializing the interface.
Table 2-25
Output Value Description Remedy
parameters
status 16#80A1 Status display of The connection must be established
the "TUSEND" to send data.
instruction In the event of a communication error,
statusId 4 Error when sending the connection is terminated by the FB
data with "TSEND". so that it can be re-established.
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 34
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 35
2 Engineering
Order to terminate connection with "TDISCON" was not executed (watchdog timer
expired)
The watchdog timer is started as soon as a connection release order is started with
TDISCON (REQ = 1). A disconnect request is started when one of the following
conditions is met:
• A falling edge is detected at the "enable" input of the
FB "LOpenUserComm_Udp".
• An error occurs when establishing a connection with TCON, so that the
connection must first be terminated before it can be re-established.
• An error occurs when receiving or sending data.
If the order to terminate the connection was executed with "TDISCON" with
DONE = 1 or ERROR = 1, the watchdog timer is reset.
If the job to terminate the connection with "TDISCON" has not been completed
after 30 s, the watchdog timer runs out and the FB "LOpenUserComm_Udp"
changes to the state "STATE_IDLE", so that the connection can be established
again with enable = 1.
If you try to establish the connection with enable = 1 while the watchdog timer is
running, the output parameters of the FB "LOpenUserComm_Udp" for one cycle
are set as follows.
Table 2-28
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 36
2 Engineering
parameters
status 16#8086 Status display of the In the parameter data set
"TDISCON" "TCON_IP_V4", enter a value for "ID"
instruction that lies in the value range from 1 to
statusId 5 Error when 4095.
disconnecting with
"TDISCON".
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 37
2 Engineering
Note Since in the event of an error, the values at the output parameters are only
output for one cycle, the values of "status" and "statusId" must be stored if
error = 1.
Job to establish connection with "TCON" could not be executed successfully (watchdog
timer expired)
The watchdog timer is started as soon as a rising edge is detected at the "enable"
input of the FB "LOpenUserComm_Udp".
If the order to establish the connection was successfully executed with "TCON"
(DONE = 1), the watchdog timer is reset, but there is no acknowledgement from
the communication partner that the communication connection has really been
established successfully.
If the job to establish the connection with "TCON" has not been successfully
© Siemens AG 2019 All rights reserved
completed after 30 s, the watchdog timer runs out and the output parameters of the
FB "LOpenUserComm_Udp" are set for one cycle as follows.
Table 2-33
Output Value Description Remedy
parameters
status 16#8102 Connection could Check whether an error occurred when
not be established establishing a connection with "TCON"
(watchdog timer (ERROR = 1): Evaluate the output
(30 s) expired). parameters "statusID" and "status" of
the FB "LOpenUserComm_Udp" and,
statusId 1 Internal error in
if necessary, correct the error when
function module
establishing the connection with
Error 1 Error display: "TCON".
1: Error identified Initiate the connection setup again via
the parameter enable = 1.
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 38
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 39
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 40
2 Engineering
Table 2-39
Output Value Description Remedy
parameters
status 16#80A3 Status display of the Use a different connection ID for
"TCON" instruction each connection.
statusId 2 Error when Initiate the connection setup
establishing a again via the parameter
connection with enable = 1.
"TCON"
Error 1 Error display:
1: Error identified
2. If the connection ID is already used by an established connection that uses the
same parameter record at the udpConnParam parameter, an attempt is made
to establish an existing connection. The output parameters of the
FB "LOpenUserComm_Udp" are set for one cycle as follows.
Table 2-40
Output Value Description Remedy
parameters
status 16#80A3 Status display of the Use a separate parameter data
"TCON" instruction set with different connection ID
and port number for each
statusId 2 Error when
connection.
establishing a
connection with Initiate the connection setup
"TCON" again via the parameter
enable = 1.
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 41
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 42
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 43
2 Engineering
The output parameters of the FB "LOpenUserComm_Udp" are set for one cycle as
in Table 2-46 if the following conditions are given:
• Receive area is too small
• Value at parameter "rcvLen" greater than the receive range specified at
parameter "rcvData"
Table 2-46
Output Value Description Remedy
parameters
status 16#8088 Status display of the The value at parameter "rcvLen" must
"TURCV" instruction not be larger than the receive range
specified at parameter "rcvData".
statusId 3 Error when
receiving data with
"TURCV".
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 44
2 Engineering
Communication error
The output parameters of the FB "LOpenUserComm_Udp" are set for one cycle as
in Table 2-47 if one of the following communication errors occurs:
• The specified connection between user program and communication layer of
the operating system has not yet been established.
• The specified connection between the user program and the communication
layer of the operating system is being disconnected. A receive job over this
connection is not possible.
• The interface is being reconfigured.
Table 2-47
Output Value Description Remedy
parameters
status 16#80A1 Status display of The connection must be established
the "TURCV" to receive data.
instruction In the event of a communication error,
statusId 3 Error when the connection is terminated by the FB
receiving data with so that it can be re-established.
"TURCV".
Error 1 Error display:
1: Error identified
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 45
2 Engineering
Parameter "rcvData" was changed before the current job was finished.
© Siemens AG 2019 All rights reserved
If you change the parameter "rcvData" before the current receive job has been
completed, the output parameters of the FB "LOpenUserComm_Udp" for one cycle
are set as follows.
• Table 2-50
Output Value Description Remedy
parameters
Status 16#80B1 Status display of Initiate the connection setup again via
the "TURCV" the parameter enable = 1.
instruction
statusId 3 Error when
receiving data with
"TURCV".
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 46
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 47
2 Engineering
Communication error
The output parameters of the FB "LOpenUserComm_Udp" are set for one cycle as
in Table 2-53 if one of the following communication errors occurs:
• The specified connection between user program and communication layer of
the operating system has not yet been established.
• The specified connection between the user program and the communication
layer of the operating system is being disconnected. Transmission over this
connection is not possible.
• Reinitializing the interface.
Table 2-53
Output Value Description Remedy
parameters
Status 16#80A1 Status display of The connection must be established
the "TUSEND" to send data.
instruction In the event of a communication error,
statusId 4 Error when sending the connection is terminated by the FB
data with "TSEND". so that it can be re-established.
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 48
2 Engineering
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 49
2 Engineering
Order to terminate connection with "TDISCON" was not executed (watchdog timer
expired)
The watchdog timer is started as soon as a connection release order is started with
TDISCON (REQ = 1). A disconnect request is started when one of the following
conditions is met:
• A falling edge is detected at the "enable" input of the
FB "LOpenUserComm_Udp".
• An error occurs when establishing a connection with TCON, so that the
connection must first be terminated before it can be re-established.
• An error occurs when receiving or sending data.
If the order to terminate the connection was executed with "TDISCON" with
DONE = 1 or ERROR = 1, the watchdog timer is reset.
If the job to terminate the connection with "TDISCON" has not been completed
after 30 s, the watchdog timer runs out and the FB "LOpenUserComm_Udp"
changes to the state "STATE_IDLE", so that the connection can be established
again with enable = 1.
If you try to establish the connection with enable = 1 while the watchdog timer is
running, the output parameters of the FB "LOpenUserComm_Udp" for one cycle
are set as follows.
© Siemens AG 2019 All rights reserved
Table 2-56
Output Value Description Remedy
parameters
Status 16#8104 Connection could Initiate the connection setup again via
not be terminated the parameter enable = 1.
(watchdog timer
(30 s) expired)".
statusId 1 Internal error in
function module
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 50
2 Engineering
parameters
Status 16#8086 Status display of the In the parameter data set
"TDISCON" "TCON_PAR", enter a value for "id"
instruction that lies in the value range from
statusId 5 Error when W#16#0001 to 16#0FFF.
disconnecting with
"TDISCON".
Error 1 Error display:
1: Error identified
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 51
2 Engineering
2.7.1 STATE_IDLE
In the idle state "STATE_IDLE" all parameters (static variables and outputs of the
FB "LOpenUserComm_Udp") are reset.
The FB "LOpenUserComm_Udp" waits in the state "STATE_IDLE" until it detects a
positive edge at the input parameter "enable".
2.7.2 STATE_CONNECT
© Siemens AG 2019 All rights reserved
The order to establish the connection is triggered if the following conditions are
fulfilled:
• The input parameter "enable" is set to the value "true" so that the FB
recognizes a positive edge at the input parameter "enable".
• The connection has not yet been established.
• In order for the FB to be able to correct an error independently, the connection
setup is restarted internally.
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 52
2 Engineering
2.7.3 STATE_CONNECTED
2.7.4 STATE_RECEIVE
2.7.5 STATE_SEND
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 53
2 Engineering
2.7.6 STATE_DISCONNECT
with enable = 1.
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 54
2 Engineering
2.7.7 STATE_ERROR
The state "STATE_ERROR" evaluates the most important error information of the
OUC statements ("TON", "TDISCON", "TUSEND" and "TURCV") and shows the
user how to react to this error information.
The user has the option of extending the "STATE_ERROR" state according to this
schema as follows:
• Analyze further OUC error messages and realize individual reactions.
• Perform your own user-specific error analyses, e.g. if the received data does
not correspond to what the program expects.
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 55
2 Engineering
The following figure shows the general scheme according to which this state is
realized.
Figure 2-5
Start
From which
state was the
call made?
y Define
from STATE_ Decision on
CONNECT subsequent
reaction
state
n
y Define
from Decision on
© Siemens AG 2019 All rights reserved
STATE_ subsequent
DISCONNECT reaction
state
n
from y Define
STATE_
Decision on
subsequent
SEND reaction
state
n
from y Define
STATE_
Decision on
subsequent
SEND reaction
state
Start/Stop
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 56
2 Engineering
Note If an error occurs, the output parameter "error" is set to the value "1" for one
cycle and the corresponding error information is output at the output parameter
"status". The output parameter "statusId" provides you with information on the
status in which the error occurred.
The following table shows the values and meaning of the output parameters
"status" and "statusId" of the function module "LOpenUserComm_Udp".
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 57
2 Engineering
Table 2-61
statusId Meaning Status Comment
Wert (dec) Wert (hex)
1 internal error in 16#8101 Function module could not be activated
function module
1 internal error in 16#8102 Connection setup failed. The watchdog
function module timer (30 s) has expired.
1 internal error in 16#8103 Connection termination is still active.
function module Connection setup cannot yet be
started.
1 Internal error in 16#8104 Connection cannot be disconnected.
function module Watchdog timer (30 s) running. Restart
connection setup with enable = 1.
2 Error at TCON − The status of TCON is output at the
output parameter "status" of the
function block.
3 Error at TURCV − The status of TURCV is output at the
output parameter "status" of the
function module.
4 Error at TUSEND − The status of TUSEND is output at the
output parameter "status" of the
function module.
5 Error at − The status of TDISCON is output at the
TDISCON output parameter "status" of the
© Siemens AG 2019 All rights reserved
function module.
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 58
3 Useful information
3 Useful information
3.1 Basics
3.1.1 Basics of the UDP protocol
Further information about the UDP protocol can be found in the following FAQ:
[Link]
range: 0 to 65535)
2 to 3 ID CONN_OUC 1 Connection number
(value range 0 to 4095)
4 ConnectionType BYTE 19 Connection type:
• 19: UDP (19 dec =
0x13 hex)
5 ActiveEstablished BOOL FALSE Identifier for the manner
in which the connection
is established: You must
assign FALSE to this
parameter.
6 to 9 RemoteAddress ARRAY [1..4] − • IP address of the
of BYTE partner endpoint,
e.g. for [Link]:
– ADDR[1] = 192
– ADDR[2] = 168
– ADDR[3] = 0
– ADDR[4] = 2
• Multicast address of
an IPv4 multicast
group for S7-1500
CPUs V2.0 and later
10 to 11 RemotePort UINT 2000 Port address of the
remote connection
partner
(Value range: 1 to 49151)
12 to 13 LocalPort UINT 2000 Port of the local
connection partner (value
range 1 to 49151)
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 59
3 Useful information
Note We recommend that you use the same port for the local and remote connection
partners.
Table 3-2
Byte Parameters Data type Start value Description
0 to 1 block_length WORD W#16#40 Length of UDT 65:
64 bytes (fixed)
2 to 3 id WORD W#16#0001 Connection number:
(Value range:
W#16#0001 to
W#16#0FFF)
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 60
3 Useful information
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 61
3 Useful information
When using UDP connections in S7-1500 CPUs and S7-1200 CPUs, the address
information of the communication partner is stored in the system data type
"TADDR_Param":
• At the parameter "addrTusend" you pass the address information of the
recipient via "TADDR_Param".
The stored address data of the remote partner are read from the system data
type by the "TUSEND" instruction.
• At the parameter "addrTurcv" you get the address of the sender via
"TADDR_Param".
The address data is written from the instruction "TURCV" to the system data
type.
The system data type "TADDR_Param" contains the address information of the
communication partner, consisting of the IP address and the port number.
Table 3-3
Byte Parameters Data type Value Description
0 to 3 REM_IP_ADDR ARRAY − • IP address of the
[1..4] of communication partner,
BYTE e.g. [Link]
– REM_IP_ADDR[1] =
© Siemens AG 2019 All rights reserved
B#16#C0 (192)
– REM_IP_ADDR[2] =
B#16#A8 (168)
– REM_IP_ADDR[3] =
B#16#00 (0)
– REM_IP_ADDR[1] =
B#16#02 (2)
The IP address can be found
in the "Devices & Networks"
view in the properties of the
interface of the
communication partner.
• Multicast address of an
IPv4 multicast group:
For the instruction
"TUSEND" at S7-1500
CPUs from firmware
version V2.0.
• The "TURCV" statement
enters the IP address of
the sender in this
parameter if the sender
is in an IPv4 multicast
group.
4 to 5 REM_PORT_NR UINT 2000 Remote port number
(Value range: 1 to 49151)
6 to 7 RESERVED UINT 0 Not used. Leave this
parameter at the value "0".
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 62
3 Useful information
When using UDP connections in S7-300 CPUs and S7-400 CPUs, the address
information of the communication partner is stored in the data structure UDT 66
"TADDR_PAR":
• At the parameter "addrTusend" you pass the address information of the
recipient via "TADDR_PAR".
The stored address data of the remote partner are read from the system data
type by the "TUSEND" instruction.
• At the parameter "addrTurcv" you get the address of the sender via
"TADDR_PAR".
The address data is written from the instruction "TURCV" to the system data
type.
The system data type "TADDR_PAR" contains the address information of the
communication partner, consisting of the IP address and the port number.
Table 3-4
Byte Parameters Data type Value Description
0 to 3 rem_ip_addr ARRAY − • IP address of the
[1..4] of communication partner,
© Siemens AG 2019 All rights reserved
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 63
3 Useful information
Figure 3-1
The region "edgeDetection" contains the edge evaluation of the following input
parameters:
• "enable": Positive and negative edges are evaluated
• "sendRequest": Positive edge are evaluated
If a positive edge is detected at the input parameter "enable", the following actions
are executed in the FB "LOpenUSerComm_Udp":
• Output parameter "busy" is set to the value "1".
• State machine is initialized with the state "STATE_PARAM" in order to read in
the connection parameters and initiate a job for establishing the connection.
• State machine is initialized with the state "STATE_DISCONNECT" to terminate
the connection if it is not successfully established within 30 s.
If a negative edge is detected at the input parameter "enable", the state machine is
initialized with the state "STATE_DISCONNECT" in order to initiate a job to
terminate the connection.
If a positive edge is detected at the input parameter "sendRequest" and the
connection is established, the state machine is initialized with the state
"STATE_SEND" in order to initiate a send job.
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 64
3 Useful information
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 65
4 Appendix
4 Appendix
4.1 Service and support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks:
[Link]
Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts. Please send queries
to Technical Support via Web form:
[Link]/industry/supportrequest
© Siemens AG 2019 All rights reserved
Service offer
Our range of services includes the following:
• Plant data services
• Spare parts services
• Repair services
• On-site and maintenance services
• Retrofitting and modernization services
• Service programs and contracts
You can find detailed information on our range of services in the service catalog
web page:
[Link]
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 66
4 Appendix
OUC: UDP
Entry-ID: 109747710, V1.0, 07/2019 67