×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 18208090, Entry date: 02/15/2012
(11)
Rate

What should you watch out for when configuring a CP342-5 as DP master and why is it necessary to call the FC1 "DP_SEND" and FC2 "DP_RECV" functions in the user program of the CPU in order to transfer data?

  • Entry
  • Associated product(s)
This entry shows you what to watch out for when configuring a CP342-5 as DP master and describes why is it necessary to call the FC1 "DP_SEND" and FC2 "DP_RECV" functions in the user program of the CPU.

The entry is divided as below:

  1. Communication by means of the integrated PROFIBUS interface of a CPU or by means of a CP443-5 EXT
  2. Communication by means of a CP342-5
  3. Parameterizing the FC1 "DP_SEND" and FC2 "DP_RECV" functions
  4. Evaluation of the feedback values of functions FC1 and FC2
  5. Data communications between CPU, CP342-5 and I/O area of the DP slaves
  6. Recommendation for programming

1. Communication by means of the integrated PROFIBUS interface of a CPU or by means of a CP443-5 EXT
If you connect a PROFIBUS DP master system to the integrated PROFIBUS interface of the CPU or to a CP443-5 EXT, you can use download and transfer commands or the system functions SFC14/15 to access the data of the DP slaves.


Fig. 01


Fig. 02

2. Communication by means of a CP342-5
If you implement a CP342-5 as DP master, you cannot access the data of the connected slaves using download and transfer commands or bit combination operations.


Fig. 03

The writing and reading of the IO data is done in two steps.

  • The write procedure transfers the data from the CPU to the CP342-5. Then the CP342-5 sends the data to the DP slaves.
  • The read procedure transfers the data from the DP slaves to the CP342-5. Then the CP342-5 sends the data to the CPU.

Communication between the CPU and the CP342-5 is made by means of the functions FC1 "DP_SEND" and FC2 "DP_RECV". The data is exchanged automatically between the CP342-5 and the DP slaves.

If you add the PROFIBUS DP master system of the CP342-5 in the hardware configuration, then a message informs you that you must call the functions FC1 "DP_SEND" and FC2 "DP_RECV" in the user program of the CPU to be able to exchange data with the DP slaves.


Fig. 04

Note
The differences between the integrated PROFIBUS interface of an S7-300 CPU and the CP342-5 are described in this Entry ID: 689920.

3. Parameterizing the FC1 "DP_SEND" and FC2 "DP_RECV" functions
The FC1 "DP_SEND" and FC2 "DP_RECV" functions have the input parameters below:

  • CPLADDR
  • SEND or RECV

Parameterization of the input parameter "CPLADDR"
You specify the module start address of the communication processor CP342-5 at the input parameter "CPLADDR". You will find this 16-byte address in the hardware configuration. Double-click the CP342-5 to open the Properties dialog. The module start address is in the "Addresses" tab.

 
Fig. 05

The length of the module start address (16 bytes) has no influence on the following:

  • The number of DP slaves you intend to run on this DP master system.
  • The size of the IO data area to be addressed.
  • At which point the IO data area is to begin.

This value is used by the CPU to address the CP342-5 and has nothing to do with the IO addresses of the DP slaves connected.

Since you can run multiple CPs on one CPU it is necessary to specify the module start address to the functions FC1 "DP_SEND" and FC2 "DP_RECV". This parameter indicates the CP or DP master system with which the function is to exchange data.

Note
The decimal value of the module start address is in the hardware configuration. You specify the hexadecimal value of the module start address at the input parameter "CPLADDR".

The figure below shows a call of the FC1 "DP_SEND" and FC2 "DP_RECV" functions in the user program of the CPU to establish communication between the CPU and the configured CP342-5 and exchange data between the DP master and the DP slaves.


Fig. 06

Parameterization of the "SEND" and "RECV" input parameters
At the "SEND" input parameter you specify the address and length of the data area that contains data to be sent. These are transferred from the CPU to the CP342-5 and then from the CP342-5 to the DP slaves.

At the "RECV" input parameter you specify the address and length of the data area where the received data is stored (receive buffer). The CP342-5 transfers the data read from the DP slaves to the defined receive buffer of the CPU.

The send and receive data areas at the input parameters "SEND" and "RECV" are defined by means of a pointer in the "ANY" format ("P#DB1.DBX3.0 BYTE 37", for example). In this example, 37 bytes of data are received and stored in DB1 starting at byte 3.

Note
For the FC1 "DP_SEND" and FC2 "DP_RECV" functions, the length of the pointer in the "ANY" format must be specified in bytes. The "ANY" format permits other length specifications.


Fig. 07

4. Evaluation of the feedback values of functions FC1 and FC2
The FC1 "DP_SEND" function indicates the status of the data transfer at the output parameters "DONE", "ERROR" and "STATUS".

The FC2 "DP_RECV" function indicates the status of the data transfer at the parameters "NDR", "ERROR", "STATUS" and "DPSTATUS".

Specify the relevant tag at the output parameter to evaluate the status of the data transfer. In this example the values of the output parameters are stored in marker areas.

Data transfer with FC1 "DP_SEND" has been successfully completed when the following conditions are fulfilled:

  • Value of the output parameter "ERROR" = False and
  • Value of the output parameter "STATUS" = 0 and
  • Value of the output parameter "DONE" = True

Data transfer with FC2 "DP_RECV" has been successfully completed when the following conditions are fulfilled:

  • Value of the output parameter "ERROR" = False and
  • Value of the output parameter "STATUS" = 0 and
  • Value of the output parameter "NDR" = True


Fig. 08

When the data has been transferred successfully, the value of the "STATUS" parameter changes between 0 and 8180 (hex) and the value of the "DONE" changes between True and False, because the FC1 "DP_SEND" and FC2 "DP_RECV" functions are called cyclically.

If data transfer is not successful, then no DP slave is involved in the data exchange with the DP master regardless of whether or not the data is relevant for that DP slave. The entire IO area of this DP master system fails - in other words, all the DP slaves connected - when communication fails.

Additional Information
More information about parameterization and status evaluation of the FC1 "DP_SEND" and FC2 "DP_RECV" functions is available in the manual "SIMATIC NET Program blocks for SIMATIC NET S7 CPs - Programming Manual" in Entry ID: 62543517.

5. Data communications between CPU, CP342-5 and I/O area of the DP slaves
You specify neither on the FC1 "DP_SEND" function nor on the FC2 "DP_RECV" function to which DP slave the data is to be written or from which DP slave the data is to be read. With the CP342-5 as DP master you cannot access individual DP slaves directly.

The CP342-5 has an internal data memory for the address area of the inputs and outputs of the DP slaves. As DP master the CP342-5 has an address area of 2160 bytes each for the inputs and outputs. This data area is copied cyclically to the complete IO processor area or is read out of the complete IO processor area. The greatest address that you can preset in the IO process area is therefore 2159 for a data area of 2160 bytes.

You can use the FC1 "DP_SEND" and FC2 "DP_RECV" functions to gain write and read access to this internal data memory of the CP342-5.

When parameterizing the pointers at the input parameters SEND and RECV you specify the length of the data area to be transferred. This data area beginning with the IO address 0 via the internal data storage of the CP342-5 is written to the IO address area or read from it.

A change to the initial value of the pointers at the input parameters SEND and RECV does not influence storage in the internal data memory of the CP342-5 and therefore does not influence the storage in the IO data area of the DP slaves connected. When using the FC1 "DP_SEND" function, the data from the area P#DB2.DBX3.0 BYTE 17 is transferred to the IO process area 0 to 16 just the same as the data from the area P#DB2.DBX32.0 BYTE 17. Thus it is not possible to address the IO area of one specific DP slave. It is always the IO address area beginning with address 0 plus the length specified on the pointer that is updated.

Note
The highest configured I/O address of a DP slave + 1 gives the length of the data area that is specified for the "SEND" and "RECV" parameters via the pointer.

Example
You have a DP slave (ET200M with 16 DI and 16 DO, for example) whose Q addresses occupy the area 200 to 201. In this case you specify a data area of 202 bytes on the pointer (P#DB88.DBX13.0 BYTE 202, for example), even if only 2 bytes are to be transferred to the slave.

To achieve the functionality shown in Fig. 2 using the CP342-5 you need the user program shown in Fig. 9.

 
Fig. 09

The figure below shows the structure of the data block DB1 used. This data block contains the return value of the FC2 "DP_RECV" function and the input address area used.


Fig. 10 

The figure below shows the structure of the data block DB2 used. This data block contains the return value of the FC1 "DP_SEND" function and the output address area used.

 
Fig. 11 

Note
In the data blocks shown DB1 and DB2 there is an offset that has occurred through storage of the feedback values. Alternatively you can store the feedback values in a marker area or in another data block so that you can store the address area of the inputs and outputs starting at address 0.
If you want to store the feedback value and the address area of the inputs and outputs in the same data block, then save the address area of the inputs and outputs starting at address 0 and store the feedback value in the data block according to the user data.

6. Recommendation for programming
Create two data blocks.
The first data block, in this example DB1, covers the address area of the inputs of the DP slaves connected.
The second data block, in this example DB2, covers the address area of the outputs of the DP slaves connected.

First you call the function FC1 "DP_SEND" and immediately afterwards the function FC2 "DP_RECV".
At the SEND input parameter of the FC1 "DB_SEND" function you specify the data block that covers the address area of the outputs - DB2 in this example.
At the RECV input parameter of the FC2 "DB_RECV" function you specify the data block that covers the address area of the inputs - DB1 in this example.

If you use the first bit in the data block as start value for the pointer, P#DB*.DBX0.0 BYTE *), for example, then you can access the area of the data blocks using the download and transfer commands as if the address of the data block were to correspond to the addresses of the process IO.

  • L DB1.DBB0 corresponds to L EB0
  • T DB2.DBB0 corresponds to T AB0


Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.