show the entry list

ET 200pro -- Configuring and programming communication -- Using communication blocks 
What restrictions are there for active jobs when communicating with SFC 58 / SFC 59 and SFB 52 / SFB 53 via PROFIBUS DP and PROFINET IO? 
How do you program the communication blocks FB63 "TSEND", FB64 "TRCV", FB65 "TCON" and FB66 "TDISCON" in order to use the TCP protocol for data exchange by means of the integrated PROFINET interface of an S7-300 or S7-400 CPU? 
How do you program the communication blocks FB63 "TSEND", FB64 "TRECV", FB65 "TCON" and FB66 "TDISCON" in order to use the ISO-on-TCP protocol for data exchange by way of the integrated PROFINET interface of a CPU or by way of the CP443-1 Advanced? 
How do you program the communication blocks FB67 "TUSEND", FB68 "TURCV", FB65 "TCON" and FB66 "TDISCON" in order to use the UDP protocol for data exchange by means of the integrated PROFINET interface of a CPU? 

What restrictions are there for active jobs when communicating with SFC 58 / SFC 59 and SFB 52 / SFB 53 via PROFIBUS DP and PROFINET IO?Go to beginning
Part number:

Configuration Notes:
System functions and blocks SFB52 "RDREC" / SFC59 "RD_REC" (read record) are used to read data records of a component (module) of a DP slave/PROFINET IO device. System functions and blocks SFB53 "WRREC" / SFC58 "WR_REC" (write record) are used to write data records to a component (module) of a DP slave/PROFINET IO device.

Depending on the CPU used, the number of active jobs of the system functions and blocks SFB53/SFC58 and SFB52/SFC59 is limited.

The following table provides information about how many active jobs of the system functions and blocks SFB53/SFC58 and SFB52/SFC59 your CPU supports simultaneously.
 
System function/
system block
SFB 52 "RDREC"/
SFB 53 "WRREC"
SFC 59 "RD_REC"/
SFC 58 "WR_REC"
Explanation Data record from DP slave, PROFINET IO device Data record from DP slave
IM154 (ET 200pro)
IM151 (ET 200S)
IM147 (ET 200X)
4 jobs together with SFC 58/59 4 jobs together with SFB 52/53
CPU 312, CPU 313, CPU 314
CPU 315, CPU 316
4 jobs together with SFC 58/59 4 jobs together with SFB 52/53
CPU 317, CPU 319
CPU 318-2
8 jobs together with SFC 58/59 8 jobs together with SFB 52/53
CPU 41x1) 8 jobs each per PROFIBUS DP segment and PROFINET IO system 8 jobs each per PROFIBUS DP segment and PROFINET IO system
1) The number of simultaneous jobs on external PROFIBUS DP segments or PROFINET IO systems must not exceed 32 jobs per SFC/SFB.

Example:
With a CPU 414-2DP, a maximum of 48 jobs per SFC/SFB can be executed at the same time (8 each on the two PROFIBUS DP segments that are connected to the integrated interfaces of the CPU, and 32 on external PROFIBUS DP segments and PROFINET IO systems).

Rules:

  • There are no restrictions for simultaneous jobs in the subracks (CR, ER). The SFCs run synchronously via the backplane bus. Any number of synchronous SFCs can be called.
  • If you are operating multiple communication partners on the PROFIBUS network, then please make sure that never more than the specified jobs are active at the same time. Here one SFC/SFB can run several CPU cycles long.
  • The restrictions listed in this entry for the active jobs of the system functions and blocks SFB53/SFC58 and SFB52/SFC59 also apply to the blocks that call these system functions and blocks internally. These include the blocks FM_CS, PID_FM and FMCS_PID, for example.
    Example:
    When communicating with an FM 355 (4 channels parameterized) via the FMCS_PID block, 4 read jobs are occupied.

Note:
System functions SFC58/59 are available on all CPUs.

How do you program the communication blocks FB63 "TSEND", FB64 "TRCV", FB65 "TCON" and FB66 "TDISCON" in order to use the TCP protocol for data exchange by means of the integrated PROFINET interface of an S7-300 or S7-400 CPU?Go to beginning
Part number:

Description
The CPUs with integrated PROFINET interface and the WinAC RTX support open IE communication.

Entry ID 18909487 gives you an overview of the communication services that are supported by the CPUs with integrated PROFINET interface and by the WinAC RTX. This overview gives you information about which protocols of open IE communication are supported by the CPUs with integrated PROFINET interface and by the WinAC RTX.

The following communication blocks are available for open communication by way of Industrial Ethernet using TCP Protocol:

  • FB65 "TCON" for establishing the connection
  • FB66 "TDISCON" for ending the connection
  • FB63 "TSEND" for sending data
  • FB64 "TRECV" for receiving data

These communication blocks are available in the Standard Library -> Communication Blocks.
Copy the latest versions of the above-mentioned communication blocks from the standard library into your user program and then call them in your user program.
The connection parameters for setting up the TCP connection are saved in a data structure.
In this example, the data structure UDT65 "TCON_PAR" is used, which is parameterized by the user. The TCP connection is not configured in NetPro.

Description of the sample program
The S7 program contains the call of the FB65 "TCON" and the data structure UDT65 "TCON_PAR" with the connection parameters for setting up the TCP connection. The S7 program also includes the call of the communication blocks FB63 "TSEND" and FB64 "TRECV" from the Standard Library -> Communication Blocks. The FB63 "TSEND" is for sending data to an S7 station or to an S5 station, to a PC station or to a third-party system. The FB64 "TRECV" is for receiving data from another S7 station or an S5 station, from a PC station or from a third-party system.

First create the hardware configuration for the S7-300 station. Configure Marker byte 10 as clock marker. The send request is triggered by this clock marker. Save and compile the hardware configuration of your S7-300 station and load it into the CPU.

The STEP 7 program consists of blocks OB100, OB1, FB300, DB300, FC97, UDT65 and FB63, FB64, FB65 and FB66.

OB100
The OB100 is a restart OB and is run when the CPU is restarted (warm start). In this OB the first communication trigger is enabled with marker M0.3.

OB1
OB1 is called cyclically. The FB300 is called in OB1 with the instance data block DB300 and marker M0.3 as INIT_COM parameter. The marker M0.3 is reset in OB1 after the FB300 has been called.


Fig. 01

FB300
The FB300 is called cyclically in OB1.
The function FC97 "SET_TCP_ENDPOINTx" and the function blocks FB65 "TCON", FB63 "TSEND", FB64 "TRCV" and FB66 "TDISCON" are called in the FB300.


Fig. 02

Using the input parameters of the function FC97 "SET_TCP_ENDPOINTx" you define the local and remote parameters of the TCP connection.
 
Input parameters Data type Description
ID Word Connection number
DEV_ID Byte "local_device_id" of the interface by means of which the TCP connection is established with the FB65 "TCON".

Entry ID 51339682 informs you about which "local_device_id" you should parameterize at the DEV_ID input parameter in order to establish a connection with FB65 "TCON" for open communication by way of Industrial Ethernet.

ACTIVE Bool 0 = connection established passively
1 = connection established actively
LOC_PORT DInt Local port in the CPU

The manual "System and Standard Functions for S7-300/400 Volume 1 and Volume 2", section 24.2, provides information about the port numbers permitted for TCP and UDP. The manual is available for downloading in Entry ID 44240604.

REM_PORT DInt Remote port of the communication partner

The manual "System and Standard Functions for S7-300/400 Volume 1 and Volume 2", section 24.2, provides information about the port numbers permitted for TCP and UDP. The manual is available for downloading in Entry ID 44240604.

Note
If the CPU connection is established passively, this means ACTIV=0, then you do not have to specify the remote port of the communication partner, this means that you define REM_PORT=0.

IP_ADDR1 Int IP address of the communication partner

Note
If the CPU connection is established passively, this means ACTIV=0, then you do not have to specify the IP address of the communication partner, this means that you define IP_ADDR1=0, IP_ADDR2=0, IP_ADDR3=0 and IP_ADDR4=0.

IP_ADDR2 Int
IP_ADDR3 Int
IP_ADDR4 Int

Note
You enter the connection number in Network 2 of FB300. This is stored in a static tag and so in the instance DB DB300.


Fig. 03

Establishing a connection is started by a positive edge in the input parameter "REQ" of the FB65 "TCON". The data structure UDT65 "TCON_PAR" with the connection parameterization is incorporated in the instance data block of the FB300.
On the input parameter "CONNECT" of the FB65 "TCON", the memory area is specified that contains the connection parameterization.
The connection is set up at system start and remains until it is disabled with FB66 "TDISCON", or the CPU goes into STOP mode, or the power supply is switched off.


Fig. 04

The send request is triggered via a positive edge at the input parameter "REQ" of the FB63 "TSEND". The send job trigger is controlled by clock marker M10.6 and the "C1.SEND_BUSY" tag. If the send job is running, "C1.SEND_BUSY" is set. Triggering a new send request is not then possible.
You specify the memory area that contains the data to be sent at the input parameter "DATA".
You enter the number of bytes to be sent at the input parameter "LEN".
The output parameters "DONE", "ERROR" and "STATUS" are required for job evaluation.


Fig. 05

If the send job is completed successfully, "C1.SEND_BUSY" is reset. A new send job can now be triggered.

If the send job is completed with an error, then the "C1.SEND_BUSY" tag is likewise reset and the value of the "STATUS" output parameter of FB63 is saved for error analysis.


Fig. 06


Fig. 07

The data can be received as soon as the TCP connection is established.
With the input parameter "DATA", you specify the address and length of the data area where the received data is saved.


Fig. 08

The output parameter "NDR" is for showing that new data has been received. The output parameter "LEN" indicates the length of the data received.
If the data is not received successfully, then the value of the "STATUS" output parameter is saved and evaluated.


Fig. 09

You can clear down the TCP connection with the FB66 "TDISCON". You start the request to clear down the TCP connection with a positive edge at the "REQ" input parameter of the FB66 "TDISCON".


Fig. 10 

Note
The TCP protocol is used in this sample program for data transfer, which means that the "connection_type" parameter is defined with the value "B#16#11" in the UDT65 parameterization.
The S7-300 CPUs V2.3 support the TCP (compatibility mode). If you want to run the sample program on an S7-300 CPU V2.3, then change the value of the "connection_type" parameter to "B#16#01" in the UDT65 parameterization.

The STEP 7 project as download
The STEP 7 project contains a sample program for calling FB300 and the function FC97 "SET_TCP_ENDPOINTx", the blocks FB65 "TCON", FB66 "TDISCON", FB63 "TSEND" and FB64 "TRECV" with status evaluation. It was created with STEP 7 V5.5.

Sample_open_TCP.zip ( 46 KB )

Configuring additional TCP connections
To configure additional TCP connections, you copy the FB300 so that you receive another function block (such as FB301). Change the parameters and generate a new instance data block.

Additional information

  • Detailed information on open communication by way of Industrial Ethernet is available in the manual "System and Standard Functions for S7-300/400 Volume 1 and Volume 2" in Entry ID: 44240604.
  • Instructions for configuring a TCP connection for communication by way of S7-300 and S7-400 Industrial Ethernet CPs are available in Entry ID: 22385024.

How do you program the communication blocks FB63 "TSEND", FB64 "TRECV", FB65 "TCON" and FB66 "TDISCON" in order to use the ISO-on-TCP protocol for data exchange by way of the integrated PROFINET interface of a CPU or by way of the CP443-1 Advanced?Go to beginning
Part number:

Description
You can use the open communication over Industrial Ethernet for data exchange by way of the integrated PROFINET interface of a CPU or by way of CP4431 Advanced, for example. The protocols below are supported for this:

  • TCP
  • ISO-on-TCP
  • UDP

The following communication blocks are available for open communication over Industrial Ethernet using ISO-on-TCP Protocol:

  • FB65 "TCON" for establishing the connection
  • FB66 "TDISCON" for ending the connection
  • FB63 "TSEND" for sending data
  • FB64 "TRECV" for receiving data

These communication blocks are available in the Standard Library -> Communication Blocks.
Copy the latest versions of the above-mentioned communication blocks from the standard library into your user program and then call them in your user program.
The connection parameters for establishing the ISO-on-TCP connection are saved in a data structure. In this example, the data structure UDT65 "TCON_PAR" is used, which is parameterized by the user. The ISO-on-TCP connection is not configured in NetPro.

Description of the sample program
The S7 program contains the call of the FB65 "TCON" and the data structure UDT65 "TCON_PAR" with the connection parameters for establishing the ISO-on-TCP connection. The S7 program also includes the call of the communication blocks FB63 "TSEND" and FB64 "TRECV" from the Standard Library -> Communication Blocks. The FB63 "TSEND" is for sending data to an S7 station or to an S5 station, to a PC station or to a third-party system. The FB64 "TRECV" is for receiving data from another S7 station or an S5 station, from a PC station or from a third-party system.

First create the hardware configuration for your S7-300 station. Configure Marker byte 10 as clock marker. The send request is triggered by this clock marker. Save and compile the hardware configuration of your S7-300 station and load it into the CPU.

The STEP 7 program consists of blocks OB100, OB1, FB400, DB400, FB420, UDT65 and FB63, FB64, FB65 and FB66.

OB100
The OB100 is a restart OB and is run when the CPU is restarted (warm start). In this OB the first communication trigger is enabled with marker M0.3.

OB1
OB1 is called cyclically. The FB400 is called in OB1 with the instance data block DB400 and marker M0.3 as INIT_COM parameter. The marker M0.3 is reset in OB1 after the FB400 has been called.


Fig. 01

FB400
The FB400 is called cyclically in OB1. The following function blocks are called in FB400:

  • FB420 "SET_ISO_PARAM"
  • FB65 "TCON",
  • FB63 "TSEND",
  • FB64 "TRECV",
  • FB66 "TDISCON"


Fig. 02

Using the input parameters of the function FB420 "SET_ISO_PARAM" you define the local and remote parameters of the ISO-on-TCP connection.
 
Input parameters Data type Description
ID Word Connection number
DEV_ID Byte B#16#0 for the CP443-1 Adv
B#16#1 for the IM151-8 PN/DP CPU or
B#16#2 for the CPU 31x-2PN/DP, IM154-8 CPU or
B#16#3 for the CPU 319-3PN/DP or
B#16#5 for the CPU 412-2 PN, CPU 414-3 PN/DP, CPU 416-3 PN/DP
ACTIVE Bool True = connection established actively
False = connection established passively
TSAP Struct Local TSAP in the CPU and remote TSAP of the communication partner
IP_ADDR1 Int IP address of the communication partner
IP_ADDR2 Int
IP_ADDR3 Int
IP_ADDR4 Int
Table 01

The input parameter "TSAP" of the Struct data type is structured as follows:
 
Parameter Data type Description
LOC_RACK_SLOT Byte

Define the LOC_RACK_SLOT parameter with the value B#16#0 if the local TSAP is not to be prefixed with the two bytes with the values 0xE0 (hex) and 0x02 (hex). In the case of CPUs that support the ASCII format for the TSAPs, then the first two bytes of the local TSAP must not be defined with the values 0xE0 and 0x02.

Define the LOC_RACK_SLOT parameter with the value B#16#0 if the local TSAP is not to be prefixed with the two bytes with the values 0xE0 (hex) and 0x02 (hex). This is necessary for CPUs that do not support the ASCII format for the TSAPs.

LOC_TSAP String
  • Local TSAP (connection end point)
  • The user-defined ASCII string has the following values: 'TCP-1'.
CP_RACK_SLOT Byte Specify the rack and slot of the CP when communication is made over a CP443-1 Advanced.
REM_RACK_SLOT Byte

Define the REM_RACK_SLOT parameter with the value B#16#0 if the TSAP in the communication partner is not to be prefixed with the two bytes with the values 0xE0 (hex) and 0x02 (hex). In the case of CPUs that support the ASCII format for the TSAPs, then the first two bytes of the local TSAP must not be defined with the values 0xE0 and 0x02.

Define the REM_RACK_SLOT parameter with the value B#16#2 if the TSAP in the communication partner is to be prefixed with two bytes with the values 0xE0 (hex) and 0x02 (hex). This is necessary for CPUs that do not support the ASCII format for the TSAPs.

REM_TSAP String
  • TSAP (connection end point) in the communication partner
  • The user-defined ASCII string has the following values: 'TCP-1'.
Table 02

The CPUs below support the ASCII format for the TSAPs.

  • CPU 314C-2 PN/DP
  • CPU 315-2 PN DP, CPU 317-2 PN/DP as from V3.1
  • CPU 319-3 PN/DP as from V2.7
  • CPU 414-3 PN DP, CPU 416-3 PN/DP as from V5.2
  • CPU 412-2 PN as from V6.0
  • IM 151-8 PN/DP CPU as from V2.7
  • IM 154-8 CPU as from V3.2

Define local TSAP and TSAP in the communication partner
In this case the following TSAPs (connection end points) are used.
 
  Local TSAP in the CPU Remote TSAP of the communication partner
Initial value (ASCII) TCP-1 TCP-1
Initial value (hex) E0.02.54.43.50.2D.31 54.43.50.2D.31
Table 03

In the interface parameterization of FB400, you change the value of the local and remote TSAP in accordance with your configuration (see Fig. 04). In the "T_TSAP" structure, for the "LOC_TSAP" and "REM_TSAP" parameters you enter the local and remote TSAP of your configuration as initial value.
If the first two bytes of the local TSAP in the CPU are to be defined with the values 0xE0 and 0x02, then you change the interface parameters of FB400. In the "T_TSAP" structure, you define the initial value "B#16#2" for the "LOC_RACK_SLOT" parameter.
If the first two bytes of the remote TSAP are to be defined with the values 0xE0 and 0x02, then you change the interface parameters of FB400. In the "T_TSAP" structure, you define the initial value "B#16#2" for the "LOC_RACK_SLOT" parameter.


Fig. 03

Define connection number
You can change the connection number separately. Change the connection number in network 2 of FB400 in accordance with your configuration. The connection number is stored in a static tag and so in the instance data block DB400.
The connection number "1" is defined in this example.


Fig. 04

Connection setup
Establishing a connection is started by a positive edge in the "REQ" input parameter of the FB65 "TCON". The data structure UDT65 "TCON_PAR" with the connection parameterization is incorporated in the instance data block of the FB400.
On the input parameter "CONNECT" of the FB65 "TCON", the memory area is specified that contains the connection parameterization.
The connection is set up at system start and remains until it is disabled with FB66 "TDISCON", or the CPU goes into STOP mode, or the power supply is switched off.


Fig. 05

The send request is triggered by a positive edge at the input parameter "REQ" of the FB63 "TSEND". The send job trigger is controlled by clock marker M10.6 and the "C1.SEND_BUSY" tag. If the send job is running, "C1.SEND_BUSY" is set. It is then not possible to trigger a new send request.
You specify the memory area that contains the data to be sent at the input parameter "DATA".
You enter the number of bytes to be sent at the input parameter "LEN".
The output parameters "DONE", "ERROR" and "STATUS" are required for job evaluation.


Fig. 06

If the send job is successfully completed, "C1.SEND_BUSY" is reset. A new send job can now be triggered.
If the send job is completed with an error, then "C1.SEND_BUSY" is likewise reset and the value of the output parameter "STATUS" of FB63 is saved for error analysis.


Fig. 07


Fig. 08

The data can be received as soon as the ISO-on-TCP connection is established.
At the input parameters "DATA" and "LEN" you specify the address and length of the data area where the received data is saved.


Fig. 09

The output parameter "NDR" is for showing that new data has been received. The "RECV_LEN" output parameter indicates the length of the data received.
If the data is received successfully, then the value of the "RECV_LEN" output parameter is saved.


Fig. 10 

If the data is not received successfully, then the value of the "STATUS" output parameter is saved and evaluated.


Fig. 11 

You can clear down the ISO-on-TCP connection with FB66 "TDISCON". You start the request to clear down the ISO-on-TCP connection with a positive edge on the "REQ" input parameter of FB66 "TDISCON".


Fig. 12 

The STEP 7 project as a download
The STEP 7 project contains a sample program for calling FB400 "TSEND_TRECV_ISO1" and the function blocks FB420 "SET_ISO_PARAM", FB65 "TCON", FB66 "TDISCON", FB63 "TSEND" and FB64 "TRECV" with status evaluation. It has been created with STEP 7 V5.4 SP5.

Sample_open_ISO.zip ( 52 KB )

Configuring additional ISO-on-TCP connections
To configure additional ISO-on-TCP connections you copy the FB400 so that you receive another function block (such as FB401). Change the parameters and generate a new instance data block.

Additional Information

  • Detailed information on open communication over Industrial Ethernet is available in the manual "System and Standard Functions for S7-300/400 Volume 1 and Volume 2" in Entry ID: 44240604.
  • Instructions for configuring an ISO-on-TCP connection for communication with S7-300 and S7-400 Industrial Ethernet CPs are available in Entry ID: 47885440.

How do you program the communication blocks FB67 "TUSEND", FB68 "TURCV", FB65 "TCON" and FB66 "TDISCON" in order to use the UDP protocol for data exchange by means of the integrated PROFINET interface of a CPU?Go to beginning
Part number:

Description
You can use the open communication of the PROFINET for data exchange by means of the integrated Industrial Ethernet interface of a CPU, for example. The protocols below are supported for this:

  • TCP
  • ISO-on-TCP
  • UDP

The following communication blocks are available for open communication by way of Industrial Ethernet using the UDP protocol:

  • FB65 "TCON" for connecting the UDP endpoint
  • FB66 "TDISCON" for disconnecting the UDP endpoint
  • FB67 "TUSEND" for sending data
  • FB68 "TURCV" for receiving data

These communication blocks are available in the Standard Library -> Communication Blocks.
Copy the latest versions of the above-mentioned communication blocks from the standard library into your user program and then call them in your user program.
The parameters for connecting the UDP endpoint are saved in a data structure. In this example, the data structure UDT65 "TCON_PAR" is used, which is parameterized by the user. There is no need to configure a communication connection in NetPro.

Description of the sample program
The S7 program contains the call of the FB65 "TCON" and the data structure UDT65 "TCON_PAR" with the parameters for connecting the UDP endpoint. The S7 program also includes the call of the communication blocks FB67 "TUSEND" and FB68 "TURCV" from the Standard Library -> Communication Blocks. The FB67 "TUSEND" is for sending data to an S7 station, to a PC station, or to a third-party system. The FB68 "TURCV" is for receiving data from an S7 station, from a PC station or from a third-party system.

First create the hardware configuration for the S7-300 station. Configure Marker byte 10 as clock marker. The send request is triggered by this clock marker. Save and compile the hardware configuration of your S7-300 station and load it into the CPU.

The STEP 7 program consists of blocks OB100, OB1, FB500, DB500, FC95, FC96, UDT65, UDT66, and FB63, FB64, FB67 and FB68.

OB100
The OB100 is a restart OB and is run when the CPU is restarted (warm start). In this OB the first communication trigger is enabled with marker M0.3.

OB1
OB1 is called cyclically. The FB500 is called in OB1 with the instance data block DB500 and marker M0.3 as INIT_COM parameter. The marker M0.3 is reset in OB1 after the FB500 has been called.


Fig. 01

FB500
The FB500 is called cyclically in OB1.

The functions FC95 "SET_UDP_REMOTE"and FC96 "SET_UDP_ENDPOINT" as well as the function blocks FB65 "TCON", FB67 "TUSEND", FB68 "TURCV" and FB66 "TDISCON" are called in the FB500.


Fig. 02

Using the input parameters of the function FC96 "SET_UDP_ENDPOINT" you define the parameters of the UDP endpoint.
 
Input parameters Data type Description
ID Word Connection number
DEV_ID Byte B#16#01 for the IM151-8 PN/DP CPU
B#16#02 for the CPU 31x-2PN/DP, IM154-8 CPU
B#16#03 for the CPU 319-3PN/DP
B#16#05 for the CPU 412-2PN, CPU 414-3 PN/DP, CPU 416-3 PN/DP
LOC_PORT DInt Local port in the CPU
Permissible port numbers for S7-300 CPUs up to and including V2.6 and S7-400 CPUs up to and including V5.1: 2000 to 5000
Permissible port numbers for S7-300 CPUs V2.7 onwards and S7-400 CPUs V5.2 onwards: 1 to 49151


Fig. 03

Using the input parameters of the function FC95 "SET_UDP_REMOTE" you define the parameters of the UDP endpoint.
 
Input parameters Data type Description
REM_PORT DInt Remote port of the communication partner
Permissible port numbers for S7-300 CPUs up to and including V2.6 and S7-400 CPUs up to and including V5.1: 2000 to 5000
Permissible port numbers for S7-300 CPUs V2.7 onwards and S7-400 CPUs V5.2 onwards: 1 to 49151
IP_ADDR1 Int IP address of the communication partner
IP_ADDR2 Int
IP_ADDR3 Int
IP_ADDR4 Int

Note
You enter the connection number in Network 2 of FB500. This is stored in a static tag and so in the instance data block DB500.


Fig. 04

Connection of the UDP endpoint is started by a positive edge at the input parameter "REQ" of FB65 "TCON". The data structure UDT65 "TCON_PAR" with the parameterization of the local UDP endpoint is incorporated in the instance data block of FB500.
On the input parameter "CONNECT" of the FB65 "TCON", the memory area is specified that contains the parameterization of the local UDP endpoint.
The connection of the UDP endpoint is set up at system start and remains until it is disabled with FB66 "TDISCON", the CPU goes into STOP mode, or the power supply is switched off.


Fig. 05

The send job is triggered by a positive edge on the input parameter "REQ" of the FB67 "TUSEND". The send job trigger is controlled by clock marker M10.6 and the "C1.SEND_BUSY" tag. If the send job is running, "C1.SEND_BUSY" is set. It is then not possible to trigger a new send request.
You specify the memory area that contains the data to be sent at the input parameter "DATA".
You enter the number of bytes to be sent at the input parameter "LEN".
At the input parameter "ADDR" you specify the address of the data area where the recipient's IP address is stored. In this example, the address parameters of the communication partner are stored in the data structure UDT66 "TADDR_PAR". This is incorporated in instance data block DB500.
The output parameters "DONE", "ERROR" and "STATUS" are required for job evaluation.


Fig. 06

If the send job is successfully completed, "C1.SEND_BUSY" is reset. A new send job can now be triggered.
If the send job is completed with an error, then "C1.SEND_BUSY" is likewise reset and the value of the output parameter "STATUS" of FB67 is saved for error analysis.


Fig. 07


Fig. 08

The data can be received as soon as the UDP endpoint is connected.
With the input parameter "DATA", you specify the address and length of the data area where the received data is saved.
At the input parameter "ADDR" you specify the address of the data area where the sender's IP address is stored. In this example, the address parameters of the communication partner are stored in the data structure UDT66 "TADDR_PAR". This is incorporated in instance data block DB500.


Fig. 09

The output parameter "NDR" is for showing that new data has been received. The RCVD_LEN output parameter indicates the length of the data received.
If the data is successfully received, then the value of the "RCVD_LEN" output parameter is saved.
If the data is not received successfully, then the value of the "STATUS" output parameter is saved and evaluated.


Fig. 10 

You can disconnect the UDP endpoint with FB66 "TDISCON". You start the job to disconnect the UDP endpoint with a positive edge at the input parameter "REQ" of FB66 "TDISCON".


Fig. 11 

The STEP 7 project as download
The STEP 7 project contains a sample program for calling FB500 and the functions FC95 "SET_UDP_ENDPOINT", FC96 "SET_UDP_REMOTE", the blocks FB65 "TCON", FB66 "TDISCON", FB67 "TUSEND" and FB68 "TURECV" with status evaluation. It was created with STEP 7 V5.4 SP3.

Sample_open_UDP.zip ( 44 KB )

Configuration of UDP connections
In order to send UDP datagrams to multiple communication partners, you configure additional local and remote UDP endpoints. Copy the FB500 so that you receive more function blocks (such as FB501). Change the parameters of the local and remote UDP endpoint and generate new instance data blocks.

The ID of the local UDP endpoint can be selected from the value range of 1 to 4095.
The local and remote ports for S7-300 CPUs as from V2.7 and S7-400 CPUs as from V5.2 can be selected from the value range of 1 to 49151.

The ID and the port must be unique for each local UDP endpoint, in other words you must define a different ID and a different port for each local UDP endpoint.

Define the remote port and the IP address according to the configuration of the communication partner.

The table below shows how to configure multiple local and remote UDP endpoints. In this example, the same ID and the same port are used for the local and the remote endpoints.
 
Local/remote UDP endpoint 1 2 3
ID 1 2 3
LOC_PORT 2000 2001 2002
REM_PORT 2000 2001 2002
IP address of the communication partner 172.16.43.40 172.16.43.50 172.16.43.60

Additional information

  • Detailed information on open communication by way of Industrial Ethernet is available in the manual "System and Standard Functions for S7-300/400 Volume 1 and Volume 2" in Entry ID: 44240604.
  • Instructions for configuring a UDP connection for communication by way of S7-300 and S7-400 Industrial Ethernet CPs are available in Entry ID: 47885893.

 Entry ID:30143683   Date:2012-11-16 
I regard this article....as helpfulas not helpful                                 






























mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Topics
Help
Online Help
Guided Tour