Professional Documents
Culture Documents
Product Description 1
SIMATIC 2
Installation
Function Codes 8
Diagnostics of the FB 10
Appendices
Technical Data A
Literature List C
Glossary, Index
Edition 05/2003
A5E00218418-04
Safety Guidelines
This manual contains notices intended to ensure personal safety, as well as to protect the products and
connected equipment against damage. These notices are highlighted by the symbols shown below and
graded according to severity by the following texts:
Danger
! indicates that death, severe personal injury or substantial property damage will result if proper
precautions are not taken.
Warning
! indicates that death, severe personal injury or substantial property damage can result if proper
precautions are not taken.
Caution
! indicates that minor personal injury can result if proper precautions are not taken.
Caution
indicates that property damage can result if proper precautions are not taken.
Notice
draws your attention to particularly important information on the product, handling the product, or to a
particular part of the documentation.
Qualified Personnel
Only qualified personnel should be allowed to install and work on this equipment. Qualified persons are
defined as persons who are authorized to commission, to ground and to tag circuits, equipment, and
systems in accordance with established safety practices and standards.
Correct Usage
Note the following:
Warning
! This device and its components may only be used for the applications described in the catalog or the
technical description, and only in connection with devices or components from other manufacturers
which have been approved or recommended by Siemens.
This product can only function correctly and safely if it is transported, stored, set up, and installed
correctly, and operated and maintained as recommended.
Trademarks
SIMATIC®, SIMATIC HMI® and SIMATIC NET® are registered trademarks of SIEMENS AG.
Third parties using for their own purposes any other names in this document which refer to trademarks might
infringe upon the rights of the trademark owners.
Siemens AG
Bereich Automation and Drives
Geschaeftsgebiet Industrial Automation Systems ©Siemens AG 2003
Postfach 4848, D- 90327 Nuernberg Technical data subject to change.
Siemens Aktiengesellschaft A5E00218418-04
Preface
Notice
This manual contains the description of the driver and the function block as is valid
at the time of publication.
Special Notes
The driver described in this manual serves as a loadable protocol for the CP. It
may be used instead of standard protocols 3964R, RK512, ASCII, and the printer
protocol.
Notice
With this driver, modifications or expansions to the sequences between CP and
CPU are possible.
Furthermore, you should note that this manual only describes the modifications
and expansions as against the standard functions. Basic information can be found
in the manual for the CP used.
In order to ensure safe use of this driver, you should have detailed knowledge of
the way in which the CP functions.
Further Support
If you have any technical questions, please get in touch with your Siemens
representative or agent responsible.
http://www.siemens.com/automation/partner
Training Centers
Siemens offers a number of training courses to familiarize you with the SIMATIC
S7 automation system. Please contact your regional training center or our central
training center in D 90327 Nuremberg, Germany for details:
Telephone: +49 (911) 895-3200.
Internet: http://www.sitrain.com
Nuernberg
Worldwide (Nuernberg)
Technical Support
Phone: +49 (0) 180 5050-222 Phone: +1 (0) 423 262 2522 Phone: +86 10 64 75 75 75
Fax: +49 (0) 180 5050-223 Fax: +1 (0) 423 262 2289 Fax: +86 10 64 74 74 74
Glossary
Index
1 Product Description
Position in the The driver described here is a software product for the communications
System processors CP 341 (S7-300) and CP 441-2 (S7-400).
Environment
CP 341 and CP 441-2 can be used in S7 automation systems and can
establish serial communication links to partner systems.
Function of the This driver, together with the appropriate function block, enables you to
Driver establish a communications link between a Modbus Master control system (for
example, Modicon controllers or Honeywell TDC 3000) and the CP 341 or
CP 441-2 communications module in the form of a “Modbus capable” slave
system.
Function codes 01, 02, 03, 04, 05, 06, 08, 15 and 16 can be used for
communication between the CP and the master system.
Interpretation of The MODBUS address in the request message from the master is interpreted
MODBUS by the driver “in an S7 way.”
Addresses This means that it is possible to:
• read and write to memory bits, outputs, data blocks,
• read memory bits, inputs, timers, counters
in the S7 CPU.
The interpretation of the MODBUS address is explained in the following
chapters.
Usable Interfaces The two serial interfaces of the CP 441-2 can be operated independently using
and Protocols different standard protocols or loadable driver protocols.
Possible System The following figure shows a schematic illustration of a possible system
Configuration configuration.
PSU CPU416 CP441-2
Interface Submodule
RS232C/TTY/X27
S7-400
Useable Module The driver runs on CP 341 and CP 441-2 with part number MLFB 6ES7 441-
2AA02-0AE0 or higher.
CP 441-1 with part number MLFB 6ES7 441-1AA0x-0AE0 and CP 441-2 with
part number MLFB 6ES7 441-2AA00-0AE0 or 6ES7 441-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.
Loading Memory If you are using the CP 441-2, the loadable drivers are downloaded into the
of the CPU loading memory of the CPU after parameter assignment and transferred to the
(Memory Card) CP memory on startup.
The CPU must have sufficient loading memory available for this purpose.
Therefore a RAM or FLASH Memory Card (part number MLFB 6ES7 952-…)
is required.
Every CP interface for which this loadable driver has been assigned
parameters, requires a CPU loading memory amount of about 25 Kbytes.
If you are using the CP 341, the loadable drivers are downloaded directly to
the CP 341. Therefore you do not require a loading memory on the S7-300
CPU. You should note, however, that this means that you cannot change a
module without a programming device.
Data Structures Prior to project configuration of your S7 data structures, you should ensure
that they are compatible with the user programs of the MODBUS Master
systems (clarify which function codes and which Modbus addresses will be
used).
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:
Address Analogous to the partitioning into read/write and read-only areas, data at user
Representation level can be represented as shown in the table below:
The 127th coil is represented as coil 00127 in the user system and
is assigned the coil address 007E Hex in the transmission
message.
1.4 Notes
Data Consistency The data exchange between the S7 CPU and the CP is carried out block-by-
block by integrated system functions.
You should also note the section “Data Consistency” in the chapter “CPU-CP
Interface” in this manual.
2 Installation
Introduction In order to run the CP with loadable drivers, you require a dongle. When the
dongle is plugged in, drivers can be loaded. Both interfaces of the CP 441-2
can operate with loadable drivers.
How to Plug In the Before you can plug in the dongle, you must take the CP out of the rack. At
Dongle the back of the CP, above the plugs for the backplane bus, there is a slot into
which the dongle can be inserted.
MODBUS - MODBUS-Slave
Master-System SIMATIC CP441
General The supplied data link converts data access of the MODBUS protocol to the
Information specific memory areas of the SIMATIC S7 CPU.
MODBUS Slave The Modbus slave data link for the CP consists of two parts:
Data Link
1) Loadable Driver for the CP
2) MODBUS Communications Function Block for the SIMATIC S7 CPU
MODBUS Slave In addition to the loadable MODBUS slave driver, the SIMATIC MODBUS
Communications slave data link requires a special Communications FB in the S7 CPU.
FB
This can be found on the supplied diskette for the Modbus in the STEP 7
library Modbus. It contains the MODBUS communications function block
FB180.
The MODBUS communication function block FB80 required for the CP 341
can also be found in the STEP 7 library Modbus.
The call of the FBs is shown in the example OBs in the STEP 7 project file
Examples\Modsl. The call for the CP 441-2 is stored in the Station Modbus
Slave 400 and the call for the CP 341 is stored in the Station Modbus Slave
300.
MODBUS Slave The loadable driver realizes the MODBUS protocol and converts the MODBUS
Driver addresses in the SIMATIC memory areas.
The loadable driver is loaded into SIMATIC using the parameter assignment
tool CP: Point-to-Point Communication, Parameter Assignment where it is
automatically transferred into the CP.
Parameters The parameters and operating modes listed below must be set for the
loadable driver using the parameter assignment tool.
Task Distribution Modbus function codes 01, 02, 03, 04, 06, and 16 are processed by the CP
directly.
For function codes 05 and 15 the communications FB carries out data input
into the SIMATIC memory area bit-by-bit.
Used Function The following MODBUS function codes are supported by the driver:
Codes
Function Function in accordance with General Description
Code MODBUS Specification
01 Read Coil Status Read bits
02 Read Input Status Read bits
03 Read Holding Registers Read registers (words)
04 Read Input Registers Read registers (words)
05 Force Single Coil Write 1 bit
06 Preset Single Register Write 1 register (word)
08 Loop Back Test Line check
15 Force Multiple Coils Write several bits
16 Preset Multiple Registers Write several registers
Data Areas The individual FCs access the following SIMATIC data areas in the PLC:
Address The MODBUS address in the messages is interpreted by the driver “in an S7
Transformation 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: Point-to-Point
Communication, Parameter Assignment.
Function Codes The bit-orientated function codes 01, 05, and 15 allow both read and write
01, 05, 15 access to the SIMATIC memory areas memory bits, outputs, timers,
counters;
Timers and counters are read-only with FC01.
You can use the parameter assignment tool to specify from/to which
MODBUS address access is made to memory bits, outputs, timers, and
counters.
Furthermore, it is possible to assign parameters to a certain data element at
which access in the SIMATIC memory area is to commence.
to bbbb
to dddd
to ffff
to hhhh
Function Code 02 The bit-orientated 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.
Furthermore, it is possible to assign parameters to a certain data element at
which access in the SIMATIC memory area is to commence.
to llll
to rrrr
Function Codes The register-orientated function codes 03, 06, and 16 permit read and write
03, 06, 16 access to the SIMATIC memory area data blocks.
Calculation of the required data block number is carried out in two steps.
1) You can use the parameter assignment tool to specify a base DB number.
This base DB is the first DB which can be accessed.
15 9 8 7 0 Bit
Resulting DB Number
This means that it is possible to access a data block area consisting of 128
consecutive data blocks within the entire addressable data block area (65535
DBs).
Word Number in DB
Via the word number it is possible to address the area from DBW 0 to
DBW 1022 within each data block.
The DBs which are normally organized in bytes are in this instance interpreted
by the driver word-by-word as follows.
Function Code 04 The register-orientated function code 04 permits read-only access to the
SIMATIC memory area data blocks.
The mode and operation of this access is as described in 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.
Function Codes For the write function codes 05, 06, 15, and 16 it is possible to disable or
05, 06, 15, 16 limit access to the relevant SIMATIC memory areas.
You can use the parameter assignment tool to specify an area which enables
write access from the MODBUS master system.
If the master tries to access any SIMATIC memory areas which are outside
the enabled area, access is denied by means of an error message
(exception).
Enable Write
SIMATIC Memory Area
Access
MAX - DB No.
MAX - M (Byte)
MAX -Q (Byte)
General All of the statements in the following sections referring to STEP 7 relate to
Information STEP 7 Version 4.02.
Operation flows, names and directory names may be modified in later
versions.
To install the driver, consisting of driver code and driver-specific mask files,
proceed as follows:
2. Using Windows 95, open the dialog box for software installation by double-
clicking the “Add / Remove Software” symbol in the “Control Panel.”
3. Select the CD-ROM drive and the Setup.EXE file in the dialog box and
start the installation procedure.
Result: The driver and the parameter assignment dialog boxes are installed in
the following directory: Step7\S7fptp\S7Driver.
The directory includes the following files:
• S7wfpb1a.dll
• S7wfpb1x.cod
• S7wfpb2x.cod
The driver can be de-installed from the STEP 7 package under Windows 95
by selecting “Control Panel,” “Add / Remove Software,” and “De-Installation.”
The user can check if all the files S7wfpb1?.*, S7wfpb2?.*, S7wfpb3?.* have
been deleted successfully in the Step7\S7fptp\S7Driver directory.
Note:
Prior to de-installation of the package “Parameter Assignment Tool CP:
Point-to-Point Communication, Parameter Assignment” it is essential to de-
install 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 Insert the required project components into the opened project with the
Components SIMATIC Manager:
SIMATIC 300 station.
Before each insertion, you must select the required project by clicking it.
Insert ½ Station ½ SIMATIC 300 Station
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 a RACK-
300, a PS-300, a CPU-300 from SIMATIC 300, and the CP PtP from CP-300
with the appropriate part number.
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 Insert the required project components into the opened project using the
Components SIMATIC Manager:
SIMATIC station, partner station, PtP network.
Before each insertion, you must select the required project by clicking it.
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 a RACK-
400, a PS-400, a CPU-400 from SIMATIC 400, and the CP PtP from CP-400
with the appropriate part number.
Assigning After you have arranged the modules in your rack using “Hardware
Parameters to the Configuration,” you must assign parameters to them.
CP To start the parameter assignment tool, double-click the CP in “Hardware
Configuration” or click the CP and select the menu command Edit ½ Object
Properties.
2) Properties - CP ½ Addresses
3) Properties - CP ½ General
Click “OK” to return to the “Properties - CP 441-2” dialog box. Here you
complete parameter assignment of the CP with “OK” and return to the
“Hardware Configuration” dialog box.
Save the parameter assignment data and close the “Hardware Configuration”
dialog box. You return to the basic menu of the STEP 7 project.
Assigning After you have inserted the link partner station into your STEP 7 project, as
Parameters to the described under “Project Components: Inserting ½ Other Station,” you have to
Link Partner specify the object properties of this partner station.
Starting from the opened STEP 7 project, you can select the link partner (other
station) by clicking it.
A partner station may also have several interfaces (=PtP nodes) and may be
connected to different point-to-point networks.
This section is only relevant for the CP 441-2. If you are using a CP 341, you
can skip this section.
Project Select the CPU in the STEP 7 project in its own opened S7-400 station and
Configuration of open the “Project configuration of data link” by double-clicking “Connection.”
the Data Link The dialog box “Carry Out Project Configuration of Connections” appears.
Select the menu command Insert ½ Connection to open the “New
Connection” dialog box. Here you can select the link partner (other station) for
the new data link and select “S7 Point-to-Point Connection” as the “connection
type.”
You should note that the Connection ID (Local ID) must be used again when
you call the Modbus communications FB in the user program.
Opening the Select the SIMATIC station and double-click “Hardware” (or select the menu
Parameter command Edit ½ Open Object) to start the “Hardware Configuration.”
Assignment Tool Click the CP and select the menu command Edit ½ Object Properties.
CP-PtP
After selecting the interface (CP 441-2 only) and the interface submodule
(CP 441-2 only), click the “Parameters” button to open the protocol selection
dialog box.
In addition to the standard protocols, the selection box also displays all
Protocol Selection
installed loadable drivers. Select “MODBUS Slave” for this driver. Double-
clicking the symbol for the transmission protocol (letter-box) opens the dialog
box where the protocol-specific parameters are set.
Driver-Specific The parameters described below can be set for this driver in the individual
Parameters dialog boxes.
Overview of
Speed, Character Frame
Transmission
Parameters Parameter Description Value Default
Range Value
Transmission Data transmission speed in bits / 300 9600
Rate second 600
1200
2400
4800
9600
19200
38400
76800
Additional transfer rates for the CP 341 with order 57600
number 6ES7 341-1xH01-0AE0
Additional transfer rates for the CP 441-2 with order 57600
number 6ES7 441-2AA03-0AE0 115200
Data Bits Bit per character 8 8
Stop Bits Amount of stop bits 1 1
2
Parity No parity bit transferred none even
Amount of data bits is completed to odd
an odd number
Amount of data bits is completed to even
an even number
Transmission Rate The transmission rate is the speed of data transmission in bits per second
(bps).
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 bps.
Data Bits The amount of data bits describes how many bits represent a character to be
transmitted.
Stop Bits The amount of stop bits defines the smallest possible time interval between
two characters to be transmitted.
Parity The parity bit is for data protection; depending on parameter assignment, it
completes the amount of transmitted data bits to either an even or an odd
number.
When “no” parity is selected, no parity bit is transmitted. This reduces the
safety of data transmission.
Overview of
Protocol Parameters
Protocol
Parameters Parameter Description Value Range Default
Value
Slave Address Own slave address of the CP 1 to 255 222
Operating “Normal” operation Normal Normal
Mode “Interference Suppression” Interference
Suppression
Multiplier Multiplication factor for 1 to 10 1
Character transmission rate-dependent
Delay Time character delay time
Slave Address Here you can specify the MODBUS Slave address, to which the CP should
reply. The CP only replies to messages where the received slave address is
identical to the parameterized slave address. Messages to other slaves are
not checked and not replied to.
Normal Operation In this operating mode, all recognized transmission errors and/or BREAK
before and after receive messages from the master result in an appropriate
error message.
Multiplier If a link partner cannot meet the time requirements of the MODBUS
Character Delay specification, it is possible to multiply the character delay time ZVZ by means
Time of multiplication factor fMUL. The character delay time should only be adjusted if
the link partner cannot meet the required times.
The resulting character delay time tZVZ is calculated as follows: -
tZVZ = tZVZ_TAB ✳ fMUL ;
Overview of FC 01,
Conversion of MODBUS Addressing for FC 01, 05, 15
05, 15
Parameter Input Meaning
SIMATIC Area Memory Bits
MODBUS Address in from 0 .. 65535 Starting with this
transmission message (decimal) Modbus address
(Bit number) to 0 .. 65535 Including this Modbus
(decimal) address
SIMATIC memory area commence 0 .. 65535 Commence at this
Memory bits at (decimal) memory byte
(Memory byte number)
SIMATIC Area Outputs
MODBUS Address in from 0 .. 65535 Starting with this
transmission message (decimal) Modbus address
(Bit number) to 0 .. 65535 Including this Modbus
(decimal) address
SIMATIC memory area commence 0 .. 65535 Commence at this
Outputs at (decimal) output byte
(Output byte number)
SIMATIC Area Timers
MODBUS Address in from 0 .. 65535 Starting with this
transmission message (decimal) Modbus address
(Bit number) to 0 .. 65535 Including this Modbus
(decimal) address
SIMATIC memory area commence 0 .. 65535 Commence at this
Timers at (decimal) timer (= 16 bit word)
(Timer number )
SIMATIC Area Counters
MODBUS Address in from 0 .. 65535 Starting with this
transmission message (decimal) Modbus address
(Bit number) to 0 .. 65535 Including this Modbus
(decimal) address
SIMATIC memory area commence 0 .. 65535 Commence at this
Counter at (decimal) counter (= 16 bit word)
(Counter number )
"from" / "to" - You can use the “from” address to set the Modbus address which is the start
Modbus Address of the appropriate area; for example, memory bits, outputs, etc.
(= first bit number of area).
You can use the “to” address to set the Modbus address which is the end of
the appropriate area; for example, memory bits, outputs, etc.
(= last bit number of area).
The “from” / “to” addresses refer to the Modbus address in the transmission
message (bit numbers commencing at 0) for function codes FC 01, 05, and
15.
The individual “from / to” areas must not overlap.
Gaps between the individual “from / to” areas are permitted.
"commence at" You can use the “commence at” input to specify the start of the SIMATIC area
SIMATIC Memory where the “from” / “to” Modbus area is displayed (= first memory byte-, output
Area byte-/ timer-/ counter number of SIMATIC area).
Example
MODBUS Address in SIMATIC Memory Area
Transmission Message
to 2047
to 2559
to 4255
to 4415
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, this 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, this means last counter = C 129.
Overview of FC02
Conversion of MODBUS Addressing for FC 02
"from" / "to" - You can use the “from” address to set the Modbus address which is the start
Modbus Address of the appropriate area; for example, memory bits, inputs
(= first bit number of area).
You can use the “to” address to set the Modbus address which is the end of
the appropriate area
(= last bit number of area).
The “from” / “to” addresses refer to the Modbus address in the transmission
message (bit numbers commencing at 0) for function code FC 02.
The individual “from / to” areas must not overlap.
Gaps between the individual “from / to” areas are permitted.
"commence at" - You can use the “commence at” input to specify the start of the SIMATIC area
SIMATIC Memory where the “from” / “to” Modbus area is displayed (= first memory byte-, input
Area byte number of SIMATIC area).
Example
MODBUS Address in SIMATIC Memory Area
Transmission Message
to 4095
to 5119
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.
Overview of FC 03,
Conversion of MODBUS Addressing for FC 03, 06, 16
06,16
Parameter Input Meaning
SIMATIC Area Data Blocks
MODBUS Address = 0 in transmission
message
(register number) means access to:
SIMATIC memory area commence 1 .. 65535 Commence at this
Data Blocks at DB (decimal) data block
Commence at DBW 0
(= base DB number)
"commence at DB" You can use the “commence at DB” input to specify the first data block of the
SIMATIC area which is to be accessed (= base DB Number).
This DB is accessed when the register number of the Modbus message has
value 0, starting at data word DBW 0.
Higher Modbus register numbers access the following data words / data
blocks.
Up to 127 successive DBs can be addressed.
The driver interprets bits 9 - 15 of the Modbus register number for the access of
the individual successive DBs (please follow the note on page 8-2).
Example
MODBUS Address in SIMATIC Memory Area
Transmission Message
Register Number = 0
means: access to ---> Data Blocks commence
at DB 800
You can use Modbus register address 0 to access data block 800
commencing at DBW 0 in the SIMATIC system.
Higher Modbus register addresses (≥ 512, etc.) access the following DBs
DB 801, etc.
Overview of FC 04
Conversion of MODBUS Addressing for FC 04
"commence at DB" You can use the “commence at DB” input to specify the first data block of the
SIMATIC area which is to be accessed (= base DB Number).
This DB is accessed when the register number of the Modbus message has
value 0, starting at data word DBW 0.
Higher Modbus register numbers access the following data words / data
blocks.
Up to 127 successive DBs can be addressed.
The driver interprets bits 9 - 15 of the Modbus register number for the access
of the individual successive DBs (please follow the note on page 8-2).
Example
MODBUS Address in SIMATIC Memory Area
Transmission Message
Register Number = 0
means: access to ---> Data Blocks commence
at DB 1200
You can use Modbus register address 0 to access data block 1200
commencing at DBW 0 in the SIMATIC system.
Higher Modbus register addresses (≥ 512, 1024, etc.) access the following
DBs DB 1201, 1202, etc.
Overview of FC 05,
SIMATIC Limits for Write Access (FC 05, 06, 15, 16)
06, 15, 16
Parameter Input Meaning
Data blocks DB: MIN 1 to 65535 First enabled DB
Resulting DB number
MAX 1 to 65535 Last enabled DB
MAX = 0 all DBs disabled.
Memory bits M MIN 0 to 65535 First enabled memory byte
(Memory byte
number)
MAX 1 to 65535 Last enabled memory byte
MAX = 0 all memory bits
disabled
Outputs Q MIN 0 to 65535 First enabled output byte
(Output byte number)
MAX 1 to 65535 Last enabled output byte
MAX = 0 all outputs
disabled.
"MIN" / "MAX" For the write function codes, it is possible to specify lower and upper access
SIMATIC Memory limits (MIN / MAX). Write access is permitted within this enabled area only.
Area
If the value for the upper limit is 0, it means that the entire area is disabled.
When selecting the size of the enabled area, remember which CPU it refers
to.
If the master attempts a write access to an area which is outside the upper /
lower limit, this is rejected by the CP with an error message.
The MIN / MAX values for the data block area must be specified as resulting
DB numbers.
Example
SIMATIC Memory Area
MAX - DB 699
MAX 1127
MAX 319
SIMATIC data blocks DB 600 to DB 699 can be accessed with write function
codes (FC 06, 16).
SIMATIC memory bytes MB 1000 to MB 1127 (FC 05, 15) can be accessed
with write function codes.
SIMATIC outputs output bytes QB 256 to QB 319 (FC 05, 15) can be
accessed with write function codes.
Overview
X27 (RS422/485) Interface
“Full-Duplex In this operating mode, data are sent via the transmission line T(A),T(B) and
(RS422) Four-Wire received via the receive line R(A),R(B).
Operation”
Error handling is carried out in accordance with the function set at the “driver
operating mode” parameter (Normal or Interference Suppression).
“Half-Duplex In this operating mode, the driver switches the 2-wire receiving line R(A),R(B)
(RS485) Two-Wire of the RS422/485 (X27) interface from send to receive operation.
Operation”
In this operating mode, all recognized transmission errors and/or BREAK
before and after receive messages are ignored.
BREAK level during messages pauses is also ignored.
The start of the receive message from the master is recognized by means of
the correctly-received slave address.
The setting R(A) 0V, R(B) 5V (High) is recommended as the preset for the
receiving line.
Selecting Select the settings required for your data link and exit the individual dialog
Parameters boxes by clicking “OK.”
4.7 Loading the Configuration and Parameter Assignment Data for the CP 341
Data Management When you close the “Hardware Configuration,” the data are automatically
saved into your STEP 7 project.
Loading the The configuration and parameter assignment data can now be loaded online
Configuration and from the programming device to the CPU. Use the menu command PLC ½
Parameters Download to transfer the data to the CPU.
During CPU startup and each time you switch between STOP mode and
RUN mode, the module parameters of the CP are automatically transferred
to the CP as soon as it can be reached via the S7-300 backplane bus.
The driver code is not saved in the CPU, but directly with the parameter
assignment tool in the retentive memory of the CP 341. You should note,
however, that for this reason you cannot change a module without a
programming device.
Further Please refer to the User Manual for STEP 7 for a detailed description of:
Information
• How to save the configuration and the parameters.
• How to load the configuration and the parameters into the CPU.
• How to read, change, copy, and print the configuration and the
parameters.
4.8 Loading the Configuration and Parameter Assignment Data for the
CP 441-2
Data Management When you close the “Hardware Configuration” and/or “Project Configuration of
Connection,” the data (including module parameters and driver codes) is
automatically saved into your STEP 7 project.
Loading the The configuration and parameter assignment data can now be loaded online
Configuration and from the programming device to the CPU. Use the menu command PLC ½
Parameters Download to transfer the data to the CPU.
Further Please refer to the User Manual for STEP 7 for a detailed description of:
Information
• How to save the configuration and the parameters.
• How to load the configuration and the parameters into the CPU.
• How to read, change, copy, and print the configuration and the
parameters.
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.
This section is only relevant for the CP 441-2. If you are using a CP 341, you
can skip this section.
Hardware To avoid problems during startup of the CPU-CP, the following setting should
Configuration be made when carrying out Parameter Assignment of the CPU in
“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: When a CP 441-2 interface is assigned parameters with a loadable
driver, the driver code is transferred to the CP as well as the parameter
assignment values. The entire loading procedure is monitored for the time
mentioned above which must be long enough.
Supplied Diskette 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. It is also stored 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.
3. If required, transfer the startup OBs OB100 and OB101, the cyclic OB1,
and DB180 or DB80 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:
OB1 and OB100/OB101 can also be generated themselves.
If the instance DB is not included in the transfer, it must be generated when
calling FB180 or FB80 in OB1/OB100/OB101.
STEP 7 Project The STEP 7 project file Modsl contains a complete project in the form of a
loadable example consisting of:
• Hardware project 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.
The SFBs and SFCs are integrated in the CPU, the variable tables have been
added for diagnostic purposes only.
TRUE:
TRUE:
General The Modbus communications FB for the loadable Modbus slave driver must
Information be called in SIMATIC S7 CPU in the cyclic part.
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, After each complete restart or restart of the CPU, you must carry out an
Initialization initialization of the Modbus communications FB.
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 / 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.
Timeout After mains-on, the CP needs several seconds for hardware and memory
Initialization checks until it is ready for run. Initialization attempts of the Modbus FB during
(START_TIME) this time are completed with error. Because of this, the Modbus FB repeats its
initialization job several times during this timeout.
Time Value for A cyclic read of the SYSTAT area (only relevant for CP 441-2 (FB180)) on
Read SYSTAT every PLC cycle or every other PLC cycle would cause an overload for the CP
(CP 441-2 only) and the K-Bus and would reduce data throughput. Therefore a time interval
can be set for reading the SYSTAT area.
After the time interval STATUS_TIME in STATUS_TIMER has elapsed, the
Modbus FB activates the SFB STATUS for reading the SYSTAT area.
I/O Access Errors, Input parameter OB_MASK can be used to instruct the Modbus FB to mask
Delay Alarms I/O access errors. In the event of a write access to non-existent I/Os, the CPU
does not go to STOP and neither does it call the error OB.
The access error is, however, recognized by the FB and the function is ended
with an error message to the CP. I/O access errors in the event of a write
command are masked only if parameter OB_MASK is = TRUE.
Prior to masking the access errors, all higher priority alarms are delayed
(SFC14), and they are re-enabled after write access of the FBs and after
unmasking the access errors (SFC42).
This ensures that access errors are recognized by higher priority programs
(time or process alarms) in case the FB is interrupted between masking and
unmasking.
Example
OB100/101 Segment 1
Communications The MODBUS communications FB carries out all necessary SFB calls and
FB processes those function codes which the CP cannot run itself (write bit-by-
bit with FC05 or FC15 to the SIMATIC areas memory bits and outputs).
SYSTAT Area The Modbus FB180 for the CP 441-2 reads from the SYSTAT area of the CP
(CP 441-2 only) cyclically and stores the data in the instance DB commencing at DBW 40.
Furthermore, you must program the user-specific error handling in the user
program.
Bytes 4 to 15 (events 1 to 6) of SYSTAT are always stored in the instance
DB commencing at DBW 44, providing the error bit (Bit 2.0) has been set in
SYSTAT.
Please refer to chapter “Diagnostics” of this manual and the CP 441-2
manual for a detailed description of the structure of SYSTAT.
Reaction Times One FB sequence (one PLC cycle) plus data transfer times CP--->CPU and
CPU--->CP are required to process the write function codes FC05, FC15.
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 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.
Processed by
Modbus FB
Request CP sends
message reply
received from message
Master
t
----------------------->
The reaction times depend on the cycle time of the CPU program (Modbus
FB) and the CPU type (data transfer CPU<-->CP).
6 CPU - CP Interface
Modbus Data transfer between CP and CPU is carried out by the function blocks
Communications P_SND_RK and P_RCV_RK.
FB The supplied Modbus communications FB calls the FBs.
Module Address The only remaining task is to specify the module address (LADDR) at the
Modbus communications FB.
Data Transfer Transfer of data CP <-> CPU is carried out by the function blocks P_SND_RK
Length and P_RCV_RK.
This means that the Modbus slave driver replies with an error message with
Exception_Code, in the event that a read or write access is carried out which
exceeds the data lengths specified above.
Block Size Data transfer between CPU and CP is carried out by function blocks
P_SND_RK and P_RCV_RK.
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 amounts of data, the data is transferred in the listed block size with
a time delay between each block.
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:
Modbus Data transfer between CP and CPU is carried out by the integrated system
Communications functions PUT and GET and the SFBs BSEND and STATUS. The supplied
FB 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 The only remaining task is to specify the Connection ID from the project
Link configuration at the Modbus communications FB.
Data Transfer Transfer of data CP <-> CPU is carried out by the system functions PUT and
Length GET.
This means that the Modbus slave driver replies with an error message with
Exception_Code, in the event that a read or write access is carried out which
exceeds the data lengths specified above.
S7-400
Modbus Maximum Maximum
Function Code Amount of Amount of
Registers Bits
01, 02 2040
03, 04, 16 127
15 2040
Block Size Data transfer between CP and CPU is carried out by the integrated system
functions PUT and GET.
The block size for the access to the SIMATIC memory areas (data blocks,
memory bits,…) is 32 bytes.
Data Consistency The access to the CPU memory areas by the utilities PUT and GET is carried
out asynchronous to the STEP 7 application program. Therefore data
consistency during data transmission is given only for the above-listed block
sizes.
For larger amounts of data, the data is transferred in the listed block sizes with
a time delay between each block.
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.
Modbus Slave This means the following for the driver Modbus slave:
You should also note that the read and write access of the Modbus function
codes may be carried out at any time within the S7 application program.
7 Transmission Protocol
Master-Slave The Modbus master system initiates transmission, and after outputting a
Relationship request message it waits for a reply message from the slave. Message
exchange from slave to slave is not possible.
Message Structure The data exchange “Master-Slave” and/or “Slave-Master” begins with the
Slave Address, followed by the Function Code. Then the data are
transferred. The structure of the data field depends on the function code used.
The CRC check is transmitted at the end of the message.
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 The master uses slave address zero to address all slaves on the bus.
Message Message
Broadcast Messages are only permitted in conjunction with writing Function
Codes 05, 06, 15, and 16.
Function Code The function code defines the meaning as well as the structure of a message.
The following function codes are supported by the CP:
Data Field DATA The data field DATA is used to transfer the function code-specific data such
as:
Bytecount, Coil_Start Address, Register_Start Address; Number_of_Coils,
Number_of_Registers, ... . See also Chapter “Function Codes.”
CRC Check Message end is identified by means of the CRC 16 checksum consisting of 2
16 15 2
bytes. It is calculated by the following polynominal: x + x + x + 1.
The first byte to be transferred is the Low Byte, then the High Byte.
Message End The driver recognizes message end, when no transmission takes place
during the time period required for the transmission of three and a half
characters (3.5 times character delay time) (see MODBUS Protocol
Reference Guide).
Transmission TIME_OUT
Rate
76800 bps 0.5 ms
38400 bps 1 ms
19200 bps 2 ms
9600 bps 4 ms
4800 bps 8 ms
2400 bps 16 ms
1200 bps 32 ms
600 bps 64 ms
300 bps 128 ms
After completion of the message end TIME_OUT, the reply message received
by the slave is evaluated and its format is checked.
Exception On recognition of an error in the request message from the master (for
Responses example, register address illegal), the slave sets the highest value bit in the
function code of the reply message.
This is followed by transmission of one byte of error code (Exception Code),
which describes the reason for the error.
Exception Code The error code reply message from the slave has the following structure:
Message for example, slave address 5, function code 5, exception code 02
Reply Message from Slave EXCEPTION_CODE_xx:
RS 232C The following RS 232C secondary signals exist on the CP when the RS 232C
Secondary Signals interface submodule is used
Using the RS 232C The RS 232C secondary signals can be used as follows:
Secondary Signals
• When the automatic use of all RS 232C secondary signals is
parameterized
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 V24_STAT FB.
The sections that follow describe how the control and evaluation of the RS
232C secondary signals is handled.
Automatic Use of The automatic use of the RS 232C secondary signals on the CP is
the Secondary implemented as follows:
Signals • As soon as the CP is switched by means of parameterization to an
operating mode with automatic use of the RS 232C secondary signals, it
switches the RTS line to OFF and the DTR line to ON (CP ready for use).
Message frames cannot be sent and received until the DTR line is set to
ON. As long as DTR remains set to OFF, no data is received via the
RS 232C interface. If a send request is made, it is aborted with an error
message.
• When a send request is made, RTS is set to ON and the parameterized
data output waiting time starts. When the data output time elapses and
CTS = ON, the data is sent via the RS 232C interface.
• If the CTS line is not set to ON within the data output time so that data
can be sent, or if CTS changes to OFF during transmission, the send
request is aborted and an error message generated.
• After the data is sent, the RTS line is set to OFF after the parameterized
time to RTS OFF has elapsed. The CP340 does not wait for CTS to
change to OFF.
• Data can be received via the RS 232C interface as soon as the DSR line
is set to ON. If the receive buffer of the CP threatens to overflow, the CP
does not respond.
• A send request or data receipt is aborted with an error message if DSR
changes from ON to OFF. The message "DSR = OFF (automatic use of
V24 signals)" is entered in the diagnostics buffer of the CP.
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 is parameterized,
neither RTS/CTS data flow control nor RTS and DTR control by means of the
V24_SET FB are not possible.
Note
The "time to RTS OFF" must be set in the parameterization interface so that the
communication partner can receive the last characters of the message frame in
their entirety before RTS, and thus the send request, is taken away. The "data
out put waiting time" must be set so that the communication partner can be
ready to receive before the time elapses.
Time Diagram
The following figure illustrates the chronological sequence of a send request.
ON
RTS
OFF
ON
CTS
OFF
1
TXD
0
t
Send request: Transmission
RTS = ON terminated
Figure 4-1 Time Diagram for Automatic Use of the RS 232C Secondary Signals
8 Function Codes
Used Function The following MODBUS function codes are supported by the driver:
Codes
Function Function in Function in SIMATIC S7
Code accordance with
MODBUS
Specification
01 Read coil status Read bit-by-bit Memory bits M
Read bit-by-bit Outputs Q
Read bit-by-bit Timers T
(16 bit interval)
Read bit-by-bit Counters C
(16 bit interval)
02 Read input status Read bit-by-bit Memory bits M
Read bit-by-bit Inputs I
03 Read holding Read word-by-word Data block DB
registers
04 Read input Read word-by-word Data block DB
registers
05 Force single coil Write bit-by-bit Memory bits M
Write bit-by-bit Outputs Q
06 Preset single Write word-by-word Data block DB
register
08 Loop back test - -
15 Force multiple coils Write bit-by-bit Memory bits M
(1...2040 bits)
Write bit-by-bit Outputs Q
(1...2040 bits)
16 Preset multiple Write word-by-word Data block DB
(holding) registers (1...127 registers)
Note
All Modbus addresses listed below refer to the transmission message level
and not to the user level in the Modbus master system.
This means that the Modbus addresses in the transmission messages begin
with 0000 Hex.
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,16).
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.
Function This function enables the MODBUS master system to read individual bits from
the SIMATIC memory areas listed below.
Note
Please note the CPU-specific limitations as described in the chapter “CPU-CP
Interface.”
Address Calculation:
The Modbus address “start_address” 0040 Hex (64 decimal) is located in the
“memory bit” area:
Amount of Bits:
The amount of Modbus bits “bit_number” 0020 Hex (32 decimal) means that
32 Bits = 4 Bytes should be read.
Further Examples
Some other access examples are listed in the table below.
Function This function enables the MODBUS master system to read individual bits from
the SIMATIC memory areas listed below.
bit_number Any value from 1 to 2040 is allowed as the bit_number (number of coils). This
amount of bits is read.
Note:
Please note the CPU-specific limitations as described in the chapter “CPU-CP
Interface.”
Address Calculation:
The Modbus address “start_address” 1030 Hex (4144 decimal) is located in
the area “Inputs”:
Amount of Bits:
The amount of Modbus bits “bit_number” 0018 Hex (24 decimal) means that
24 bits = 3 bytes should be read.
Further Examples Some other access examples are listed in the table below.
Function This function enables the MODBUS master system to read data words from a
data block.
Reply Message ADDR FUNC Byte_count n n/2-Register DATA (High, Low) CRC
15 9 8 7 0 Bit
For further address generation, the driver uses the “base DB number” (from
DB xxxxx) entered in the dialog box “Conversion of MODBUS Addressing
for FC 03, 06, 16.”
The address calculation for access (address conversion) is carried out in two
steps as follows:
Note:
Please note the CPU-specific limitations as described in the chapter “CPU-CP
Interface.”
Address Calculation:
The Modbus address “start_register” 0050 Hex (80 decimal) is interpreted as
follows:
15 9 8 7 0 Bit
Amount of Registers:
The amount of Modbus registers “register_number” 0002 Hex (2 decimal)
means 2 registers = 2 data words are read.
Further Examples Some other access examples are listed in the table below.
start_register
start_register Base Offset Word Number resulting DB DBW
DB No. DB_No.
Hex decimal decimal decimal Hex decimal decimal decimal
Function This function enables the MODBUS master system to read data words from a
data block.
Reply Message ADDR FUNC Byte_count n n/2-Register DATA (High, Low) CRC
15 9 8 7 0 Bit
start_register-Offset_DB_No. start_register-word-No.
For further address generation, the driver uses the “base DB number” (from
DB xxxxx) entered in the dialog box “Conversion of MODBUS Addressing
for FC 04.”
The address calculation for access (address conversion) is carried out in two
steps as follows:
Note:
Please note the CPU-specific limitations as described in the chapter “CPU-CP
Interface.”
Address Calculation:
The Modbus address “start_register” 02C0 Hex (704 decimal) is interpreted as
follows:
15 9 8 7 0 Bit
Amount of Registers:
The amount of Modbus registers “register_number” 0003 Hex (3 decimal)
means 3 registers = 3 data words are read.
Further Examples Some other access example are listed in the table below.
start_register
start_register Base Offset Word Number resulting DB DBW
DB No. DB_No.
Hex decimal decimal decimal Hex decimal decimal decimal
Function This function enables the MODBUS master system to write a bit into the
SIMATIC memory areas 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 these areas,
which was entered during parameter assignment in the dialog box
“Conversion of MODBUS Addressing for FC 01, 05, 15” (from / to : memory
bits, outputs, timers, counters).
Access to SIMATIC areas timers and counters is not permitted with function
code FC 05 and is rejected by the driver with an error message.
DATA on/off The following two values are permitted as DATA on/off:
FF00H ➭ set bit.
0000H ➭ delete bit.
Address Calculation:
The Modbus address “coil_address” 0809 Hex (2057 decimal) is located in the
area “outputs”:
Further Examples For further access examples to memory bits and outputs, please refer to
FC 01.
Function This function enables the MODBUS master system to write a data word in a
data block of the CPU.
Request Message ADDR FUNC start_register DATA value (High, Low) CRC
Reply Message ADDR FUNC start_register DATA value (High, Low) CRC
15 9 8 7 0 Bit
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:
DATA Value Any value can be used as the DATA value (register value).
Address Calculation:
The Modbus address “start_register” 0180 Hex (384 decimal) is interpreted:
15 9 8 7 0 Bit
0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0
It does not effect the S7 CPU, nor the user programs, nor user data. The
received message is independently returned to the master system by the
driver.
Request Message ADDR FUNC Diagnostic Code (High, Low) Test Data CRC
Reply Message ADDR FUNC Diagnostic Code (High, Low) Test Data CRC
Function This function enables the MODBUS master system to write several bits in the
SIMATIC memory areas listed below.
Request Message
ADDR FUNC start_address quantity byte_count n n-DATA CRC
Access to SIMATIC areas timers and counters is not permitted with function
code FC 15 and is rejected by the driver with an error message.
Quantity Any value between 1 and 2040 is permitted as the quantity (amount of bits).
Note:
Please note the CPU-specific limitations as described in the chapter “CPU-CP
Interface.”
DATA Bit status (any values) are contained in the DATA field.
Action:
The MODBUS master system wants to write the following bit status on to
memory bits M 1144.0 ... M 1144.7 and M 1145.0 ... M 1145.3:
Address Calculation:
The Modbus address “coil_address” 0480 Hex (1152 decimal) is located in the
“memory bit” area:
Further Examples For further access examples to memory bits and outputs, please refer to
FC 01.
Function This function code enables the MODBUS master system to write several data
words in a data block of the SIMATIC CPU.
Request Message ADDR FUNC start_register quantity byte_count n n-DATA (High, Low) CRC
15 9 8 7 0 Bit
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:
Quantity Any value between 1 and 127 is permitted as the quantity (amount of
registers). Please follow the following rule:
Note:
Please note the CPU-specific limitations as described in the chapter “CPU-CP
Interface.”
DATA (High, Low) Any value can be used as DATA (High, Low) (register value).
Action:
The MODBUS master system wants to write values CD09 Hex, DE1A Hex,
EF2B Hex to data words DBW 100, DBW 102, DBW 104 of DB 800.
Address Calculation:
15 9 8 7 0 Bit
0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0
Diagnostic The diagnostic functions of the CP enable you to locate occurred errors
Functions quickly. The following diagnostics facilities are available:
Display Elements The display elements provide information on the operating status and/or a
(LED) possible error status of the CP. The display elements give a first overview of
internal or external errors, as well as interface-specific errors.
STATUS Output of Each function block / system function block has a STATUS output for error
FBs / SFBs diagnostics purposes. Reading this STATUS output enables the user to obtain
information on errors which occurred during communication. The STATUS
parameter can be evaluated in the user program.
Error Message The error message area SYSTAT is a storage area on the CP where all errors
Area SYSTAT / events recognized by the CP are entered in detail. You can read the SYSTAT
(CP 441-2 only) area by programming the system function block STATUS in the user program.
Diagnostic Buffer All errors / events described in Section 9.3 are also entered in the diagnostic
of the CP buffer of the CP. The manual for the CP describes how you can read the
diagnostic buffer.
Introduction The display elements of the CP 341 provide information on the CP 341. The
following different display functions are available:
• Special Displays
- TXD (green) Send active; lights up when the CP 341 sends user
data via the interface
- RXD (green) Receive active; lights up when the CP 341 receives
user data via the interface
Group Error The group error display SF always lights up after mains-on and goes out after
Display SF initialization is complete. If parameter assignment data were created for the
CP 341, the SF LED lights up again briefly when new parameters are
assigned.
The group error display SF lights up, when the following errors have occurred:
• Hardware error
• Firmware error
Introduction Each function block has a STATUS parameter for error diagnostics purposes.
Each STATUS message number has the same meaning, independent of the
system function block used.
Event Class / The following figure shows the structure of the STATUS parameter.
Event Number
Numbering
Scheme
Bit No. 15 13 12 8 7 0
STATUS
(Error Number)
Display Functions The display elements of the CP 441-2 provide information on the CP 441-2.
The following different display functions are available:
• Special Displays
- TXD BSEND job for this interface is being processed on the CP
- RXD Received data of this interface are being transferred by the CP to
the CPU
Error Messages of The following table describes the error messages of the display elements.
Display Elements
Error Display Error Description Remedy
INTF lit CP reports an internal error; Program the SFB STATUS
for example, hardware or for detailed information.
software error.
EXTF lit CP 441-2 reports an Program the SFB STATUS
external error; for example, for detailed information.
BREAK on receiving line
FAULT off Interface ready, or interface -
submodule not plugged in
FAULT blinking Interface is initialized and Check general configuration
slowly ready, but no and data link project
communication possible via configuration
S7-400 backplane bus.
FAULT blinking Parameter incorrect or Check parameter setting in
fast wrong and/or faulty parameter assignment
interface submodule interface and/or interface
plugged in (submodule and submodule.
interface parameters do not
match).
FAULT lit No interface parameters Carry out parameter
available or substantial assignment with parameter
error in submodule assignment tool and/or
(hardware). check interface submodule.
Introduction Each system function block has a STATUS parameter for error diagnostics
purposes. Each STATUS message number has the same meaning,
independent 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.”
Messages at
STATUS Output of STATUS Error Description
SFB
0 no error
1 Communications problems between CP and CPU.
2 Negative acknowledgment, function cannot be executed
(for example, link partner does not respond or sends negative
acknowledgment).
3 R-ID not known in this communications link, device not available.
4 Number of data areas or individual data types do not match.
5 Reset request received.
6 Remote block is in disabled state.
7 Remote partner in incorrect state.
8 Access to remote object denied, access error occurred in server
(GET/PUT).
9 Overrun warning (ERROR=0): receive data were overwritten with
newer data.
10 Access to local user memory not possible (for example, DB
deleted).
11 Warning (ERROR=0): new job ineffective, because previous job
not yet completed.
12 Instance is incompatible with system call; no instance, but normal
DB was called.
13 Error in format description.
14 The referenced data link (application-related) does not exist, ID
not known (you must specify the local ID from the data link project
configuration).
15 Data link referenced via ID is generated.
16 Data link cannot be generated due to lack of resources.
Displaying and The STATUS output of the system function blocks can be displayed and
Evaluating evaluated by means of the STEP 7 variable table.
STATUS Output
Note:
Reading the SYSTAT area with the STATUS job will provide you with detailed
information on errors / events which have occurred during communication
between the CP, the associated CPU, and the connected link partner.
Reading by The error message area SYSTAT is already read by the MODBUS
Communications Communications FB.
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.”
Note:
Due to the fact that the STATUS job runs asynchronously to the other jobs on
a link, it is not possible to allocate an SFB with a specific R_ID. This means
that even though it is possible to display which errors occurred on the data
link, it is impossible to ascertain which SFB call caused them.
Introduction The error message area SYSTAT is a data area of CP 441 where all errors /
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.
Structure of The first six errors / events recognized by the CP are entered into the SYSTAT
SYSTAT Area area. Further errors / events can only be entered once the SYSTAT area has
been deleted.
Deleting the After the SYSTAT area has been read with SFB STATUS, all SYSTAT
SYSTAT Area messages are automatically deleted.
Numbering The numbering scheme for the events in the SYSTAT area is structured as
Scheme follows:
Bit No. 15 13 12 8 7 0
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 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.
08 30H 48 Broadcast not allowed with this function code. The Modbus master system is
allowed to use Broadcast only
for the function codes enabled
for this purpose.
08 31H 49 Received function code not allowed. This function code cannot be
used for this driver.
08 32H 50 Maximum amount of bits or registers Limit maximum amount of bits
exceeded, to 2040, maximum amount of
or amount of bits cannot be divided by 16 registers to 127. Access to
when accessing SIMATIC memory areas SIMATIC timers / counters only
timers or counters. in 16 bit intervals.
08 33H 51 Amount of bits or registers for function codes Correct amount of bits /
FC 15/16 and message element byte_count registers or byte_count.
do not match.
08 34H 52 Illegal bit coding recognized for “set bit / reset Only use codings 0000Hex or
bit.” FF00Hex for FC05.
08 35H 53 Illegal diagnostic subcode (≠ 0000Hex) Only use subcode 0000Hex for
recognized for function code FC 08 “Loop FC08.
Back Test.”
08 36H 54 The internally-generated value of the CRC 16 Check CRC checksum
checksum does not match the received CRC generation by Modbus master
checksum. system.
08 37H 55 Message sequence error: Increase the timeout to the
The Modbus master system sent a new slave reply message for the
request message before the last reply Modbus master system.
message was transferred by the driver.
0E 30H 48 Internal error during data transfer to CPU: Can be ignored if it happens
Unexpected acknowledgment Passive. intermittently.
0E 31H 49 Timeout during data transfer to CPU. Check CP-CPU interface.
0E 32H 50 Error occurred during data transfer to CPU Check CP-CPU interface.
with RCV:
Exact failure reason (detailed error) is in
SYSTAT before this entry.
0E 33H 51 Internal error during data transfer to CPU: Check CP-CPU interface.
Illegal status of automatic device.
: :
0E 38H 56 Error occurred when accessing one of the Check if the addressed
SIMATIC areas “memory bits, outputs, SIMATIC area exists and
timers, counters, inputs” with function codes whether an attempt was made
FC 01 or FC 02: to access in excess of range
for example, input does not exist, or read end.
attempt in excess of range end.
0E 39H 57 Error occurred when accessing SIMATIC Check if the addressed data
area “data block” with function codes FC 03, block exists and that it is
04, 06, 16: sufficiently long.
Data block does not exist or is too short.
0E 3AH 58 Error occurred when executing a write job Check if instance DB
with function codes FC 05, 15: parameterized on the Modbus
Instance data block of Modbus FB does not communications FB exists and
exist or is too short. that it is sufficiently long.
0E 3BH 59 Timeout during execution of a write job by Check project configuration of
Modbus communications FB. data link and CP-CPU interface
(SFB SEND): possibly reload
Modbus communications FB.
0E 3CH 60 Illegal job with this driver. Only SFB BSEND, BRCV,
STATUS (CP 441-2 only) are
permitted.
0E 50H 80 The rest bit number resulting from the Only use Modbus addresses
Modbus address is ≠ 0 for the word- which result in valid bit
orientated SIMATIC areas timers / counters. numbers.
0E 51H 81 The received Modbus address is outside the Only use addresses as the
parameterized “from/to” areas. (see section address specification in the
“Assigning Parameters to the Loadable request message, which have
Driver”). previously been defined during
parameter assignment.
0E 52H 82 SIMATIC range limitation exceeded during Limit access range to valid
access attempt by Modbus master system: SIMATIC memory areas.
Resulting DB number < 1, or
write access to an area which has not been
enabled (parameter assignment), or
write access to instance DB of the
communications FB.
0E 53H 83 SIMATIC range limitation exceeded during Limit access range to valid
access attempt by Modbus master system, SIMATIC memory areas.
for example, overflow when generating the
resulting DB number (> 65535).
0E 54H 84 Access in excess of parameterized range Limit access range to valid
end, or access in excess of SIMATIC range SIMATIC memory areas.
end.
0E 55H 85 Write access to this SIMATIC memory area Carry out write access only to
is not allowed. SIMATIC data areas memory
bits, outputs.
0E 56H 86 Data link operation not possible because Make cyclic call of Modbus
communications FB not running. communications FB in STEP 7
user program.
If required, re-initialize
communications FB.
0E 57H 87 Error occurred in communications FB during Analyze exact reason as
processing of the Modbus function code. described in Chapter
“Diagnostics of the
Communications FB.”
Diagnostic The Modbus communications FB has the following two output parameters,
Functions which indicate occurred errors:
• Parameter “ERROR_NR”
• Parameter “ERROR_INFO”
Deleting the Errors The errors are deleted with a rising edge at CP_START.
The error displays may be deleted by the user at any time, if required.
“Other Errors”
ERROR_ ERROR_INFO Error Text Remedy
No
(decimal)
90 SFB12->STATUS Error during transmission of an Analyze STATUS information.
acknowledgment message to the
driver with SFB12 (BSEND).
91 SFB22->STATUS Error when reading SYSTAT with Analyze STATUS information.
SFB22 (STATUS).
92 FB7->STATUS Error when executing a Analyze FB7-STATUS
RECEIVE/FETCH call with FB7
(RCV_RK).
A Technical Data
Transmission The following tables contain measured transmission times for the different
Times function codes.
If you are using another device as a partner (master or slave), you must use
the times which correspond to that device for either the master or the slave,
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.
Slave is CP 341 Function Code 1 (Read) – Read Coil (Output) Status (Times in msec.)
Transmission 300
Rate (bps)
Transmission 9600
Rate (bps)
1 Byte 74 8 18 6
10 Bytes 75 8 19 16
20 Bytes 77 8 19 27
50 Bytes 83 8 62 62
Transmission 76800
Rate (bps)
1 Byte 73 1 13 1
10 Bytes 74 1 13 2
20 Bytes 76 1 13 3
50 Bytes 86 1 20 8
100 Bytes 93 1 29 15
200 Bytes 95 1 45 29
255 Bytes 97 1 50 37
Slave is CP 341 Function Code 15 (Write) – Force Multiple Coils (Time in msec.)
Transmission 300
Rate (bps)
Transmission 9600
Rate (bps)
1 Byte 48 10 41 8
10 Bytes 48 20 41 8
20 Bytes 50 32 43 8
50 Bytes 52 67 48 8
Transmission 76800
Rate (bps)
1 Byte 58 1 40 1
10 Bytes 61 3 43 1
20 Bytes 62 4 43 1
50 Bytes 63 8 44 1
100 Bytes 64 15 50 1
200 Bytes 66 30 69 1
255 Bytes 68 38 85 1
Slave is CP 441-2 Function Code 1 (Read) – Read Coil (Output) Status (Times in msec.)
Transmission 300
Rate (bps)
Transmission 9600
Rate (bps)
1 Byte 33 8 40 6
10 Bytes 33 8 43 16
20 Bytes 35 8 44 28
50 Bytes 42 8 45 62
Transmission 76800
Rate (bps)
1 Byte 35 1 23 1
10 Bytes 36 1 25 2
20 Bytes 37 1 26 3
50 Bytes 46 1 27 8
100 Bytes 61 1 30 15
200 Bytes 82 1 39 29
255 Bytes 92 1 48 37
Slave is CP 441 Function Code 15 (Write) – Force Multiple Coils (Time in msec.)
Transmission 300
Rate (bps)
Transmission 9600
Rate (bps)
1 Byte 64 11 62 8
10 Bytes 64 21 63 8
20 Bytes 69 32 64 8
50 Bytes 69 67 68 8
Transmission 76800
Rate (bps)
1 Byte 60 1 56 1
10 Bytes 60 3 58 1
20 Bytes 62 4 58 1
50 Bytes 64 9 60 1
100 Bytes 67 16 67 1
200 Bytes 72 30 77 1
255 Bytes 77 38 84 1
Memory The following table displays the memory requirements of the function blocks of
Requirements the CP 341 (FB80) and CP 441 (FB180) in bytes. The memory requirements
of the FBs 7 and 8 can be found in the manual for the CP 341.
Sender Receiver
MODBUS Master
e.g.: CP341 or CP441-2
2 9 4 11
T(A)- T(B)+ R(A)- R(B)+
Connector
330 Ω
330 Ω
Caution
In the RS422 mode CP341 and CP441-2 can only be used as a Master“ because
you can switch your receive lines to “Tri State“!
Sender Receiver
MODBUS Master
e.g.: CP341 or CP441-2
4 11
Connector
R(A)- R(B)+
330 Ω
330 Ω
4 11
R(A)- R(B)+
• A terminating resistor of approx. 330 Ω is to be soldered into the connector on the last receiver
of a node sequence
• Recommended cable type: LIYCY 3 x 2 x 0,14 R(A)/R(B) and T(A)/T(B) twisted pairs
C Literature List
Address The address identifies a physical storage location and enables the user
to directly access the operand stored there.
B
Block Blocks are elements of the user program which are defined by their
function, structure, or purpose. With STEP 7 there are
_ 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 Parameter Block parameters are wildcards within multiple-use blocks, which are
replaced with current values when the relevant block is called.
C
Configuration The configuration is the setup of individual modules of the PLC in the
configuration table.
Cycle Time The cycle time is the time the CPU needs to scan the user program
once.
Data Block (DB) These are blocks containing data and parameters with which the user
program works. Unlike all other blocks, data blocks do not contain
instructions. They are subdivided into global data blocks and instance
data blocks. The data held in the data blocks can be accessed
absolutely or symbolically. Complex data can be stored in structured
form.
Data Type Data types allow the user to define how the value of a variable or
constant is to be used in the user program. They are subdivided into
elementary and structured data types.
Default Setting The default setting is a practical basic setting which is always used if no
other value is specified.
Diagnostic Buffer Every CPU has a diagnostic buffer, in which detailed information on
diagnostic events is stored in the order in which they occur.
Diagnostic Events Diagnostic events are, for example, errors on a module or system errors
in the CPU, which may be caused by a program error or by operating
mode transitions.
Diagnostic Functions The diagnostic functions cover the entire system diagnosis and include
detection, analysis, and reporting of errors within the PLC.
Download Downloading means loading load objects (for example, code blocks)
from the programming device into the load memory of the CPU.
F
Function Block (FB) Function blocks are components of the user program and, in
accordance with the IEC standard, are “blocks with memory.” The
memory for the function block is an assigned data block of the “instance
data block.” Function blocks can be assigned parameters, or they can
be used without parameters.
H
Hardware Hardware is the term given to all the physical and technical equipment of
a PLC.
I
Instance Data Block An instance data block is a block assigned to a function block and
contains data for this particular function block.
Interface Submodule The CP 441-2 interface submodule is responsible for the physical
conversion of signals. By changing the interface submodule, you can
make the communications processor compatible with the
communications partner.
Module Parameter Module parameters are used to set the module reactions. A distinction is
made between static and dynamic module parameters.
O
Online / Offline Online means that a data circuit exists between PLC and programming
device. Offline means that no such data circuit exists.
Online Help STEP 7 allows you to display contextual help texts on the screen while
working with the programming software.
Operand An operand is part of a STEP 7 instruction and states with what the
processor is to do something. It can be both absolutely and symbolically
addressed.
Operating System of The operating system of the CPU organizes all functions and operations
the CPU of the CPU which are not connected to a specific control task.
Process Image The process image is a special memory area in the PLC. At the
beginning of the cyclic program, the signal states of the input modules
are transferred to the process image input table. At the end of the cyclic
program, the process image output table is transferred to the output
modules as signal state.
Project Configuration Project configuration of data link is the term given to the allocation of a
of Data Link Connection ID in the system function block. The Connection ID enables
the system function blocks to communicate between two communication
terminal points.
RESTART On transition from the STOP to the RUN mode, the PLC goes through
the RESTART mode.
S
Software Software is the term given to all the programs used on a computer
system. These include the operating system and the user programs.
System Block System blocks differ from the other blocks in that they are already
integrated into the S7-300/400 system and are available for already
defined system functions. They are subdivided into system data blocks,
system functions, and system function blocks.
System Function (SFC) System functions are modules without memory which are already
integrated into the operating system of the CPU and can be called up by
the user as required.
System Function Block System function blocks are modules with memory which are already
(SFB) integrated into the operating system of the CPU and can be called up by
the user as required.
Upload Uploading means loading load objects (for example, code blocks) from
the load memory of the CPU into the programming device.
User Program The user program contains all instructions and declarations for signal
processing, by means of which a system or a process can be controlled.
The user program for SIMATIC S7 is structured and is divided into
smaller units called blocks.
V
Variable A variable is an operand (for example, E 1.0) which can have a symbolic
name and can therefore also be addressed symbolically.
W
Work Memory The work memory is a RAM on the CPU which the processor accesses
while processing the user program.
Index
A L
Address representation ................................. 1-3 Loading memory............................................1-2
B M
Broadcast Message ...................................... 7-1 Memory bits ...................................................3-3
Message structure .........................................7-1
C
Multiplier ZVZ.................................................4-9
Character delay time ............................4-10, 7-2 Multipoint connection .....................................1-1
Communications FB....................... 5-8, 6-1, 9-6
N
Configuration of data link .............................. 4-7
Connection ID.........................................4-7, 6-2 Normal operation ...........................................4-9
Counter.......................................................... 3-3
O
CPU parameter assignment........................ 4-21
CRC............................................................... 7-2 Operating mode.............................................4-9
Outputs ..........................................................3-3
D
P
Data bits ........................................................ 4-8
Data block ..................................................... 3-3 Parameter assignment .......................... 4-4, 4-8
Data consistency ............................ 1-4, 6-2, 6-4 Parity..............................................................4-8
De-installation................................................ 4-2
Diagnostics R
Communications FB ................................ 10-1 Reaction times ..................................................8
Driver ......................................................... 9-1
Display elements (LED)................................. 9-1 S
Dongle ....................................................1-2, 2-1 Slave address ........................................ 4-9, 7-1
E Startup
Loading procedure ...................................4-21
Exception code.............................................. 7-3 Startup characteristics .................................4-21
F Stop bits.........................................................4-8
SYSTAT.......................................... 5-8, 9-1, 9-6
Function Block......................... 1-1, 3-1, 3-2, 5-2 Event class.................................................9-7
Function Code ......................... 1-1, 3-3, 7-2, 8-1 Event number.............................................9-7
FC-01........................................ 1-3, 4-11, 8-2
FC-02........................................ 1-3, 4-13, 8-5 T
FC-03........................................ 1-3, 4-15, 8-7 Timer .............................................................3-3
FC-04...................................... 1-3, 4-16, 8-10 Transmission errors............................. 4-9, 4-19
FC-05............................. 1-3, 4-11, 4-17, 8-13 Transmission rate ..........................................4-8
FC-06............................. 1-3, 4-15, 4-17, 8-15 Transmission times ...................................... A-1
FC-08....................................................... 8-17
FC-15............................. 1-3, 4-11, 4-17, 8-18
FC-16............................. 1-3, 4-15, 4-17, 8-21
I
Inputs............................................................. 3-3
Instance data block ........................ 3-1, 5-1, 5-5
Interface
RS422/485 (X27) ..................................... 4-18
Interface submodule
RS232C ..................................................... 1-1
RS422/485 (X27) ....................................... 1-1
TTY.....................................................1-1, 2-2
X27 ............................................................ 2-2
Interference suppression............................. 4-10