Professional Documents
Culture Documents
s7300 Modbus Slave Operating Instructions en-US en-US PDF
s7300 Modbus Slave Operating Instructions en-US en-US PDF
SIMATIC S7-300/S7-400 Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
______________ 2
______________
Product Description
3
______________
Installation
SIMATIC
4
______________
Mode of Operation
S7-300/S7-400
5
Loadable Driver for Point-to-Point ______________
Commissioning the Driver
CPs: MODBUS Protocol, RTU Commissioning the
6
format, S7 is Slave ______________
Communications FB
Operating Instructions
7
______________
CPU-CP interface
8
______________
Transmission Protocol
9
______________
Function Codes
10
______________
Diagnostics of the Driver
Diagnostics of the
11
______________
Communications FB
A
______________
Technical Data
B
______________
Wiring Diagrams Multipoint
C
______________
References
09/2009
A5E00218418-06
Legal information
Legal information
Warning notice system
This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent
damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert
symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are
graded according to the degree of danger.
DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.
WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.
CAUTION
with a safety alert symbol, indicates that minor personal injury can result if proper precautions are not taken.
CAUTION
without a safety alert symbol, indicates that property damage can result if proper precautions are not taken.
NOTICE
indicates that an unintended result or situation can occur if the corresponding information is not taken into
account.
If more than one degree of danger is present, the warning notice representing the highest degree of danger will
be used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to
property damage.
Qualified Personnel
The product/system described in this documentation may be operated only by personnel qualified for the specific
task in accordance with the relevant documentation for the specific task, in particular its warning notices and
safety instructions. Qualified personnel are those who, based on their training and experience, are capable of
identifying risks and avoiding potential hazards when working with these products/systems.
Proper use of Siemens products
Note the following:
WARNING
Siemens products may only be used for the applications described in the catalog and in the relevant technical
documentation. If products and components from other manufacturers are used, these must be recommended
or approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and
maintenance are required to ensure that the products operate safely and without any problems. The permissible
ambient conditions must be adhered to. The information in the relevant documentation must be observed.
Trademarks
All names identified by ® are registered trademarks of the Siemens AG. The remaining trademarks in this
publication may be trademarks whose use by third parties for their own purposes could violate the rights of the
owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software
described. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the
information in this publication is reviewed regularly and any necessary corrections are included in subsequent
editions.
1 Preface ...................................................................................................................................................... 7
2 Product Description ................................................................................................................................. 11
2.1 Application Options ......................................................................................................................11
2.2 Hardware and Software Requirements........................................................................................13
2.3 Summary of the GOULD-MODBUS Protocol ..............................................................................14
3 Installation ............................................................................................................................................... 17
3.1 Use of the Dongle ........................................................................................................................17
3.2 Interface Connection....................................................................................................................18
4 Mode of Operation ................................................................................................................................... 19
4.1 Components of the SIMATIC / MODBUS Slave Data Link..........................................................19
4.2 Task Distribution ..........................................................................................................................21
4.3 Used MODBUS Function Codes..................................................................................................21
4.4 Data Areas in the SIMATIC CPU .................................................................................................22
4.5 Access with Bit-Orientated Function Codes ................................................................................23
4.6 Access with Register-Orientated Function Codes .......................................................................24
4.7 Enable/disable Write Access .......................................................................................................26
5 Commissioning the Driver........................................................................................................................ 27
5.1 Installing the Driver on the STEP 7 Programming Device/PC.....................................................27
5.2 Uninstalling the Driver..................................................................................................................28
5.3 Configuring the Data Link ............................................................................................................28
5.3.1 Configuring a Data Link with the CP 341.....................................................................................28
5.3.2 Configuring a Data Link with the CP 441-2..................................................................................29
5.4 Assigning Parameters to the CP..................................................................................................31
5.4.1 Assigning Parameters to the CP..................................................................................................31
5.4.2 Assigning Parameters to the CP 341...........................................................................................31
5.4.3 Assigning Parameters to the CP 441-2 .......................................................................................32
5.5 Configuration of the Data Link .....................................................................................................34
5.6 Assigning parameters to the loadable driver ...............................................................................35
5.6.1 MODBUS Slave Protocol .............................................................................................................35
5.6.2 Conversion of MODBUS Addresses for Bit Functions.................................................................38
5.6.3 Conversion of MODBUS Addresses for Register Functions .......................................................42
5.6.4 Limits for Write Functions ............................................................................................................44
5.6.5 RS422/485 (X27) Interface ..........................................................................................................46
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 3
Table of contents
5.7 Loading the Configuration and Parameter Assignment Data for the CP 341 ............................. 48
5.8 Loading drivers to the CP 341 .................................................................................................... 49
5.9 Loading the Configuration and Parameter Assignment data for the CP 441-2 .......................... 50
5.10 Startup Characteristics of the CP................................................................................................ 50
5.11 Parameter Assignment for "Startup of the CPU" ........................................................................ 51
6 Commissioning the Communications FB ................................................................................................. 53
6.1 Installing the FB .......................................................................................................................... 53
6.2 STEP 7 project ............................................................................................................................ 54
6.3 FB 80 Parameters (CP 341)........................................................................................................ 56
6.4 FB 180 Parameters (CP 441-2) .................................................................................................. 57
6.5 Program Call ............................................................................................................................... 58
6.6 Cyclic Operation.......................................................................................................................... 61
7 CPU-CP interface .................................................................................................................................... 63
7.1 CPU-CP interface for CP 341 ..................................................................................................... 63
7.1.1 General Information .................................................................................................................... 63
7.1.2 Data Transfer Length CPU <-> CP ............................................................................................. 63
7.1.3 Data Consistency ........................................................................................................................ 64
7.2 CPU-CP Interface for CP 441-2.................................................................................................. 65
7.2.1 General Information .................................................................................................................... 65
7.2.2 Data Transfer Length CPU <-> CP ............................................................................................. 65
7.2.3 Data Consistency ........................................................................................................................ 66
8 Transmission Protocol ............................................................................................................................. 67
9 Function Codes........................................................................................................................................ 73
9.2 Function Code 01 – Read Coil (Output) Status........................................................................... 75
9.3 Function code 02 - Read Input Status ........................................................................................ 79
9.4 Function Code 03 - Read Output Registers................................................................................ 82
9.5 Function code 04 - Read Input Registers ................................................................................... 85
9.6 Function Code 05 - Force Single Coil ......................................................................................... 89
9.7 Function code 06 - Preset Single Register ................................................................................. 92
9.8 Function code 08 - Loop back Diagnostic Test........................................................................... 95
9.9 Function code 15 - Force Multiple Coils...................................................................................... 97
9.10 Function code 16 - Preset Multiple Registers ........................................................................... 100
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
4 Operating Instructions, 09/2009, A5E00218418-06
Table of contents
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 5
Table of contents
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
6 Operating Instructions, 09/2009, A5E00218418-06
Preface 1
Purpose of the Manual
The information in this manual will enable you to set up and commission a data link between
a CP in the form of a “Modbus capable” slave and a MODBUS Master control system.
Note
This manual contains the description of the driver and the function block as is valid at the
time of publication.
Guide
This manual describes the function of the loadable driver and its integration into the
hardware and software of the CP 341 and CP 441-2 communications processors.
The manual covers the following topics:
● Product Description/Installation
● Mode of Operation of the Data Link
● Commissioning the Driver / Installation / Parameter Assignment
● Commissioning the Function Block / Parameter Assignment / STEP 7 Application
Example
● CPU-CP Interface
● Transmission Protocol / Function Codes
● Diagnostics of the Driver
● Diagnostics of the Function Block
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 7
Preface
Conventions
This manual uses the generic term CP, or CP 341 and CP 441-2.
Special Notes
The driver described in this manual serves as a loadable protocol for the CP, which may be
used instead of the 3964R, RK512, ASCII, and printer standard protocols.
Note
Communication sequences between the CP and CPU can be modified or expanded in the
case of this driver.
In particular, the existing event classes and event numbers for diagnostics can be modified
and expanded.
Also note that this manual only describes the modifications and expansions compared to the
standard functions. You will find all basic information in the manual for the CP you are using.
In order to ensure safe use of this driver, you should have detailed knowledge of the way in
which the CP functions.
Technical Support
You can contact Technical Support for all Industry Automation products using the Web form
to request support under
http://www.siemens.com/automation/support-request
Additional information about our technical support is available in the Internet at
http://www.siemens.com/automation/service.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
8 Operating Instructions, 09/2009, A5E00218418-06
Preface
Further Support
If you have any further questions about the use of products described in this manual, and do
not find the right answers there, contact your local Siemens representative.
You will find information on who to contact at:
http://www.siemens.com/automation/partner
You will find a guide to the technical documentation we offer for individual SIMATIC products
and systems at:
http://www.siemens.com/simatic-tech-doku-portal
The online catalog and ordering system are available at:
http://mall.automation.siemens.com
Training Center
We offer a range of courses to help you to get started with the SIMATIC S7 automation
system. Please contact your regional training center or our main training center in
Nuremberg, Germany, for details:
http://www.sitrain.com
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 9
Preface
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
10 Operating Instructions, 09/2009, A5E00218418-06
Product Description 2
2.1 Application Options
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 11
Product Description
2.1 Application Options
69 &38 &3b
,QWHUIDFHPRGXOHV
56&77<;
6
Data consistency
The data exchange between the S7 CPU and the CP is carried out block-by-block by
integrated system functions.
For more information see the sections "Data Consistency (Page 64)" and "Data Consistency
(Page 66)" in this manual.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
12 Operating Instructions, 09/2009, A5E00218418-06
Product Description
2.2 Hardware and Software Requirements
Useable Module
The driver runs on CP 341 and CP 441-2 with part number MLFB 6ES7441-2AA02-0AE0 or
higher.
CP 441-1 with part number MLFB 6ES7441-1AA0x-0AE0 and CP 441-2 with part number
MLFB 6ES7441-2AA00-0AE0 or 6ES7441-2AA01-0AE0 cannot be used with loadable
drivers.
Dongle
In order to use the CP with loadable drivers, you require a dongle. The dongle is supplied
with the driver.
Software Requirements
An installed version of STEP 7 Basis V5.3 or higher.
An installed version of the optional package Assigning Parameters to Point-To-Point
Connections CP PtP Param V5.1 or higher.
Data Structures
Prior to configuration of your S7 data structures, you should ensure that they are compatible
with the user program of the MODBUS Master systems. Clarify which function codes and
which MODBUS addresses will be used.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 13
Product Description
2.3 Summary of the GOULD-MODBUS Protocol
Function Codes
The type of data exchange between the MODBUS systems is controlled by Function Codes
(FCs).
Data Exchange
The following FCs can be used to carry out data exchange bit-by-bit:
● FC 01 Read coil (output) status,
● FC 02 Read input status,
● FC 05 Force single coil,
● FC 15 Force multiple coils.
The following FCs can be used to carry out data exchange register-by-register:
● FC 03 Read holding registers,
● FC 04 Read input registers,
● FC 06 Preset single register,
● FC 16 Preset multiple registers.
Data Areas
As a rule, the individual FCs operate in accordance with the table below:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
14 Operating Instructions, 09/2009, A5E00218418-06
Product Description
2.3 Summary of the GOULD-MODBUS Protocol
Address Representation
Analogous to the partitioning into read/write and read-only areas, data at user level can be
represented as shown in the table below:
In the transmission message frame on the serial transmission line, the addresses used in the
MODBUS user system are referenced to 0.
In the MODBUS user system itself, these addresses are counted beginning with 1!
Example
● The first holding register in the user system is represented as register 40001. In the
transmission message frame the value 0000 Hex is transmitted as the register address
when FC 03, 06, or 16 is used.
● The 127th coil is represented as coil 00127 in the user system and is assigned the coil
address 007E Hex in the transmission message frame.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 15
Product Description
2.3 Summary of the GOULD-MODBUS Protocol
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
16 Operating Instructions, 09/2009, A5E00218418-06
Installation 3
3.1 Use of the Dongle
Introduction
In order to use the CP with loadable drivers, you require a dongle. When the dongle is
plugged in, drivers can be loaded. For the CP 441-2, you can download drivers for both
interfaces.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 17
Installation
3.2 Interface Connection
RS 232C / TTY
It is possible to create a point-to-point connection to a master system.
Further information on the interface connection can be found in the manual “CP: Point-to-
Point Communication.”
X27/RS485 (2-wire)
It is possible to create a multipoint connection (network) connecting up to 32 slaves to one
master system.
The driver of the CP switches the receive 2-wire line between send and receive.
02'%86PDVWHU 02'%866ODYH
V\VWHP 6,0$7,&6&3
75$ 5$
75% 5%
*1' *1'
(QFORVXUHVKLHOG (QFORVXUHVKLHOG
Figure 3-1 Schematic connection: 1 master system, 1 slave system at the bus
Further information on the interface connection can be found in the manual “CP: Point-to-
Point Communication”.
X27/RS422 (4-wire)
It is possible to create a point-to-point connection to a master system.
Direct creation of a multipoint connection (network) is not possible, because it is not
supported by the RS422/RS485 (X27) interface hardware.
Additional information on the interface connection is available in the section "Wiring
Diagrams Multipoint (Page 127)" and in the manual “CP: Point-to-Point Communication”.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
18 Operating Instructions, 09/2009, A5E00218418-06
Mode of Operation 4
General Information
The supplied data link converts data access of the MODBUS protocol to the specific memory
areas of the SIMATIC S7 CPU.
Note
Any modifications carried out to the supplied function block will invalidate the warranty.
Consequential damages cannot be claimed.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 19
Mode of Operation
4.1 Components of the SIMATIC / MODBUS Slave Data Link
Parameters
The parameters and operating modes listed below must be set for the loadable driver using
the parameter assignment tool.
● Transmission rate, parity
● Slave address of CP
● Operating mode (normal, interference suppression)
● Multiplication factor for the character delay time
● Address areas for FC 01, 05, 15
● Address areas for FC 02
● Base DB number for FC 03, 06, 16
● Base DB number for FC 04
● Limits for write-only access
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
20 Operating Instructions, 09/2009, A5E00218418-06
Mode of Operation
4.2 Task Distribution
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 21
Mode of Operation
4.4 Data Areas in the SIMATIC CPU
Data areas
The individual FCs access the following SIMATIC data areas in the PLC:
Function code MODBUS data type SIMATIC data type Type of access
01 Coil status Memory bit Read bit by bit
Outputs Read bit by bit
Timers Read bit by bit
(16-bit interval)
Counters Read bit by bit
(16-bit interval)
02 Input status Memory bit Read bit by bit
Inputs Read bit by bit
03 Holding registers Data block Read word by word
04 Input register Data block Read word by word
05 Single coil Memory bit Write bit by bit
Outputs Write bit by bit
06 Single (holding) register Data block Write word by word
08 - - Mirror reception
15 Multiple coils Memory bit Write bit by bit
Outputs Write bit by bit
16 Multiple (holding) registers Data block Write word by word
Address Transformation
The MODBUS address in the message frame is interpreted by the driver “in an S7 way” and
transformed in the SIMATIC memory area.
Access to the individual SIMATIC memory areas can be specified by the user by means of
the parameter assignment tool CP: Assigning Parameters to Point-To-Point Connections.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
22 Operating Instructions, 09/2009, A5E00218418-06
Mode of Operation
4.5 Access with Bit-Orientated Function Codes
02'%86DGGUHVVLQ
WUDQVPLVVLRQPHVVDJH 6,0$7,&PHPRU\DUHD
IUDPH
WR EEEE
WR GGGG
WR IIII
WR KKKK
Function Code 02
The bit-oriented function code 02 permits read-only access to the SIMATIC memory areas
memory bits and inputs.
You can use the parameter assignment tool to specify from/to which MODBUS address
access is made to memory bits and inputs.
It is also possible to parameterize the data element in the SIMATIC memory area from which
access should begin.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 23
Mode of Operation
4.6 Access with Register-Orientated Function Codes
The MODBUS address areas and SIMATIC memory areas of FC 02 can be selected
independently from those of FC 01, 05, and 15.
02'%86DGGUHVVLQ
WUDQVPLVVLRQPHVVDJH 6,0$7,&PHPRU\DUHD
IUDPH
WR OOOO
WR UUUU
%LW
2IIVHW'%QXPEHU :RUGQXPEHU
Resulting DB number
The resulting DB number, which is then accessed, is obtained as follows:
Base DB number + Offset DB number.
This can be used to access a data block area consisting of 128 consecutive data blocks
within the entire addressable data block area of 65,535 DBs.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
24 Operating Instructions, 09/2009, A5E00218418-06
Mode of Operation
4.6 Access with Register-Orientated Function Codes
Function Code 04
The register-orientated function code 04 permits read-only access to the SIMATIC memory
area data blocks.
The way this access works is the same as with function codes 03, 06 and 16.
Function code 04 has its own base DB number available for free parameter assignment with
the parameter assignment tool. This will enable you to select a second independent area
consisting of 128 DBs.
However, these DBs have read-only access; it is not possible to write to them.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 25
Mode of Operation
4.7 Enable/disable Write Access
6,0$7,&PHPRU\DUHD
'DWDEORFNV 0,1'%QR
UHVXOWLQJ'%QXPEHU
0$;'%1R
0$;0%\WH
0$;$%\WH
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
26 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver 5
General Information
The tasks relating to STEP 7 described below refer to STEP 7 Version 5.3.
Sequences, names and directory information can differ in later versions.
Introduction
To install the driver, consisting of driver code and driver-specific mask files, proceed as
follows:
1. Insert your MODBUS Slave CD in the CD-ROM drive.
2. In Windows, start the dialog for installing software by double-clicking the "Add and
Remove Programs" icon in the "Control Panel".
3. In the dialog box, select the CD-ROM drive and then the setup.exe file and start the
installation process.
4. Follow the instructions displayed on the installation program step by step.
Result: The driver and the parameter assignment screen forms are installed in the following
directory: Step7\S7fptp\S7Driver.
The directory contains among other things the following files:
● S7wfpb1a.dll
● S7wfpb1x.cod
● S7wfpb2x.cod
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 27
Commissioning the Driver
5.2 Uninstalling the Driver
Introduction
You can uninstall the driver from the STEP 7 package in Windows using "Control Panel",
"Add/Remove Software" and "Uninstall".
Afterwards, you can verify that all files S7wfpb1?.*, S7wfpb2?.*, S7wfpb3?.* have been
deleted from the Step7\S7fptp\S7Driver directory.
Note
Prior to uninstallation of the package "Parameter Assignment Tool CP: Assigning
Parameters to Point-To-Point Connections" it is essential to uninstall all the loadable drivers.
Introduction
The configuration of a data link comprises the hardware allocation in the configuration table
using HW config. The configuration can be carried out using the STEP 7 software.
S7 Project
Before you can carry out the configuration, you must have created a S7 project with STEP 7.
Project Components
Insert the required project components into the opened project with the SIMATIC Manager:
● SIMATIC 300 station.
Before each insertion, you must select the required project by clicking it.
Insert > Station > SIMATIC 300 station
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
28 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.3 Configuring the Data Link
Hardware Configuration
The configuration of the hardware comprises defining the hardware components themselves,
and also their properties.
To start the hardware configuration, select the SIMATIC 300 station and double-click
“Hardware” or select the menu command "Edit > Open Object".
Use the menu command "Insert > Hardware Components" to insert the following
components:
● from SIMATIC 300 a RACK-300, a PS-300 and a CPU-300
● from CP-300 the CP PtP with the appropriate order number.
A detailed description of how to configure S7 -300 modules can be found in the User Manual
for STEP 7.
Introduction
For a point-to-point data link, you must configure a SIMATIC 400 station, the link partner
station, the PtP nodes, and the PtP network.
S7 Project
Before you can carry out the configuration, you must have created a S7 project with STEP 7.
Project Components
Insert the required project components into the opened project with the SIMATIC Manager:
● SIMATIC station, other station, PtP network.
Before each insertion, you must select the required project by clicking it.
– Insert > Station > SIMATIC 400 Station
for your own S7 program (Rack, PS, CPU, CP 441-2, ...),
– Insert > Station > Other Station
for the data link partner,
– Insert > Subnet > PtP
for a PtP network between the SIMATIC 400 Station and the data link partner.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 29
Commissioning the Driver
5.3 Configuring the Data Link
Hardware Configuration
The configuration of the hardware comprises defining the hardware components themselves,
and also their properties.
To start the hardware configuration, select the SIMATIC 400 station and double-click
“Hardware” or select the menu command "Edit > Open Object".
Use the menu command "Insert > Hardware Components" to insert the following
components:
● from SIMATIC 400 a RACK-400, a PS-400 and a CPU-400
● from CP-400 the CP PtP with the appropriate order number.
A detailed description of how to configure S7 400 modules can be found in the User Manual
for STEP 7.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
30 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.4 Assigning Parameters to the CP
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 31
Commissioning the Driver
5.4 Assigning Parameters to the CP
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
32 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.4 Assigning Parameters to the CP
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 33
Commissioning the Driver
5.5 Configuration of the Data Link
Introduction
This chapter is relevant only for the CP 441-2. If you are using a CP 341, you can skip this
chapter.
Communications Link
The CP represents the link in a data link between a S7 CPU and a communications
partner/bus connected via a point-to-point data link. You must carry out data link
configuration for each serial interface to be connected to the link partner/bus.
Connection Properties
You are given an ID which you can modify if required.
Select "Communication Direction 3: Local <-> Partner".
The parameterized routing is displayed.
Both indications of a CPU number are irrelevant for the operation of this driver.
Accept all settings with “OK.”
Save the “Project Configuration of Data Link” and close the dialog box.
You should note that the Connection ID (Local ID) must be used again when you call the
MODBUS communications FB in the user program.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
34 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Protocol Selection
In addition to the standard protocols, the selection dialog box also displays any installed
loadable drivers. Select "MODBUS Slave" for this driver.
Double-click the mailbox icon for the transmission protocol. This takes you to the dialog box
for setting the protocol-specific parameters.
Driver-Specific Parameters
The parameters described below can be set for this driver in the individual dialog boxes.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 35
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Transmission rate
The transmission rate is the speed of data transmission in bits per second (baud).
Note the maximum total transmission rate of the CP 441-2. The total transmission rate is the
sum of the transmission rates parameterized for the two interfaces.
The maximum transmission rate for the TTY interface is 19200 baud.
Data Bits
The number of data bits describes how many bits a character is mapped to for transmission
purposes.
Stop Bits
The number of stop bits defines the smallest possible time interval between two characters
to be transmitted.
Parity
The parity bit is used for data security. Depending on the parameter assignment, it
supplements the number of data bits to be transmitted to form an even or odd number.
If a parity of "none" has been set, no parity bit is transmitted. This reduces the transmission
integrity.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
36 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Slave address
Here you can specify the separate MODBUS Slave address to which the CP should reply.
The CP only replies to message frames where the received slave address is identical to the
parameterized slave address. Message frames to other slaves are not checked and do not
receive a response.
Normal operation
In this operating mode, all detected transmission errors or BREAKs before and after receive
message frames from the link partner result in an appropriate error message.
The first character of a frame has to be a valid slave address.
The end of message frame is only recognized when the character delay time expires.
Interference Suppression
If BREAK is detected on the receiving line at the start of a receive message frame, or if the
CP interface block detects transmission errors, this does not result in an error message in
the user program.
Transmission errors or BREAKs are also ignored when they occur after the end of the
receive message frame (CRC code).
The start of a receive message frame from the link partner is detected by means of the
correctly received slave address.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 37
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
38 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 39
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Example
02'%86DGGUHVVLQ
WUDQVPLVVLRQPHVVDJH 6,0$7,&PHPRU\DUHD
IUDPH
WR
WR
WR
WR
The MODBUS addresses from 0 to 2047 access the SIMATIC memory bits commencing at
memory bit M 1000.0; i.e. length of area = 2048 bits = 256 bytes, which means last memory
bit = M 1255.7.
The MODBUS addresses from 2048 to 2559 access the SIMATIC outputs commencing at
output Q 256.0; i.e. length of area = 512 bits = 64 bytes, which means last output bit = Q
319.7.
The MODBUS addresses from 4096 to 4255 access the SIMATIC timers commencing at
timer T 100; i.e. length of area = 160 bits = 10 words, which means last timer = T 109.
The MODBUS addresses from 4256 to 4415 access the SIMATIC counters commencing at
counter C 120; i.e. length of area = 160 bits = 10 words, which means last counter = C 129.
Overview of FC 02
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
40 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Example
02'%86DGGUHVVLQ
6,0$7,&PHPRU\DUHD
WUDQVPLVVLRQPHVVDJH
IUDPH
WR
WR
The MODBUS addresses from 0 to 4095 access the SIMATIC memory bits commencing at
memory bit M 0.0; i.e. length of area = 4096 bits = 512 bytes, which means last memory bit =
M 511.7.
The MODBUS addresses from 4096 to 5119 access the SIMATIC inputs commencing at
input I 128.0; i.e. length of area = 1024 bits = 128 bytes, which means last input bit = I 255.7.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 41
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Note
The value entered for "commence at memory bit" is completely independent of the value
entered for "commence at memory bit" for function codes 01, 05 and 15.
This means that with FC 02 it is possible to use a second SIMATIC memory bit area (read-
only) that is completely independent of the first.
There is no point in defining memory bytes for simultaneous access with both FC01 and
FC02!
"commence at DB"
"Commence at DB" can be used to specify the first data block of the SIMATIC area to be
accessed (=base DB number).
This DB is accessed when the register number of the MODBUS message frame has the
value 0, starting from data word DBW 0.
Higher MODBUS register numbers access the data words/data blocks that follow this.
Up to 127 successive DBs can be addressed. The driver interprets bits 9 - 15 of the
MODBUS register number for the purpose of accessing the individual successive DBs
(please note the information in the section "Function Codes (Page 73)").
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
42 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Example
02'%86DGGUHVVLQ
6,0$7,&PHPRU\DUHD
WUDQVPLVVLRQPHVVDJH
IUDPH
5HJLVWHUQXPEHU
PHDQV$FFHVVWR 'DWDEORFNV FRPPHQFHDW'%
MODBUS register address 0 can be used to access data block 800 commencing at DBW 0
in the SIMATIC system. Higher MODBUS register addresses (≥ 512, etc.) access the DBs
that follow this, such as DB 801 and so on.
Overview of FC 04
"commence at DB"
"Commence at DB" can be used to specify the first data block of the SIMATIC area to be
accessed (=base DB number).
This DB is accessed when the register number of the MODBUS message frame has the
value 0, starting from data word DBW 0.
Higher MODBUS register numbers access the data words/data blocks that follow this.
Up to 127 successive DBs can be addressed. The driver interprets bits 9 - 15 of the
MODBUS register number for the purpose of accessing the individual successive DBs
(please note the information in the section "Function Codes (Page 73)").
Note
The value entered for "commence at DB" is completely independent of the value entered for
"commence at DB" for function codes 03, 06 and 16.
This means that with FC 04 it is possible to use a second SIMATIC data block area (read-
only) that is completely independent of the first.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 43
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Example
02'%86DGGUHVVLQ
6,0$7,&PHPRU\DUHD
WUDQVPLVVLRQPHVVDJH
IUDPH
5HJLVWHUQXPEHU
PHDQV$FFHVVWR 'DWDEORFNV FRPPHQFHDW'%
MODBUS register address 0 can be used to access data block 1200 commencing at DBW 0
in the SIMATIC system. Higher MODBUS register addresses (≥ 512, 1024 etc.) access the
DBs that follow this, such as DB 1201, 1202 and so on.
Table 5- 7 SIMATIC limits for write access (FC 05, 06, 15 and 16)
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
44 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Example
6,0$7,&PHPRU\DUHD
0$;'%
0$;
0$;
The SIMATIC data blocks DB 600 to DB 699 can be accessed with write function codes FC
06 and 16.
The SIMATIC memory bytes MB 1000 to MB 1127 can be accessed with the write function
codes FC 05 and 15).
The SIMATIC outputs output bytes QB 256 to QB 319 can be accessed with the write
function codes FC 05 and 15.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 45
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Overview
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
46 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.6 Assigning parameters to the loadable driver
Selection of parameters
Select the settings necessary for your connection and exit the individual screen forms with
"OK".
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 47
Commissioning the Driver
5.7 Loading the Configuration and Parameter Assignment Data for the CP 341
5.7 Loading the Configuration and Parameter Assignment Data for the
CP 341
Data Storage
When you close the "hardware configuration" the data are automatically stored in your
STEP 7 project.
Further Information
The STEP 7 User Manual provides a detailed description of how to:
● Save the configuration and parameters
● Load the configuration and parameters to the CPU
● Read, modify, copy and print the configuration and parameters.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
48 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.8 Loading drivers to the CP 341
Requirements
You have an online connection to the CPU.
Load drivers
1. Select the desired loadable driver in the "Protocol" drop-down list in the "Assigning
Parameters to Point-to-Point Connection" window.
2. Click the "Load drivers" icon.
In the "Load drivers to CP341" window, you see the driver version loaded online on the
module and the driver version you have selected offline on the programming device.
3. Click the "Load drivers" button and confirm with "Yes".
The driver will be loaded to the CP 341.
After loading is complete, the information "Driver version online on the module" will be
updated.
If the driver you have loaded is already located on the CP 341, the loading operation will
be canceled with the message "Driver already exists". In this case, confirm with "OK" and
close the "Download Drivers to CP341" window.
If driver files are missing or incorrect, you receive the error message "Module rejected
driver download". In this case, you must repeat the driver installation.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 49
Commissioning the Driver
5.9 Loading the Configuration and Parameter Assignment data for the CP 441-2
5.9 Loading the Configuration and Parameter Assignment data for the
CP 441-2
Data Storage
When you close the "hardware configuration" and/or "configuration of connections” the data
including module parameters and driver codes are automatically stored in your STEP 7
project.
Further Information
The STEP 7 User Manual provides a detailed description of how to:
● Save the configuration and parameters
● Load the configuration and parameters to the CPU
● Read, modify, copy and print the configuration and parameters.
Introduction
The startup of the CP is divided into two phases:
● Initialization with CP in power on mode
● Parameter Assignment
Initialization
As soon as voltage is applied to the CP, and after completion of a hardware test program,
the firmware on the CP is prepared for operation.
Parameter Assignment
During parameter assignment, the CP receives the module parameters allocated to the
current slot.
The CP is now ready to operate.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
50 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Driver
5.11 Parameter Assignment for "Startup of the CPU"
Introduction
This chapter is relevant only for the CP 441-2. If you are using a CP 341, you can skip this
chapter.
Hardware Configuration
To avoid problems during startup of the CPU-CP, the following setting should be made when
carrying out parameter assignment of the CPU with "Hardware configuration".
After starting the parameter assignment by double-clicking the CPU or by clicking the CPU
and selecting the menu command Edit > Object properties, the "Properties - CPU" page
appears.
In the "Startup" tab, set a minimum value of 1000 (= 100s) under "Monitoring Time for" at the
point "Transfer of Parameters to Modules (100ms).
Reason: In the case of parameter assignment of a CP 441-2 interface with a loadable driver,
the driver code is transferred to the CP in addition to the assigned parameters. The entire
loading procedure is monitored for the time mentioned above which must be sufficient.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 51
Commissioning the Driver
5.11 Parameter Assignment for "Startup of the CPU"
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
52 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Communications FB 6
6.1 Installing the FB
Supplied CD
The MODBUS slave communications FB is part of a STEP 7 project which is stored to the
directory EXAMPLES of the STEP 7 software under the name “Modsl” for CP 441-2 or CP
341 when the driver is installed in the library Modbus.
You should ensure that there is not already a project with the same name.
Transfer
1. The project file Modsl contains a complete STEP 7 project in the form of a loadable
example.
2. Transfer the MODBUS communications FB 180 for CP 441-2 or FB 80 for CP 341 to your
user project if you wish to continue working in your own user project.
3. If required, transfer the startup OBs OB 100 and OB 101, the cyclic OB 1, and DB 180 or
DB 80 to your user project.
This will enable you to access the call example for the communications FB, as well as a
completed instance DB for the FB.
Note
OB 1 and OB 100/OB 101 can also be generated themselves.
If the instance DB is not included in the transfer, it must be generated when calling FB 180 or
FB 80 in OB 1/OB 100/OB 101.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 53
Commissioning the Communications FB
6.2 STEP 7 project
STEP 7 Project
The STEP 7 project file Modsl contains a complete project in the form of a loadable example
consisting of:
● Hardware configuration with UR1, PS, CPU and CP
● CP parameter assignment
● STEP 7 program with OBs and MODBUS communications FB
The blocks in the program file are to be understood as examples only and may be changed
by the user according to his requirements.
If necessary, the MODBUS communications FB may be renamed as required.
The SFCs are integrated in the CPU, the variable tables have been added for diagnostic
purposes only.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
54 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Communications FB
6.2 STEP 7 project
The SFBs and SFCs are integrated in the CPU, the variable tables have been added for
diagnostic purposes only.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 55
Commissioning the Communications FB
6.3 FB 80 Parameters (CP 341)
Overview
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
56 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Communications FB
6.4 FB 180 Parameters (CP 441-2)
Overview
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 57
Commissioning the Communications FB
6.5 Program Call
General Information
The MODBUS communications FB for the loadable MODBUS slave driver must be called in
the SIMATIC S7 CPU in the cyclic part.
The communications FB initializes the CP and carries out those MODBUS functions which
the driver cannot carry out itself. The MODBUS slave communications FB must be called in
the user program, even if these function codes are not used by the MODBUS master
system.
Communication between the CP and the FB is carried out via the CPU operating system
functions and the system function block SFB BSEND (CP 441-2) or P_SND_RK and
P_RCV_RK (CP 341) which is called from the FB.
Furthermore, the MODBUS FB (CP 441-2 (FB180) only) reads the error message area
SYSTAT of the CP using SFB STATUS.
Startup, Initialization
After each cold restart or warm restart of the CPU, you must carry out an initialization of the
MODBUS communications FB.
Initialization is activated with a rising edge at input CP_START.
First of all the FB deletes the instance DB, reads operand areas I, Q, M, T, C from the CPU
with SFC51 SZL_READ, and stores them in the instance DB. This enables you to check the
write requirements of the MODBUS master system for area overflow.
The number of the instance DB and the completed initialization sequence is communicated
to the CP by means of a SEND job.
As soon as the SEND job has been completed without error, output CP_START_OK is set
and the FB initialization is complete.
If the SEND job is completed with error, CP_START is reset and CP_START_ERROR is set.
If the initialization was completed with error, MODBUS communication is not possible. All
requests from the MODBUS Master system are answered with an Exception Code message
frame.
Instance DB
All data relevant to the MODBUS FB are located in an instance data block. This DB is also
the instance DB (multi instances) for the used FBs and SFBs and work area for the
MODBUS communications FB. No further data area is required.
The MODBUS FB only uses the instance DB and local data.
Access to the instance DB is permitted only as read-only.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
58 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Communications FB
6.5 Program Call
Timeout Initialization
After power on, the CP needs several seconds for hardware and memory checks until it is
ready to run. Initialization attempts of the MODBUS FB during this time are completed with
error. Because of this, the MODBUS FB repeats its initialization job several times during this
timeout.
CP_START_OK is set if the initialization could be completed without error within the
parameterized time START-TIME of the timer START-TIMER. If initialization could not be
completed without error after the monitoring time has elapsed, CP_START_ERROR is set.
Example OB100/101
Segment 1
AN M 180.0 // set CP_START
S M 180.0 // !
A M 180.1 // re-set CP_START_FM
R M 180.1 // !
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 59
Commissioning the Communications FB
6.5 Program Call
Segment 1
CALL FB 80 , DB80 // MODBUS SLAVE CP341 FB
LADDR :=256 // Base address of the CP
START_TIMER :=T120 // Timer Timeout initi.
START_TIME :=S5T#5S // Time value Timeout
OB_MASK :=TRUE // Mask errors
CP_START :=M180.0 // Start initialization
CP_START_FM :=M180.1 // Edge trigger memory bit
CP_NDR :=M180.2 // New write job from CP
CP_START_OK :=M180.3 // Init. CP-FB without error
CP_START_ERROR :=M180.4 // Init. CP-FB with error
CP_ERROR_NR :=MW182 // Error number
CP_ERROR_INFO :=MW184 // Error additional info
Segment 1
CALL FB 180 , DB180 // MODBUS SLAVE CP441 FB
ID :=W#16#1000 // Connection ID
START_TIMER :=T180 // Timer Timeout initi.
START_TIME :=S5T#5S // Time value Timeout
STATUS_TIMER :=T181 // Timer read SYSTAT
STATUS_TIME :=S5T#2S // Time value read SYSTAT
OB_MASK :=TRUE // Mask errors
CP_START :=M180.0 // Start initialization
CP_START_FM :=M180.1 // Edge trigger memory bit
CP_NDR :=M180.2 // New write job from CP
CP_START_OK :=M180.3 // Init. CP-FB without error
CP_START_ERROR :=M180.4 // Init. CP-FB with error
CP_ERROR_NR :=MW182 // Error number
CP_ERROR_INFO :=MW184 // Error additional info
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
60 Operating Instructions, 09/2009, A5E00218418-06
Commissioning the Communications FB
6.6 Cyclic Operation
Communications FB
The MODBUS communications FB carries out all necessary SFB calls and processes those
function codes which the CP cannot run itself such as write bit-by-bit to the SIMATIC areas
memory bits and outputs with FC05 or FC15.
Response Times
One FB sequence, one PLC cycle, plus data transfer times CP--->CPU and CPU--->CP are
required to process the write function codes FC 05 and FC 15.
The other functions which are processed by the CP directly only require data transfer times
CP--->CPU or CPU--->CP.
The CP does not send the reply message frame to the master system until after the data
transfer CPU--->CP. In this instance the standard reply monitoring time of 2 sec. can be met.
3URFHVVHGE\
0RGEXV)%
'DWDWUDQVIHU 'DWDWUDQVIHU
&3!&38 &38!&3
5HTXHVW &3VHQGV
PHVVDJH UHSO\PHVVDJH
IUDPHUHFHLYHG IUDPH
IURP0DVWHU
The response times depend on the cycle time of the CPU program (MODBUS FB) and the
CPU type (data transfer CPU<-->CP).
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 61
Commissioning the Communications FB
6.6 Cyclic Operation
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
62 Operating Instructions, 09/2009, A5E00218418-06
CPU-CP interface 7
7.1 CPU-CP interface for CP 341
MODBUS Communications FB
Data transfer between CP and CPU is carried out by the function blocks P_SND_RK and
P_RCV_RK.
The supplied MODBUS communications FB calls the FBs.
It is not necessary to program any further FB calls in the SIMATIC user program.
Module Address
The only remaining task is to specify the module address LADDR at the MODBUS
communications FB.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 63
CPU-CP interface
7.1 CPU-CP interface for CP 341
Block Size
Data transfer between CPU and CP is carried out by function blocks P_SND_RK and
P_RCV_RK.
To ensure a stable reaction handling to system interrupts of the S7 automation system, data
transfer between CPU and CP is carried out block-by-block.
The block size for the access to the SIMATIC memory area (data blocks, memory bits,…) is
32 bytes.
Data Consistency
Data consistency during data transmission is given only for the above-listed block size of 32
bytes.
For larger volumes of data, the data is transferred in the listed block size with a time delay
between each block.
Data consistency between the individual blocks cannot be guaranteed because the data may
be processed by the user program at the same time.
Access to the CPU memory is carried out while the user program is running whenever the
P_RCV_PK is passed.
MODBUS Slave
This means the following for the driver MODBUS slave:
If data consistency is required when reading/writing registers or bits, the volume of data
transferred by a single message frame must be limited to the above-mentioned block size:
for example, a maximum of 16 registers with FC 03, 04 and 16 or a maximum of 256 bits
with FC 01, 02 and 15.
If required, it is possible to ensure consistent processing of related data areas by means of
appropriate coordination mechanisms at user program level.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
64 Operating Instructions, 09/2009, A5E00218418-06
CPU-CP interface
7.2 CPU-CP Interface for CP 441-2
MODBUS Communications FB
Data transfer between CP and CPU is carried out by the integrated system functions PUT
and GET and the SFBs BSEND and STATUS.
The supplied MODBUS communications FB calls the SFBs BSEND and STATUS.
PUT and GET are operating system functions which run in the background program of the
CPU, independently of the user program.
It is not necessary to program any further SFB calls in the SIMATIC user program.
Communications Link
The only remaining task is to specify the Connection ID from the link configuration at the
MODBUS communications FB.
The Parameter ID describes the unique communication link to a communication partner.
This means that the MODBUS slave driver replies with an error message frame with
Exception_Code in the event that a MODBUS read or write access is carried out which
exceeds the data lengths specified above .
The table below shows the maximum amount of data.
S7-400
MODBUS function code Maximum number of registers Maximum number of bits
01, 02 2040
03, 04, 16 127
15 2040
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 65
CPU-CP interface
7.2 CPU-CP Interface for CP 441-2
Block Size
Data transfer between CP and CPU is carried out by the integrated system functions PUT
and GET.
To ensure a stable reaction handling to system interrupts of the S7 automation system, data
transfer between CPU and CP is carried out block-by-block.
The block size for the access to the SIMATIC memory area (data blocks, memory bits,…) is
32 bytes.
Data Consistency
As the access to the CPU memory area by the utilities PUT and GET is carried out
asynchronous to the STEP 7 application program, data consistency during data transmission
is given only for the above-mentioned block sizes.
For larger volumes of data, the data is transferred in the listed block size with a time delay
between each block.
Data consistency between the individual blocks cannot be guaranteed because the data may
be processed by the user program at the same time.
Please note furthermore that access to the CPU memory can be carried out at any time
while the user program is running because the integrated system functions PUT and GET
run in the background program of the CPU.
This system response specific to the S7 CPUs is described in the Reference Manual
“System and Standard Functions” in chapters 17 and 18 (Data Consistency) (see also
Further Sources of Information in the preface of this manual).
MODBUS Slave
This means the following for the driver MODBUS slave:
If data consistency is required when reading/writing registers or bits, the volume of data
transferred by a single message frame must be limited to the above-mentioned block size:
for example, for S7-400: a maximum of 16 registers with FC 03, 04 and 16 or a maximum of
256 bits with FC 01, 02 and 15.
You should also note that the read and write access of the MODBUS function codes may be
carried out at any time within the user program.
If required, it is possible to ensure consistent processing of related data areas by means of
appropriate coordination mechanisms at user program level.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
66 Operating Instructions, 09/2009, A5E00218418-06
Transmission Protocol 8
General Information
The procedure used is a code-transparent, asynchronous half-duplex procedure.
Data transfer is carried out without handshake.
Master-Slave Relationship
The MODBUS master system initiates transmission, and after outputting a request message
frame it waits for a reply message frame from the slave. Message frame exchange from
slave to slave is not possible.
Slave Address
The slave address can be within the range 1 to 255. The address is used to address a
defined slave on the bus.
Broadcast Message
The master uses slave address 0 to address all slaves on the bus.
Broadcast messages are only permitted in conjunction with writing Function codes 05, 06, 15
and 16.
A broadcast message is not followed by a reply message frame from the slave.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 67
Transmission Protocol
Function code
The function code defines the meaning of the message frame. It also defines the structure of
the message frame.
The following function codes are supported by the CP:
CRC-Check
The end of the message frame is identified by means of the CRC 16 checksum consisting of
2 bytes. It is calculated by the following polynominal: x16 + x15 + x2 + 1.
The low byte is transferred first, followed by the high byte.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
68 Operating Instructions, 09/2009, A5E00218418-06
Transmission Protocol
During "Normal operation" the Modbus message frame received by the link partner is
evaluated and format checked after the end of frame for TIME_OUTs is received.
During "Interference supression" the end of frame is recognized by correctly formatted
receive frame with a correct CRC code.
Exception Responses
On recognition of an error in the request message frame from the master, for example,
register address illegal, the slave sets the highest value bit in the function code of the reply
message frame.
This is followed by transmission of one byte of error code (Exception Code), which describes
the reason for the error.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 69
Transmission Protocol
When the CP 441 is switched on, the output signals are in the OFF state (inactive).
You can parameterize the way in which the DTR/DSR and RTS/CTS control signals are
used with the parameterization interface Assigning Parameters to Point-To-Point
Connections or control them by means of function calls (FBs) in the user program.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
70 Operating Instructions, 09/2009, A5E00218418-06
Transmission Protocol
Note
When automatic use of the RS 232C secondary signals is parameterized, neither RTS/CTS
data flow control nor RTS and DTR control by means of the V24_SET FB are possible!
On the other hand, it is always possible to read all RS 232C secondary signals by means of
the FB V24_STAT function.
The sections that follow describe how the control and evaluation of the RS 232C secondary
signals are handled.
Note
Automatic use of the RS 232C secondary signals is only possible in half-duplex mode. When
automatic use of the RS 232C secondary signals has been set, neither RTS/CTS data flow
control nor RTS and DTR control by means of the FB 24_SET are not possible.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 71
Transmission Protocol
Time Diagram
The following figure illustrates the chronological sequence of a send request.
21
576
2))
21
&76
2))
7;'
5HTXHVWWRVHQG 6HQGLQJ W
576 21 WHUPLQDWHG
3DUWQHU 7LPHWR
&76 21 576
'DWDRXWSXWZDLWWLPH 3DUWQHU
H[SLUHG6HQG &76 2))
'DWDRXWSXWZDLW 7LPHWR576
WLPH RII
Figure 8-1 Time diagram for automatic use of the RS 232C secondary signals
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
72 Operating Instructions, 09/2009, A5E00218418-06
Function Codes 9
Used function codes
The following MODBUS function codes are supported by the driver:
Note
All MODBUS addresses listed below refer to the transmission message frame level and not
to the user level in the MODBUS master system.
This means that the MODBUS addresses in the transmission message frames begin with
0000 Hex.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 73
Function Codes
Note
The MODBUS slave driver supports a maximum data block length of 512 data words in all
the function codes which access the SIMATIC range "data block DB" (FC 03, 04, 06 and16).
When converting addresses from MODBUS to SIMATIC addresses, a "direct transition" from
one DB number to the subsequent DB number within a MODBUS master request message
frame is not possible. The MODBUS slave replies to this request message frame with an
exception code message frame and outputs "0E 39" (error while accessing the SIMATIC
range "Data block") to the diagnostic buffer.
For example, the DBX word address 510 with a length >2 cannot be output because the
address for Register no. >2 (e.g. Register 3) would automatically mean word address 0 in
DBX+1.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
74 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.1 Function Code 01 – Read Coil (Output) Status
Function
This function enables the MODBUS master system to read individual bits from the SIMATIC
memory areas listed below.
start_address
The MODBUS bit address "start_address" is interpreted by the driver as follows:
The driver checks that “start_address” is located within one of the areas which were
specified during parameter assignment in the dialog box "Conversion of MODBUS
Addressing for FC 01, 05, 15" (from/to: memory bits, outputs, timers, counters).
If the MODBUS bit address start_address is access is made to this SIMATIC memory area
located in one of these areas,
From aaaaa to bbbbb commence at memory M uuuuu.0
bit
From ccccc to ddddd commence at output Q ooooo.0
From eeeee to fffff commence at timer T ttttt
From ggggg to hhhhh commence at counter C zzzzz
The address calculation for access (address conversion) is carried out as follows:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 75
Function Codes
9.1 Function Code 01 – Read Coil (Output) Status
bit_number
Values between 1 and 2040 are permitted as the bit_number, number of coils. This number
of bits is read.
Access to "timers" and "counters"
When accessing SIMATIC areas “Timers” and “Counters,” it must be possible to divide the
"bit_number" by 16 (access word-by-word only).
Please note that a maximum of 16 “timers” and/or “counters” can be read if you are using the
CP 341.
Note
Please note the CPU-specific limitations as described in the chapter "CPU-CP Interface
(Page 63)".
Application Example
Example of parameter assignment:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
76 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.1 Function Code 01 – Read Coil (Output) Status
Address calculation:
The MODBUS address “start_address” 0040 Hex (64 decimal) is located in the “memory bit”
area:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 77
Function Codes
9.1 Function Code 01 – Read Coil (Output) Status
Further Examples
Some other access examples are listed in the table below.
All examples are based on the above area specification.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
78 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.2 Function code 02 - Read Input Status
Function
This function enables the MODBUS master system to read individual bits from the SIMATIC
memory areas listed below.
start_address
The MODBUS bit address "start_address" is interpreted by the driver as follows:
The driver checks that "start_address" is located within one of the areas which were entered
during parameter assignment in the dialog box "Conversion of MODBUS Addressing for FC
02" (from/to: memory bits, inputs).
If the MODBUS bit address is located in area SIMATIC memory area is accessed
start_address ,
from kkkkk to lllll commence at memory M vvvvv.0
bit
from nnnnn to rrrrr from input I sssss.0
The address calculation for access, address conversion, is carried out as follows:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 79
Function Codes
9.2 Function code 02 - Read Input Status
bit_number
Any value between 1 and 2040 is permitted as the bit_number, number of coils. This number
of bits is read.
Note
Please note the CPU-specific limitations as described in the chapter "CPU-CP Interface
(Page 63)".
Application Example
Example of parameter assignment:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
80 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.2 Function code 02 - Read Input Status
Address calculation:
The MODBUS address "start_address" 1030 Hex (4144 decimal) is located in the "Inputs"
area:
Number of bits:
The number of MODBUS bits "bit_number" 0018 Hex (24 decimal) means that 24 bits =
3 bytes are to be read.
Further Examples
Some other access examples are listed in the table below.
All examples are based on the above area specification.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 81
Function Codes
9.3 Function Code 03 - Read Output Registers
Function
This function enables the MODBUS master system to read data words from a data block
start_register
The MODBUS register address "start_register" is interpreted by the driver as follows:
0RGEXVUHJLVWHUQXPEHUVWDUWBUHJLVWHU
%LW
VWDUWBUHJLVWHURIIVHWB'%BQR VWDUWBUHJLVWHUZRUGQR
For further address generation, the driver uses the “base DB number” (commencing at DB
xxxxx) entered in the dialog box "Conversion of MODBUS Addressing for FC 03, 06, 16"
during parameter assignment.
The address calculation for access, address conversion, is carried out as follows:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
82 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.3 Function Code 03 - Read Output Registers
register_number
Any value between 1 and 127 is permitted as the register _number, number of registers. This
number of registers is read. Please observe the following rule:
Note
Please note the CPU-specific limitations as described in the chapter "CPU-CP Interface
(Page 63)".
Application Example
Example of parameter assignment:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 83
Function Codes
9.3 Function Code 03 - Read Output Registers
Address calculation:
The MODBUS address "start_register" 0050 Hex (80 decimal) is interpreted as follows:
%LW
VWDUWBUHJLVWHURIIVHWB'%BQR VWDUWBUHJLVWHUZRUGQR
+H[GHFLPDO +H[GHFLPDO
'DWDEORFN'% EDVH'%QXPEHU[[[[
UHVXOWLQJ'% VWDUWBUHJLVWHURIIVHWB'%BQR
'DWDZRUG'%: VWDUWBUHJLVWHUZRUGB1R
Number of registers:
The number of MODBUS registers "register_number" 0002 Hex (2 decimal) means that
2 registers = 2 data words are read.
Further Examples
Some other access examples are listed in the table below.
start_register
start_register Base DB Offset Word number Resulting DB DBW
no. DB_no.
Hex decimal decimal decimal Hex decimal decimal decimal
0000 0 800 0 000 0 800 0
01F4 500 800 0 1F4 500 800 1000
0200 512 800 1 000 0 801 0
02FF 767 800 1 0FF 255 801 510
0300 768 800 1 100 256 801 512
03FF 1023 800 1 1FF 511 801 1022
0400 1024 800 2 000 0 802 0
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
84 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.4 Function code 04 - Read Input Registers
Function
This function enables the MODBUS master system to read data words from a data block.
start_register
The MODBUS register address "start_register" is interpreted by the driver as follows:
0RGEXVUHJLVWHUQXPEHUVWDUWBUHJLVWHU
%LW
VWDUWBUHJLVWHURIIVHWB'%BQR VWDUWBUHJLVWHUZRUGQR
For further address generation, the driver uses the “base DB number” (commencing at DB
xxxxx) specified in the dialog box "Conversion of MODBUS addressing for FC4".
The address calculation for access, address conversion, is carried out in two steps as
follows:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 85
Function Codes
9.4 Function code 04 - Read Input Registers
register_number
Any value between 1 and 127 is permitted as the register _number, number of registers. This
number of registers is read. Please observe the following rule:
Note
Please note the CPU-specific limitations as described in the chapter "CPU-CP Interface
(Page 63)".
Application Example
Example of parameter assignment:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
86 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.4 Function code 04 - Read Input Registers
Address Calculation:
The MODBUS address "start_register" 02C0 Hex (704 decimal) is interpreted as follows:
%LW
VWDUWBUHJLVWHURIIVHWB'%BQR VWDUWBUHJLVWHUZRUGQR
+H[GHFLPDO &+H[GHFLPDO
'DWDEORFN'% EDVH'%QXPEHU[[[[
UHVXOWLQJ'% VWDUWBUHJLVWHURIIVHWB'%BQR
'DWDZRUG'%: VWDUWBUHJLVWHUZRUGB1R
Number of registers:
The number of MODBUS registers "register_number" 0003 Hex (3 decimal) means that
3 registers = 3 data words are read.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 87
Function Codes
9.4 Function code 04 - Read Input Registers
Further examples
Some other access examples are listed in the table below.
start_register
start_register Base DB Offset Word number Resulting DB DBW
no. DB_no.
Hex decimal decimal decimal Hex decimal decimal decimal
0000 0 900 0 000 0 900 0
0064 100 900 0 064 100 900 200
00C8 200 900 0 0C8 200 900 400
0190 400 900 0 190 400 900 800
1400 5120 900 10 000 0 910 0
1464 5220 900 10 064 100 910 200
14C8 5320 900 10 0C8 200 910 400
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
88 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.5 Function Code 05 - Force Single Coil
Function
This function enables the MODBUS master system to write a bit into the SIMATIC memory
of the CPU as listed below.
coil_address
The MODBUS bit address "coil_address" is interpreted by the driver as follows:
The driver checks whether "coil_address" is located within one of the areas which were
entered during parameter assignment in the dialog box "Conversion of MODBUS Addressing
for FC 01, 05, 15" (from/to: memory bits, outputs, timers, counters).
If the the
MODBUS bit address SIMATIC memory area is accessed
coil_address
is located in the area
from aaaaa to bbbbb commence at M uuuuu.0
memory bit
from ccccc to ddddd commence at output Q ooooo.0
The address calculation for access (address conversion) is carried out as follows:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 89
Function Codes
9.5 Function Code 05 - Force Single Coil
DATA on/off
The following two values are permitted as DATA-on/off:
● FF00H -> Set bit.
● 0000H -> Delete bit.
Application Example
Example of parameter assignment:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
90 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.5 Function Code 05 - Force Single Coil
Address Calculation:
The MODBUS address "coil_address" 0809 Hex (2057 decimal) is located in the "outputs"
area:
Further Examples
For further examples of access to memory bits and outputs, refer to FC 01.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 91
Function Codes
9.6 Function code 06 - Preset Single Register
Function
This function enables the MODBUS master system to write a data word in a data block of the
CPU.
start_register
The MODBUS register address "start_register" is interpreted by the driver as follows:
0RGEXVUHJLVWHUQXPEHUVWDUWBUHJLVWHU
%LW
VWDUWBUHJLVWHURIIVHWB'%BQR VWDUWBUHJLVWHUZRUGQR
For further address generation, the driver uses the "base DB number" commencing at DB
xxxxx entered in the dialog box "Conversion of MODBUS Addressing for FC 03, 06, 16"
during parameter assignment .
The address calculation for access, address conversion, is carried out in two steps as
follows:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
92 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.6 Function code 06 - Preset Single Register
DATA Value
Any value can be used as the DATA value, register value.
Application Example
Example of parameter assignment:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 93
Function Codes
9.6 Function code 06 - Preset Single Register
Address Calculation:
The MODBUS address "start_register" 0180 Hex (384 decimal) is interpreted as follows:
%LW
VWDUWBUHJLVWHURIIVHWB'%BQR VWDUWBUHJLVWHUZRUGQR
+H[GHFLPDO +H[GHFLPDO
'DWDEORFN'% EDVH'%QXPEHU[[[[
UHVXOWLQJ'% VWDUWBUHJLVWHURIIVHWB'%BQR
'DWDZRUG'%: VWDUWBUHJLVWHUZRUGB1R
Further examples
For further access examples, please refer to FC 03.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
94 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.7 Function code 08 - Loop back Diagnostic Test
Function
This function is used to check the communications connection.
It has no effect on the S7 CPU, the user programs or user data. The received message
frame is returned to the master system by the driver independently.
Diagnostic Code
Only Diagnostic Code 0000 is supported!
Test Data
Any 16-bit value.
Application Example
Request message frame FUNCTION 08:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 95
Function Codes
9.7 Function code 08 - Loop back Diagnostic Test
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
96 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.8 Function code 15 - Force Multiple Coils
Function
This function enables the MODBUS master system to write several bits to the SIMATIC
memory areas listed below.
start_address
The MODBUS bit address "start_address" is interpreted by the driver as follows:
The driver checks whether “start_address” is located within one of the areas which were
entered during parameter assignment in the dialog box "Conversion of MODBUS Addressing
for FC 01, 05, 15" (from/to: memory bits, outputs, timers, counters).
If the MODBUS bit address is located in area SIMATIC memory area is accessed
start_address,
from aaaaa to bbbbb commence at M uuuuu.0
memory bit
from ccccc to ddddd commence at output Q ooooo.0
The address calculation for access, address conversion, is carried out as follows:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 97
Function Codes
9.8 Function code 15 - Force Multiple Coils
Quantity
Any value between 1 and 2040 is permitted as the quantity, number of bits.
Note
Please note the CPU-specific limitations as described in the chapter "CPU-CP Interface
(Page 63)".
DATA
Any values are contained in the DATA field as bit statuses.
Application Example
Example of parameter assignment:
Action:
The MODBUS master system wants to write the following bit statuses on to memory bits M
1144.0 ... M 1144.7 and M 1145.0 ... M 1145.3:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
98 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.8 Function code 15 - Force Multiple Coils
Address Calculation:
The MODBUS address "coil_address" 0480 Hex (1152 decimal) is located in the "memory
bit" area:
Further Examples
For further examples of access to memory bits and outputs, refer to FC 01.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 99
Function Codes
9.9 Function code 16 - Preset Multiple Registers
Function
The function code enables the MODBUS master system to write several data words in a
data block of the SIMATIC CPU.
start_register
The MODBUS register address "start_register" is interpreted by the driver as follows:
0RGEXVUHJLVWHUQXPEHUVWDUWBUHJLVWHU
%LW
VWDUWBUHJLVWHURIIVHWB'%BQR VWDUWBUHJLVWHUZRUGQR
For further address generation, the driver uses the "base DB number" commencing at DB
xxxxx entered in the dialog box "Conversion of MODBUS Addressing for FC 03, 06, 16"
during parameter assignment .
The address calculation for access, address conversion, is carried out in two steps as
follows:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
100 Operating Instructions, 09/2009, A5E00218418-06
Function Codes
9.9 Function code 16 - Preset Multiple Registers
Quantity
Any value between 1 and 127 is permitted as the quantity, number of registers. Please
observe the following rule:
Note
Please note the CPU-specific limitations as described in the chapter "CPU-CP Interface
(Page 63)".
DATA (High,Low)
Any value can be used as DATA DATA (High,Low) (register value).
Application example
Example of parameter assignment:
Action:
The MODBUS master system wants to write the values CD09 Hex, DE1A Hex and EF2B
Hex to data words DBW 100, DBW 102 and DBW 104 of DB 800.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 101
Function Codes
9.9 Function code 16 - Preset Multiple Registers
Address calculation:
The MODBUS address "start_register" 0032 Hex (50 decimal) is interpreted as follows:
%LW
VWDUWBUHJLVWHURIIVHWB'%BQR VWDUWBUHJLVWHUZRUGQR
+H[GHFLPDO +H[GHFLPDO
'DWDEORFN'% EDVH'%QXPEHU[[[[
UHVXOWLQJ'% VWDUWBUHJLVWHURIIVHWB'%BQR
'DWDZRUG'%: VWDUWBUHJLVWHUZRUGB1R
Further examples
For further access examples, please refer to FC 03.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
102 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Driver 10
Diagnostic Functions
The diagnostic functions of the CP enable you to quickly locate any errors that occur. The
following diagnostic functions are available:
● Diagnostics via the display elements of the CP
● Diagnostics via the STATUS output of the function blocks
● Diagnostics via the SYSTAT error message area (for CP 441-2 only)
● Diagnostic buffer of the CP
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 103
Diagnostics of the Driver
10.1 Diagnostic Facilities on the CP 341
Display Elements
The display elements of the CP 341 provide information on the CP 341. The following
display functions are available:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
104 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Driver
10.1 Diagnostic Facilities on the CP 341
Introduction
Each function block has a STATUS parameter for error diagnostics purposes. Each STATUS
message number has the same meaning, irrespective of which function block is used.
%LWQR
67$786
The individual errors/events are listed in the chapter "Table of Errors/Events (Page 110)".
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 105
Diagnostics of the Driver
10.2 Diagnostic Facilities on the CP 441-2
Display Functions
The display elements of the CP 441-2 provide information on the CP 441-2. The following
display functions are available:
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
106 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Driver
10.2 Diagnostic Facilities on the CP 441-2
Introduction
Each system function block has a STATUS parameter for error diagnostics purposes. Each
STATUS message number has the same meaning, irrespective of the system function block
used. The STATUS messages which are most important for the CP are described in the
table below. You will find a complete and current description of the STATUS messages in
the reference manual "System Software for S7-300/400, System and Standard Functions".
Note
Reading the SYSTAT area with the STATUS job will provide you with detailed information on
errors and events which have occurred during communication between the CP, the
associated CPU, and the connected link partner.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 107
Diagnostics of the Driver
10.2 Diagnostic Facilities on the CP 441-2
Reading by Communications FB
The error message area SYSTAT is already read by the MODBUS communications FB.
The FB reads the SYSTAT area cyclically and stores the data in the instance DB
commencing at DBW 40 (See also Chapter "Commissioning the Communications FB
(Page 53)").
Note
Because the STATUS request is executed asynchronously to the rest of the requests
running on a link, an SFB with a specific R_ID cannot be assigned to the error messages.
This means that although SYSTAT can display which errors have occurred on the data link,
it cannot show which SFB call triggered the error.
Introduction
The error message area SYSTAT is a data area of CP 441-2 where all errors and events
recognized by the CP are entered in detail. The SYSTAT area comprises six events for each
interface, as well as information on the operating state of the CP and the state of the
SYSTAT area.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
108 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Driver
10.2 Diagnostic Facilities on the CP 441-2
Numbering Scheme
The numbering scheme for the events in the SYSTAT area is structured as follows:
%LWQR
An exact breakdown of event classes and event numbers can be found in the following
chapters and in the manual CP 441-2: Point-to-Point Communication.
Note
In contrast to standard drivers, the event classes/event numbers for the SYSTAT area are
partly modified for use with loadable drivers.
The following sections describe all the modified event classes/event numbers in their driver-
specific meaning.
Unless an event is mentioned in this manual, you can assume it corresponds to the standard
data links, and it will be described in the CP 441-2 manual.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 109
Diagnostics of the Driver
10.3 Table of Errors/Events
Event Classes
The following event classes are defined:
Description
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
110 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Driver
10.3 Table of Errors/Events
Description
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 111
Diagnostics of the Driver
10.3 Table of Errors/Events
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
112 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Driver
10.3 Table of Errors/Events
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 113
Diagnostics of the Driver
10.3 Table of Errors/Events
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
114 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Driver
10.3 Table of Errors/Events
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 115
Diagnostics of the Driver
10.3 Table of Errors/Events
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
116 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Communications FB 11
Diagnostic Functions
The MODBUS communications FB has the following two output parameters which indicate
occurred errors:
● Parameter "ERROR_NR"
● Parameter "ERROR_INFO"
ERROR_NR, ERROR_INFO
Occurred errors are indicated at the ERROR_NR output.
Further details on the error in ERROR_NR are displayed at the output ERROR_INFO.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 117
Diagnostics of the Communications FB
11.1 Diagnostics via Parameters ERROR_NR, ERROR_INFO
ERROR_No 1...9
Error during Initialization FB and CP
Error numbers 1...9 indicate initialization with error. Parameter CP_START_ERROR is 1.
MODBUS communication to the master system is not possible.
ERROR_No 10...19
Error during Processing of a Function Code
Error numbers 10...19 indicate an error during processing of a function code. The CP
transmitted an illegal processing job to the communications FB.
The error is also reported to the driver.
Subsequent processing jobs continue to be processed.
ERROR_No 90...99
Other Errors
A processing error has occurred.
The error is not reported to the driver.
Subsequent processing jobs continue to be processed.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
118 Operating Instructions, 09/2009, A5E00218418-06
Diagnostics of the Communications FB
11.1 Diagnostics via Parameters ERROR_NR, ERROR_INFO
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 119
Diagnostics of the Communications FB
11.1 Diagnostics via Parameters ERROR_NR, ERROR_INFO
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
120 Operating Instructions, 09/2009, A5E00218418-06
Technical Data A
A.1 Technical Data
Transmission Times
The following tables contain measured transmission times for the different function codes.
The times were measured using an S7-300 programmable controller with a CPU 315-2 DP
(6ES7315-2AF01-0AB0) and a CP 341, and an S7-400 programmable controller as the
partner device with a CPU 414 (6ES7414- 1XG01-0AB0) and a CP 441-2. The following
times were measured:
● the processing time from initiation of the job in the user program, including the processing
time on the master,
● the time taken for the job to be transmitted to the partner via the serial interface
● the time for processing on the slave,
● the time required for transmission of the acknowledgment on the serial interface.
The four times must be added to calculate the time for a complete transmission.
If you are using another master or slave as a partner, you must use the corresponding times
of the master or slave used, instead of the times in the table. The times for the job and
acknowledgment remain the same; they are only dependent on the transmission rate used.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 121
Technical Data
A.1 Technical Data
Slave is CP 341
Function Code 1 (Read) – Read Coil (Output) Status (Times in msec.)
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
122 Operating Instructions, 09/2009, A5E00218418-06
Technical Data
A.1 Technical Data
Slave is CP 341
Function Code 15 (Write) – Force Multiple Coils (Time in msec.)
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 123
Technical Data
A.1 Technical Data
Slave is CP 441-2
Function Code 1 (Read) – Read Coil (Output) Status (Times in msec.)
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
124 Operating Instructions, 09/2009, A5E00218418-06
Technical Data
A.1 Technical Data
Slave is CP 441
Function Code 15 (Write) – Force Multiple Coils (Time in msec.)
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 125
Technical Data
A.1 Technical Data
Memory Requirements
The following table displays the memory requirements of the function blocks of the CP 341
(FB 80) and CP 441 (FB 180) in bytes. The memory requirements of the FBs 7 and 8 can be
found in the manual for the CP 341.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
126 Operating Instructions, 09/2009, A5E00218418-06
Wiring Diagrams Multipoint B
Wiring diagram RS422 multipoint (MODBUS Multipoint)
6HQGHU 5HFHLYHU
02'%86PDVWHU
HJ&3RU&3
2 9 4 11
T(A)- T(B)+ R(A)- R(B)+
&RQQHFWRU
330 Ω
330 Ω
NOTICE
In the RS422 mode, CP 341 and CP 441-2 can only be used as "Master" because they
cannot switch their send lines to "Tri State".
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 127
Wiring Diagrams Multipoint
6HQGHU 5HFHLYHU
02'%86PDVWHU
HJ&3RU&3
4 11
&RQQHFWRU
R(A)- R(B)+
330 Ω
330 Ω
4 11
R(A)- R(B)+
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
128 Operating Instructions, 09/2009, A5E00218418-06
References C
C.1 References
MODBUS Protocol
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 129
References
C.1 References
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
130 Operating Instructions, 09/2009, A5E00218418-06
Glossary
Block
Blocks are elements of the user program which are defined by their function, structure, or
purpose. STEP 7 has the following:
● Code blocks (FB, FC, OB SFB, SFC)
● Data blocks (DB, SDB)
● User-defined data types (UDT).
Block call
A block call occurs when program processing branches to the called block.
Block parameters
Block parameters are placeholders within multiple-use blocks which are supplied with
updated values when the relevant block is called.
Communications processor
A communications processor is a programmable module for communications tasks, for
example, networking or point-to-point connection.
Configuration
Configuration is the combination of individual modules to form a PLC.
CPU
Central processing unit of the S7 programmable controller with control and arithmetic unit,
memory, system program, and interfaces to I/O modules.
CRC
Cyclic Redundancy Check = checksum with a guaranteed accuracy of error recognition.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 131
Glossary
Cycle time
The cycle time is the time that the CPU requires to process the user program once.
Data type
Data types allow the user to define how the value of a variable or constant in the user
program is to be used. SIMATIC S7 makes available two types of data types in accordance
with IEC 1131-3:
● elementary data types
● structured data types
Default setting
The default setting is a basic setting that is always used when no other value is specified.
Diagnostic buffer
The diagnostic buffer is a battery-backed up memory area in CPUs, for example, which is
organized as a ring buffer. Diagnostic events are stored in their order of occurrence.
Diagnostic events
A diagnostic event triggers an entry in the diagnostic buffer of the CPU. A distinction is made
between the diagnostic events as follows:
● errors on a module
● errors in the process wiring
● system errors in the CPU
● operating mode transitions of the CPU
● errors in the user program
● user-defined diagnostic events
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
132 Operating Instructions, 09/2009, A5E00218418-06
Glossary
Diagnostic functions
Diagnostic functions cover the entire system diagnostics and include the detection,
interpretation, and reporting of errors within the PLC.
Download
Downloading of load objects (e.g. code blocks) from the programming device into the load
memory of the central processing unit (CPU).
Hardware
Hardware is the term given to all the physical and technical equipment of a PLC.
Interface submodule
The CP 441-2 interface module physically converts the signals. By changing the plug-in
interface modules, you can make the communications processor compatible with the
communications partner.
Interrupt
Interrupt is a term that designates the interruption of the processing of a program in the
processor of a programmable controller by an external alarm
Main memory
The main memory is a RAM memory unit in the CPU that the processor accesses when
running the user program.
Module
Modules are pluggable PCBs for automation systems.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 133
Glossary
Module parameters
Module parameters are values that can be used to set the module reactions. A distinction is
made between static and dynamic module parameters.
Online help
STEP 7 allows you to display contextual help texts on the screen while working with the
programming software.
Online/Offline
When you are online there is a data connection between the PLC and the programming
device, when you are offline there is no data connection between them.
Operand
An operand is part of a STEP 7 instruction and indicates with what the processor is to
perform an action. An operand can be addressed both absolutely and symbolically.
Operating mode
The SIMATIC S7 programmable controllers have three different operating modes:
STOP, RESTART and RUN. The functionality of the CPU varies in the individual operating
modes.
Parameter
A parameter is
● a variable of a STEP 7 code block,
● a variable for specifying the behavior of a module,
As delivered, each module has an appropriate default setting that can be changed via
hardware configuration.
There are two types of parameters: static and dynamic parameters
Parameter assignment
Parameter assignment means setting the behavior of a module.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
134 Operating Instructions, 09/2009, A5E00218418-06
Glossary
Point-to-point connection
In a point-to-point connection, the communications processor forms the interface between a
programmable logic controller and a communication peer.
Procedure
A procedure is the execution of a data transmission according to a particular protocol.
Process image
The process image is a special memory area in the programmable controller. At the start of
the cyclic program the signal states of the input modules are transferred to the process
image input image. At the end of the cyclic program the process output image is transferred
as a signal state to the output modules.
Programmable controller
A programmable controller is an electronic control device consisting of at least one CPU,
various input and output modules, and operator control and monitoring devices.
Protocol
The communications partners involved in data transmission must abide by fixed rules for
handling and implementing the data traffic. These rules are called protocols.
Rack
The rack is the rail containing slots for the modules.
Software
Software refers to the entirety of all programs that are used on a computer system. These
include the operating system and the user programs.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 135
Glossary
STARTUP
RESTART mode is executed at the transition from STOP to RUN mode. This can be
triggered by the following events:
● By activating the operating mode switch
● After Power on
● By an operator input on the programming device
A distinction is made between a cold restart, restart, and warm restart.
STEP 7
STEP 7 is the programming software of SIMATIC S7.
System blocks
System blocks differ from other blocks in that they are already integrated into the S7-300/S7-
400 system and are available for already defined system functions. They are subdivided into
system data blocks, system functions, and system function blocks.
Tool
A tool is a software tool for configuring and programming.
Upload
Uploading of load objects (e.g. code blocks) from the load memory of the central processing
unit into the programming device.
User program
The user program contains all instructions and declarations for processing the signals used
for controlling a system or a process. In SIMATIC S7 the user program is structured and
divided into small units, the blocks.
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
136 Operating Instructions, 09/2009, A5E00218418-06
Glossary
Variable
A variable is a data element with variable content that can be used in the STEP 7 user
program. A variable consists of an operand (such as M 3.1) and a data type (such as BOOL)
and can be designated with a symbol (such as BELT_ON).
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 137
Glossary
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
138 Operating Instructions, 09/2009, A5E00218418-06
Index
FC-01, 14
FC-02, 14
A FC-03, 14
FC-04, 14
Address Representation, 15
FC-05, 14, 44
Assigning parameters to the CPU, 51
FC-06, 14, 44
FC-08, 95
B
Broadcast, 67 I
Inputs, 22
Instance data block, 19, 53, 58
C
Interface modules
Character delay time CDT, 38, 69 RS 232C, 11
Configuration of data link, 34 TTY, 11
Connection ID, 34, 65 X27, 11
Counters, 22
CRC, 68
L
Load memory, 13
D
Data blocks, 22
Data consistency, 64, 66 M
Diagnostics, 103, 117
Memory bit, 22
Display elements (LEDs), 103
Message frame structure, 67
Dongle, 13, 17
Multipoint connection, 11
E O
Exception code, 69
Operating mode, 37
Outputs, 22
F
Function block, 11, 19, 21, 54, 55, 108 P
Function code, 11, 22, 68
Parameter assignment, 31, 32
FC 01, 38
Parity, 36
FC 03, 42
FC 04, 43
FC 05, 38
R
FC 06, 42
FC 15, 38 Response time, 61
FC -15, 14
FC -15, 44
FC 16, 42 S
FC -16, 14
Slave Address, 37, 67
FC -16, 44
Startup characteristics, 50
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
Operating Instructions, 09/2009, A5E00218418-06 139
Index
Loadable Driver for Point-to-Point CPs: MODBUS Protocol, RTU format, S7 is Slave
140 Operating Instructions, 09/2009, A5E00218418-06