Modbus/TCP Communication Via IE CP
Modbus/TCP Communication Via IE CP
Modbus/TCP Communication
via IE CP
SIMATIC Modbus/TCP CP, SIMATIC S7-300/S7-400
http://support.automation.siemens.com/WW/view/en/75312612
This entry originates from the Siemens Industry Online Support. The conditions of
use specified there apply (www.siemens.com/nutzungsbedingungen).
Security Siemens offers products and solutions with industrial security functions which
Notes support the secure operation of plants, solutions, machines, devices and/or
networks. They are important components in a comprehensive industrial security
concept. The Siemens products and solutions continue to be developed under
this aspect. Siemens recommends that you keep yourself regularly informed
about product updates.
For the safe operation of Siemens products and solutions it is necessary to take
appropriate security measures (cell protection concept, for example) and to
integrate each component in an overall industrial security concept which is state
of the art. This should also cover the third-party products used. Additional
information about industrial security is available at:
http://www.siemens.com/industrialsecurity.
In order to keep yourself informed about product updates, we recommend
subscribing to our product-specific newsletter. Additional information about this is
available at: http://support.automation.siemens.com.
Siemens AG 2015 All rights reserved
Contents
1 Introduction ........................................................................................................ 3
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13
(TIA Portal) ......................................................................................................... 4
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13
(TIA Portal) ....................................................................................................... 18
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 2
1 Introduction
1 Introduction
The Modbus/TCP blocks for the Industrial Ethernet CPs of S7-300 and S7-400 are
available for downloading in the form of a library: "Modbus_TCP_CP".
http://support.automation.siemens.com/WW/view/en/103474603
You can only install the "Modbus_TCP_CP" library on PCs on which STEP 7 V5.4
or V5.5 is already installed. In order to use the blocks of the "Modbus_TCP_CP"
library in STEP 7 Professional V11/12/V13 (TIA Portal) you must migrate the
blocks to the TIA Portal.
This document describes how to migrate the library blocks of "Modbus_TCP_CP"
V4.3 and "Modbus_TCP_CP" V5.0.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 3
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 4
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
4. Copy the blocks from the "Modbus_TCP_CP" and add them to the new project.
5. Open the "SIMATIC_NET_CP" library with the "File > Open" menu. In the "Open
Project" dialog you switch to the "Libraries" tab and select the
"SIMATIC_NET_CP" library.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 5
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
6. If you are using a SIMATIC S7-300, then copy the following blocks from the
"SIMATIC_NET_CP > CP 300 > Blocks" library and add them to the new project.
FC5 "AG_SEND"
FC6 "AG_RECV"
If you are using a current station, copy the FC10 "AG_CNTRL" as well into your
project.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 6
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
7. If you are using a SIMATIC S7-400, then copy the following blocks from the
"SIMATIC_NET_CP > CP 400 > Blocks" library and add them to the new project.
FC50 "AG_LSEND"
FC60 "AG_LRECV"
If you are using a current station, copy the FC10 "AG_CNTRL" as well into your
project.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 7
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
8. If you change the numbers of the function blocks, use the "Rewire" function. It is
no longer possible to rewire after migration.
Right-click the block folder in the S7 program of the CPU. In the pop-up menu
you select the "Rewire" function.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 8
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
10. Select "Migrate project" in the Portal view or the "Project > Migrate project..."
menu in the Project view. The "Migrate project" dialog opens.
Portal view
Siemens AG 2015 All rights reserved
Project view
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 9
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
11. In the "Migrate project" dialog you select the project to be migrated.
Deselect the "Include hardware configuration" option.
Specify the project name and target path of the TIA Portal project.
Click the "Migrate" button to execute the migration.
Siemens AG 2015 All rights reserved
12. Close the "Migrate project" dialog and open the migration log.
You are informed that the associated SCL sources of the blocks FB106, FB107
and FB108 are missing. You can ignore this message.
13. In addition you get the message "All PLCs have been replaced by unspecified
CPUs".
To clear this message you switch to the Network view and there you right-click
the CPU. Select "Change device" in the pop-up menu. The "Change device"
dialog opens.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 10
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
14. In the "Change device" dialog you select the correct CPU according to your
hardware setup, CPU 315-2 DP, for example. Confirm the settings with "OK".
Siemens AG 2015 All rights reserved
15. According to your hardware setup, in the Device view you drag-and-drop the
Industrial Ethernet CP from the Hardware Catalog to the rack of the
SIMATIC S7-300.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 11
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
16. In the Device view you mark the PROFINET interface of the Industrial Ethernet
CP.
In the inspector window you assign a subnet to the PROFINET interface and
enter the IP address and subnet mask of the Industrial Ethernet CP in "Properties
> General > Ethernet addresses".
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 12
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
18. In the "Create new connection" dialog you make the following settings.
Select "Unspecified" as the connection partner.
Select the Industrial Ethernet CP as local interface.
Disable the "Establish active connection" function if the Modbus block is
parameterized as server.
Enable the "Establish active connection" function if the Modbus block is
parameterized as client.
Click "Add" and close the dialog.
Siemens AG 2015 All rights reserved
19. The TCP connection established is displayed in the table area of the Network
view in the "Connections" table. The properties of the TCP connection are
displayed in the TCP connection.
In the Properties of the TCP connection you open the "General" tab.
Navigate to and open the "General" area. Here you enter the IP address of the
partner if the Modbus block is parameterized as client.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 13
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
20. Navigate to and open the "Local ID" area. Enter the local ID that you
parameterize for the Modbus TCP connection on the Modbus block.
Note the LADDR for the parameterization of the Modbus blocks.
If you parameterize the Modbus block as client, you enter the IP address of the
partner and specify Port 502 as the partner port. You can apply the default value
for the local port of the CPU, 2000, for example.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 14
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
22. In the project navigation you open the folder structure for the CPU 315-2 DP.
Here you open the "Program blocks" folder.
Double-click the "Add new block" command. The "Add new block" dialog opens.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 15
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
23. In the "Add new block" dialog you click the "Organization block (OB)" button.
Select the Startup OB: OB 100. Click the "OK" button to add OB100 to your
project.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 16
2 Migrate the "MODBUS_TCP_CP" V4.3 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
24. Double-click the "Add new block" command again. The "Add new block" dialog
opens.
Click the "Organization block (OB)" button. Select the Fault interrupt OB: OB121.
Click the "OK" button to add OB121 to your project.
Siemens AG 2015 All rights reserved
25. Add the data blocks (DBs) for the Modbus data.
26. Now you program the calls of the FB108 "MODBUSCP" block in the OB100 and
in a cyclic OB, OB1, for example, as described in the manual.
Note
The manual for MODBUS/TCP communication over an Industrial Ethernet CP of
S7-300 or S7-400 is available for downloading:
http://support.automation.siemens.com/WW/view/en/103474603
27. Now compile the project. There should be no errors or warnings.
Note In STEP 7 V11/12/V13 (TIA Portal) it is not permitted to add migrated know-how-
protected blocks to a library. If you do do this and add the library blocks to a
project, this might damage the project.
It is not recommended to copy the blocks into another project, because this can
lead to problems.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 17
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 18
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
4. Copy the blocks from the "Modbus_TCP_CP" and add them to the new project.
5. Open the "SIMATIC_NET_CP" library with the "File > Open" menu. In the "Open
Project" dialog you switch to the "Libraries" tab and select the
"SIMATIC_NET_CP" library.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 19
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
6. If you are using a SIMATIC S7-300, then copy the following blocks from the
"SIMATIC_NET_CP > CP 300 > Blocks" library and add them to the new project.
FC5 "AG_SEND"
FC6 "AG_RECV"
FC10 "AG_CNTRL"
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 20
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
7. If you are using a SIMATIC S7-400, then copy the following blocks from the
"SIMATIC_NET_CP > CP 400 > Blocks" library and add them to the new project.
FC50 "AG_LSEND"
FC60 "AG_LRECV"
FC10 "AG_CNTRL"
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 21
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
8. If you change the numbers of the function blocks, use the "Rewire" function. It is
no longer possible to rewire after migration.
Right-click the block folder in the S7 program of the CPU. In the pop-up menu
you select the "Rewire" function.
Siemens AG 2015 All rights reserved
Note
The Modbus/TCP-CP Wizard is not available for TIA Portal projects. If you do not
create the parameter DB before migration, you have to create it manually in the
TIA Portal.
10. Start STEP 7 Professional V11/V12/13 (TIA Portal)
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 22
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
11. Select "Migrate project" in the Portal view or the "Project > Migrate project..."
menu in the Project view. The "Migrate project" dialog opens.
Portal view
Siemens AG 2015 All rights reserved
Project view
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 23
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
12. In the "Migrate project" dialog you select the project to be migrated.
Deselect the "Include hardware configuration" option.
Specify the project name and target path of the TIA Portal project.
Click the "Migrate" button to execute the migration.
Siemens AG 2015 All rights reserved
13. Close the "Migrate project" dialog and open the migration log.
You are informed that the associated SCL sources of the blocks FB106, FB107
and FB108 are missing. You can ignore this message.
14. In addition you get the message "All PLCs have been replaced by unspecified
CPUs".
To clear this message you switch to the Network view and there you right-click
the CPU. Select "Change device" in the pop-up menu. The "Change device"
dialog opens.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 24
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
15. In the "Change device" dialog you select the correct CPU according to your
hardware setup, CPU 315-2 DP, for example. Confirm the settings with "OK".
Siemens AG 2015 All rights reserved
16. According to your hardware setup, in the Device view you drag-and-drop the
Industrial Ethernet CP from the Hardware Catalog to the rack of the
SIMATIC S7-300.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 25
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
17. In the Device view you mark the PROFINET interface of the Industrial Ethernet
CP.
In the inspector window you assign a subnet to the PROFINET interface and
enter the IP address and subnet mask of the Industrial Ethernet CP in "Properties
> General > Ethernet addresses".
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 26
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
19. In the "Create new connection" dialog you make the following settings.
Select "Unspecified" as the connection partner.
Select the Industrial Ethernet CP as local interface.
Disable the "Establish active connection" function if the Modbus block is
parameterized as server.
Enable the "Establish active connection" function if the Modbus block is
parameterized as client.
Click "Add" and close the dialog.
Siemens AG 2015 All rights reserved
20. The TCP connection established is displayed in the table area of the Network
view in the "Connections" table. The properties of the TCP connection are
displayed in the TCP connection.
In the Properties of the TCP connection you open the "General" tab.
Navigate to and open the "General" area. Here you enter the IP address of the
partner if the Modbus block is parameterized as client.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 27
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
21. Navigate to and open the "Local ID" area. Enter the local ID that you
parameterize for the Modbus TCP connection on the Modbus block.
Note the LADDR for the parameterization of the Modbus blocks.
If you parameterize the Modbus block as client, you enter the IP address of the
partner and specify Port 502 as the partner port. You can apply the default value
for the local port of the CPU, 2000, for example.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 28
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
23. In the project navigation you open the folder structure for the CPU 315-2 DP.
Here you open the "Program blocks" folder.
Double-click the "Add new block" command. The "Add new block" dialog opens.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 29
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
24. In the "Add new block" dialog you click the "Organization block (OB)" button.
Select the Startup OB: OB 100. Click the "OK" button to add OB100 to your
project.
Siemens AG 2015 All rights reserved
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 30
3 Migrate the "MODBUS_TCP_CP" V5.0 Library to STEP 7 V11/12/13 (TIA Portal)
No. Procedure
25. Double-click the "Add new block" command again. The "Add new block" dialog
opens.
Click the "Organization block (OB)" button. Select the Fault interrupt OB: OB121.
Click the "OK" button to add OB121 to your project.
Siemens AG 2015 All rights reserved
26. Add the data blocks (DBs) for the Modbus data.
27. Now you program the calls of the FB108 "MODBUSCP" block in the OB100 and
in a cyclic OB, OB1, for example, as described in the manual.
Note
The manual for MODBUS/TCP communication over an Industrial Ethernet CP of
S7-300 or S7-400 is available for downloading:
http://support.automation.siemens.com/WW/view/en/103474603
28. Now compile the project. There should be no errors or warnings.
Note In STEP 7 V11/12/V13 (TIA Portal) it is not permitted to add migrated know-how-
protected blocks to a library. If you do do this and add the library blocks to a
project, this might damage the project.
It is not recommended to copy the blocks into another project, because this can
lead to problems.
Modbus/TCP-Kommunikation über IE CP
Entry ID: 75312612, V2.0, 02/2015 31