show the entry list

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 Modbus 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 the communication blocks FC50 and FC60?Go to beginning
Part number:

Instructions
To communicate using one of the following communication connections you must call the communication blocks FC50 "AG_SEND" and FC60 "AG_RECV" in the S7 program of the S7-400.

  • TCP connection
  • ISO-on-TCP connection (RFC 1006)
  • ISO transport connection
  • UDP connection
  • FDL connection

Features of communication blocks FC50 "AG_LSEND" and FC60 "AG_LRECV"

  • FC50 and FC60 are asynchronous communication functions.
  • FC50 and FC60 run for several OB1 cycles.
  • FC50 is activated by the input parameter "ACT".
  • The end of the job is indicated by "DONE" or "ERROR".
  • AG_LSEND and AG_LRCV can communicate simultaneously via one connection.
  • The latest version the communication blocks FC50 "AG_LSEND" and FC60 "AG_LRCV" is available in the "SIMATIC_NET_CP" library under "CP 400 > Blocks".

Description of the sample program
The S7 program contains the call of the communication blocks FC50 "AG_LSEND" and FC60 "AG_LRECV" from the SIMATIC_NET_CP library. The FC50 "AG_LSEND" is for sending data to an S7 station or to an S5 station, to a PC station or to a third-party system. The FC60 "AG_RECV" is for receiving data from another S7 station or an S5 station, from a PC station or from a third-party system.
The sample program shows the functions of the communication blocks FC50 "AG_LSEND" and FC60 "AG_LRCV" using an ISO-on-TCP connection.

First create the hardware configuration for the S7-400 station.

Note
Configure the Marker byte 10 as clock marker. The send request is triggered by this clock marker. Save and compile the hardware configuration of your S7-400 station and load it into the CPU.
The timer resource T10 is used in this sample program.

Configure one of the above-mentioned communication blocks for the CPU in NetPro. You can configure a specified communication connection if the communication partners are configured together in a STEP 7 project. If the communication partner is not configured in the same STEP 7 project as the S7-400 station, then an unspecified communication connection is configured. Make sure you assign the IP address or PROFIBUS address correctly when you configure the communication connection. You also need to make sure you assign the PORT, TSAP or LSAP correctly. These are for clearly identifying the communication connection between the communication partners.

You find the value that must be specified for the input parameters "ID" and "LADDR" of communication blocks FC50 "AG_LSEND" and FC60 "AG_LRECV" in the Properties dialog of the Communication connection -> "General" tab.


Fig. 01

The STEP 7 program consists of blocks OB100, OB1, FB200, DB200, DB201, FC50 and FC60.

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 1.0.

OB1
OB1 is called cyclically. FB200 is called in this OB (instance data block: DB200) with M1.0 as parameter (INIT_COM). M1.0 is reset as soon as FB200 has been executed.


Fig. 02

FB200
FB200 is called in the OB1 cycle. FC50 "AG_LSEND" and FC60 "AG_LRECV" are called in this FB . The send request is triggered via a positive edge on the input parameter "ACT" of the FC50. The send request trigger is controlled by clock marker M10.7 and the variable "SND_BUSY". If the send request is running, "SND_BUSY" is set. It is then not possible to trigger a new send request.
The receive request trigger is controlled by the variable "RCV_DISABLE". The value of this variable = FALSE, so that the FC50 "AG_LRCV" is always ready to receive and data can be received at all times. 

This locking of the function is particularly important, because the function is asynchronous and can last several cycles. Continual triggering of new send requests without waiting to see if they worked or ended with errors can create a communication overload.

The values for the input parameters "ID" and "LADDR" must be taken from the Properties dialog of the communication connection in NetPro (see Fig. 01).
You specify the address and length of the data area that contains the data to be sent (send buffer) on the input parameter "SEND" of the FC50, for instance: P#DB201.DBX0.0 BYTE 100.
You enter the length of the data to be sent in bytes for the input parameter "LEN". In this example the length of the data to be sent is 100 bytes.
The output parameters "DONE", "ERROR" and "STATUS" are required for the job evaluation and are only valid in the same cycle.


Fig. 03


Fig. 04

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


Fig. 05

If the send request is completed with an error, then "SND_BUSY" is likewise reset and the value of the output parameter "STATUS" of the FC50 is saved for an error analysis.
If the value of the output parameter is "STATUS" 0x7000Hex (28672Dec), then the function FC50 "AG_LSEND" is called again.


Fig. 06

If the value of the output parameter is "STATUS" 0x8183Hex (32381Dec) or 0x8304Hex (31996Dec),  in other words, the communication connection cannot be established, then a send job is initiated only every 10 seconds.


Fig. 07

The values for the input parameters "ID" and "LADDR" must be taken from the Properties dialog of the communication connection in NetPro (see Fig. 01). You specify the address and length of the data area that contains the data received (receive buffer) on the input parameter "RECV" of the FC60, for instance: P#DB201.DBX100.0 BYTE 100.


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

If the value of the output parameter is "STATUS" 0x8183Hex (32381Dec) or 0x8304Hex (31996Dec),  in other words the communication connection cannot be established, then the variable "RCV_DISABLE" is set for 10 seconds. No data is received during this time. Data can be received again only once this time has expired (10s).


Fig. 10 

The length of the data received successfully is stored in a static variable.


Fig. 11 

In FB200 there is an evaluation of how often the relevant STATUS values occur on the FC50 "AG_LSEND" and FC60 "AG_LRCV". This information is saved in the statistical interface parameters of the FB200 in the variable "STATISTIC" of data type "Structure".


Fig. 12 

It is possible to switch on/off the STATUS evaluation with the variable "#STATISTIC.ON_OFF.


Fig. 13 

Special case
If the data exchange takes place via a TCP connection, then the output parameter "NDR" is only set if the entire receive buffer has been filled. The value of the output parameter "LEN" thus always indicates the total length of the receive buffer.

The STEP 7 project as download
The STEP 7 project contains a sample program for calling the FC50 and the FC60 with status evaluation. It has been created with STEP 7 V5.5 SP2.

NET_S7400_LSEND_LRECV.zip ( 195 KB )

Note
Copy the latest version of the communication blocks FC50 and FC60 from the SIMATIC_NET_CP library or from the standard library into your user program and then call it in your user program.

Additional Keywords
Send, Receive

How do you program communication blocks FB12 "BSEND" and FB13 "BRCV" for data exchange in the S7 program of an S7-300 CPU?Go to beginning
Part number:

Instructions
Communication blocks FB12 "BSEND" and FB13 "BRCV" have to be called in the program in order to transfer data between two S7-300 stations by way of an S7 connection configured in NetPro. The S7 connection has to be configured on both sides, because the S7 communication by way of FB12 "USEND" and FB13 "URCV" is based on the client-client principle.

Features of the communication blocks FB12 "BSEND" and FB13 "BRCV"

  • The FB12 and FB13 function blocks are asynchronous communication functions.
  • In this example, the blocks are called in the OB1 cycle (see also Entry ID: 2795485).
  • The FB12 and FB13 function blocks run for several OB1 cycles.
  • The FB12 function block is activated by the "REQ" input parameter.
  • The FB13 function block is activated by the "EN_R" input parameter.
  • The end of the job is indicated by "DONE", "NDR" or "ERROR".
  • BSEND and BRCV can communicate simultaneously through one connection.
  • The latest version of the FB12 "BSEND" and FB13 "BRCV" 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 FB12 "BSEND" and FB13 "BRCV" 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 S7 program contains the call of the communication blocks FB12 "BSEND" and FB13 "BRCV" from the Standard Library. The FB12 "BSEND" function block is for sending data and the FB13 "BRCV" function block is for receiving data.
The sample program shows the functions of the FB12 "BSEND" and FB15 "BRCV" communication blocks using an S7 connection.

First create the hardware configuration for your S7-300 station.

Note
Configure the 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 timer resource T10 is used in this sample program.

Configure an S7 connection for the CPU in NetPro. You can configure a specified S7 connection if the communication partners are configured together in a STEP 7 project. If the communication partner is not configured in the same STEP 7 project as the S7-300 station, then an unspecified S7 connection is configured. Make sure you assign the IP address or PROFIBUS address correctly when you configure the S7 connection. You also need to make sure you assign the rack/slot and connection resource correctly. These are for clearly identifying the S7 connection between the communication partners.

You find the value that must be specified for the "ID" input parameter of communication blocks FB12 "BSEND" and FB13 "BRCV" in the Properties dialog of the S7 connection -> tab "General".

 
Fig. 01

The STEP 7 program consists of blocks OB100, OB1, FB105, DB105, DB200, DB201, FB12 and FB13.

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 0.3 "START-UP".

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


Fig. 02

FB105
FB105 is called in the OB1 cycle. The FB12 "BSEND" and FB13 "BRCV" communication block calls are in FB105.

At the "ID" input parameter of the communication blocks you must specify the connection number of the S7 connection configured in NetPro. The value for the "ID" input parameter must be taken from the Properties dialog of the S7 connection configured in NetPro (see Fig. 01).
You can change the connection number separately in FB105. Change the connection number in network 2 of FB105 in accordance with your configuration. The connection number is stored in a static tag and so in the instance data block DB105.
The connection number "1" is defined in this example.


Fig. 03

FB12 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 of the function call is 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.

With the "R_ID" input parameter you define the coherence of a send job and a receive job. The "R_ID" on the FB12 "BSEND" of the sender must match that on the FB13 "BRCV" of the recipient.

At the "SD_1" input parameter of FB12 you specify the address and length of the data area that contains the data to be sent (send buffer), for instance: P#DB201.DBX0.0 BYTE 8000.
You enter the length of the data to be sent in bytes at the "LEN" input parameter. You define the length of the data to be sent in Network 1 of FB105. This is stored in a static tag and so in the instance data block DB105.
In this example the length of the data to be sent is 8000 bytes.

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


Fig. 04

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


Fig. 05

FB13 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.

With the "R_ID" input parameter you define the coherence of a send job and a receive job. The "R_ID" for FB12 on the Send side and FB13 on the Receive side must match.

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 8000.

The "LEN" output parameter indicates the length of the data received in bytes. The output parameters "NDR", "ERROR" and "STATUS" are required for the job evaluation and are only valid in the same cycle.


Fig. 06

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


Fig. 07

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 FB12 "BSEND" and FB13 "BRCV" 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 FB12 and the FB13 communication blocks. It was created with STEP 7 V5.5.

Sample_S7-300_BSEND_BRCV.zip ( 47 KB )

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

How do you program communication blocks FB14 "GET" and FB15 "PUT" for data exchange in the S7 program of an S7-300 CPU?Go to beginning
Part number:

Instructions
Communication blocks FB14 "GET" and FB15 "PUT" have to be called in the program in order to transfer data between two S7-300 stations by way of an S7 connection configured in NetPro. The S7 connection does not have to be configured on both sides, because the S7 communication via FB14 "GET" and FB15 "PUT" is based on the server-client principle.

Features of the communication blocks FB14 "GET" and FB15 "PUT"

  • The FB14 and FB15 function blocks are asynchronous communication functions.
  • In this example, the blocks are called in the OB1 cycle (see also Entry ID: 2795485).
  • The FB14 and FB15 function blocks run for several OB1 cycles.
  • The FB14 and FB15 function blocks are activated by the "REQ" input parameter.
  • The end of the job is indicated by "DONE", "NDR" or "ERROR".
  • PUT and GET can communicate simultaneously by way of one connection.
  • The latest version of the FB14 "GET" and FB15 "PUT" 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 FB14 "GET" and FB15 "PUT" 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 S7 program contains the call of the communication blocks FB14 "GET" and FB15 "PUT" from the Standard Library. Function block FB14 "GET" is for reading data out of a remote CPU and function block FB15 "PUT" is for writing data to a remote CPU.
The sample program shows the functions of the FB14 "GET" and FB15 "PUT" communication blocks using an S7 connection.

First create the hardware configuration for your S7-300 station.

Note
Configure the Marker byte 10 as clock marker. The read and write job is triggered by this clock marker. Save and compile the hardware configuration of your S7-300 station and load it into the CPU.
The timer resource T10 is used in this sample program.

Configure an S7 connection for the CPU in NetPro. You can configure a specified S7 connection if the communication partners are configured together in a STEP 7 project. If the communication partner is not configured in the same STEP 7 project as the S7-300 station, then an unspecified S7 connection is configured. Make sure you assign the IP address or PROFIBUS address correctly when you configure the S7 connection. You also need to make sure you assign the rack/slot and connection resource correctly. These are for clearly identifying the S7 connection between the communication partners.

You find the value that must be specified for the "ID" input parameter of communication blocks FB14 "GET" and FB15 "PUT" in the Properties dialog of the S7 connection -> tab "General".


Fig. 01

The STEP 7 program consists of blocks OB100, OB1, FB115, DB115, DB200, DB201, FB14 and FB15.

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 0.3 "START-UP".

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


Fig. 02

FB115
FB115 is called in the OB1 cycle. The FB14 "GET" and FB15 "PUT" communication block calls are in FB115.

At the "ID" input parameter of the communication blocks you must specify the connection number of the S7 connection configured in NetPro. The value for the "ID" input parameter must be taken from the Properties dialog of the S7 connection configured in NetPro (see Fig. 01).
You can change the connection number separately in FB115. Change the connection number in network 1 of FB115 in accordance with your configuration. The connection number is stored in a static tag and so in the instance data block DB115.
The connection number "1" is defined in this example.


Fig. 03

FB14 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 read job is completed either successfully or with an error. This means that a new read job can only be triggered once the running job has been completed.
This locking of the function call is 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 "ADDR_1" parameter refers to a data area in the remote CPU that is written to or read from, for instance: P#DB201.DBX0.0 BYTE 200. For the "RD_1" parameter you must specify the data area for the data read, for instance: P#DB200.DBX0.0 BYTE 100. The output parameters "NDR", "ERROR" and "STATUS" are required for the job evaluation and are only valid in the same cycle.


Fig. 04

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


Fig. 05

FB15 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 write job is completed either successfully or with an error. This means that a new write job can only be triggered once the running job has been completed.
This locking of the function call is 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 "ADDR_1" parameter refers to a data area in the remote CPU that is written to or read from, for instance: P#DB200.DBX0.0 BYTE 20. For the "SD_1" parameter you must specify the data area for the data to be sent, for instance: P#DB201.DBX0.0 BYTE 20. The output parameters "DONE", "ERROR" and "STATUS" are required for the job evaluation and are only valid in the same cycle.


Fig. 06

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


Fig. 07

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 FB14 "GET" and FB15 "PUT" communication blocks. This manual is available for downloading in Entry ID 44240604. ".
  • Entry ID 17628518 includes a description of how to configure a specified and unspecified S7 connection.

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

Sample_S7-300_PUT_GET.zip ( 197 KB )

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

Which blocks for Modbus TCP can you rename or re-wire when the block numbers of the Modbus blocks are already being used in the user program?Go to beginning
Part number:

Description
The blocks that are available for Modbus communication with SIMATIC S7 are delivered with a unique block number.
If there are already blocks in the user program that have these block numbers, there is a block number conflict.

Please proceed as follows to avoid this conflict.

  • You can rename the Modbus blocks that are called directly in the user program.
  • You cannot rename the blocks that are called internally in the Modbus blocks. You have to re-wire those blocks.

The table below shows the Modbus blocks that you can rename or re-wire.
 
Product Article no. Modbus block > rename Block called internally from the Modbus library > re-wire Block called internally from the Standard / SIMATIC NET library > re-wire
Modbus/TCP CP 2XV9450-1MB00 FB108 FB106, FB107 AG_(L)SEND
AG_(L)RECV
EQ_STRNG(*)
AG_CNTRL(**)
Modbus/TCP RED V1 2XV9450-1MB01 FB1733 FB1734 AG_(L)SEND
AG_(L)RECV
Modbus/TCP RED V2 2XV9450-1MB11 FB909, FB907 FB908, FB906 AG_(L)SEND
AG_(L)RECV
EQ_STRNG(*)
AG_CNTRL(**)
Modbus/TCP PN CPU 2XV9450-1MB02 FB102 FB103, FB104, FB105 TSEND
TRCV
TCON
TDISCON
EQ_STRNG(*)
Modbus/TCP PN CPU Redundant 6AV6676-6MB10-0AX0 FB915, FB917 FB913, FB914, FB916 TSEND
TRCV
TCON
TDISCON
Modbus/TCP SENTRON PAC 6AV6676-6MA30-0AX0
6AV6676-6MA30-1AX0
6AV6676-6MA30-2AX0
FB109, FB110, FB111 FB99, FB103, FC99 TSEND
TRCV
TCON
TDISCON
TUSEND
Table 01

(*) The EQ_STRNG block is only in older versions of the product.
(**) If both EQ_STRNG and AG_CNTRL are used by the Modbus blocks are used, then AG_CNTRL is already re-wired in the Modbus library. More information about this is available in the relevant product manual.

You must follow a specific order when re-wiring the blocks that are called internally in the Modbus blocks. Re-wire the blocks - if necessary - in the order listed.

  1. EQ_STRNG, AG_CNTRL, AG_(L)SEND, AG_(L)RECV, TSEND, TRCV, TCON, TDISCON
  2. Internally called blocks (FB106, FB107, FB1734, FB908, FB906, FB103, FB104, FB105, FB913, FB914, FB915, FB99, FB103, FC99)
  3. Remaining blocks

You do not have to re-wire all the blocks. Even if you re-wire only a few internally called blocks, you must nevertheless keep to the order given above. In this case, you leave out the blocks that are not re-wired.

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?Go to beginning
Part number:

Description
You must call the function blocks below in the S7 program in order to transfer data with the S7-300 via an S7 connection configured in NetPro:

  • FB14 "GET"
  • FB15 "PUT"

Function block FB14 "GET" is for reading data out of the partner CPU and function block FB15 "PUT" is for writing data to the partner CPU.
The S7 connection does not have to be configured on both sides, because the S7 communication via FB14 "GET" and FB15 "PUT" is based on the server-client principle.

Description of the S7 program
This sample program shows how to call the function blocks FB14 "GET" and FB15 "PUT" sequentially in the S7 program of the S7-300 in order to transfer more than 160 bytes of data via an S7 connection.

FB14 "GET" is called three times in a row with the same connection number so that 400 bytes of data can be received.

FB15 "PUT" is called three times in a row with the same connection number so that 240 bytes of data can be sent.

The file below gives a detailed description of the S7 program.

PUT_GET_Sequencer_en.pdf ( 1121 KB )

Download the S7 program
The STEP 7 project contains an S7 program for sequential calling of the function blocks FB14 "GET" and FB15 "PUT" so that the S7-300 can receive 400 bytes and send 240 bytes of data via an S7 connection.

Sequencer.zip ( 41 KB )

Notes

  • If you are using an Industrial Ethernet CP or PROFIBUS CP for data communication via S7 connections in the S7-300 station, then utilize the function blocks FB14 "GET" and FB15 "PUT" from the "SIMATIC_NET_CP" library under "CP 300 > Blocks".
  • If you are using the integrated PROFINET interface of the CPU for data communication via S7 connections, then utilize function blocks FB14 "GET" and FB15 "PUT" from "Standard Library -> Communication Blocks -> Blocks" with the family "CPU_300".
  • Information about configuring an S7 connection for data communication with S7-300 and S7-400 Industrial Ethernet CPs are available in Entry ID: 17628518.
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?Go to beginning
Part number:

Description
This entry includes sample programs and documentation for using the PROFIBUS DP (Distributed I/O or Periphery) for data communication between SIMATIC S5 modules and SIMATIC S7 modules.

Using the PROFIBUS DP protocol the data is transferred cyclically between DP master and DP slave. This means

  • The DP master reads data from the input area of the DP slave.
  • The DP master writes data to the output area of the DP master.
DP master DP slave Sample program for
DP master
Sample program for
DP slave
S5 S7    
CP5431 CP342-5 IO_DP_CP5431_V20.zip ( 5 KB ) IO_DP_CP342-5_V20.zip ( 90 KB )
IM 308C CP342-5 IO_DP_IM308C_V20.zip ( 3 KB ) IO_DP_CP342-5_V20.zip ( 90 KB )

Note:
More information about communication with SIMATIC S5 and SIMATIC S7 is available in the Entry IDs below.
 
Entry ID Description
26582939 What properties, advantages and special features does the DP protocol offer?
48066532 Where can you find sample programs and documentation for using the PROFIBUS FMS communication protocol for data communication between SIMATIC S5 modules and SIMATIC S7 modules as well as for data communication between SIMATIC S5 modules and PCs?
48352979 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?
1158693 S7 CPs for PROFIBUS Configuration and Commissioning
1158418 SIMATIC NET NCM S7 for PROFIBUS / FMS Volume 2
1804226 SINEC CP 5430 TF with COM 5430 TF, CP 5431 FMS with COM 5431 FMS
12585718 SINEC CP 5431 FMS with COM 5431 FMS
30564821 Functions (FC) and Function Blocks (FB) for SIMATIC NET S7 CPs Programming Manual
35222591 SIMATIC NET PROFIBUS Network Manual and System Manual
20982954 CPU-CPU Communication with SIMATIC Controllers (Compendium)

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?Go to beginning
Part number:

Description
Where can you find sample programs and documentation for communication between SIMATIC S5 modules and SIMATIC S7 modules by way of PROFIBUS using the free Layer 2 access of the FDL protocol.

In the sample programs below we use the SDA (Send Data with Acknowledge) service of the FDL protocol for data communication between SIMATIC S5 modules and SIMATIC S7 modules.
 
Active partner S7 Passive partner S5 Sample program for active partners Sample program for passive partners
CP342-5 CP5431 SDA_FDL_CP342-5_V20.zip ( 190 KB ) SDA_FDL_CP5431_V20.zip ( 3 KB )

The document below contains

  • An overview of the plant configuration used for creating the sample programs.
  • An introduction to the blocks required and their communication structure.
  • Details of the user programs of SIMATIC S5 and SIMATIC S7.
  • Information on how to use the sample programs.
  • Other notes, tips and tricks, etc.

PB_communication_S5_and_S7_FDL_freeLayer2access_en.pdf ( 413 KB )

Note:
More information about communication with SIMATIC S5 and SIMATIC S7 is available in the Entry IDs below.
 
Entry ID Description
26098555 What properties, advantages and special features does the FDL protocol offer?
17596048 How do you configure an FDL connection between the SIMATIC S5 (CP5431) and SIMATIC S7 via PROFIBUS?
48457189 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?
48066532 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?
48352979 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?
1158693 S7 CPs for PROFIBUS Configuration and Commissioning
1158418 SIMATIC NET NCM S7 for PROFIBUS / FMS Volume 2
1804226 SINEC CP 5430 TF with COM 5430 TF, CP 5431 FMS with COM 5431 FMS
12585718 SINEC CP 5431 FMS with COM 5431 FMS
30564821 Functions (FC) and Function Blocks (FB) for SIMATIC NET S7 CPs Programming Manual
20982954 CPU-CPU Communication with SIMATIC Controllers (Compendium)

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?Go to beginning
Part number:

Description
This entry includes sample programs and documentation for communication from SIMATIC S5 modules to SIMATIC S7 modules by way of PROFIBUS using the FDL protocol.

In the sample programs below we use the services SEND and RECEIVE of the FDL protocol for data communication between SIMATIC S5 modules and SIMATIC S7 modules.
 
Active partner S7 Passive partner S5 Sample program for active partners Sample program for passive partners
CP342-5 AG95U SR_FDL_CP342-5_V20.zip ( 72 KB ) SR_FDL_AG95U_V20.zip ( 1 KB )
CP342-5 CP5431 SR_FDL_CP342-5_V20.zip ( 87 KB ) SR_FDL_CP5431_V20.zip ( 4 KB )
CP343-5 AG95U SR_FDL_CP343-5_V20.zip ( 88 KB ) SR_FDL_AG95U_V20.zip ( 1 KB )
CP343-5 CP5431 SR_FDL_CP343-5_V20.zip ( 88 KB ) SR_FDL_CP5431_V20.zip ( 4 KB )
CP443-5 BASIC AG95U SR_FDL_CP443-5B_V20.zip ( 78 KB ) SR_FDL_AG95U_V20.zip ( 1 KB )
CP443-5 BASIC CP5431 SR_FDL_CP443-5B_V20.zip ( 78 KB ) SR_FDL_CP5431_V20.zip ( 4 KB )
CP443-5 EXTENDED AG95U SR_FDL_CP443-5E_V20.zip ( 88 KB ) SR_FDL_AG95U_V20.zip ( 1 KB )
CP443-5 EXTENDED CP5431 SR_FDL_CP443-5E_V20.zip ( 86 KB ) SR_FDL_CP5431_V20.zip ( 4 KB )

In the sample programs below we use the services SEND and RECEIVE of the FDL protocol for data communication between SIMATIC S5 modules and SIMATIC S7 modules. Data communication is by way of a multicast connection, i.e. the active partner sends a message to a group of nodes. Receipt of data is not acknowledged.
 
Active partner S7 Passive partner S5 Sample program for active partners Sample program for passive partners
CP342-5 AG95U MC_FDL_CP342-5_V20.zip ( 111 KB ) MC_FDL_AG95U_V20.zip ( 2 KB )
CP342-5 CP5431 MC_FDL_CP342-5_V20.zip ( 109 KB ) MC_FDL_CP5431_V20.zip ( 6 KB )
CP343-5 AG95U MC_FDL_CP343-5_V20.zip ( 116 KB ) MC_FDL_AG95U_V20.zip ( 2 KB )
CP343-5 CP5431 MC_FDL_CP343-5_V20.zip ( 115 KB ) MC_FDL_CP5431_V20.zip ( 6 KB )
CP443-5 BASIC AG95U MC_FDL_CP443-5B_V20.zip ( 131 KB ) MC_FDL_AG95U_V20.zip ( 2 KB )
CP443-5 BASIC CP5431 MC_FDL_CP443-5B_V20.zip ( 129 KB ) MC_FDL_CP5431_V20.zip ( 6 KB )
CP443-5 EXTENDED AG95U MC_FDL_CP443-5E_V20.zip ( 121 KB ) MC_FDL_AG95U_V20.zip ( 2 KB )
CP443-5 EXTENDED CP5431 MC_FDL_CP443-5E_V20.zip ( 120 KB ) MC_FDL_CP5431_V20.zip ( 6 KB )

The document below contains

  • An overview of the plant configuration used for creating the sample programs.
  • An introduction to the blocks required and their communication structure.
  • Details of the user programs of SIMATIC S5 and SIMATIC S7.
  • Information on how to use the sample programs.
  • Other notes, tips and tricks, etc.

PB_communication_S5_and_S7_FDL_en.pdf ( 394 KB )

Note:
More information about communication with SIMATIC S5 and SIMATIC S7 is available in the Entry IDs below.
 
Entry ID Description
26098555 What properties, advantages and special features does the FDL protocol offer?
17596048 How do you configure an FDL connection between the SIMATIC S5 (CP5431) and SIMATIC S7 via PROFIBUS?
48457189 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?
48066532 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?
1158693 S7 CPs for PROFIBUS Configuration and Commissioning
1158418 SIMATIC NET NCM S7 for PROFIBUS / FMS Volume 2
1804226 SINEC CP 5430 TF with COM 5430 TF, CP 5431 FMS with COM 5431 FMS
12585718 SINEC CP 5431 FMS with COM 5431 FMS
30564821 Functions (FC) and Function Blocks (FB) for SIMATIC NET S7 CPs Programming Manual
20982954 CPU-CPU Communication with SIMATIC Controllers (Compendium)

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?Go to beginning
Part number:

Description
This entry includes sample programs and documentation for using the PROFIBUS FMS (Fieldbus Message Specification) protocol for data communication between SIMATIC S5 modules and SIMATIC S7 modules as well as for data communication between SIMATIC S5 modules and PCs.

The following services of the PROFIBUS FMS protocol are used for data communication:

  • READ and WRITE
  • REPORT

READ and WRITE
Data communication between SIMATIC S5 modules and SIMATIC S7 modules is by way of PROFIBUS FMS using the Layer 7 services READ and WRITE.
 
FMS Client FMS Server Sample program for
FMS Client
Sample program for
FMS Server
S7 S5    
CP343-5 CP5431 RW_FMS_CP343-5.zip ( 83 KB ) RW_FMS_CP5431.zip ( 3 KB )
CP343-5 IM318 (acyclic) RW_FMS_CP343-5_acyclic.zip ( 82 KB ) -
CP343-5 IM318
(cyclic)
RW_FMS_CP343-5_cyclic.zip ( 85 KB ) RW_FMS_IM318_cyclic.zip ( 2 KB )
CP443-5 CP5431 RW_FMS_CP443-5.zip ( 86 KB ) RW_FMS_CP5431.zip ( 3 KB )
CP443-5 IM318 (acyclic) RW_FMS_CP443-5_acyclic.zip ( 85 KB ) -
CP443-5 IM318 (cyclic) RW_FMS_CP443-5_cyclic.zip ( 82 KB ) RW_FMS_IM318_cyclic.zip ( 2 KB )
S5 S7    
CP5431 CP343-5 RW_FMS_CP5431_CP343-5.zip ( 3 KB ) RW_FMS_CP343-5.zip ( 55 KB )
CP5431 CP443-5 RW_FMS_CP5431_CP443-5.zip ( 3 KB ) RW_FMS_CP443-5.zip ( 60 KB )

Data communication between SIMATIC S5 modules and PCs is by way of PROFIBUS FMS using the Layer 7 services READ and WRITE..
 
FMS Client FMS Server Sample program for
FMS Client
Sample program for
FMS Server
PC S5    
CP5412 A2 CP5431 RW_FMS_CP5412.zip ( 41 KB ) RW_FMS_CP5431.zip ( 3 KB )
CP5412 A2 IM318 (acyclic) RW_FMS_CP5412_IM318.zip ( 41 KB ) -
CP5412 A2 SIMOCODE
(acyclic)
RW_FMS_CP5412_acyclic.zip ( 42 KB ) -
CP5412 A2 SIMOCODE
(cyclic)
RW_FMS_CP5412_cyclic.zip ( 44 KB ) -

REPORT
Data communication between SIMATIC S5 modules and SIMATIC S7 modules is by way of PROFIBUS FMS using the Layer 7 service REPORT.
 
FMS Client FMS Server Sample program for
FMS Client
Sample program for
FMS Server
S5 S7    
CP5431 CP343-5 IR_FMS_CP5431.zip ( 55 KB ) IR_FMS_CP343-5.zip ( 3 KB )
CP5431 CP443-5 IR_FMS_CP5431.zip ( 3 KB ) IR_FMS_CP443-5.zip ( 60 KB )

The document below contains

  • An overview of the plant configuration used for creating the sample programs.
  • An introduction to the blocks required and their communication structure.
  • Details of the user programs of SIMATIC S5 and SIMATIC S7.
  • Information on how to use the sample programs.
  • Other notes, tips and tricks, etc.

PB_communication_S5_and_S7_FMS_en.pdf ( 512 KB )

Note:
More information about communication with SIMATIC S5 and SIMATIC S7 is available in the Entry IDs below.
 
Entry ID Description
26583930 What properties, advantages and special features does the FMS protocol offer?
48457189 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?
48352979 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?
1158693 S7 CPs for PROFIBUS Configuration and Commissioning
1158418 SIMATIC NET NCM S7 for PROFIBUS / FMS Volume 2
1804226 SINEC CP 5430 TF with COM 5430 TF, CP 5431 FMS with COM 5431 FMS
12585718 SINEC CP 5431 FMS with COM 5431 FMS
30564821 Functions (FC) and Function Blocks (FB) for SIMATIC NET S7 CPs Programming Manual
20982954 CPU-CPU Communication with SIMATIC Controllers (Compendium)

Notes on using an instance for multiple connection IDsGo to beginning
Part number:

QUESTION:
Why isn't it useful to realize BRCV or URCV with an instance via multiple communication connections?

ANSWER:
The communication services BSEND/BRCV and USEND/URCV are bilateral communication functions that enter a 1:1 connection with each other. This is why a BSEND is always assigned to exactly one BRCV via one S7 connection. The S7 communication functions (SFBs) are realized on the S7-400 controllers in such a way that the input parameters ID and R_ID cannot be changed dynamically in the program, but always belong to one specific instance DB.

The dynamics of the downloadable communication functions for S7-300 controllers is different: an instance (DB) is fixed for only one communication task and then it can be used for another partner, i.e. S7 connection. This is practical in particular for the S7 functions PUT/GET in order to be able to address several partners with one instance.

This is more complicated for the S7 functions BSEND/BRCV and USEND/URCV. Here you could implement dynamic use of the instance DBs for the Send blocks BSEND/USEND. However, this is not possible on the Receive side, because you cannot foresee exactly which S7 Communication would like to send.

This applies also for parallel communication functions for an S7 connection that are realized with the parameter R_ID (task reference). There is no point either in using a single instance in this variant of the S7 Communication.

Keywords:
Downloadable communication, URECEIVE, BRECEIVE,
SFB8, FB8, SFB9, FB9, SFB12, FB12, SFB13, FB13, SFB14, FB14, SFB15, FB15


Processing the data from DP slaves via CP342-5 on CPU31xGo to beginning
Part number:


QUESTION:
Under which address is data from DP slaves, which is processed via the CP342-5 as DP master, addressed in the user program of the CPU 31x?

ANSWER:
In the hardware configuration you assign the addresses for your DP slaves just as you are used to doing for other interfaces. The data of the DP slaves is stored in the DP master according to the address assignment made. The data transfer between the CPU and the CP is done via block calls. You need the "DP-Send" block to transfer data from the CPU to the CP, and with "DP-Recv" you can fetch data from the CP into the CPU. When calling these two blocks you specify the data areas in which the data of the DP slaves is to be located.

Example for providing parameters for the block FC 1 "DP-Send"
 

PARAMETER

Value

Meaning

CPLADDR:
SEND:
DONE:
ERROR:
STATUS:

W#16#120
P#DB1.DBX0.0 BYTE 30
M 99.1
M 99.0
MW 104

Address of CP342-5 from HW Config
This is where the data is located on the CPU

With "1" data is transferred to the CP
With "1" an error has occurred
Status display shows cause of error

The following information is transferred with the parameter SEND of the block:

SEND:= "Initial address of the data area on CPU" BYTE "Length"

Initial address on CPU:
Initial address area of the CPU (e.g. M10.0; E4.0; DB1.DBX0.0). Here you specify where the data is located on the CPU.

Length:
Amount of data to be transferred from the CPU to the CP. In the above example, 30 bytes of data are transferred from the CPU to the CP.

The following diagram clearly shows the assignment of the data of the DP slaves to the addresses in the CPU at which the data is stored. The hatched areas are not used.

Fetching data from the CP into the CPU using the "DP-Recv" block works in the same way.

Block calls for communications processors in multiple runtime layers Go to beginning
Part number:

QUESTION:
May I execute block calls for the communications processors CP 34x-5 and CP 343-1 / IT/ PN in multiple runtime layers at the same time?

ANSWER:
No, it is not permissible to process communications blocks (SIMATIC_NET_CP library) at the same time in multiple runtime layers (e.g. OB1 and OB35).
Contrary to the information in the manual "Communications with SIMATIC" block processing can be interrupted at any time by organization blocks of higher priority.

If you call the blocks in multiple OBs, you have to make sure at program level that a running block is not interrupted by another block for processing the communications processor (e.g. via Block/release SFC alarms).

Keywords:
Master, Slave, Communications service

Changing the input parameter of the user blocks "AG_SEND" and "AG_RECV" during the runtime of a job Go to beginning
Part number:

QUESTION:
Can the input parameter of user blocks for the send/recieve interface be changed during the runtime of a job?

ANSWER:  
The following description applies to all CPs(communication processor) for the automation system S7-300 and S7-400 which support SEND/RECEIVE communication, a service for transferring user data transparently on the level 4 of the OSI reference model.
The current Industrial Ethernet CPs are:

  • 6GK7 443-1EX11-0XE0 (CP 443-1)
  • 6GK7 443-1GX11-0XE0 (CP 443-1 IT)
  • 6GK7 343-1EX20-0XE0 (CP 343-1)

This applies as well to PROFIBUS-CPs which support equivalent FDL communication.

Calling the user blocks
To send and receive the individual data blocks, a certain function is available:

  • FC5 (AG_SEND): Sending data blocks
  • FC6 (AG_RECV): Receiving data blocks

Calling the blocks in the user program of a S7-CPU further on is displayed in the programming language STL:

Figure 1: FC5 (AG_SEND)

Figure 2: FC6 (AG_RECV)

Instruction
If a job has been started with the first call of the block, the red marked input parameter of the blocks may not be changed until

  • block FC5 answers with DONE = 1 or
  • block FC6 answers with NDR = 1 or
  • one of the blocks answers with ERROR = 1

If this instruction is not andhered to, error messages at the user interface or misleading entries in the diagnose buffer may occur:

Errors that may occur when ignoring the instruction

  • In the S7-300 CPs, at the user interface, there appears the error message 0x80B1 that informs that the indication of length (in the parameter LEN) is wrong. This message will then persist.
  • In the S7-400 CPs, sporadically an entry that informs that the connection number x is out of the permitted range of values will appear in the diagnose buffer.

Both of these behaviours can indicate that the instruction has not been adhered to and therefore the input parameters of the user blocks have been altered at runtime.

Note about "AG_LSEND" and "AG_LRECV":
The described facts apply also to the blocks FC50 (AG_LSEND) and FC60 (AG_LRECV) that must be used in older S7 300 groups and for all S7 400 groups for data lengths of more than 240 byte.

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"?Go to beginning
Part number:

Configuration Notes:
Make sure when calling the communication blocks FC5/50 "AG SEND/AG_LSEND" and FC6/60 "AG_RCV/AG_LRCV" that only the data type BYTE is in the ANY pointer for the input parameters SEND and RECV.

If, for example, you wish to transfer a variable of the data type "REAL" with FC5 "AG_SEND" and declare the ANY pointer at the "SEND" input parameter as follows:

  •  P#DB1.DBX0.0 Byte 4,

then this ANY pointer is converted by STEP 7 into its symbolic address, i.e. the ANY pointer points to the data type REAL in the data block (DB) specified. The data types BYTE, WORD and DWORD are permitted for the ANY pointer at the "SEND" input parameter. However, the data type REAL is used in this example, i.e. the data to be transferred is not interpreted correctly. The ERROR output parameter of FC5 is set.


Fig. 01: Symbolic name of the ANY pointer

Remedy:
Increase the value of the ANY pointer at the "SEND" input parameter by at least 1 byte to prevent the symbolic display of the ANY pointer.

The declaration now looks like this:

  • P#DB1.DBX0.0 Byte 5


Fig. 02: ANY pointer with a length greater than the value to be sent

How do you program the communication blocks FC5 and FC6?Go to beginning
Part number:

Instructions
Table 01 shows which communication connections in the S7-300 are used for data exchange over communication processors (CPs) and which CPs support the communication connections.
To communicate using one of the communication connections listed in Table 01, you must call the communication blocks FC5 "AG_SEND" and FC6 "AG_RECV" in the S7 program of the S7-300.
 
Communication connection CP Order number Remark
  • TCP connection
  • ISO-on-TCP communication
    (RFC 1006)
  • UDP connection
CP343-1
Lean
6GK7343-1CX10-0XE0
6GK7343-1CX00-0XE0
More information about the TCP, ISO-on-TCP (RFC 1006) and UDP protocols is available in Entry IDs 26171811, 26484227 and 26484229.
CP343-1
Standard
6GK7343-1EX30-0XE0
6GK7343-1EX21-0XE0
6GK7343-1EX20-0XE0
6GK7343-1EX11-0XE0
CP343-1
Advanced
6GK7343-1GX30-0XE0
6GK7343-1GX31-0XE0
6GK7343-1GX21-0XE0
CP343-1 IT 6GK7343-1GX20-0XE0
6GK7343-1GX11-0XE0
  • ISO transport connection
CP343-1
Standard
6GK7343-1EX21-0XE0
6GK7343-1EX30-0XE0
6GK7343-1EX11-0XE0
More information about the ISO transport protocol is available in Entry ID: 26582267.
CP343-1
Advanced
6GK7343-1GX31-0XE0
6GK7343-1GX30-0XE0
6GK7343-1GX21-0XE0
CP343-1 IT 6GK7343-1GX11-0XE0
  • FDL connection
CP342-5 6GK7342-5DA03-0XE0
6GK7342-5DA02-0XE0
6GK7342-5DA01-0XE0
6GK7342-5DA00-0XE0
More information about the FDL protocol is available in Entry ID: 26098555.
CP342-5 FO 6GK7342-5DF00-0XE0
CP343-5 6GK7343-5FA01-0XE0
6GK7343-5FA00-0XE0
Table 01

 Features of the communication blocks FC5 "AG_SEND" and FC6 "AG_RECV"

  • FC5 and FC6 are asynchronous communication functions.
  • In this example, the blocks are called in the OB1 cycle (see also Entry ID: 2795485)
  • They can run over several OB1 cycles.
  • The FC5 is activated by the input parameter "ACT".
  • The end of the job is indicated by "DONE" or "ERROR".
  • AG_SEND and AG_RECV can communicate simultaneously by way of one connection.
  • The latest version the communication blocks FC5 "AG_SEND" and FC6 "AG_RCV" is available in the "SIMATIC_NET_CP" library under "CP 300 > Blocks".

Description of the sample program
The S7 program contains the call of the communication blocks FC5 "AG_SEND" and FC6 "AG_RECV" from the SIMATIC_NET_CP library. The FC5 "AG_SEND" is for sending data to another S7 station, to a PC station, or to a third-party system. The FC6 "AG_RECV" is for receiving data from another S7 station, from a PC station, or from a third-party system.
The sample program shows the functions of the communication blocks FC5 "AG_SEND" and FC6 "AG_RCV" using an ISO-on-TCP connection.

First create the hardware configuration for your S7-300 station.

Note
Configure the 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 timer resource T10 is used in this sample program.

Configure one of the above-mentioned communication blocks for the CPU in NetPro. You can configure a specified communication connection if the communication partners are configured together in a STEP 7 project. If the communication partner is not configured in the same STEP 7 project as the S7-300 station, then an unspecified communication connection is configured. Make sure you assign the IP address or PROFIBUS address correctly when you configure the communication connection. You also need to make sure you assign the PORT, TSAP or LSAP correctly. These are for clearly identifying the communication connection between the communication partners.

The value that must be specified for the input parameters "ID" and "LADDR" of communication blocks FC5 "AG_SEND" and FC6 "AG_RECV" is in the Properties dialog of the communication connection -> "General" tab.


Fig. 01

The STEP 7 program consists of blocks OB100, OB1, FB200, DB200, DB201, FC5 and FC6.

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 0.3 "START-UP".

OB1
OB1 is called cyclically. FB200 is called in this OB (instance data block: DB200) with M0.3 "START-UP" as parameter (INIT_COM). After FB200 was run there is a reset with M0.3 "START-UP".


Fig. 02

FB200
FB200 is called in the OB1 cycle. The call of communication blocks FC5 "AG_SEND" and FC6 "AG_RECV" is in the FB200.

FC5 "AG_SEND" parameters
The send request is triggered via a positive edge at the input parameter "ACT". The send request trigger is controlled by clock marker M10.7 and the variable "SND_BUSY". If the send request is running, "SND_BUSY" is set. Triggering a new send request is not then possible.

This locking is particularly important, because the function is asynchronous and can last several cycles. Continual triggering of new send requests without waiting to see if they worked or ended with errors can create a communication overload.

The values for the input parameters "ID" and "LADDR" must be taken from the Properties dialog of the communication connection in NetPro (see Fig. 01).
On the input parameter "SEND" of the FC5 you specify the address and length of the data area that contains the data to be sent (send buffer), for instance: P#DB201.DBX0.0 BYTE 100.
You enter the length of the data to be sent in bytes at the input parameter "LEN". In this example, the length of the data to be sent is 100 bytes.
The output parameters "DONE", "ERROR" and "STATUS" are required for the job evaluation and are only valid in the same cycle.


Fig. 03

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

If the send request is completed with an error then "SND_BUSY" is likewise reset and the value of the output parameter "STATUS" of the FC5 is saved for an error analysis.


Fig. 04

FC6 "AG_RECV" parameters
The values for the input parameters "ID" and "LADDR" must be taken from the Properties dialog of the communication connection in NetPro (see Fig. 01). At the input parameter "RECV" of the FC6 you specify the address and length of the data area that contains the data received (receive buffer), for instance: P#DB201.DBX100.0 BYTE 100.


Fig. 05

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 successfully received, then the value of the output parameter is saved and evaluated.

 
Fig. 06

In FB200 there is an evaluation of how often the relevant STATUS values occur on the FC5 "AG_SEND" and FC6 "AG_RCV". This information is saved in the statistical interface parameters of the FB200 in the variable "STATISTIC" of data type "Structure".


Fig. 07

It is possible to switch on/off the STATUS evaluation by means of the variable "#STATISTIC.ON_OFF. The STATUS evaluation is switched on by default.


Fig. 08

Special case
If the data exchange takes place by way of a TCP connection, then the output parameter "NDR" is only set if the entire receive buffer has been filled.
The value of the output parameter "LEN" thus always indicates the total length of the receive buffer.

The STEP 7 project as download
The STEP 7 project contains a sample program for calling the FC5 and the FC6 with status evaluation. It was created with STEP 7 V5.4 SP3.

S7_300_SEND_RCV.zip ( 45 KB )

Note
Copy the latest version of the communication blocks FC5 and FC6 from the SIMATIC_NET_CP library into your user program and then call it in your user program.

Additional Keywords
FUP, SEND/RECEIVE, Sample program, STEP 7 configuration, Data transfer

What properties and special features does S7 Basis Communication offer?Go to beginning
Part number:

Configuration Notes:
All recent (not high-availability) S7/M7 300/400s (incl. WinAC Slot 41x) and C7-600 CPUs have simple functions (SFCs) for transferring small volumes of data via S7 connections. The connections are not configured, but are set up explicitly when the SFC is called and transfer the data either via the MPI bus or via PROFIBUS DP.

Like S7 communication, S7 basic communication also uses the S7 protocol for data transfer. The S7 protocol is on Layer 7 (Application Layer) of the ISO-OSI reference model, because the system interface used is purely for application data.

( 46 KB )
Fig. 01: ISO-OSI reference model

Protocol services:
 
Type of service Description
I_PUT / I_GET Permits reading / writing of data of an I slave on the PROFIBUS DP.
X_PUT / X_GET Permits reading / writing of data of another MPI or backplane bus node.

Note:

  • A detailed description of the I and X functions is available in the sample application "Communication with SIMATIC S7", section 3.1.2 in Entry ID: 20982954.
  • An example of "Client / Server Communication with (I) Slaves via S7 Basic Communication (I_PUT/ I_GET)" is available in Entry ID: 20987910.

Keywords:
Not configured connection, X_SEND, X_RCV

PROFIBUS: diagnostics of S7 connections with STEP 7Go to beginning
Part number:

QUESTION:
What diagnostics options are available for S7 connections in STEP 7?

ANSWER:
For the topic of "Communication in Automation" we have created a sample application entitled "S7 Communication between S7-300 and S7-400 via PROFIBUS CPs with BSEND / BRECEIVE and multiple job references (R_IDs)". Based on a practical example we have worked out a solution in the form of a description and executable code. The answer to your question is included in one of the chapters. We have made this solution chapter available for you as an excerpt in the form of a PDF document ready for downloading: 

  Solution chapter ( 99 KB )    

If you wish to benefit from the advantages of the entire sample application, you can download this in the portal for Applications & Tools.

Entry-ID: 20987358

Keywords:
S7 protocol, S7 communication, Diagnostics, NCM S7


Repeating the "BSEND" job (SFB12) when the "BRCV" block (SFB13) is in the "disabled" state ("EN_R = 0")Go to beginning
Part number:

QUESTION:  
In S7 communication on the S7-400 with the "BSEND" (SFB12) and "BRCV" (SFB13) blocks, is the send job repeated automatically on the system side when the "BRCV" block (SFB13) is in the "disabled" state ("EN_R = 0")? 

ANSWER:  
If the send job has been started on "BSEND" block and the recipient ("BRCV") is in the "disabled" state ("EN_R = 0"), then the "BSEND" block receives a negative acknowledgment in the user program (ERROR = 1; STATUS = 6 (decimal)). The send job is thus completed. 
There is no system-side strategy for repeating the "BSEND" job, this is the responsibility of the user. This means that the send job has to be repeated in the user program until the "BRCV" block is ready to receive the data sent - "EN_R = 1" on the "BRCV" block.

How do you program communication blocks FB8 "USEND" and FB9 "URCV" for data exchange on the S7-300?Go to beginning
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.

Particularities when assigning parameters of the communication blocks of CP 342 / CP 343Go to beginning
Part number:

QUESTION:  
Why doesn't the communication block of CP342-5 / CP343-1 / CP343-5 work when I assign the ANY parameter symbolically?

ANSWER:  
For data transfer with CP342-5 / CP343-1 / CP343-5 you are using one of the following communication blocks:

  • FC 1 "DP_SEND"
  • FC 2 "DP_RECV"
  • FC 3 "DP_DIAG"
  • FC 4 "DP_CTRL"
  • FC 5 "AG_SEND"
  • FC 6 "AG_RECV"

The Help specifies that only specific VARTYPES (e.g. bytes) are permitted for the ANY parameter.

In a program without symbols you assign the ANY parameter directly with the pointer format as follows, for example:
P#db1.dbx0.0 byte 20
With this the communication works perfectly.

In a program with symbols the pointer input can under certain circumstances be converted into a symbolic input. In such cases it might happen that the blocks report an error.

Technical background:
If there is a symbol for the area addressed (e.g. in a data block), then the actual VARTYPE of the area is recognized and converted into the symbolic representation.
This is the case, for example, when an array of characters has been declared in the data block and the pointer length matches the byte length of the array. Then the VARTYPE CHAR is used instead of the VARTYPE BYTE - consequently the block reports an error.

Remedy:
Either you provide for actual bytes in the memory area (i.e. only bytes are defined in the data block) or you do not permit the compiler to convert into symbols. You can achieve this by addressing slightly less than the symbolic area.


What should you watch out for when upgrading the CP 342-5 or fitting spare parts?Go to beginning
Part number:

Spare parts case: 
Module 6GK7 342-5DA01-0XE0 is replaced by module 6GK7 342-5DA02-0XE0.
There is no need to make any changes either in the HW Config or in the user program. This means that

  • In HW Config module 6GK7 342-5DA01-0XE0 remains parameterized.
  • If the neighboring modules cannot be moved to close the gap, you have to use a placeholder module (order number: 6ES7 370-0AA01-0AA0), which is not configured in HW Config.
  • If the CP has been chosen as the storage place for the configuration, you must reload the configuration; acknowledge the warning message that is displayed when you transfer the configuration.
  • You continue to use the same user program, i.e. without replacing the communication blocks.

  Upgrading/Replacing: 
You want to use additional features / extended quantity frameworks of CP342-5 (order number: 6GK7 342-5DA02-0XE0).

  • In HW Config you must parameterize module 6GK7 342-5DA02-0XE0.
  • You must replace the communication blocks DP_SEND/DP_RECV(FC1/FC2), AG_SEND/AG_RECV(FC5/FC6). Which block version can be used with which module type is given in the table in Entry ID: 187699
    Please note that for these blocks only Byte is permitted as data type on the ANY pointer.

Detailed information is available in the device manual that is supplied electronically (CD) with the CP.

Keywords:
Communication elements, Version change, Upgrade


Which version of the function blocks do you need to operate a CP 342-5?Go to beginning
Part number:

Configuration Notes:
There are revised function blocks available for operating CP 342-5 (order number: 6GK7342-5DA02-0XE0) or CP 342-5 FO (order number: 6GK7342-5DF00-0XE0). The following table lists which functions you have to use.

 

FC type

Version

Can be used with module type CP 342-5
 with order no.

 

6GK7 342-5DA00-
0XE0

6GK7 342-5DA01-
0XE0

6GK7 342-5DA02-
0XE0 configured as ...DA00 or ...DA01

6GK7 342-5DA02-0XE0 / 6GK7 342-5DF00-0XE0

FC5

< V3.0

Yes

Yes

Yes

No

FC6 < V3.0 Yes Yes Yes No
FC5 V 4.2 Yes 1) Yes 1) Yes Yes
FC6 V 4.7 Yes 1) Yes 1) Yes Yes
FC1 V 3.0 Yes 1) Yes 1) Yes Yes

FC2

V 3.0

Yes 1)

Yes 1)

Yes

Yes

FC1 V 1.11 Yes Yes Yes 1) No

FC2

V 1.11 Yes Yes Yes 1) No
1)

Ignore temporary status = 80C4h (entry in diagnostics buffer: "Error in miniprotocol")

Warning:
Please note that for these blocks byte is the only permissible data type on the ANY pointer.

Keywords:  
AG_SEND, AG_RECV, DP_SEND, DP_RECV


CP 342-5 -- How can you tell that the CP 342-5 has withdrawn from the PROFIBUS?Go to beginning
Part number:

Instructions:
Through various faults on the PROFIBUS (double-token etc.) it might happen that the CP 342-5 then withdraws from the bus. In doing so the CP 342-5 switches to the CLEAR operating mode. However, this event is not entered in the diagnostics buffer of the CPU. Nor is an alarm OB called in the CPU. The only way of finding out about this is via the communications blocks of the CP 342-5. For this you have 2 options:

  1. Evaluate the parameter DPSTATUS on FC 2 "DP_RECV".


Fig. 01: Sample call of DP_SEND

 

If Bit 5 is on FALSE and Bit 4 on TRUE in the DPSTATUS parameter, then the CP 342-5 is in Clear mode.

  1. Call FC 3 "DP_DIAG" with DTYPE 4 job


Fig. 02: Sample call of DP_DIAG  
 

Note
More information on evaluating the return parameters from the communications blocks is available in the Online Help of STEP 7. For this you select the required block in the block folder of your project (FC 1, FC 2 or FC 3) and press the F1 key.

CP 342-5 -- How do you program data communications when your DP slave only has outputs?Go to beginning
Part number:

Instructions:
If the DP configuration of a CP 342-5 includes only one or multiple slaves that only have outputs, it is not necessary to call the FC 2 "DP_RECV".

Note
In some older versions of the CP 342-5 DA 02 (firmware V5.0) you must use FC 2 "DP_RECV" with a data length of 0 bytes or use "dummy" inputs. You must define the ANY pointer required by the DP_RECEIVE call with a data length of 0 bytes.

History:
FAQ 14557906 has been incorporated into the present FAQ and deleted as a separate FAQ.

CP 342-5 -- How can you read and write consistent data of a DP slave via the CP 342-5?Go to beginning
Part number:

Instructions:
You simply use communications blocks FC 1 and FC 2 for the transfer of consistent data with the CP 342-5. These blocks always transfer the data consistently (taking into account the evaluation of the block parameters DONE/NDR.

Note:
With the CP 342-5 communications processor you cannot use the system functions SFC14 "DPRD_DAT" and SFC15 "DPWR_DAT". These system functions are released only for integrated DP interfaces with the S7-300.

History:
FAQ 855860 has been incorporated into the present FAQ and deleted as a separate FAQ.

 Entry ID:21629966   Date:2014-03-10 
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