You are on page 1of 18

Automation and Drives

CP342-5 DP as PROFIBUS DP master

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 1 03/2007
Siemens AG 2007 - Subject to change without prior notice

Contents Page
Differences between the CP342-5 and the integral DP interface ....................................................... 2
Basic procedure ................................................................................................................................ 3
Configuring with STEP 7 .................................................................................................................. 4
Properties of CP 342-5 DP: General .................................................................................................. 5
Characteristics of the PROFIBUS DP network .................................................................................. 6
Properties of CP 342-5 DP: Addresses ........................................................................................... 7
Properties of CP 342-5 DP: DPM operating mode ............................................................................ 8
Properties of CP 342-5 DP: Options .................................................................................................. 9
CP 342-5 DP (master station without slaves) .................................................................................... 10
Data exchange: DP master and CPU (1) ............................................................................................ 11
Data exchange: DP master and CPU (2) ........................................................................................... 12
Data exchange: DP master and CPU (3) .......................................................................................... 13
Data areas on the ET 200M ............................................................................................................... 14
Data areas on the ET 200S ............................................................................................................... 15
Exercise 1: Configure the CP342-5 DP as a DPM ............................................................................ 16
Exercise 2: Configure the ET200M and ET200S ............................................................................... 17
Exercise 3: Program a data exchange ............................................................................................. 18

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 1 DP master CP342-5 DP
Automation and Drives

Differences between the CP342-5 and the


integral DP interface

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 2 03/2007
Siemens AG 2007 - Subject to change without prior notice

Differences In relation to configuring and programming, the CP342-5 is fundamentally


different to the DP interfaces integrated in S7 CPUs, the CP443-5 extended
and the IM modules of the AS400.

Configuration The DP master system is set up when the CP is configured and not
when the CPU is configured. The IO areas of the DP slaves configured during this
process are not IO areas of the CPU, but merely mailboxes of the DP master.

Programming The CP342-5 does not simulate IO areas. In other words, the CPU does not "see"
the IO areas configured for the master system and consequently does not
automatically transfer data to the process image areas.
This data exchange must be explicitly programmed in the S7 program using the
two blocks FC1 "DP_SEND" and FC2 "DP_RECV" from the library
SIMATIC_NET_CP.

Data consistency Using blocks FC1 and FC2 always ensures automatic data consistency,
regardless of the number of IO bytes transferred.

Performance parameters
There are no longer any differences in the data volume of the maximum possible
baud rate with the later versions of the CP342-5 (see Equipment Manual).

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 2 DP master CP342-5 DP
Automation and Drives

Basic procedure

Configuring
CP 342-5 DP
Use of
library blocks

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 3 03/2007
Siemens AG 2007 - Subject to change without prior notice

Configuration 1.Configure the DP master system, i.e. specify the DP master and associated DP
slaves in the configuration table.
2.Assign the DP master system parameters (IO addresses, groups, etc).

S7 program You program the user program in the S7-CPU :


1.Exchange of data between the DP master and CPU. Blocks FC1 "DP_SEND"
and FC2 "DP_RECV" are used for this purpose.
2.Functional processing of IO data from DP slaves in the S7 program.
3.Detection of slave faults by programmed diagnostic routines, i.e.
in contrast to the integrated interface, faults are not automatically detected
OB86) if a slave fails.
For this purpose, another block FC3 "DP_DIAG" in the S7 program must be
used.

Library The functions described here (blocks of type FC) plus the STEP 7 basic package
and the loadable option NCM S7 for PROFIBUS are all supplied as a library.
Instructions on how to use these blocks can be found below.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 3 DP master CP342-5 DP
Automation and Drives

Configuring with STEP 7

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 4 03/2007
Siemens AG 2007 - Subject to change without prior notice

Properties You open the properties dialog of the CP 342-5 by double clicking on the CP
module.

"General" tab The "General" tab specifies the type and location of the module as well as
information relevant to the network in the case of modules with interfaces,
e.g. the node address. You will also find information in this tab sheet regarding
the STEP 7 project in which the relevant module is integrated.

Short description, order number/firmware, name


The short description, the information below it and the order number/firmware are
identical to the data in the "Hardware catalog" window.
The "Name" field contains the short description of the module that you can
change according to your information. When you change the description, the new
description is displayed in SIMATIC Manager.

Interface You configure the PROFIBUS address and the assignment to a PROFIBUS
subnet of the CP in this field.
You can edit the properties of the subnet by clicking on the Properties button
(see following page).

Backplane bus AS300 modules have an independent MPI address for ONLINE access. This can
be adjusted in the MPI address field. The default setting is the next higher value
from the CPU MPI address. If this station is operated on an MPI network on which
the default address setting has already been assigned (second CPU), then the
default value must be changed on this tab.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 4 DP master CP342-5 DP
Automation and Drives

Properties of CP 342-5 DP: General

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 5 03/2007
Siemens AG 2007 - Subject to change without prior notice

Interface Click on the Properties button on the General tab to enter settings for the subnet.

Network settings You can change the PROFIBUS address and select the PROFIBUS subnet to
which the interface of the node is connected.

Subnet This field specifies the PROFIBUS subnet via which the node is networked.
Select either an existing (previously configured subnet), or

New... click the "New" button if you want to create another PROFIBUS subnet.

Delete If you want to delete a subnet, select it and click on the Delete button. The subnet
is deleted but not the nodes. You can connect the nodes of a previous subnet to
another subnet.

Address If you assign the subnet before you configure the bus address, you will
automatically avoid duplicate address assignments because STEP7 will now
"know" the addresses already used on the assigned subnet.
The transmission rate set and the "highest address
are displayed for information purposes (can be changed by clicking the
"Properties" button).

Properties Click on the Properties button if you want to display or edit the properties of the
selected subnet.
Apart from the bus address itself, the main properties of a subnet includes the
baud rate, the profile and other data required to calculate internal bus parameters.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 5 DP master CP342-5 DP
Automation and Drives

Characteristics of the PROFIBUS DP network

Network configuration

Copper or fiber optic


cables

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 6 03/2007
Siemens AG 2007 - Subject to change without prior notice

Network settings You can change the PROFIBUS address and select the PROFIBUS subnet to
which the interface of the node is connected.

Subnet This field specifies the PROFIBUS subnet via which the node is networked.
Select either an existing (previously configured subnet), or

New... click the New button if you want to create another PROFIBUS
subnet.

Delete If you want to delete a subnet, select it and click on the Delete button. The subnet
is deleted but not the nodes. You can connect the nodes of a previous subnet to
another subnet.

Address If you assign the subnet before you configure the bus address, you will
automatically avoid duplicate address assignments because STEP7 will now
"know" the addresses already used on the assigned subnet.
The transmission rate set and the "highest address are displayed for information
purposes (can be changed by clicking the "Properties" button).

Properties Click on the Properties button if you want to display or edit the properties
of the selected subnet.
Apart from the bus address itself, the main properties of a subnet include the
baud rate, the profile and information about other network components, such as
cable lengths, optical element, etc. which are required to calculate internal bus
parameters.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 6 DP master CP342-5 DP
Automation and Drives

Properties of CP 342-5 DP: Addresses

The "CPLADDR" parameter of


DP_SEND
must be entered in Hex:
CPLAADR:=w#16#130

The "CPLADDR" parameter of


DP_RECV
must be entered in Hex:
CPLAADR:=w#16#130

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 7 03/2007
Siemens AG 2007 - Subject to change without prior notice

Addresses tab This value is passed as parameter CPLADDR to blocks FC1 "DP_SEND" and
FC2 "DP_RECV" in the S7 program. It specifies the address which can be used
to access the CP342-5 via the backplane bus.
This address is dependent on the CP slot and is calculated in exactly the same
way, for example, as the address of an analog module:

CPLADDR:= [(STPL - 4) * 16] + 256

This formula is automatically applied when the box System selection is checked.
When this box is unchecked, any address value can be input, but it should be
outside the PII and PIO areas.

Example

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 7 DP master CP342-5 DP
Automation and Drives

Properties of CP 342-5 DP:


DPM operating mode

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 8 03/2007
Siemens AG 2007 - Subject to change without prior notice

Operating modes The CP342-5 can be operated in three different modes.

- No DP The CP342-5 is used only for the FDL protocol, i.e. it is neither
a DP master nor a DP slave (default setting).
Via the FDL protocol, for example, it can exchange data with
an S5 control.
- DP master The CP generally operates in this mode. The module is the DP
master, i.e. the entire DP master system is configured on this CP.
- DP slave The CP342-5 is operated as a DP slave. It is then coupled to a
master system as a "configured station".
If the CP must also be capable of using the STEP7 ONLINE
access, the box Module is active node on
PROFIBUS subnet must be checked.

DP delay time The start of the next DP cycle in each case is delayed by the value configured
here. Within this time period, the CP can exchange data via the S7 protocol
(STEP7 online) and/or the FDL protocol.
The DP data exchange is "braked" by this delay period.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 8 DP master CP342-5 DP
Automation and Drives

Properties of CP 342-5 DP: Options

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 9 03/2007
Siemens AG 2007 - Subject to change without prior notice

Module replacement without PG


With this option, you can specify that the CP configuration data should be stored
in the CPU.
When the CP is replaced, its configuration data are automatically downloaded
from the CPU when the CP is started up.
Select this option to specify fail-safe long-term data storage in the CPU rather
than in the EEPROM of the CP. However, note that even on the CPU, fail-safe
long-term storage is only ensured to the extent that the CPU is protected against
power failure with a battery backup or an S7 Memory Card.

Supplementary note about downloading configuring data


Whenever you change this option, you must always download the configuration
data for the complete S7 station and not just the configuration data for the CP
whose parameters you have modified here!

Multiplex OP connections / assign internal CPU connection resource


In order to connect TD/OPs or HMI devices, you can optimize the connection
resources in the S7-300 CPU by enabling up to 16 of these units to communicate
on a single CPU connection resource (multiplex operation).
If you choose not to use this option, the number of TD/OPs or HMI devices which
can be operated will depend on the number of available connection resources of
the CPU used (see also CPU connection resources).
The option is deactivated in the default setting. A CPU connection resource is
therefore only reserved for multiplex mode where necessary.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 9 DP master CP342-5 DP
Automation and Drives

CP 342-5 DP (master station without slaves)

DP master
mode

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 10 03/2007
Siemens AG 2007 - Subject to change without prior notice

Result The master station is preconfigured and comprises a CPU 315-2 DP (without
configured DP function) and a CP342-5 as the DP master.

Updating DP data areas


Programmed FC block calls in the user program of the CPU are used to start
transfer of the DP data areas to the PROFIBUS CP and to monitor successful
execution. The position of the DP data area is specified in the call parameters of
the FC blocks.

FC blocks The following blocks are made available for the S7 program in library SIMATIC_
NET_CP:
- FC1 "DP_SEND"
This block transfers the entire DP output area from the CPU to the DP master
(CP).
- FC2 "DP_RECV"
This block transfers the entire DP input area from the DP master (CP) to the
CPU.
- FC3 "DP_DIAG"
This block enables the DP master to scan the diagnostic data of DP slaves.
- FC4 "DP_CTRL"
This block manages check functions for the distributed I/Os, such as Sync,
Freeze, activate/deactivate slave, etc.
CPU cycle A possible processing sequence for the DP FC function blocks in combination
with organization and program blocks in the CPU cycle is shown in the diagram
above. The example shows a case in which, at the beginning of every CPU cycle,
process data are read in and following execution of the user programs, the
created output data are output to the process I/O. An independent diagnostic
program is provided for DP slave monitoring.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 10 DP master CP342-5 DP
Automation and Drives

Data exchange: DP master and CPU (1)

Slot 2 4 5 7

CPU 314 32DI 32D CP342-5 DP master


PII PIQ O
DP IB DP QB
PQB
0 0 0 0
. . 4,5,6,7
PIB . .
. . . .
. . . .
0,1,2,3
2160 2160
127 127

U I 8.0 Slave poll list


UN I 1.3 ADR I Q
= Q 8.5
4 2-5 -
L IW 10 8 0 0

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 11 03/2007
Siemens AG 2007 - Subject to change without prior notice

I/O areas Unlike a CP with an integrated DP master interface or a CP443-5, the CP342-5
does not make any I/O areas available to the CPU.
This means that the IO areas programmed with HW Config here have nothing to
do with the IO address space on the CPU, in other words, they are "invisible" to
the CPU.
These address areas are presented as IO areas within the HW configuration
merely to represent the functional aspect of the data exchange between the DP
master and the DP slaves. The areas which access these I/Os from the viewpoint
of STEP7 are not configured until the S7 program is created and cannot be
identified in the DP master system configuration.
Accordingly, no data are exchanged between the process images PII/PIO and the
CPU.
This data exchange must be programmed explicitly. The two blocks FC1 "DP-
SEND" and FC2 "DP-RECV" are provided for this purpose.

Advantages There are some functional advantages to using these two functions:
1. Data are always transferred consistently, i.e. in one block, between the CPU
and the DP master
2. In addition to process images, data blocks or bit memories can also be used as
data areas on the CPU.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 11 DP master CP342-5 DP
Automation and Drives

Data exchange: DP master and CPU (2)

Slot 2 4 5 7

CPU 314 32DI 32D CP342-5 DP master


PII PIO O
DP IB DP QB
PQB
0 0 0 0
. . 4,5,6,7
PIB . .
. . FC 2: DP-RECV . .
. . . .
0,1,2,3
2160 2160
127 127

U I 8.0 Slave poll list


UN I 1.3 ADR I Q
= Q 8.5
4 2-5 -
L EW 10 8 0 0

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 12 03/2007
Siemens AG 2007 - Subject to change without prior notice

Transfer of input signals of all DP slaves from DP master to CPU


The input signals of the DP slaves are stored in the I area of the CP342-5.
Block FC2 "DP-RECV" in the S7 program is used to transfer them from this area
to the CPU.
If FC2 is called cyclically in OB1, the data transfers are automatically
synchronized with the S7 program. Alternatively, the data can be read to the CPU
within a specific time frame by OB35.
The destination area is specified in ANY format at parameter RECV of FC2. The
source area always begins at address 0 in the I area of the CP342-5. The length
is defined by parameter RECV.

Rules The following rules must be applied:


1.The CP always begins reading the data at the 1st byte (byte 0).
2.The data are always read out as a contiguous block i.e. if there are gaps
between the assigned I bytes of the individual slaves, these bytes are still
transferred to the CPU and written to the destination area (I byte 1 in our
example).
3.If you add the I address configured in HW Config as an OFFSET to the
start address of the destination area (parameter RECV of FC2), you obtain the
input address to be used in the S7 program.

Example for ET200M Values programmed in the hardware configuration:


- EW 2 (1st analog channel) and EW 4 (second analog channel)
- Parameter RECV on FC2 : P#E8.0 Byte 6:
2 + 8 = 10 : EW10 for the 1st analog channel
4 + 8 = 12 : EW12 for the 2nd analog channel

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 12 DP master CP342-5 DP
Automation and Drives

Data exchange: DP master and CPU (3)

Slot 2 4 5 7

CPU 314 32DI 32D CP342-5 DP master


PII PIQ O
DP IB DP QB
PQB
0 0 0 0
. . 4,5,6,7
PIB . .
. . . .
. . FC 1: DP-SEND
. .
0,1,2,3
2160 2160
127 127

U I 8.0 Slave poll list


UN I 1.3 ADR I Q
= Q 8.5
4 2-5 -
L IW 10 8 0 0

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 13 03/2007
Siemens AG 2007 - Subject to change without prior notice

Transfer of output signals of all DP slaves from CPU to DP master


The output signals of the DP slaves must be transferred to the O area of the
CP342-5 from the CPU. This is done using function FC1 "DP-SEND".
If FC1 is called cyclically in OB1, the data transfers are automatically
synchronized with the S7 program. Alternatively, the data can be written within a
specific time frame by OB35.
The destination area is specified in ANY format at parameter SEND of FC1. The
destination area always begins at address 0 in the O area of the CP342-5. The
length is defined by parameter SEND.
The following rules must be applied:
1.Data are always written to the CP starting at byte 0.
2.The data are always transferred as a contiguous block i.e. if there are gaps
between the assigned O bytes of the individual slaves, these bytes are still
transferred from the CPU and written to the destination area (O byte 1 in our
example).
3.If you add the I address configured in HW Config as an OFFSET to the
start address of the destination area (parameter RECV of FC2), you obtain the
input address to be used in the S7 program.

Example for ET200S Value programmed in the hardware configuration: QB 0


- Parameter RECV on FC1 : P#Q8.0 Byte 1 0 + 8 = 8 : QB8

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 13 DP master CP342-5 DP
Automation and Drives

Data areas on the ET 200M

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 14 03/2007
Siemens AG 2007 - Subject to change without prior notice

ET200M The addresses set here (2 to 5) have no connection whatsoever to the address
areas on the CPU, i.e. they are not used as address areas in the S7 program.
They merely represent the source and destination areas for data exchanges with
the CPU.
However, the address value itself can also be used as an offset to the start value
of the address for the source or destination area of the DP-SEND/DP-RECV
blocks.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 14 DP master CP342-5 DP
Automation and Drives

Data areas on the ET 200S

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 15 03/2007
Siemens AG 2007 - Subject to change without prior notice

Address areas The addresses set here (0 to 4) have no connection whatsoever to the address
areas on the CPU, i.e. they are not used as address areas in the S7 program.
They merely represent the source and destination areas for data exchanges with
the CPU.
However, the address value itself can also be used as an offset to the start value
of the address for the source or destination area of the DP-SEND/DP-RECV
blocks.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 15 DP master CP342-5 DP
Automation and Drives

Exercise 1 : Configure the CP342-5 DP


as a DPM

Online diagnosis
(cyclical)

DP master
mode

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 16 03/2007
Siemens AG 2007 - Subject to change without prior notice

Task description: Your task is to use the CP342-5 as a DP master instead of the integrated CPU
interface. You must use the ET200M (with analog module) and the ET 200S as
DP slaves.

Procedure 1.Install the CP342-5 module in the rack of the master station
2.Disconnect the bus cable from the integrated CPU interface (DP master)
and connect it to the interface of the CP
3.Use the bus cable to connect up the ET200M (address 4) and theET200S
(address 8) as DP slaves (switch over terminating resistors)
4.Switch the ONLINE interface of STEP7 over to MPI
5.Configure the CP342-5 DP as the DP master
6.Use the Save and compile function to create new system data blocks and load
them to the CPU.
7.Monitor the boot process and correct any errors that might occur
8.Open the properties dialog of the CP342-5 and click on command
Execute on the Diagnosis tab
9.In the left-hand window, open the folder PROFIBUS and select Nodes

Result Even though no DP slave has yet been configured, the stations networked on the
bus cable are displayed with their bus address and the active/passive status. This
view is updated dynamically if you activate monitoring mode (spectacles symbol).

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 16 DP master CP342-5 DP
Automation and Drives

Exercise 2 : Configure the ET200M and ET200S

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 17 03/2007
Siemens AG 2007 - Subject to change without prior notice

Task Your task is to configure the ET 200M and ET 200S as DP slaves on the CP342-5
DP master system.

Procedure 1.Configure the ET 200S with the following parameters as a DP slave on the
master system:
- Bus address: 8
- I address: 0.0 - 0.7 (compress addresses)
- O address: 0.0 - 0.7 (compress addresses)

2.Configure the ET200M with the following parameters as a DP slave on the


master system:
- Bus address: 4
- Module AI 2x12bit : I address: 2 .. 5
3.Create new system data blocks (Save and compile)
4.Download the configuration to the PLC
5.Open the properties dialog of the CP342-5 again. Click on command Execute
on the Diagnosis tab.
6.Open the folder DP master in the left-hand window.

Result The two slaves are still displayed as "faulted". The reason for this is that the
master does not commence a cyclic data exchange with the two slaves until a
data exchange using blocks DP_SEND and DP_RECV is already in progress
between the CPU and DP master.
This will be programmed in the next exercise.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 17 DP master CP342-5 DP
Automation and Drives

Exercise 3 : Program a data exchange

304(dec) = 130(hex)

304(dec) = 130(hex)

SITRAIN
IK-PBSYS / DP Master CP342-5 DP Page 18 03/2007
Siemens AG 2007 - Subject to change without prior notice

S7 program Programming the data interface between the S7 program (CPU) and the DP
master (CP).

Procedure 1.Unzip project 09_DPM_CP342-5DP.zip


2.Open OB1 in block container "Conveyor belt", add the call for function FC1
"DP_SEND" and assign the block interface parameters
3.In a new final NW, insert the call for block FC2 "DP_RECV" and assign the
block interface parameters
4.If necessary, copy the blocks FC105 and OB35 to your S7 program. Check the
analog addresses, etc.
5.Download all blocks in the program Conveyor belt to the CPU.
6.Open the properties dialog of the CP342-5 and click on command
Execute on the Diagnosis tab
7.Open the folder DP master in the left-hand window.

Result The two slaves are now displayed as "o.k.". The master system itself is also
displayed as functioning correctly: BF LEDs on the DP master and slaves have
now gone out.
The belt model function and analog value display on the simulator should now
work exactly the same as if the CPU interface had been used as the DP master.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 18 DP master CP342-5 DP

You might also like