Escolar Documentos
Profissional Documentos
Cultura Documentos
S7 communication services
Global data
Global data
OS of Controlled via OS
OS of
the CPU via MPI, C bus, PROFIBUS and
the CPU
Industrial Ethernet
Basic
Basiccommunication
communicationwithout
without Extended
Extendedcommunication
communicationvia
via
connection
connectionconfiguration
configuration configured
configuredconnections
connections
Program
controlled via
SFC SFC SFB
SFB SFB
SFC MPI or C bus SFC SFB
SITRAIN
IK-PBSYS / S7 Connections Page 1 03/2007
Siemens AG 2007 - Subject to change without prior notice
Contents Page
S7 communication services with S7-300/400 .................................................................................... 2
Extended S7 communication ........................................................................................................... 3
Block overview for SFB/FB communication .................................................................................... 4
Libraries ............................................................................................................................................ 5
One-way communication services via S7 connections .................................................................... 6
Insert connection into the "Active station" ......................................................................................... 7
Assignment of connection parameters .............................................................................................. 8
User program in the "active" CPU ..................................................................................................... 9
Exercise 1: One-way S7 connection .................................................................................................. 10
Two-way S7 connections .................................................................................................................... 11
Insert an S7 connection .................................................................................................................... 12
Properties of an S7 connection ........................................................................................................... 13
Compile and download the configuration data ................................................................................. 14
Connection test ................................................................................................................................. 15
Example: S7 program in the station AS1 ........................................................................................... 16
Example: S7 program in the station AS2 ........................................................................................... 17
Exercise 2: Two-way S7 connection .................................................................................................. 18
OS of Controlled via OS
OS of
the CPU via MPI, C bus, PROFIBUS and
the CPU
Industrial Ethernet
SITRAIN
IK-PBSYS / S7 Connections Page 2 03/2007
Siemens AG 2007 - Subject to change without prior notice
Global data This type of communication allows data to be transferred cyclically between
CPUs via the MPI interface without the need for programming. Data is transferred
at the cycle control point at the same time as the process image is updated.
Basic communication
These communication services allow data to be transferred via an MPI subnet or,
within a station, via the C bus, on all S7-300/400 CPUs. In the user program,
system functions (SFCs), are called such as X_SEND at the transmitting end and
X_RCV at the receiving end.
The maximum quantity of useful data that can be transferred in a call is 76 bytes.
When the system functions are called, a connection to the communication partner
is dynamically established and disconnected again on completion of the transfer;
there is therefore no need to configure a connection.
Extended communication
These communication services can be used for all S7-400 CPUs. Up to 64 KB of
data can be transferred over different subnets (MPI, C bus, PROFIBUS and
Industrial Ethernet).
The programming interface is available in the form of system function blocks
(SFBs). These SFBs are only integrated in the operating system in the CPUs of
S7-400, they are not available with S7-300.
Apart from functions for data transfer, this communications service also offers
control functions such as START and STOP of the partner PLC.
Data are exchanged via configured connections (connection table). The
configured connections are established when the station powers up and remain
permanently established.
Extended S7 communication
SITRAIN
IK-PBSYS / S7 Connections Page 3 03/2007
Siemens AG 2007 - Subject to change without prior notice
Overview The SFB blocks are available on all S7-400 CPUs and are used for data
communication with S7/M7-300/400 CPUs. Using these blocks, up to 64 KB of
data can be transferred via different subnets (MPI, PROFIBUS and Industrial
Ethernet).
Connections The communications SFBs offer you the possibility of secure data communication
via configured S7 connections. These connections are configured with the help of
the NETPRO tool that is transparently integrated into the SIMATIC manager.
The configured connections are set up when the stations are restarted and
remain intact even when the station switches to STOP mode. On a warm start,
the connections are not set up again.
Communication is only possible between stations in the same S7 project. The
communication partners must be connected to a common MPI, PROFIBUS or
Industrial Ethernet subnet.
SFBs Special S7 blocks of type SFB form the interface for S7 communication to the
user program in the SIMATIC S7. The SFBs are based on the ISO/IEC 61131-5
standard and offer the user a uniform interface.
Connections must be configured for communication. The corresponding
connection number (ID number) references the assigned nodes and the
transmission medium. The ID number is transferred to the block in the SFB call
as block parameter "ID".
Useful data The quantity of useful data depends on the block used and the partner:
PUT/GET 160 bytes to CPU 31X and 180 bytes to CPU 31XC
400 bytes to S7-400/M7
USEND/URCV up to 440 bytes
BSEND/BRCV up to 64 KB
SITRAIN
IK-PBSYS / S7 Connections Page 4 03/2007
Siemens AG 2007 - Subject to change without prior notice
SFBs: S7- 400 The SFBs for S7 communication are integrated into the operating system of the
S7-400 CPU as system function blocks.
The user will find the block headers in the Standard Library in the S7 program
container System Function Blocks for integration in the user program.
SFBs: S7 - 300 The S7-300 contains no SFBs for extended communication. The operating
system of the S7-300 CPUs however does support the server functions of the
one-way S7 communication services. Data can, for example, be read from a CPU
3xx with the help of the GET block from a CPU 4xx or written to it using PUT.
SFBs for The SFBs for data exchange are used for data communication between two
data exchange partners with communications capability (S7/M7 CPUs, M7 FMs):
GET/PUT (one-way reading and writing of variables)
USEND/URCV (two-way, uncoordinated transmitting/receiving)
BSEND/BRCV (two-way, blocked transmitting/receiving)
SFBs for program The SFBs for program management are used to control and evaluate the
management operating states of the partner or the connections.
START/STOP/RESUME (control functions)
STATUS/USTATUS (monitoring functions)
CONTROL (connection status)
Libraries
SITRAIN
IK-PBSYS / S7 Connections Page 5 03/2007
Siemens AG 2007 - Subject to change without prior notice
No connection S7-300/400
configured
Logical
Connection S7 connection
S7-400 configured (one-way or two-way) CPU CP
MPI=2
CPU
CP Local ID
1 PROFIBUS = 3
MPI=2
Physical connection
PROFIBUS = 2 via PROFIBUS
1
Operating
SFB: system of
- GET the CPU
- PUT
- STOP
- START
- STATUS
SITRAIN
IK-PBSYS / S7 Connections Page 6 03/2007
Siemens AG 2007 - Subject to change without prior notice
One-way S7 connections
It is only possible to call one-way communication services via one-way
connections. For one-way communication services, an appropriate SFB/FB call is
only necessary on the client side. On the other communication partner (server),
the service is provided completely by the operating system. There is no need for
any programming by the user on the server side.
One-way S7 connections are always established by the client on power-up.
"One-way" SFBs The one-way communication services include the following SFBs:
GET, PUT
STOP, START, RESUME
STATUS, USTATUS
In the case of one-way communication services, the user program on the server
side is not informed when new data have been transferred.
AS2 without
configured connection
SITRAIN
IK-PBSYS / S7 Connections Page 7 03/2007
Siemens AG 2007 - Subject to change without prior notice
Notes
SITRAIN
IK-PBSYS / S7 Connections Page 8 03/2007
Siemens AG 2007 - Subject to change without prior notice
Address details The Address Details tab serves as the object properties dialog for the S7
connection.
End point The following is displayed:
The local end point of the connection (station name/module name)
The connection partner for the connection (station name/module name)
Rack/slot For SIMATIC S7 stations, the number of the rack and the number of the slot is
displayed.
Note:
If the S7 connection is configured as a partner with the S7-300 CPU and is routed
via an S7-300 CP (downloadable S7 communication), the CP is displayed as the
endpoint. When you create an S7 connection to an unspecified connection
partner of type S7-300 CPU/CP, you also need to specify the rack/slot of the
CPas the end point!
SITRAIN
IK-PBSYS / S7 Connections Page 9 03/2007
Siemens AG 2007 - Subject to change without prior notice
Get block You can read data from a remote CPU using SFB/FB 14 "GET".
S7-300: The read process takes place after a positive edge on REQ. With every positive
edge on REQ, parameters ID, ADDR_1 and RD_1 are loaded. On completion of a
task, you can assign new values to the parameters ID, ADDR_1 and RD_1.
S7-400: The SFB is started with a positive edge at control input REQ. The relevant
pointers to the areas to be read out (ADDR_i) are sent to the partner CPU.
The remote partner returns the data. The received data are copied to the
configured receive areas (RD_i) on the next SFB/FB call.
You need to ensure that the areas defined via parameters ADDR_i and RD_i
match in terms of number, length and data type.
The completion of the job is indicated by a 1 at the status parameter NDR.
Another read process cannot be activated until the previous one has been
completed.
The remote CPU can be in RUN or STOP state.
If access problems occurred when the data was being read, or the data type
check resulted in an error, errors and warnings are output via ERROR and
STATUS.
"AS2"
No connection
"AS1" configured
No connection Logical one-way
S7 connection
S7-400 configured CPU CP
MPI=2
CPU
CP Local ID
1 PROFIBUS = 11
MPI=2
Physical connection
PROFIBUS = 9 via PROFIBUS
1
Operating
SFB / FB: system of
- GET read the CPU
- PUT write
SITRAIN
IK-PBSYS / S7 Connections Page 10 03/2007
Siemens AG 2007 - Subject to change without prior notice
Objective : To configure a one-way S7 connection and exchange data using library blocks
SFB/FB "GET, PUT"
Procedure: 1.Create two S7 projects ( AS1 and AS2 ) with the S7 stations involved in the
data exchange
2.Transfer the hardware of the passive station AS2 to the CPU
3.Set up an unspecified S7 connection in the active station
4.Transfer the hardware and the connection to this active CPU
5.Write an S7 program for this CPU with which you will read / write data from / to
the passive station.
Two-way S7 connections
Connection S7-300/400
configured
Logical
Connection S7 connection
S7-400 configured (one-way or two-way) CPU
MPI=2
CPU
1 Local ID
PROFIBUS = 3
MPI=2
Physical connection
PROFIBUS = 2 via PROFIBUS
2 1
SFB: SFBs
- USEND - URCV
- URCV - USEND
- BSEND - BRCV
- BRCV - BSEND
SITRAIN
IK-PBSYS / S7 Connections Page 11 03/2007
Siemens AG 2007 - Subject to change without prior notice
Two-way S7 connections
With two-way connections, a connection ID is assigned at each end that can be
used by the two ends to reference the connection.
Each partner can use this to start a communication service as the initiator (client).
Both one-way (PUT, GET, etc.) and two-way communication services can be
handled via two-way connections.
With two-way S7 connections, it can be specified on configuration which node
initiates connection set-up.
Insert an S7 connection
Select an S7 connection
SITRAIN
IK-PBSYS / S7 Connections Page 12 03/2007
Siemens AG 2007 - Subject to change without prior notice
Notes
Properties of an S7 connection
S7 CPU slot
Address details
SITRAIN
IK-PBSYS / S7 Connections Page 13 03/2007
Siemens AG 2007 - Subject to change without prior notice
Connection Path In this part of the dialog field, you are shown which route the connection takes
from the local partner to the connection partner. You can select the route in
accordance with the modules with communications capability and their
networking.
Example: The local partner is a CPU that is a node on an MPI subnet and a
PROFIBUS subnet; your connection partner is a CPU that is also a node on the
same MPI and PROFIBUS subnet. In this case, you can select whether the
connection should be "routed" via the MPI subnet or the PROFIBUS subnet.
Address details Click the "Address details" button to access the dialog field for displaying and
setting the addressing information for the local partner and the connection partner
of an S7 connection.
One-way When the "One-way" box is activated, only one-way communication blocks can
be used in the user program of an S7 CPU with this connection (SFB 14
"PUT"/SFB 15 "GET"). One-way means that the connection partner is the server
for this connection and cannot actively send or receive.
Two-way Two-way communication blocks (block pairs) cannot be used with one-way
connections; such as SFBs 8 and 9 ("USEND" and "URCV"), SFBs 12 and 13
("BSEND" and "BRCV") or SFB 23 ("USTATUS").
Load
in current project
SITRAIN
IK-PBSYS / S7 Connections Page 14 03/2007
Siemens AG 2007 - Subject to change without prior notice
Compile and Before you can download the connection data into the individual nodes
save (download to the PLC), the connection table must be saved in NETPRO and
compiled to form connection data. The menu command File -> Save and
compile is used for this purpose.
You can select one of the following alternatives from the box:
Compile and check everything: This saves all the connections and checks them
for consistency within a project. All connections are compiled and stored in the
system data. If any inconsistencies have arisen, a dialog field appears in which
the errors are indicated.
Select "Compile and check everything" if you have changed the network
configuration (changed node addresses, deleted nodes or subnets). In this case,
connections may no longer exist and "Compile and check everything" will provide
this information.
Compile changes only: This saves all the connections within the project and
compiles the connections that have changed since the last "save and compile".
When you finish configuring the connection, you are asked whether you want to
save the changed data or not. After confirming with "Yes", the changed
connection data must be saved and compiled to create system data.
Load When the connection table is saved and compiled, connection data are generated
and entered in the system data of the relevant modules. The system data are
downloaded into the modules through the MPI, PROFIBUS or Industrial Ethernet
interface of the modules.
Connection test
Connection is established
SITRAIN
IK-PBSYS / S7 Connections Page 15 03/2007
Siemens AG 2007 - Subject to change without prior notice
Connection status The "Connection status" column of the connection table is only displayed
if the "Connection status" function was activated.
To activate this function, use the menu command PLC Activateconnection
status.
. For each connection status (e.g. "being set up"), the menu command Edit
Object properties can be used to call a dialog field containing detailed information
on the connection status.
Note The "Connection status" column has a yellow background when the connection is
only available online, i.e., is not available in the project offline. One reason for this
can be that this connection was downloaded into the module without it being
saved beforehand in the project.
SITRAIN
IK-PBSYS / S7 Connections Page 16 03/2007
Siemens AG 2007 - Subject to change without prior notice
Notes
SITRAIN
IK-PBSYS / S7 Connections Page 17 03/2007
Siemens AG 2007 - Subject to change without prior notice
Notes
MPI=2
CPU
CP Local ID
1 PROFIBUS = 11
MPI=2
Physical connection
PROFIBUS = 9 via PROFIBUS
2 1
SFB/FB: SFBs/FB
- BSEND - BRCV
- BRCV - BSEND
SITRAIN
IK-PBSYS / S7 Connections Page 18 03/2007
Siemens AG 2007 - Subject to change without prior notice
Procedure 1.Create two S7 projects ( AS1 and AS2 ) with the S7 stations involved in
the data exchange. Please find the hardware constellation on your
training device.
2.Transfer the hardware to your station AS X.
3.Create an unspecified S7 connection in your station using the procedure
described in the theory section.
4.To obtain the correct settings for the connection addresses, discuss and
coordinate the address settings with your partner group.
5.Transfer the hardware and the connection to your CPU
6.Write an S7 program for this CPU with which you will read / write data from / to
the "other" station.