-

UDP_SEND

Note
For this function block, a new implementation is available which requires firmware version 2021.3 or newer. The new FB supports broadcasting. Refer to the topic "UDP_SEND_2" for details.

Type Function block
Description The function block is used to send an UDP (Universal Datagram Protocol) datagram to an UDP-capable Ethernet device via an IP socket. The IP socket must first be opened using the UDP_SOCKET function block before data can be sent.

Each transmission operation is triggered by a rising edge at the request REQ input. During this cycle, the function block copies the data to be sent (applied to the DATA input) into an internal buffer. The BUSY output is set to TRUE as long as data are being sent from the internal buffer. While BUSY = TRUE, the REQ input is ignored. The transmission of new data that are available at the DATA input during the ongoing transmission cycle can only be triggered with a rising edge at the REQ input once the BUSY output has been set to FALSE.

If an error occurs during execution of the function block, the ERROR output is set to TRUE for one cycle. The corresponding error code is provided at the STATUS output within this cycle.

The device to which the data are to be sent is specified with the DEST_IP parameter (IP address of the receiving device) and DEST_PORT parameter (port number of the receiving device).

WARNING
Unintended machine operation
Verify that the influence of the output data cannot result in an unintended or hazardous behavior of the entire system.1

1When running the application logic in simulation mode, the function blocks for Ethernet communication establish a real connection to other devices/servers. Thus, outputs and variables connected to real hardware may be set and therefore may cause real damage to the machine.

Notes
  • The IP socket opened by the UDP_SOCKET function block can only be used for subsequent calls of the UDP_SEND function block as long as the ACTIVE output of the UDP_SOCKET function block is TRUE. Calling the UDP_SEND function block while ACTIVE = FALSE causes an error at the UDP_SEND function block (ERROR = TRUE and STATUS code = 0xC210 issued).
  • For controllers with integrated firewall, make sure that the firewall does not block the ports involved in the communication. Otherwise, the connection cannot be established.
  • All IP addresses used are IPv4 addresses that consist of four numbers (0 to 255) separated by dot.
  • Function blocks have to be instantiated.
    The instance name of the function block has to be declared in the 'Variables' table of the POU where the FB is going to be used. The instance name must be unique within the POU.
Parameters Inputs

REQ

HANDLE

DEST_IP

DEST_PORT

DATA_CNT

Input/Output

DATA

Outputs

DONE

BUSY

ERROR

STATUS