Siemens SIMATIC S7 Manual

Siemens SIMATIC S7 Manual

Open modbus / tcp
Hide thumbs Also See for SIMATIC S7:

Advertisement

SIMATIC
S7 - OPEN MODBUS / TCP
Communication via CP343-1 and CP443-1
Manual

Advertisement

Table of Contents
loading

Summary of Contents for Siemens SIMATIC S7

  • Page 1 SIMATIC S7 - OPEN MODBUS / TCP Communication via CP343-1 and CP443-1 Manual...
  • Page 2 Preface, Table of Contents Product Description Getting Started SIMATIC S7 Commissioning OPEN MODBUS / TCP Licensing Communication via CP343-1 and 443-1 FB MODBUSCP Diagnostics Manual Application Samples Appendices Literature Glossary Edition 4.3...
  • Page 3 The other brand names in this manual may be trademarks use of which by third parties for Trademarks their purposes may infringe the proprietors’ rights. Copyright © Siemens AG 2004-2009 All Rights Reserved Exclusion from Liability The reproduction, transmission or use of this document or its contents We have checked the contents of this document with regard to is not permitted without express written authority.
  • Page 4 Preface Preface Purpose of the The information in this manual allows you to set up and put in operation the connection between the CP 343-1/CP 443-1 and a device that supports the Manual Open MODBUS/TCP protocol. Contents of the This manual describes the function of the function block MODBUSCP and Manual its integration into the hardware and software of the communication processors CP 343-1/CP 443-1.
  • Page 5 If you have further questions regarding the use of the FBs described in this Questions manual, which are not answered in this document, please contact your Siemens partner who supplied you with this function block. Terminology This document uses the term CP or CP 343/CP 443. The descriptions only apply to communications processor CP 343-1/CP 443-1.
  • Page 6: Table Of Contents

    Table of contents Table of Contents ..Product Description....................... 1-1 ..Field of Applications..................1-1 ..Hardware and Software Prerequisites.............. 1-2 ..Getting Started ....................... 2-1 ..Commissioning ......................3-1 ..Installing the Library on the STEP7 PG/-PC ............ 3-1 ..
  • Page 7 Table of contents ..Sample project STL ..................7-2 ..Sample project CFC ..................7-3 OPEN MODBUS / TCP communication via CP343-1 and 443-1 2XV9450-1MB00; Manual edition 4.3...
  • Page 8: Product Description

    1, 2, 3, 4, 5, 6, 15 and 16 are provided. Data transmission is carried out following the Client-Server principle. The SIMATIC S7 can act as both client and server during the data transmission. TCP/IP with CP343-1 and CP434-1 uses static connections. The TCP TCP/IP with connection is not disconnected during errror-free operation.
  • Page 9: Hardware And Software Prerequisites

    The usage of the modbus blocks is possible with STEP7 Version 5.4 or higher. Withal the use of the blocks AG_LSEND/AG_LRECV V3.1 of the update of SIMATIC NET library (http://support.automation.siemens.com/WW/view/en/22172239) is required. The FB MODBUSCP requires ca. 6k byte work and load memory. Memory requirements The FB MB_CPCLI requires ca.10k byte work and memory.
  • Page 10: Getting Started

    Getting started Getting Started Procedure 1. Install “OpenModbusTCP CP“. => Section 3.1 2. Parameterize the connection parameters regarding your requirements (IP-address, port number, etc.). => Section 3.2 to 3.4 3. Insert the Modbus function blocks into your SIMATIC project. => Section 3.6 4.
  • Page 11: Commissioning

    To access the Modbus library the first time, use the browse function of the open dialog for libraries. The manual can be accessed via short cut in \Program Files \Siemens \Documentation as well. OPEN MODBUS / TCP communication via CP343-1 and 443-1...
  • Page 12: Parameterization Of The Cp

    Commissioning Parameterization of the CP Parameterization If you have your stations connected with each other without a router, then they have to be within the same subnet. of the CP In the field Subnet connect the CP with the Industrial Ethernet. In order to do that, select the entry with the name of your network.
  • Page 13 Commissioning Parameterization In the mode “CP is client” an “other station” is required for network configuration. of the Communication Partner After you have inserted the communication partner’s station into your STEP7 project (as described in “Project components: Insert Other station“) you have to specify the object properties of the external station.
  • Page 14: Network Configuration

    Commissioning 2) Properties – Other Station General In tab “General” you do not have to make any settings. Network Configuration Communications The CP is the link for the Industrial Ethernet connection between the S7-CPU and the communication partner / bus. A connection configuration must be Connection made for the connection of the interfaces to the communication partner / bus.
  • Page 15 Commissioning After selecting Insert New Connection... the dialog box ”Insert new connection“ will come up. Select the connection partner (Other Station) for the new connection and use “TCP Connection” for the connection. Put a check mark on “Show properties dialog“ Click “OK“.
  • Page 16 Commissioning • An ID is provided. You can change the ID if needed. Object Properties • Click on the button “Routing” and the configured connection will be shown. of the Connection • The MODBUS client must execute “Active connection establishment”. •...
  • Page 17 Commissioning Unspecified If you have got a communication with CP as MODBUS server, the communication is set up as “unspecified connection”. The client must carry Connection with out active connection establishment. “CP is server” After selecting Insert New Connection... the dialog box ”Insert new connection“...
  • Page 18 Commissioning Click “OK“. This will take you back to the dialog box “Properties TCP connection“. The check box “active connection establishment” must not be activated. In the register “addresses” all information regarding the partner, “IP” and “PORT” are left blank. Click on “OK“...
  • Page 19: How To Select The Appropriate Modbus Block

    Commissioning How to Select the Appropriate Modbus Block General The block FC10 AG_CNTRL of the SIMATIC_NET library permits to terminate and reestablish an established connection. This block was also implemented Information in the Modbus blocks for a more effective use of the resources of CPU and CP.
  • Page 20: Insertion Of The Function Blocks Into The Program

    Commissioning Insertion of the Function Blocks into the Program Content of The following blocks are required for the Modbus communication: MODBUS library • MODBUSCP • MB_CPCLI • MB_CPSRV Insertion of the In order to exchange data with MODBUS devices, you need the function blocks MODBUSCP, MB_CPCLI, MB_CPSRV and AG_CNTRL if applicable.
  • Page 21 Commissioning Insertion of the The Modbus function blocks use the function blocks AG_SEND and AG_RECV in S7-300 or AG_LSEND and AG_LRECV in S7-400. Communication You can find these communication function blocks in the library Blocks “SIMATIC_NET_CP“ which are included in the software package NCM S7 for Industrial Ethernet.
  • Page 22: Multiple Connections Via Port 502

    Modbus clients can establish a connection via port 502. The CP acts as Modbus server. Here you can find information which CP and which firmware release support multiple connections via port 502: www.siemens.com/s7modbus Pre-requisits To use the functionality, the parameterization must be carried out as follows: •...
  • Page 23: Start_Up Characteristics Of Cp343 / Cp443

    Commissioning Start_up Characteristics of CP343 / CP443 Introduction The start up of the CP is divided into the following phases: • Initialization (Power on of the CP) • Parameterization Initialization As soon as the CP is connected to power, the hardware self test runs. The firmware of the CP is set up for operation.
  • Page 24: Changeover Of A Previous Version To V4.X

    8. Delete the previous Modbus call or comment it out. Load the program into the CPU and execute a restart of the CPU. Notes to V4.3 Here you find information to V4.3: www.siemens.com/s7modbus, tab “Downloads”. OPEN MODBUS / TCP communication via CP343-1 and 443-1 3-14 2XV9450-1MB00;...
  • Page 25: Licensing

    Licensing Licensing General The block MODBUSCP must be licensed for each CPU individually. The licensing takes place in two steps: reading the IDENT_CODE and declaring the registration key REG_KEY. The OB121 must be available in the CPU. To read the IDENT_CODE please proceed as follows: Read the IDENT_CODE 1.
  • Page 26 Copy this string per copy/paste from the DB und and insert it in the form IT4Industry SOFTWARE REGISTRATION FORM. This form is stored in the library path ..\Program Files\Siemens\Step7\S7LIBS\Modbus_TCP_CP during installation and is also available on the installation CD. Insert the License-No. of the product package into the form.
  • Page 27 Licensing Declaration of the The registration key REG_KEY must be declared for each call of the block MODBUSCP. Registration Key REG_KEY The registration key REG_KEY should be stored in a global DB. Via this global DB all MODBUSCP blocks can receive the registration key (See also the following example).
  • Page 28 Licensing Missing or Wrong When the registration key is missing or a wrong one is detected, the SF LED (S7-300) or the INTF LED (S7-400) of the CPU is flashing. A cyclic error Licensing message regarding the missing license is displayed in the diagnostic buffer too.
  • Page 29: Function Block Modbuscp

    Function Block MODBUSCP Function Block MODBUSCP Functionality of the FB General The function block MODBUSCP allows a communication between a CP443-1 and CP 343-1 and a partner, which supports Open MODBUS/TCP protocol. Information The function codes 1, 2, 3, 4, 5, 6, 15 and 16 are supported. Depending on the parameterization the FB can be operated both in client and in server mode.
  • Page 30 Function Block MODBUSCP • Data transfer to and from the parameterized DB • Monitoring the data reception with a time-out • Verification of the registration key Online-Help In Simatic Manager an online help for function block MODBUSCP is provided. Mark the FB and press the key “F1”. The online help is displayed; it contains the main information regarding the FB.
  • Page 31 Function Block MODBUSCP Initiate Request A rising edge at the trigger input ENQ_ENR initiates a request. Depending on the input parameters UNIT, DATA_TYPE, START_ADDRESS LENGTH and CP is Client WRITE_READ a MODBUS request telegram is generated and sent to the partner station via the TCP/IP connection.
  • Page 32: Parameters Of The Function Block Modbuscp

    Function Block MODBUSCP Parameters of the Function Block MODBUSCP Parameter Decl. Type Description Value range Init WORD Connection-ID as per configuration in NetPro 1 to 64 laddr WORD Input-Address of the CP in HW Config dependent MONITOR TIME Monitoring Time: Wait for data from T#20ms to communication partner T#+24d20h31...
  • Page 33 Function Block MODBUSCP Parameter Decl. Type Description Value range Init start _3 WORD 3rd data area: first Modbus address in this DB 0 to 65535 W#16#0000 to W#16#FFFF end _3 WORD 3rd data area: last Modbus address in this DB 0 to 65535 W#16#0000 to W#16#FFFF...
  • Page 34 Function Block MODBUSCP Parameter Decl. Type Description Value range Init end _7 WORD 7th data area: last Modbus address in this DB 0 to 65535 W#16#0000 to W#16#FFFF data_type_8 BYTE 8th data area: data type (Coils, Inputs, 0 to 4 Holding Register, Input Register), NULL if not used db _8...
  • Page 35 Function Block MODBUSCP Parameter Decl. Type Description Value range Init LENGTH WORD Number of registers to be processed (INPUT if in CLIENT mode, OUTPUT if in SERVER mode) Coils: reading function 1 to 2000 writing function 1 to 1968 Inputs: reading function 1 to 2000 Holding Register: reading function 1 to 125...
  • Page 36 Function Block MODBUSCP For each configured connection in STEP7 (NetPro) a connection ID is assigned. The connection ID identifies unambiguously the connection from the CPU via the CP to the communication partner. The number from the connection configuration has to be entered here. The range of values for this parameter is 1 to 64.
  • Page 37 Function Block MODBUSCP db_x The parameter db_x defines the number of the data block in which the consecutively defined MODBUS registers or bits are mapped. 0 cannot be used as DB number since it is reserved for system functions. db_x DB-Number 1 - 65535 (W#16#0001 to W#16#FFFF) start_x...
  • Page 38 Function Block MODBUSCP DONE_NDR In the operating mode “CP is client“ the activated request was executed without error. For a read function the response data from the server has already been entered into the DB. For a write function the response to the request telegram has been received from the server.
  • Page 39 Function Block MODBUSCP DATA_TYPE The parameter DATA_TYPE defines which Modbus data type is to be accessed with the current job. The following data types are available: Coils B#16#1 Inputs B#16#2 Holding Register B#16#3 Input Register B#16#4 In the operating mode “CP is client”, DATA_TYPE is an input parameter. In the operating mode “CP is server”, DATA_TYPE is an output parameter.
  • Page 40: Address Mapping

    Function Block MODBUSCP WRITE_READ This parameter defines if a read or write function should be carried out. If the value of the input/output is FALSE, it specifies the read mode. The value TRUE specifies the write mode. Only Holding Registers and Coils can be written. Input Registers and Inputs can be read merely.
  • Page 41 Function Block MODBUSCP Example: data_type_1 B#16#3 Holding Register db_1 W#16#B DB 11 Parameterization start_1 W#16#1 Start address: 1 of the Memory end_1 W#16#1F4 End address: 500 Areas data_type_2 B#16#3 Holding Register db _2 W#16#C DB 12 start _2 W#16#2D0 Start address: 720 end _2 W#16#384 End address: 900...
  • Page 42 Function Block MODBUSCP SIMATIC Modbus device DB 14 Coils (from 00001) + 0.0 00001 + 0.1 00641 +76.2 1250 00642 DB 16 + 0.0 1700 1250 01251 + 0.1 1701 1700 01701 +74.7 2299 +75.0 2300 2300 02301 Inputs (from 10001) 2301 02302 DB 15...
  • Page 43: Data And Standard Functions Used By The Fb

    Function Block MODBUSCP Data and Standard Functions used by the FB Instance DB The function block MODBUSCP stores its data in an instance DB. This instance DB is created by STEP7 at the first call of the FB. The instance data block contains parameters of type Input, Output, Input/Output as well as static variables that it needs for its execution.
  • Page 44 Function Block MODBUSCP MODBUSCP: The FB MODBUSCP uses the following SFBs/SFCs from the standard library: SFCs for • SFB4 „TON“ Miscellaneous • Functions SFC6 „RD_SINFO“ • SFC20 „BLKMOV“ • SFC51 „RDSYST” • SFC52 „WR_USMSG MB_CPCLI and The FBs MB_CPCLI and MB_CPSRV use the following SFCs from the MB_CPSRV: standard library: SFCs for...
  • Page 45: Renaming Of Standard Functions

    Function Block MODBUSCP Renaming of Standard Functions Inducement Whether you have already used the numbers of standard functions in your project or the block number is reserved for a different application, you may rename the internal called functions FC5/FC50 or FC6/FC60, FC10 or the blocks MODBUSCP, MB_CPCLI and MB_CPSRV.
  • Page 46: Diagnostics

    Diagnostics Diagnostics Diagnostic The diagnostic functions of the CP 343/ CP 443 allow you fast failure Function localization. The following diagnostic features are available: • Diagnostics via the display elements of the CP • Diagnostics via the STATUS output of the function block MODBUSCP. The display elements inform you about the operating mode or about the Display Elements failure conditions of the CP.
  • Page 47: Diagnostic Messages Of The Fb Modbuscp

    Diagnostics Diagnostic Messages of the FB MODBUSCP Messages at the The block MOBUSCP has got 2 status outputs: STATUS and STATUS_FUNC. STATUS displays all error numbers. STATUS_FUNC shows STATUS Output of the name of the function, which caused the error. STATUS is valid when the FB ERROR is TRUE.
  • Page 48: Cp343-1 And

    Diagnostics Error messages FB MODBUSCP STATUS Event text Remedy (Hex) A006 The given range of data defined with DATA_TYPE, CP is Client: START_ADDRESS and LENGTH does not exist in Correct the parameter’s data_type_1 to data_type_8. combination DATA_TYPE, CP is server: START_ADDRESS and The CP sends an exception telegram.
  • Page 49 Diagnostics Error messages the FB MODBUSCP STATUS Event text Remedy (Hex) A00E The length indicated in the MODBUS specific telegram Verify the data of the header does not match the number of registers/bits or communication partner with the the byte count in the telegram. The FB receives all data help of a telegram trace.
  • Page 50 Diagnostics Error messages of FB MODBUSCP STATUS Event text Remedy (Hex) A01E The CP has received invalid data which could not be Check the error message of the assigned. communication partner and verify the data with a telegram trace if MODBUSCP V2.x: needed.
  • Page 51: Licensing

    Diagnostics Error messages of FB MODBUSCP STATUS Event text Remedy (Hex) A067 The parameterized areas data_type_6 and Correct the parameterization. data_type_7 overlap. The data areas must not contain A068 The parameterized areas data_type_6 and any overlapping register areas. data_type_8 overlap. A078 The parameterized areas data_type_7 and data_type_8 overlap.
  • Page 52: Fb Modbuscp

    Diagnostics Error messages of FB MODBUSCP STATUS Event text Remedy (Hex) An exception telegram with exception code 1 was The communication partner does A091 received (only if CP is client) not support the requested function. An exception telegram with exception code 2 was Correct LENGTH or A092 received (only if CP is client)
  • Page 53: Diagnostic Messages Of Fc5/Fc6 And Fc50/Fc60

    Diagnostics Diagnostic Messages of FC5/FC6 and FC50/FC60 Diagnostic messages of the included blocks AG_SEND/AG_RECV (FC5/FC6) and AG_LSEND/AG_LRECV (FC50/FC60) at the output STATUS STATUS Event text Remedy (Hex) 7xxx For detailed information please refer to the online help See online help (SIMATIC of SIMATIC Manager.
  • Page 54: Application Samples

    Application Sample Application Samples General With the installation 2 sample projects are installed in \Program Files\Siemens\Step7\Examples. Information • sample project “MB_TCP_CP” written in STL and • sample project “MB_TCP_CP_CFC” written in CFC The S7 programs are for information purposes only and are not to be understood as a solution for a customer specific installation configura- tion.
  • Page 55: Open Modbus / Tcp Communication Via Cp343-1 And

    Application Sample Sample project STL General The sample project written in STL includes serveral Simatic stations for the different applications. Information • Simatic Station is S7-300 or S7-400 • Simatic Station is client or server • Simatic Station supports or doesn’t support AG_CNTRL Used Blocks The subsequent listed blocks are used in the provided example project for S7 stations with FB MODBUSCP.
  • Page 56: Sample Project Cfc

    Application Sample Sample project CFC General The sample project written in CFC includes two Simatic S7-400 stations, one is parameterized as client, the other one as server. Information Used Blocks The subsequent listed blocks are used in the provided example project with FB MODBUSCP.
  • Page 57 A Literature MODBUS IDA MODBUS APPLICATION PROTOCOL SPECIFICATION V1.1b, December 28, 2006 http://www.modbus-IDA.org OPEN MODBUS / TCP communication via CP343-1 and 443-1 Appendix - 1 2XV9450-1MB00; Manual edition 4.3...
  • Page 58 Customer Support Siemens AG Industry Sector I IS IN OC Werner-von-Siemens-Str. 60 91052 Erlangen Tel: ++49 9131 7-46111 Fax: ++49 9131 7-44757 Mail: it4.industry@siemens.com http://www.siemens.com/s7modbus Siemens Aktiengesellschaft Subject to change without prior notice. Stand: 06/2011 OPEN MODBUS / TCP communication via CP343-1 and 443-1...

This manual is also suitable for:

Cp 443-1Simatic net cp 343-1

Table of Contents