Modbus TCP PN CPU English
Modbus TCP PN CPU English
Modbus TCP PN CPU English
Getting Started
Commissioning
Parameterization
Licensing
FB MODBUSPN
Additional Blocks
Diagnosis
Sample Application
SIMATIC S7
SIMATIC Modbus/TCP
Communication via the
integrated PN interface of the PLC
Manual
Appendices
Literature
Glossary
Edition 2.7
This manual contains warnings, which you should note for your own safety as well as
for the prevention of damage to property. These warnings are indicated by means of a
warning triangle and are displayed as follows in accordance with the level of danger:
__________________________________________________________________
Danger
indicates that loss of life, severe personal injury or substantial damage
will result if proper precautions are not taken.
__________________________________________________________________
__________________________________________________________________
Warning
indicates that loss of life, severe personal injury or substantial damage can result if proper
precautions are not taken.
__________________________________________________________________
__________________________________________________________________
Caution
indicates that minor personal injury or property damage can result if proper precautions are
not taken.
__________________________________________________________________
__________________________________________________________________
Note
represents an important information especially significant to the product, handling of the
product or a specific part of this documentation.
__________________________________________________________________
Qualified
Personnel
The start-up and the operation of the device may only be carried out by qualified
personnel. Qualified personnel in the sense of the security advices of this manual are any
persons authorized to commission, ground and label devices, systems and electric circuits.
Use as prescribed
Please note:
_________________________________________________________________________
Warning
This device may only be used for applications as prescribed in the catalogue and the
technical description. Furthermore, they may only be used in conjunction with third-party
devices and components recommended and authorized by Siemens.
A successful and safe operation of this product is depends on proper transport, and correct
storage, installation and assembly as well as careful operation and maintenance.
Copyright
Since any other brand names in this manual may refer to trademarks, the use of these
names by third parties for their own purposes may infringe the rights of the owner.
Exclusion of Liability
We have checked the contents of this document with regard to its
conformity with the described hardware and software. Deviations,
however, cannot be excluded. Therefore, we cannot guarantee its
complete conformity. The information in this document is checked
regularly and necessary corrections are contained in subsequent
versions. We will be grateful for any suggestions for improvement.
Technical data subject to change.
Preface
Preface
Purpose of the
Manual
The information in this manual allows you to set up and put in operation the
connection between a PLC with integrated PN interface and a device that
supports the Modbus/TCP protocol.
Contents of the
Manual
This manual describes the function of the Modbus function block and its
parameterization.
The manual contains the following topics:
Production description
Getting Started
Commissioning
Parameterization
Licensing
Function block MODBUSPN
Diagnosis
Sample application
Scope of this
Manual
Identification number
From version
Modbus/TCP PN CPU
2XV9 450-1MB02
2.6.1
FB 102 MODBUSPN
3.7
FB 103 TCP_COMM
3.2
FB 104 MOD_CLI
1.6
FB 105 MOD_SERV
1.5
Note
This manual contains the FB description valid at the time of publication.
Preface
Additional
Sources of
Information
SIMATIC
Windows Automation Center RTX
WinAC RTX 2008
Operating Instructions
A5E00486536-02
SIMATIC
Windows Automation Center RTX
WinAC RTX 2009
Operating Instructions
A5E00486536-03
Modbus/TCP communication via the integrated PN interface of the CPU
2XV9450-1MB02; Manual edition 2.7
Preface
SIMATIC
Windows Automation Center RTX
WinAC RTX (F) 2010
Operating Instructions
A5E00486536-04
Additional information concerning STEP7 can be found in the following
manuals:
SIEMENS
SIMATIC Software
Base software for S7 and M7
STEP7 user manual
C79000-G7000-C502-..
SIEMENS
SIMATIC Software
System software for S7-300/400
System and standard functions
Reference manual C79000-G7000-C503-02
Additional
Questions
For further questions regarding the use of the FBs described in this manual,
please contact your Siemens partner who provided you with this function
block.
Terminology
This document uses the term PN PLC. The descriptions apply to PN PLCs
of series 314C, 315, 317, 319, 412, 414 and 416 as well as IM 151-8 PN/DP
CPU and WinAC RTX.
Scope of
Application
Table of Contents
Table of Contents
1
1.2
3.1
3.2
3.3
3.4
4.2
6.1
6.2
6.3
6.4
6.5
7.2
8.2
Table of Contents
8.3
8.4
8.5
9.2
Literature ....................................................................................................................... 1
ii
Product Description
Product Description
1.1
Field of Applications
Placement in the
System Environment
The function block described here is a software product for PLCs with
integrated PN interface of Simatic S7-300, S7-400 and IM 151-8 PN/DP
CPU.
Function of the
FBs
Use of Port
Number 502
In general, the protocol uses the port 502. This port number has been
released for all PN PLCs with the corresponding firmware version. You can
find the information about the released port numbers on the internet:
http://support.automation.siemens.com/WW/view/en/34010717.
With specific CPUs it is possible to use multiple connections via port 502 to
different clients simultaneously.
In section 3.4 Multiple Connections via Port 502 you can find technical
details regarding this matter.
1.2
Usable Modules
Software Versions
1-1
Product Description
Memory
requirements
The FB MODBUSPN requires ca. 8 kbyte work memory and ca. 9 kbyte load
memory.
The FB MOD_CLI requires ca. 9 kbyte work memory and ca. 10 kbyte load
memory.
The FB MOD_SERV requires ca. 9 kbyte work memory and ca. 10 kbyte load
memory.
The FB TCP_COMM requires ca. 2 kbyte work memory and ca. 2 kbyte load
memory.
1-2
Getting Started
Getting Started
Procedure
1. Install Modbus/TCP PN CPU and insert the Modbus function blocks into
your SIMATIC project.
=> Section 3.1 to 3.3
2. Parameterize the connection parameters regarding your requirements
(IP-address, port number, etc.).
=> Section 4.1 and 4.2
3. Parameterize the Parameter-DBs MODBUS_PARAM regarding your
requirements (client/server, connect at start-up, register numbers,
DB numbers, etc.).
=> Section 4.1 and 4.2
4. Call the Modbus block FB102 in the required OBs.
=> Section 6.1
5. Parameterize the Modbus block for initialization and runtime.
=> Section 6.2
6. Load the user program into the PLC and license the Modbus block for this
CPU.
=> Section 5
.
2-1
Commissioning
Commissioning
General
Information
The information below on STEP7 refers to Version 5.5. In later versions, the
sequences, names and directories might be different.
Requirements
3.1
What We Provide
Requirements
Installation
Insert your Modbus CD into the CD ROM drive and follow the instructions
which are displayed automatically by the installation program step by step. If
the installation program does not start automatically, please proceed as
follows:
1. In the Windows Explorer, navigate to the CD ROM drive. Open the setup
directory and double-click on Setup.EXE to start the installation.
2. Follow the instructions which are displayed by the installation program
step by step.
Now you can find
the library in
\Program Files\Siemens\Step7\S7libs,
3-1
Commissioning
3.2
Introduction
Procedure
3-2
Commissioning
3-3
Commissioning
3.3
Content of the
MODBUS library
Blocks of the
Standard Library
Communication Blocks.
Please note that the following versions of the FBs are a requirement for the
faultless function of the FB MODBUSPN:
TSEND
TRCV
TCON
TDISCON
Restart in
Commissioning
V2.1
V2.2
V2.4
V2.1
3-4
Commissioning
3.4
General
Requirements
Number of
Released
Connections
The maximum number of Modbus clients that can be connected to port 502
of the CPU is CPU-specific and can be found in the technical data of the
CPU.
Programming
For each client that should be connected to port 502 of the server, 1 unique
connection is needed in the parameter data block. Furthermore in the S7
program 1 Modbus block instance is needed for each client.
3-5
General
Information
For the communication via the integrated PN interface of the PLC, a network
configuration in NetPro is not necessary. The connections are established
and terminated by means of the function blocks TCON (FB65) und TDISCON
(FB66).
Several connections to different communication partners can be
parameterized and established at the same time. The maximal number of
coexistent connections depends on the PLC.
Connection
Description DB
MODBUS_PARAM
Name
STRUCT
+0.0
+64.0
+650.0
+714.0
...
...
STRUCT
650*i
650*i+64
4-1
Connection
Parameters
The parameters of the connection are defined in the first block, e.g. the used
local interface and the IP address of the communication partner. The
functions TCON and TDISCON can establish and terminate a connection by
means of these parameters. The detailed structure can be found in section
4.2.
The structure of the connection parameter block is obligatory und may not be
changed. Otherwise it becomes impossible to establish a connection.
Modbus
Parameters
The Modbus parameters define the mode of communication and the address
reference, e.g. how many register or bit areas are mapped to which DB and
the differentiation between the S7 acting as server or as client. The structure
of the parameter DB has to remain unchanged to ensure proper
communication.
Alternatives for
Parameterization
4.1
General
Information
With the wizard ModbusTCP Wizard you can easily parameterize the
connection parameters as well as the Modbus parameters in the parameter
data block MODBUS_PARAM. The complete structure (connection
parameters and Modbus parameters) is created.
It is recommended to use the wizard for the parameterization of the block
MODBUS_PARAM.
4-2
4.2
Procedure
Copy DB2 of the library Modbus_PN_CPU and insert it in your project. If the
number is already used, rename the DB.
The parameter of data block MODBUS_PARAM must not be changed during
runtime. It is necessary to restart the PLC after the modification of
MODBUS_PARAM.
Structure and
Adaption of
Connection
Parameters
block_length
This parameter describes the length of the connection parameters and must
not be changed.
Fixed value:
id
W#16#40
W#16#1 to W#16#FFF
4-3
connection_type
The values vary depending on the used firmware. You can find further
information on the internet:
http://support.automation.siemens.com/WW/view/en/24294554
active_est
local_device_id
TRUE
FALSE
local_tsap_id_len
B#16#1
B#16#2
B#16#3
B#16#5
B#16#6
B#16#B
B#16#F
0
2
rem_subnet_id_
len
This parameter is currently not used. Please assign the value B#16#0.
rem_staddr_len
rem_tsap_id_len
B#16#0
B#16#4
This parameter defines the length of rem_tsap_id, the port number of the
remote communication partner.
Active connection establishment:
Passive connection establishment:
next_staddr_len
2
0
B#16#0
4-4
local_tsap_id
This parameter defines the local port number. The representation depends on
the parameter connection_type. The value range depends on the PLC. The
port number has to be unique within the PLC.
With connection_type B#16#01
local_tsap_id[1]
low byte of the local port number in hexadecimal
local_tsap_id[2]
high byte of the local port number in hexadecimal
local_tsap_id[3-16]
B#16#00
With connection_type B#16#11
local_tsap_id[1]
high byte of the local port number in hexadecimal
local_tsap_id[2]
low byte of the local port number in hexadecimal
local_tsap_id[3-16]
B#16#00
rem_subnet_id
This parameter is currently not used. Please assign the value B#16#0.
rem_staddr
rem_tsap_id
This parameter defines the remote port number. The representation depends
on the parameter connection_type. The value range depends on the PLC.
With connection_type B#16#01
local_tsap_id[1]
low byte of the remote port number in hexadecimal
local_tsap_id[2]
high byte of the remote port number in hexadecimal
local_tsap_id[3-16]
B#16#00
With connection_type B#16#11
local_tsap_id[1]
high byte of the remote port number in hexadecimal
local_tsap_id[2]
low byte of the remote port number in hexadecimal
local_tsap_id[3-16]
B#16#00
next_staddr
This parameter defines rack and slot of the corresponding CP. When using
the integrated PN interface of the PLC, assign 0 to this parameter.
next_staddr[1-6]
spare
B#16#00
4-5
Adaption of the
Modbus
Parameters
server_client
TRUE: S7 is server
FALSE: S7 is client
single_write
4-6
connect_at_
startup
This parameter defines the point in time at which the connection is being
established.
FALSE: establish connection when ENQ_ENR=TRUE
TRUE: establish connection immediate after PLC start-up
When connect_at_startup = TRUE, the first request should be started after
the connection was established (CONN_ESTABLISHED = TRUE) or an error
has been reported respectively (ERROR =TRUE).
8 Data Areas
8 data areas are available to map the Modbus addresses in the S7 storage.
At least the first data area has to be defined. The other 7 data areas are
optional. Depending on the type of request, these memory areas are read or
written.
With one request, only one DB can be accessed. Even if consecutive register
numbers or coils are located in two different DBs, two requests are necessary
to access them both. This has to be taken into account during the
parameterization.
It is possible to map more Modbus values (registers or coils) in one data
block than could be processed with one telegram.
data_type_x
db_x
Data type
Coils
Bit
Inputs
Bit
Holding Register
Word
Input Register
Word
Size
The parameter db_x defines the number of the data block in which the
consecutively defined MODBUS registers or bits are mapped.
0 cannot be used as DB number since it is reserved for system functions.
db_x
DB-Number
The data block must be longer by 2 bytes than it is necessary for the
parameterized data. The last 2 bytes are required for internal purposes.
4-7
start_x
end_x
Start_x specifies the first register or bit address, which is stored in the data
block word 0 of the DB. End_x defines the address of the last MODBUS
address.
When accessing registers, the number of the data block word of the S7 DB in
which the last register is mapped, can be calculated with the following
formula:
DBW number = (end_x start_x)
When accessing coils or inputs, the number of the data element of the S7 DB
in which the last bit is mapped, can be calculated with the following formula:
DBB number = (end_x start_x +7) / 8
The defined memory areas must not overlap. The parameter end_x must not
be smaller than start_x. In case of an error occurring, the initialization of the
FB is stopped with an error. When start_x is equal to end_x, one Modbus
address (1 register or 1 bit) is allocated.
In section 6.3 you can find an example of the mapping of the MODBUS
addresses to S7 memory areas.
start_x, end_x
MODBUS address
internal_send_
buffer
This array is used internally for message data within the FB. Accessing or
changing the array is inadmissible.
internal_recv_
buffer
This array is used internally for the received data within the FB. Accessing or
changing the array is inadmissible.
4-8
Licensing
Licensing
General
The block MODBUSPN must be licensed for each CPU individually. The
licensing takes place in two steps: reading the IDENT_CODE and declaring
the registration key REG_KEY. The OB121 must be available in the CPU.
Read the
IDENT_CODE
is insufficient.
5-1
Licensing
5-2
Licensing
Declaration of the
Registration Key
REG_KEY
The registration key REG_KEY must be declared for each call of the block
MODBUSPN.
The registration key REG_KEY should be stored in a global DB. Via this
global DB all MODBUSPN blocks can receive the registration key (See also
the following example).
Please proceed as follows to declare the registration key REG_KEY:
1. Copy the prepared license block DB3 of the library
Modbus_PN_CPU into your project. If the DB number is already
used in your project, rename the license DB.
2. Open the license DB and copy the 17 digit registration key you
received to the column Initial value.
5-3
Licensing
Missing or Wrong
Licensing
When the registration key is missing or a wrong one is detected, the SF LED
(S7-300 and IM151-8) or the INTF LED (S7-400) of the CPU is flashing. A
cyclic error message regarding the missing license is displayed in the
diagnostic buffer, too. The error number of the missing license is
W#16#A090.
_____________________________________________________________
Warning
The CPU will turn to STOP mode, if the OB121 is not available.
_____________________________________________________________
5-4
6.1
Functionality of the FB
General
Information
Online Help
The SIMATIC Manager provides an online help for the function block
MODBUSPN. Mark the FB and press F1 so that he online help is displayed.
It contains the main information on the FB.
6-1
Call of the FB
Start-up of the FB
Cyclical Operation
of the FB
OB121
Programming
Error
If the block has not been licensed yet, the OB121 is called.
____________________________________________________________
Warning
The CPU will turn to STOP mode, if the OB121 is not available.
_____________________________________________________________
6-2
Connection
Handling
Multiple
Communication
Partners
6-3
Initiate Request
S7 is Client
Activation of the
Function Block
S7 is Server
With the signal TRUE at the trigger input ENQ_ENR, the FB is ready to
receive a request telegram from the client. The server remains passive and
waits for a telegram from the client. The received telegram is verified. If the
verification result is positive, the response telegram is sent. The completed
transmission is reported to the user by setting the DONE_NDR bit. At this
point, the completed function is indicated at the outputs UNIT, DATA_TYPE,
START_ADDRESS, LENGTH, TI and WRITE_READ.
An erroneous request telegram causes an error message and the ERROR bit
is set. The error number is returned in STATUS_MODBUS. The request of
the client is not executed. Depending on which error occurred, an exception
telegram is sent to the client.
6-4
6.2
Parameter
Decl. Type
Description
ID
IN
WORD
Value range
Init
1 to 4095
yes
W#16#1 to
W#16#FFF
DB_PARAM
IN
depending on
PLC
yes
RECV_TIME
IN
TIME
T#20ms
to
T#+24d20h31
m23s647ms
no
T#20ms
to
T#+24d20h31
m23s647ms
no
TRUE
FALSE
no
TRUE
FALSE
no
Character
no
CONN_TIME
IN
TIME
KEEP_ALIVE
IN
TIME
Not used
ENQ_ENR
IN
BOOL
S7 is Client:
Initiate request at positive edge
S7 is Server:
Ready to receive at TRUE signal
DISCONNECT
IN
BOOL
S7 is Client:
TRUE: connection is terminated after
reception of response
S7 is Server:
TRUE: connection is terminated when
ENQ_ENR = FALSE
REG_KEY
IN
LICENSED
OUT BOOL
BUSY
STRING
[17]
OUT BOOL
no
TRUE
FALSE
no
Job processing
TRUE
FALSE
CONN_
ESTABLISHED
OUT BOOL
Connection established
Connection terminated
TRUE
FALSE
no
DONE_NDR
OUT BOOL
S7 is Client:
TRUE: Active request finished without
errors
TRUE
FALSE
no
S7 is Server:
TRUE: Request from the client was
executed and answered
6-5
Parameter
Decl. Type
Description
ERROR
OUT BOOL
Value range
Init
TRUE
no
FALSE
STATUS_
MODBUS
OUT WORD
0 to FFFF
no
STATUS_
CONN
OUT WORD
0 to FFFF
no
STATUS_FUNC
OUT STRING
[8]
Character
no
IDENT_CODE
OUT STRING
[18]
Character
no
UNIT
IN/
BYTE
OUT
Unit Identifier
(INPUT if in CLIENT mode, OUTPUT if
in SERVER mode)
0 to 255
no
IN/
BYTE
OUT
DATA_TYPE
Coils
Inputs
Holding registers
Input registers
START_
ADDRESS
IN/
WORD
OUT
LENGTH
IN/
WORD
OUT
TI
WRITE_ READ
B#16#0 to
B#16#FF
no
1
2
3
4
0 to 65535
no
Coils
Reading function
Writing function
1 to 2000
1 to 1968
Inputs
Reading function
1 to 2000
Holding Register
Reading function
Writing function
1 to 125
1 to 123
Input Register
Reading function
1 to 125
IN/
WORD
OUT
Transaction Identifier
(INPUT if in CLIENT mode, OUTPUT if
in SERVER mode)
0 to 65535
IN/
BOOL
OUT
Write access or
Read access
(INPUT if in CLIENT mode, OUTPUT if
in SERVER mode)
TRUE
FALSE
no
W#16#0000 to
W#16#FFFF
no
W#16#0 to
W#16#FFFF
no
6-6
General
Information
Range of Values
6-7
ID
DB_PARAM
RECV_TIME
The monitoring time RECV_TIME observes the data input from the
communication partner. The shortest adjustable time is 20 ms.
In the operating mode S7 is client, an indication RECV_TIME < 20 ms
causes an error message and the request is rejected. When the time
RECV_TIME elapses, the active request is cancelled with an error.
In the operating mode S7 is server, an indication RECV_TIME < 20 ms
causes the use of the default time of 1,2s. If the monitoring time elapses, an
error is reported. The RECV_TIME monitors the duration of the TCP stream.
The interval between two requests is not taken into consideration.
CONN_TIME
6-8
ENQ_ENR
DISCONNECT
REG_KEY
The block MODBUSPN must be licensed for each CPU individually to permit
a correct program sequence.
With the registration key REG_KEY the block MODBUSPN is licensed and
the Modbus communication runs without any restraint.
You can find further information in section 5 Licensing.
LICENSED
If this output is TRUE, then the Modbus block is licensed on this CPU. If the
output is FALSE, none or a faulty license string was entered.
BUSY
CONN_
ESTABLISHED
6-9
DONE_NDR
ERROR
STATUS_MODBUS
STATUS_CONN
STATUS_FUNC
This parameter shows the name of the function, which caused the error
occurred.
IDENT_CODE
With the identification string IDENT_CODE you can order the registration
key. After start-up of the PLC an 18 character string is displayed.
You can find further information in section 5 Licensing.
UNIT
6-10
DATA_TYPE
B#16#1
B#16#2
B#16#3
B#16#4
START_ADDRESS
DATA_
TYPE
Function
Length
single_
write
Function
code
Coils
read
any
irrelevant
Coils
write
TRUE
Coils
write
FALSE
15
Coils
write
>1
irrelevant
15
Inputs
read
any
irrelevant
Holding Register
read
any
irrelevant
Holding Register
write
TRUE
Holding Register
write
FALSE
16
Holding Register
write
>1
irrelevant
16
Input Register
read
any
irrelevant
LENGTH
The parameter LENGTH specifies the number of MODBUS values that are
read or written.
In the operating mode S7 is Client, this is an input parameter. In the
operating mode S7 is Server, this is an output parameter.
With a reading function, a maximum of 125 registers or 2000 bits is possible
per telegram. With a writing function, a maximum of 123 registers or 1968
bits is possible.
For each telegram, all registers or bits have to be in the same DB.
6-11
TI
6.3
Interpretation of
MODBUS Register
Addresses
The MODBUS data model is based on a series of storage areas with distinct
properties. Some systems, e.g. MODICON PLCs, distinguish these areas by
the register or bit addresses. The Holding Register with offset 0, for example,
is called 40001 (memory type 4xxxx, reference 0001).
A potential source of confusion is the varying interpretation of the register
address in different manuals. Sometimes the register or bit address is defined
as the address of the application layer and in other manuals it is the actually
transferred address.
The FB MODBUSPN uses the register or bit address transferred for its
parameters start_x, end_x and START_ADDRESS. Therefore, it is possible
to use register or bit addresses from von 0000H to FFFFH for each function
code.
6-12
Example:
Parameterization
of the Memory
Areas
Address Mapping
data_type_1
db_1
start_1
end_1
data_type_2
db _2
start _2
end _2
data_type_3
db _3
start _3
end _3
data_type_4
db _4
start _4
end _4
data_type_5
db _5
start _5
end _5
data_type_6
db _6
start _6
end _6
data_type_7
db _7
start _7
end _7
data_type_8
db _8
start _8
end _8
B#16#3
W#16#B
W#16#0
W#16#1F3
B#16#3
W#16#C
W#16#2D0
W#16#384
B#16#4
W#16#D
W#16#2D0
W#16#3E8
B#16#0
0
0
0
B#16#1
W#16#E
W#16#280
W#16#4E2
B#16#2
W#16#F
W#16#6A4
W#16#8FC
B#16#1
W#16#10
W#16#6A4
W#16#8FC
B#16#0
0
0
0
Holding Register
DB 11
Start address: 0
End address: 499
Holding Register
DB 12
Start address: 720
End address: 900
Input Register
DB 13
Start address: 720
End address: 900
Not used
0
0
0
Coils
DB 14
Start address: 640
End address: 1250
Inputs
DB 15
Start address:1700
End address: 2300
Coils
DB 16
Start address: 1700
End address: 2300
Not used
0
0
0
6-13
SIMATIC
Modbus decive
Coils (from 00001)
0
00001
...
640
00641
641
00642
...
1250
01251
...
1700
01701
...
Inputs (from 10001)
0
2300
02301
2301
02302
10001
...
1700
11701
1701
11702
...
2300
12301
2301
12302
Input Register
(from 30001)
0
30001
30002
...
720
30721
721
30722
...
Holding Register
(from 40001)
0
40001
40002
1000
31001
1001
31002
...
499
40500
500
40501
501
40502
...
720
40721
...
900
40901
901
40902
6-14
6.4
Instance DB
The function block MODBUS stores its data in an instance DB. This instance
DB is created by STEP7 when initially calling the FB.
The instance data block contains parameters of the types input, output and
input/output as well as static variables required for its execution. These
variables are remanent and keep their validity between FB calls. The
variables control the internal process flow of the FB.
Required memory of the instance-DBs:
Instance-DB
work memory
load memory
MODBUSPN
ca. 3 kByte
Local Variables
A total of max. 156 bytes of local data is needed for one FB MODBUSPN
call.
Parameter DB
Timers
Flags
MODBUSPN:
SFCs for
Miscellaneous
Functions
The FB MODBUSPN uses the following SFCs from the standard library:
SFC6 RD_SINFO
SFC20 BLKMOV
SFC24 TEST_DB
SFC51 RDSYSST
SFC52 WR_USMSG
6-15
MOD_CLI and
MOD_SERV:
SFCs for
Miscellaneous
Functions
The FBs MOD_CLI and MOD_SERV use the following SFCs from the
standard library:
TCP_COMM:
SFCs for
Miscellaneous
Functions
The FB TCP_COMM uses the following SFB from the standard library in
addition to the T-blocks:
SFC20 BLKMOV
SFC24 TEST_DB
SFB4 TON
6-16
6.5
Inducement
If the numbers of the standard functions are already assigned within your
project or if the number interval is reserved for a different application (e.g.
CFC), it is possible to rename the internally called function blocks FB63,
FB64, FB65 and FB66 of FB TCP_COMM or the function blocks
MODBUSPN, MOD_CLI, MOD_SERV und TCP_COMM.
It is not possible to rename the system functions SFC6, SFC20, SFC24,
SFC51, SFC52 and SFB4.
Behavior
Renaming
The modifications can be verified by clicking "Options > Reference data >
Display".
6-17
Additional Blocks
Additional Blocks
7.1
General
Application Sample
The data collector FBs are located in the CFC chart. The output IDB is
connected to the DB parameters db_1 to db_8 of the parameter data block. In
CFC it is not possible to address an element in a STRUCT with the symbolic
name, so the absolute address of db_x needs to be entered, e.g.
MODBUS_PARAM.DBW68.
With this configuration the Modbus values can be connected directly from the
channel blocks to the data collector FB.
You can find the additional blocks and a detailed description here:
www.siemens.com/s7modbus or contact the Customer Support.
7-1
Additional Blocks
7.2
General
Application Sample
You can find the additional block and a detailed description here:
www.siemens.com/s7modbus or contact the Customer Support.
7-2
Diagnosis
Diagnosis
Diagnostic
Function
Display Elements
(LED)
The display elements inform you about the operating mode or about the error
conditions of the PLC. The display elements provide an overview of internal
errors, external errors and interface-specific errors.
STATUS Outputs
of the
FB MODBUSPN
8-1
Diagnosis
8.1
Display Functions
The display elements of the PLC provide information on the status of the
component. There are two types of display functions:
Group Error Displays
PN CPU 300 and IM 151-8 PN/DP CPU
- SF
Group error
When this LED is flashing, the Modbus block has not been licensed yet.
You can find further information in section 5 Licensing.
PN-CPU 400
- INTF
Internal error
When this LED is flashing, the Modbus block has not been licensed yet.
You can find further information in section 5 Licensing.
Special Displays
PN CPU 300, PN CPU 400 and IM 151-8 PN/DP CPU:
- RX/TX a telegram is transferred via the integrated interface
8-2
Diagnosis
8.2
During Start-up
Cyclical Operation
S7 is Client
8-3
Diagnosis
8-4
Diagnosis
Termination of the
Connection in
Case of Error
8-5
Diagnosis
8.3
Messages at the
STATUS Outputs
of the FB
Error Messages of
the Called SFCs
and FBs
Remedy
(Hex)
A001
A002
A003
S7 is Server:
Modify the request of the client.
8-6
Diagnosis
Remedy
(Hex)
A005
S7 is client:
An invalid value for the parameter LENGTH is given.
S7 is Server:
The number of registers/bits in the request telegram is
invalid. The S7 sends an exception telegram.
Range of values:
Read coils/inputs: 1 to 2000
Write coils: 1 to 1968
Read registers: 1 to 125
Write holding registers: 1 to 123
A006
S7 is Client:
Correct the parameter
LENGTH.
S7 is Server:
Modify the number in the
request telegram.
S7 is Client:
Correct the parameter
combination DATA_TYPE,
START_ADDRESS, LENGTH.
S7 is Server:
Modify the request of the client
or correct the parameterization
in the MODBUS_PARAM.
A007
Only if S7 is client:
Correct the parameterization.
An invalid monitoring time RECV_TIME or CONN_TIME
is parameterized.
The RECV_TIME has to be at least 20 ms, CONN_TIME
100ms
A009
Only if S7 is client:
The received transaction identifier TI is not equal to the
sent one.
The connection is terminated.
A00A
Only if S7 is client:
The received UNIT is not equal to the sent one.
A00B
S7 is client:
Received function code is not equal to the sent one.
S7 is server:
An invalid function code was received.
The S7 sends an exception telegram.
S7 is client:
Verify the data of the
communication partner with the
help of a telegram trace.
S7 is server:
The FB MODBUS only
supports the function codes 1,
2, 3, 4, 5, 6, 15 and 16.
A00C
Only if S7 is client:
The register or bit address respectively the number of
registers or bits in the response telegram is not equal to
the one in the request telegram.
A00E
8-7
Diagnosis
Remedy
(Hex)
A00F
A010
A011
A012
A013
A014
A015
A016
A017
A018
A019
A01A
A01B
A023
A024
A025
A026
A027
A028
A034
8-8
Diagnosis
Remedy
(Hex)
A035
A036
A037
A038
A045
A046
A047
A048
A056
A057
A058
A067
A068
A078
A079
A07A
A07B
A07C
A07D
A07E
A07F
8-9
Diagnosis
Remedy
(Hex)
A080
DB_PARAM is an initialization
parameter. Restart the CPU
after changing this parameter.
A081
A082
A083
Only if S7 is client:
A request was initiated prior to the completion of the
previous one.
A085
A086
A090
A091
A092
Correct LENGTH or
START_ADDRESS at the call
of the FB.
A094
A095
8-10
Diagnosis
Remedy
(Hex)
A100
A101
8-11
Diagnosis
8.4
Remedy
(Hex)
7xxx
For detailed information please refer to the online help See online help (SIMATIC
of SIMATIC Manager.
manager -> mark block -> key
F1)
8xxx
For detailed information please refer to the online help See online help (SIMATIC
of SIMATIC Manager.
manager -> mark block -> key
F1)
Remedy
(Hex)
7xxx
For detailed information please refer to the online help See online help (SIMATIC
of SIMATIC Manager.
manager -> mark block -> key
F1)
8xxx
For detailed information please refer to the online help See online help (SIMATIC
of SIMATIC Manager.
manager -> mark block -> key
F1)
8.5
Remedy
(Hex)
80A1
80B1
80B2
DB UNLINKED
8-12
Application Sample
Sample Application
General
Information
Example Project
on the CD
On the CD you can find an extensive example project which offers all
varieties of parameterization possibilities for the Simatic stations.
Simatic Station is S7-300, S7-400 or IM 151-8 PN/DP CPU
Simatic Station is client or server
9.1
Programming
Example
9-1
Application Sample
Overview
Used Blocks
Symbol
Comment
OB 1
CYCL_EXC
OB 100
COMPLETE RESTART
OB 121
PROG_ERR
programming error OB
FB 102
MODBUSPN
FB MODBUSPN
FB 103
TCP_COMM
FB TCP_COMM
FB 104
MOD_CLI
FB MOD_CLI
FB 105
MOD_SERV
FB MOD_SERV
DB 1
CONTROL_DAT
DB 2
MODBUS_PARAM
DB 3
LICENSE_DB
DB 11
DB 12
DB 13
DB 14
Coils Area
DB 15
Inputs Area
DB 16
Coils Area 2
DB 102
IDB_MODBUS
9-2
Application Sample
9.2
Overview
Used Blocks
Symbol
Comment
FB 99
Save_STATUS
Error buffer
FB 102
MODBUSPN
FB MODBUSPN
FB 103
TCP_COMM
FB TCP_COMM
FB 104
MOD_CLI
FB MOD_CLI
FB 105
MOD_SERV
FB MOD_SERV
DB 1
MEMORY_DB
DB 2
MODBUS_PARAM
DB 3
LICENSE_DB
DB 11
DB 12
DB 13
DB 14
Coils Area
DB 15
Inputs Area
DB 16
Coils Area 2
9-3
A Literature
MODBUS
Organization
http://www.modbus.org
Literature - 1
Customer Support
Siemens AG
Industry Sector
Industry Automation Division / Industrial Automation Systems
Factory Automation
I IA AS FA
Phone: +49 (0)911 895 7 222
Customer Support
http://www.siemens.com/s7modbus
Siemens Aktiengesellschaft
release: 07/2014