Você está na página 1de 18

Automation and Drives

S7 communication services
Global data
Global data

Cyclic and/or program-controlled OS


OS of
OS of OSofof
the CPU via MPI or C bus the
theCPU
CPU
the CPU

PG and HMI functions


PG and HMI functions

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

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 1 S7 Connections
Automation and Drives

S7 communication services with S7-300/400


Global data
Global data

Cyclic and/or program-controlled OS


OS of
OS of OSofof
the CPU via MPI or C bus the
theCPU
CPU
the CPU

PG and HMI functions


PG and HMI functions

OS of Controlled via OS
OS of
the CPU via MPI, C bus, PROFIBUS and
the CPU
Industrial Ethernet

Basic communication without Extended


Basic communication without Extendedcommunication
communicationvia
via
connection configuration configured
connection configuration configuredconnections
connections
Program
controlled via
SFC SFC SFB
SFB SFB
SFC MPI or C bus SFC SFB

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.

PG and HMI functions


System services such as PG and HMI functions are ultimately based on extended
S7 communication. An unreserved connection is required on the connection
partner (S7-CPU, M7-CPU, M7-FM, etc.) in order to connect a PG or HMI device
to an S7-300/S7-400 system.

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.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 2 S7 Connections
Automation and Drives

Extended S7 communication

Extended communication via configured connections


Extended communication via configured connections
Program-controlled via
SFB
SFB SFB
MPI, C bus, PROFIBUS SFB
or Industrial Ethernet

z Data exchange via MPI, C bus, PROFIBUS or Industrial Ethernet

z Configuration of the connections using the connection table

z The connections are set up on restart and remain


permanently intact (even in the STOP state)

z Useful data size up to 64 KB

z Includes communication services for controlling (stop, start) the


communication partner

z Data can also be read and written from/to an S7-300 (GET/PUT)

z Various tasks can be processed over a connection

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 training for IK-PBSYS


Automation and Industrial Solutions Page 3 S7 Connections
Automation and Drives

Block overview for SFB/FB communication


SFB/SFC NAME Comm. type Brief description
Send block for sending data to
SFB8/FB8 USEND Two-way
the URCV block (client)
Receive block for receiving data
SFB9/FB9 URCV Two-way
of the USEND block
Send block for sending large data blocks
SFB12/FB12 BSEND Two-way
to the BRCV block (up to 64 KB)
Receive block for receiving large
SFB13/FB13 BRCV Two-way
data blocks (up to 64 KB)
SFB14/FB14 GET One-way Read data from partner PLC
SFB15/FB15 PUT One-way Write data to partner PLC
SFB 16 PRINT One-way Send data to remote printer
SFB 19 START One-way Restart communication partner
SFB 20 STOP One-way Set partner to Stop
SFB 21 RESUME One-way Restart communication partner
Request status of partner
SFB 22 STATUS One-way
(RUN, STOP, Starting, Stopping)
SFB 23 USTATUS One-way Receive status messages of the partner
Request the internal status of an S7 connection
SFC 62 CONTROL ---
+ SFB

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.

Function classes The blocks can be grouped into 4 function classes:


Transmit and receive functions
Control functions
Monitoring functions
Connection status

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)

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 4 S7 Connections
Automation and Drives

Libraries

SITRAIN
IK-PBSYS / S7 Connections Page 5 03/2007
Siemens AG 2007 - Subject to change without prior notice

Classification For S7 communication, connections must be configured.


Integral communications functions are called in the user
program with SFBs/FBs or an SFC/FC.
These blocks fall into the following categories:
SFBs/FBs for data transfer
SFBs for changing operating mode
SFBs for scanning operating mode
SFC/FC for scanning connections

Availability of the S7-300/400 communication blocks


You will find the blocks for the S7-400 in the "Standard library".
You will find the loadable blocks for the S7-300 in the
"SIMATIC_NET_CP" library.
To use S7-300 blocks, you will need a SIMATIC NET CP of the
S7-300 spectrum.

SFBs/FBs for data transfer


Communication SFBs/FBs for data communication are used to transfer data
between two communications partners. Depending on whether there is a
communication SFB/FB on the local module only or on both the local
and the remote module, data communication is described as one-way or
two-way.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 5 S7 Connections
Automation and Drives

One-way communication services via


S7 connections

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

Overview S7 connections have to be configured to enable the SFBs in the respective


communication partners to communicate with each other.
S7 connections can be configured for MPI, Industrial Ethernet and PROFIBUS
networks.

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.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 6 S7 Connections
Automation and Drives

Insert connection into the "Active station"

AS2 without
configured connection

AS2 with configured


connection

SITRAIN
IK-PBSYS / S7 Connections Page 7 03/2007
Siemens AG 2007 - Subject to change without prior notice

Notes

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 7 S7 Connections
Automation and Drives

Assignment of connection parameters

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!

Resource When you configure a one-way S7 connection to an unspecified connection


partner (e.g. to an S7-300 station), you select connection resource "03" (hex)
from the drop-down list for the unspecified partner. Then there is no need to
configure the connection partner.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 8 S7 Connections
Automation and Drives

User program in the "active" CPU

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.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 9 S7 Connections
Automation and Drives

Exercise 1 : One-way S7 connection

"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.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 10 S7 Connections
Automation and Drives

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.

"Two-way" SFBs The two-way SFBs include the following blocks:


BSEND = sender (client) ==> BRCV receiver (server)
USEND = sender (client) ==> URCV receiver (server)
These blocks must always be used as a function block pair. Two-way
communication functions must be used whenever data transfer is used as a
means of further processing data.
On the one hand, the receiver (server) can use the block call URCV or BRCV to
determine when it is ready to receive new data from the sender for further
processing. On the other hand, by scanning the SFB parameter #NDR (New Data
Received), the receiver can find out whether new data have been received.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 11 S7 Connections
Automation and Drives

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

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 12 S7 Connections
Automation and Drives

Properties of an S7 connection

Active connection setup

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.

Establish an active connection


Before data transfer can actually take place, the connection must be established
(initialized). The connection must be established by one of the two nodes. The
connection is established by the node in the background. When a connection is
established, the "Establish an active connection" box must always be checked for
the local end; "Establish an active connection" will then be automatically
deactivated at the partner end.

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").

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 13 S7 Connections
Automation and Drives

Compile and download the configuration data

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.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 14 S7 Connections
Automation and Drives

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 training for IK-PBSYS


Automation and Industrial Solutions Page 15 S7 Connections
Automation and Drives

Example: S7 program in the station AS1

SITRAIN
IK-PBSYS / S7 Connections Page 16 03/2007
Siemens AG 2007 - Subject to change without prior notice

Notes

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 16 S7 Connections
Automation and Drives

Example: S7 program in the station AS2

SITRAIN
IK-PBSYS / S7 Connections Page 17 03/2007
Siemens AG 2007 - Subject to change without prior notice

Notes

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 17 S7 Connections
Automation and Drives

Exercise 2 : Two-way S7 connection


"AS2"
Unspecified
"AS1" connection
Unspecified configured
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

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

Objective: Your task is to configure a cross-project data exchange using


connection type "S7 CONNECTION". Data must be transferred
from station "AS1" to station "AS2" and vice versa.

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.

SITRAIN training for IK-PBSYS


Automation and Industrial Solutions Page 18 S7 Connections

Você também pode gostar