CP342-5 DP Master Slave en

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12
At a glance
Powered by AI
The document discusses how to configure and use a CP 342-5 communication processor as either a DP master or DP slave on a PROFIBUS network.

A CP 342-5 can be used as either a DP master or DP slave to exchange I/O data with other devices on a PROFIBUS network.

When configured as a DP master, the CP 342-5 uses the DP_SEND and DP_RECV instructions to exchange data with DP slaves. The module start address, transfer areas, and other parameters must be configured appropriately.

FAQ  01/2017

Using S7-300 PROFIBUS CP


as DP master or DP slave
CP 342-5, STEP 7 (TIA Portal)

https://support.industry.siemens.com/cs/ww/en/view/109744374
This entry is from the Siemens Industry Online Support. The general terms of use
(http://www.siemens.com/terms_of_use) apply.

Security Siemens provides products and solutions with industrial security functions that
Informa- support the secure operation of plants, systems, machines and networks.
tion 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 only
form one element of such a concept.
Customer is responsible to prevent unauthorized access to its plants, systems,
machines and networks. Systems, machines and components should only be
connected to the enterprise network or the internet if and to the extent necessary
and with appropriate security measures (e.g. use of firewalls and network
segmentation) in place.
Additionally, Siemens’ guidance on appropriate security measures should be
taken into account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them
more secure. Siemens strongly recommends to apply product updates as soon
as available and to always use the latest product versions. Use of product
versions that are no longer supported, and failure to apply latest updates may
increase customer’s exposure to cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial
 Siemens AG 2017 All rights reserved

Security RSS Feed under http://www.siemens.com/industrialsecurity.

Contents
1 Introduction ........................................................................................................ 3
2 CP 342-5 as DP Master ...................................................................................... 4
2.1 Setup .................................................................................................... 4
2.2 Address Area of the Inputs and Outputs .............................................. 4
2.3 Module Start Address ........................................................................... 5
2.4 Parameterization of the DP_SEND and DP_RECV Instructions ......... 6
3 CP 342-5 a DP Slave .......................................................................................... 8
3.1 Setup .................................................................................................... 8
3.2 Set DP Slave Mode .............................................................................. 9
3.3 Create Transfer Areas .......................................................................... 9
3.4 Module Start Address ......................................................................... 10
3.5 Parameterization of the DP_SEND and DP_RECV Instructions ....... 10

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 2
1 Introduction

1 Introduction
If you are operating an S7-300 PROFIBUS CP as DP master or DP slave, then you
have to call the DP_SEND and DP_RECV instructions in the user program of the
CPU.
STEP 7 (TIA Portal) includes the DP_SEND and DP_RECV instructions in the
"Instructions" task card under "Communication > Communications Processor >
SIMATIC NET CP > PROFIBUS CP".
 Siemens AG 2017 All rights reserved

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 3
2 CP 342-5 as DP Master

2 CP 342-5 as DP Master
This chapter describes how to configure and program an S7-300 PROFIBUS CP
as DP master in STEP 7 (TIA Portal). In the example, a CP 342-5 is used as DP
master.
The DP_SEND instruction transfers the data of a specified DP output area to the
PROFIBUS CP for output to the distributed IO.
The DP_RECV instruction reads the process data of the distributed IO and status
information into the specified DP input area.
Figure 2-1

DP_RECV

inputs
CPU CP DP slave
(DP master)
outputs

DP_SEND

2.1 Setup
 Siemens AG 2017 All rights reserved

In section 2.4 we describe the parameterization of the DP_SEND and DP_RECV


instructions taking the example below (see Figure 2-2).
Figure 2-2

2.2 Address Area of the Inputs and Outputs


3 DP slaves with the following input and output modules are configured on the
CP 342-5 (DP master):
1. Slave_1
– 1 byte DI with the address area 0-1
– 1 byte DO with the address area 0-1

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 4
2 CP 342-5 as DP Master

2. Slave_2
– 1 byte DI with the address area 380-381
– 1 byte DO with the address area 470-471

3. Slave_3
– 1 byte DI with the address area 2000-2001
– 1 byte DO with the address area 2140-2141

The address area of the inputs is 2001 bytes (0-2000).


The address area of the outputs is 2141 bytes (0-2140).

2.3 Module Start Address


 Siemens AG 2017 All rights reserved

1. Mark the CP 342-5 in the Network view or Device view. The properties of the
CP 342-5 are displayed in the inspector window.
2. Go to the "General" tab and navigate to "I/O addresses" to determine the
module start address. In this example the CP 342-5 has the following module
start address: 256 (dec) = 16#100 (hex).

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 5
2 CP 342-5 as DP Master

2.4 Parameterization of the DP_SEND and DP_RECV


Instructions
Call the DP_SEND and DP_RECV instructions in the user program of the CPU. In
this example the call is made cyclically in OB1.

DP_SEND
The following figure shows the call of the DP_SEND instruction.
Figure 2-3

The table below shows the inputs of the DP_SEND instruction.


Table 2-1
Input Data type Description
CPLADDR WORD Module start address
(See section 2.3)
 Siemens AG 2017 All rights reserved

SEND ANY Specify the address area of the outputs (see


section 2.2).
The table below shows the outputs of the DP_SEND instruction.
Table 2-2
Output Data type Description
DONE BOOLEAN The Status parameter indicates whether the
order has been executed error-free.
ERROR BOOLEAN Error display
STATUS WORD Status display
Data transfer with DP_SEND has been successfully completed when all the
following conditions are fulfilled:
 Value of the output ERROR = false
 Value of the output DONE = true
 Value of the output STATUS = 16#0000
When the data has been transferred successfully, the value of the output STATUS
changes between 16#0000 und 16#8180 and the value of the output DONE
changes between true and false, because the DP_SEND instruction is called
cyclically.

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 6
2 CP 342-5 as DP Master

DP_RECV
The following figure shows the call of the DP_RECV instruction.
Figure 2-4

The table below shows the inputs of the DP_RECV instruction.


Table 2-3
Input Data type Description
CPLADDR WORD Module start address
(See section 2.3)
RECV ANY Specify the address area of the outputs (see
section 2.2).
The table below shows the outputs of the DP_RECV instruction.
Table 2-4
 Siemens AG 2017 All rights reserved

Data type Description


NDR BOOLEAN The Status parameter indicates whether new data
has been received.
ERROR Error display
STATUS Status display
DPSTATUS DP status display
Data transfer with DP_RECV has been successfully completed when all the
following conditions are fulfilled:
 Value of the output ERROR = false
 Value of the output NDR = true
 Value of the output STATUS = 16#0000
When the data has been transferred successfully, the value of the output STATUS
changes between 16#0000 und 16#8180 and the value of the output NDR changes
between true and false, because the DP_RECV instruction is called cyclically.

Note If you use the start address 0 for address area of the inputs,
p#DB*.DBX0.0 Byte *, for example, then in program processing you can access
the areas of the data blocks using the download and transfer commands as if the
address of the data block corresponds to the addresses of the process IO.
 You use the command "L DB2.DBB380" to read the input EB 380.
 You use the command "T DB1.DBB470" to write to the output AB 470.
The outputs are transferred and the inputs are loaded.

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 7
3 CP 342-5 a DP Slave

3 CP 342-5 a DP Slave
This chapter describes how to configure and program an S7-300 PROFIBUS CP
as DP slave in STEP 7 (TIA Portal). In the example, a CP 342-5 is used as DP
slave.
If you use the CP 342-5 as DP slave, you call the DP_SEND and DP_RECV
instructions in the user program of the S7-300 CPU. In this way the data is
transferred from the S7-300 CPU to the CP 342-5 and read.
The DP_SEND instruction transfers the input data of the DP slave to the
PROFIBUS CP for transfer to the DP master.
The DP_RECV instruction reads the output data transferred from the DP master
into the DP data area specified in the instruction.
The DP master reads the data out of the CP 342-5 and writes the data to the
CP 342-5. In this way the CP 342-5 functions as a data buffer between the
controllers of the DP slave and the DP master. You have to configure a
communication for the DP slave and the DP master.
Figure 3-1

DP_SEND

inputs
CPU CP DP master
(DP slave)
 Siemens AG 2017 All rights reserved

outputs

DP_RECV

3.1 Setup
In section 3.5 we describe the parameterization of the DP_SEND and DP_RECV
instructions taking the example below (see Figure 3-2).

Figure 3-2

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 8
3 CP 342-5 a DP Slave

3.2 Set DP Slave Mode


1. Mark the CP 342-5 in the Network view or Device view. The properties of the
CP 342-5 are displayed in the inspector window.
2. Go to the "General" tab and under "Operating mode" you select the operating
mode "DP slave".

3. Assign the relevant DP master to the CP 342-5.

3.3 Create Transfer Areas


 Siemens AG 2017 All rights reserved

You have to create the transfer areas for the data exchange with the DP master.
1. Mark the CP 342-5 in the Network view or Device view. The properties of the
CP 342-5 are displayed in the inspector window.
2. Go to the "General" tab and under "Operating mode > I-slave communication"
you create the transfer areas for data exchange with the DP master. The
transfer area for the inputs has a length of 15 bytes. The transfer area for the
outputs has a length of 35 bytes.

3. Only specify the master address. The slave address is configured with the
DP_SEND and DP_RECV instructions.

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 9
3 CP 342-5 a DP Slave

3.4 Module Start Address


1. Mark the CP 342-5 in the Network view or Device view. The properties of the
CP 342-5 are displayed in the inspector window.
2. Go to the "General" tab and navigate to "I/O addresses" to determine the
module start address. In this example the CP 342-5 has the following module
start address: 256 (dec) = 16#100 (hex).

3.5 Parameterization of the DP_SEND and DP_RECV


 Siemens AG 2017 All rights reserved

Instructions
Call the DP_SEND and DP_RECV instructions in the user program of the CPU. In
this example the call is made cyclically in OB1.

DP_SEND
With the DP_SEND instruction the input addresses are sent to the DP master.
The following figure shows the call of the DP_SEND instruction.
Figure 3-3

The table below shows the inputs of the DP_SEND instruction.


Table 3-1
Input Data type Description
CPLADDR WORD Module start address
(See section 3.4)
SEND ANY Specify the length of the transfer area of the
inputs (see section 3.3).

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 10
3 CP 342-5 a DP Slave

The table below shows the outputs of the DP_SEND instruction.


Table 3-2
Output Data type Description
DONE BOOLEAN The Status parameter indicates whether the
order has been executed error-free.
ERROR BOOLEAN Error display
STATUS WORD Status display
Data transfer with DP_SEND has been successfully completed when all the
following conditions are fulfilled:
 Value of the output ERROR = false
 Value of the output DONE = true
 Value of the output STATUS = 16#0000
When the data has been transferred successfully, the value of the output STATUS
changes between 16#0000 und 16#8180 and the value of the output DONE
changes between true and false, because the DP_SEND instruction is called
cyclically.

DP_RECV
With the DP_RECV instruction the output addresses of the DP master are
received.
 Siemens AG 2017 All rights reserved

The following figure shows the call of the DP_RECV instruction.


Figure 3-4

The table below shows the inputs of the DP_RECV instruction.


Table 3-3
Input Data type Description
CPLADDR WORD Module start address
(See section 3.4)
RECV ANY Specify the length of the transfer area of the outputs
(see section 3.3).

The table below shows the outputs of the DP_RECV instruction.


Table 3-4
Data type Description
NDR BOOLEAN The Status parameter indicates whether new data
has been received.
ERROR Error display
STATUS Status display
DPSTATUS DP status display

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 11
3 CP 342-5 a DP Slave

Data transfer with DP_RECV has been successfully completed when all the
following conditions are fulfilled:
 Value of the output ERROR = false
 Value of the output NDR = true
 Value of the output STATUS = 16#0000
When the data has been transferred successfully, the value of the output STATUS
changes between 16#0000 und 16#8180 and the value of the output NDR changes
between true and false, because the DP_RECV instruction is called cyclically.
 Siemens AG 2017 All rights reserved

Using S7-300 PROFIBUS CP as DP master or DP slave


Entry ID: 109744374, V1.0, 01/2017 12

You might also like