show the entry list
Industrial Ethernet S7-300/400 CPs -- Configuring and programming communication -- Using communication blocks
How do you copy the CFC chart "Modbus" from the sample project for OPEN MODBUS / TCP into your user project?
What is the difference between the initialization and runtime parameters on the blocks for Modbus TCP?
Why is the status value A090 (hex) output for Modbus TCP although you have entered the correct license?
What are the differences between the licensed version and the downloadable demo version of the blocks for Modbus TCP?
Why is the value A083 (hex) output permanently at the STATUS output parameter of the block for Modbus TCP when the ENQ_ENR=true input parameter has been set?
How is data with variable message length transferred via the TCP protocol and received by an S7-300 station via the Industrial Ethernet CP?
How do you program the function blocks FB14 "GET" and FB15 "PUT" in the S7 program of the S7-300 in order to transfer more than 160 bytes of data?
Where can you find sample programs and documentation for communication from SIMATIC S5 modules to SIMATIC S7 modules via Industrial Ethernet using the UDP protocol?
Where can you find sample programs and documentation for communication from SIMATIC S5 modules to SIMATIC S7 modules via Industrial Ethernet using the TCP protocol?
Where can you find sample programs and documentation for communication from SIMATIC S5 modules to SIMATIC S7 modules via Industrial Ethernet using the ISO transport protocol?
How do you program the FC10 "AG_CNTRL"?
Which commands (CMD) of the FC10 "AG_CNTRL" are supported by the IE CPs?
How many communication jobs may be used simultaneously in an S7-300 CPU for S7 communication via a CP343-1?
Which ports are released for Modbus/TCP communication and how many Modbus clients can communicate with a SIMATIC S7 CPU as Modbus server?
Notes on using an instance for multiple connection IDs
Internal call of FC5 (AG_SEND) with FTP client blocks (FC 40-44) for the CP343-1 IT (6GK7 343-1GX11-0XE0)
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 communication blocks FC11 and FC12 for the PROFINET IO device?
Block calls for communications processors in multiple runtime layers
Changing the input parameter of the user blocks "AG_SEND" and "AG_RECV" during the runtime of a job
What should you watch out for if you transfer variables with the data type "REAL" when calling the communication blocks FC5/50 "AG_SEND/AG_LSEND" and FC6/60 "AG_RCV/AG_LRCV"?
What should you pay attention to when using the communication blocks FC53 "AG_SSEND" and FC63 "AG_SRECV"?
What points do you need to remember when calling communication blocks FC5/50 and FC6/60 in the STEP 7 user program of the CPU?
How do you program communication blocks FC11 and FC12 for the PROFINET IO controller?
How can you establish OPEN MODBUS / TCP communication from a SIMATIC S7 and where can you find further information?
How do you program the communication blocks FC50 and FC60?
Error STATUS "0x7000" on function block FC6 / FC60 (AG_SEND) with Send/Receive communication on the S7-400 controller
How do you program the communication blocks FC5 and FC6?
Sample program: S7 communication with the blocks SFB14 ("GET") and SFB15 ("PUT") with S7-400
Sample Program: S7 Communication with blocks FB14 ("GET") und FB15 ("PUT") of the CPU 317-2PN/DP
How do you program communication blocks FB8 "USEND" and FB9 "URCV" for data exchange on the S7-300?
"STATUS = 27" (0x001B) with the loadable S7 communication on the S7-300
How do you program communication blocks FB14 "GET" and FB15 "PUT" for data exchange in the S7 program of an S7-300 CPU?
How do you program communication blocks FB12 "BSEND" and FB13 "BRCV" for data exchange in the S7 program of an S7-300 CPU?
Repeating the "BSEND" job (SFB12) when the "BRCV" block (SFB13) is in the "disabled" state ("EN_R = 0")
PROFIBUS S7-300/400 CPs -- Configuring and programming communication -- Using communication blocks
How do you program the communication blocks FC50 and FC60?
How do you program communication blocks FB12 "BSEND" and FB13 "BRCV" for data exchange in the S7 program of an S7-300 CPU?
How do you program communication blocks FB14 "GET" and FB15 "PUT" for data exchange in the S7 program of an S7-300 CPU?
Which blocks for Modbus TCP can you rename or re-wire when the block numbers of the Mode blocks are already being used in the user program?
How do you program the function blocks FB14 "GET" and FB15 "PUT" in the S7 program of the S7-300 in order to transfer more than 160 bytes of data?
Where can you find sample programs and documentation for using the PROFIBUS DP protocol for data communication between SIMATIC S5 modules and SIMATIC S7 modules?
Where can you find sample programs and documentation for communication from SIMATIC S5 modules to SIMATIC S7 modules by way of PROFIBUS using the free Layer 2 of the FDL protocol?
Where can you find sample programs and documentation for communication from SIMATIC S5 modules to SIMATIC S7 modules by way of PROFIBUS using the FDL protocol?
Where can you find sample programs and documentation for using the PROFIBUS FMS protocol for data communication between SIMATIC S5 modules and SIMATIC S7 modules as well as for data communication between SIMATIC S5 modules and PCs?
Notes on using an instance for multiple connection IDs
Processing the data from DP slaves via CP342-5 on CPU31x
Block calls for communications processors in multiple runtime layers
Changing the input parameter of the user blocks "AG_SEND" and "AG_RECV" during the runtime of a job
What should you watch out for if you transfer variables with the data type "REAL" when calling the communication blocks FC5/50 "AG_SEND/AG_LSEND" and FC6/60 "AG_RCV/AG_LRCV"?
How do you program the communication blocks FC5 and FC6?
What properties and special features does S7 Basis Communication offer?
PROFIBUS: diagnostics of S7 connections with STEP 7
Repeating the "BSEND" job (SFB12) when the "BRCV" block (SFB13) is in the "disabled" state ("EN_R = 0")
How do you program communication blocks FB8 "USEND" and FB9 "URCV" for data exchange on the S7-300?
Particularities when assigning parameters of the communication blocks of CP 342 / CP 343
What should you watch out for when upgrading the CP 342-5 or fitting spare parts?
Which version of the function blocks do you need to operate a CP 342-5?
CP 342-5 -- How can you tell that the CP 342-5 has withdrawn from the PROFIBUS?
CP 342-5 -- How do you program data communications when your DP slave only has outputs?
CP 342-5 -- How can you read and write consistent data of a DP slave via the CP 342-5?
How do you program communication blocks FB8 "USEND" and FB9 "URCV" for data exchange on the S7-300?
Part number:

Instructions
Communication blocks FB8 "USEND" and FB9 "URCV" have to be called in the user program of the CPU in order to transfer data between two S7-300 stations by way of an S7 connection configured in NetPro.
Function block FB9 ("URCV") is for reading data out of a remote CPU and function block FB8 ("USEND") is for writing data to a remote CPU.
In this example the S7 connection for data communication between two S7-300 stations has to be configured on both sides, because the S7 communication by way of FB8 "USEND" and FB9 "URCV" is based on the client-client principle.

Note
If you are using an Industrial Ethernet CP for data communication via S7 connections in the S7-300 station, then utilize the function blocks FB8 "USEND" and FB9 "URCV" from the "SIMATIC_NET_CP" library under "CP 300 > Blocks".
If you are using the integrated PROFINET interface of a CPU31x-2PN/DP or CPU319-3PN/DP for data communication via S7 connections, then utilize function blocks FB8 "USEND" and FB9 "URCV" from "Standard Library -> Communication Blocks -> Blocks" with the "CPU_300" family.
With S7-400 the system function blocks SFB8 "USEND" and SFB9 "URCV" are available under Standard Library > System Function Blocks > Blocks for data communication via S7 connections.

Features of the FB8 "USEND" and FB9 "URCV" communication blocks

  • The FB8 and FB9 function blocks are asynchronous communication functions.
  • In this example, the blocks are called in the OB1 cycle (see also Entry ID: 2795485).
  • The FB8 and FB9 function blocks run for several OB1 cycles.
  • The FB8 function block is activated by the "REQ" input parameter.
  • The FB9 function block is activated by the "EN_R" input parameter.
  • The end of the job is indicated by "DONE", "NDR" or "ERROR".
  • USEND and URCV can communicate simultaneously via one connection.
  • Data transfer is uncoordinated, in other words receipt of data is not acknowledged by the communication partners.
  • The latest version the FB8 "USEND" and FB9 "URCV" communication blocks for data exchange by way of a CP343-1 or CP342-5 is available in the SIMATIC_NET_CP library under "CP 300 > Blocks".
  • The latest version of the FB8 "USEND" and FB9 "URCV" communication blocks with the "CPU_300" family for data exchange by way of the integrated PROFINET interface of a S7-300 CPU, IM151-8 PN/DP CPU or IM154-8 CPU is available in the Standard Library under "Communication Blocks > Blocks".

Description of the sample program
The STEP 7 project includes two S7-300 stations.
A CPU 315-2 DP is used in the first S7-300 station and a CP343-1 for data communication via Industrial Ethernet.
A CPU 319-3 PN /DP is used in the second S7-300 station. The integrated PROFINET interface of the CPU is used for data communication via Industrial Ethernet.

Marker byte 10 is configured as clock marker in both S7-300 CPUs. The send request is triggered by this clock marker.

In NetPro there is an S7 connection configured on both sides for data communication between the two S7-300 stations via Industrial Ethernet.
If you mark the CPU of the S7-300 station in NetPro, the S7 connection configured on both sides is displayed in the connection table.
In the connection table, right-click the S7 connection configured on both sides and open the Properties dialog of the S7 connection via the "Object Properties" menu.


Fig. 01

The IP addresses and the interfaces of the S7-300 stations via which data communication is to take place are defined in the Properties dialog of the S7 connection.
You determine the "Local ID" block parameters in the Properties dialog of the S7 connection. The value of the block parameter is specified at the "ID" input parameter when you call FB8 "USEND" and FB13 "URCV".
For the S7-300 station "SIMATIC 315" you activate the "Active Connection Setup" function in the Properties dialog of the S7 connection, because this actively sets up the S7 connection.
For the S7-300 station "SIMATIC 319" you deactivate the "Active Connection Setup" function in the Properties dialog of the S7 connection, because this participates passively in the connection set up.
Click the "Address Details..." button.


Fig. 02

The local TSAP and the partner TSAP are defined in the "Address Details" dialog. The S7 connection between the S7-300 stations is specified uniquely by means of the TSAPs.


Fig. 03

The STEP 7 program consists of blocks OB100, OB1, FB100, DB100, DB200, FB8 and FB9.

OB100 in CPU315-2 (Sender) and CPU319-3 PN/DP (Recipient)
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 0.3 "START-UP".

OB1 in CPU315-2 (Sender)
OB1 is called cyclically. FB100 is called in this OB (instance data block: DB100) with M0.3 "START-UP" as parameter (INIT_COM). After FB100 has been run the M0.3 "START-UP" is reset.


Fig. 04

FB100 in CPU315-2 (Sender)
FB100 is called in the OB1 cycle. In this sample program multiple send jobs are triggered by a configured S7 connection, which means that in FB100 the FB8 "USEND" is called multiple times with the same "ID" but with a different "R_ID".

Each FB8 is activated by the input parameter "REQ" when the M10.6 clock marker has a positive edge and no job is running. The "REQ" input parameter is reset only when the send job is completed either successfully or with an error.
This locking is particularly important, because the function is asynchronous and can last several cycles. Continual activation of the function block without waiting for the end of the active job can cause a communication overload.

The value for the "ID" input parameter must be taken from the Properties dialog of the S7 connection configured in NetPro (see Fig. 01).

With the "R_ID" input parameter you define the coherence of a send job and a receive job. The "R_ID" on the FB8 "USEND" of the sender must match that on the FB9 "URCV" of the recipient.

At the "SD_1" input parameter of FB8 you specify the address and length of the data area that contains the data to be sent (send buffer), for instance: P#DB200.DBX0.0 BYTE 10.
The output parameters "DONE", "ERROR" and "STATUS" are required for the job evaluation and are only valid in the same cycle.

The first FB8 "USEND" is called by the input parameters ID=1 and R_ID=1.


Fig. 05

If the send job is completed with an error, then the value of the output parameter "STATUS" of FB8 is saved for error analysis.


Fig. 06

The second FB8 "USEND" is activated by the input parameters ID=1 and R_ID=2. The third FB8 "USEND" is activated by the input parameters ID=1 and R_ID=3.

If the send jobs are completed with an error, then the value of the output parameter "STATUS" of the corresponding FB8 is likewise saved for error analysis.

OB1 in CPU319-3 (Recipient)
OB1 is called cyclically. FB100 is called in this OB (instance data block: DB100) with M0.3 "START-UP" as parameter (INIT_COM). After FB100 has been run the M0.3 "START-UP" is reset.


Fig. 07

FB100 in CPU319-3 PN/DP (Recipient)
FB100 is called in the OB1 cycle. In this sample program multiple receive jobs are triggered by a configured S7 connection, which means that in FB100 the FB9 "URCV" is called multiple times with the same "ID" but with a different "R_ID".

FB9 is activated by the "EN_R" input parameter. The value of the "EN_R" input parameter is always "1" because the marker M0.1 is set to the value "1" in the startup OB100. In this way the S7-300 station is always ready to receive.

The value for the "ID" input parameter must be taken from the Properties dialog of the S7 connection configured in NetPro (see Fig. 01).

With the "R_ID" input parameter you define the coherence of a send job and a receive job. The "R_ID" on the FB8 "USEND" of the sender must match that on the FB9 "URCV" of the recipient.

At the "RD_1" input parameter you specify the address and length of the data area where the received data is stored (receive buffer), for instance P#DB200.DBX0.0 BYTE 10.

The output parameters "NDR", "ERROR" and "STATUS" are required for the job evaluation and are only valid in the same cycle.

The first FB9 "URCV" is called by the input parameters ID=1 and R_ID=1.


Fig. 08

If the receive job is completed with an error, then the value of the "STATUS" output parameter of FB9 is saved for error analysis.


Fig. 09

Additional information

  • The manual "System and Standard Functions for S7-300/400 Volume 1/2", Chapter 22 "S7 Communication" provides information, for example, about the volume of data you can transfer using the FB8 "USEND" and FB9 "URCV" communication blocks. This manual is available for downloading in Entry ID 44240604.
  • How to configure a specified and an unspecified S7 connection is described in Entry ID: 17628518.

The STEP 7 project as download
The STEP 7 project contains a sample program for calling the FB8 and the FB9 communication blocks. It was created with STEP 7 V5.5.

Sample_S7-300_USEND_URCV.zip ( 332 KB )

Note
Copy the latest version of the communication blocks FB8 and FB9 from the SIMATIC_NET_CP library or from the Standard Library into your user program and then call it in your user program.

 Entry ID:18516417   Date:2012-04-18 
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 
Help
Online Help
Guided Tour