At your service locally, around the globe: Partner for consulting, sales, training, service, support, spare parts.... covering the entire rage of Siemens for industry. You will find your personal contact person in our

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

Entry

Associated product(s)

InstructionsCommunication 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 programThe 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.

NoteConfigure 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".

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

OB1OB1 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 downloadThe STEP 7 project contains a sample program for calling the FB14 and the FB15 communication blocks. It was created with STEP 7 V5.5.

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.

Security information

In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about industrial security, please visit