Documente Academic
Documente Profesional
Documente Cultură
http://support.automation.siemens.com/WW/view/en/67196808
This entry is from the Siemens Industry Online Support. The general terms of use
(http://www.siemens.com/terms_of_use) apply.
Security
information
Siemens provides products and solutions with industrial security functions that
support the secure operation of plants, solutions, machines, equipment and/or
networks. They are important components in a holistic industrial security
concept. With this in mind, Siemens products and solutions undergo continuous
development. Siemens recommends strongly that you regularly check for
product updates.
For the secure operation of Siemens products and solutions, it is necessary to
take suitable preventive action (e.g. cell protection concept) and integrate each
component into a holistic, state-of-the-art industrial security concept. Third-party
products that may be in use should also be considered. For more information
about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a productspecific newsletter. For more information, visit
http://support.automation.siemens.com.
Table of contents
1
Introduction ........................................................................................................ 3
OB100 .................................................................................................. 5
OB1 ...................................................................................................... 5
FC100 "FC_SEND" .............................................................................. 6
Inputs and Outputs of the TSEND_C Instruction ................................. 7
Start Send Job ...................................................................................... 9
Establish and Maintain the Communication Connection ...................... 9
LEN..................................................................................................... 10
Restart the TSEND_C Instruction ...................................................... 10
Send Area .......................................................................................... 10
Reset "DB_FC_SEND".REQ .............................................................. 10
Save STATUS of the TSEND_C Instruction ...................................... 10
FC200 "FC_RECV" ............................................................................ 12
Inputs and Outputs of the TRCV_C Instruction .................................. 13
Enable Receiving of Data ................................................................... 15
Establish and Maintain the Communication Connection .................... 15
LEN..................................................................................................... 15
Restart the TRCV_C Instruction ......................................................... 16
Receive Area ...................................................................................... 16
Save STATUS of the TRCV_C Instruction ......................................... 16
Save Length of the Data Received .................................................... 16
Connection Parameters...................................................................... 17
Define Connection Parameters .......................................................... 17
Structure of the DB2 "CONNECT" Data Block ................................... 18
1 Introduction
Introduction
You can use the open communication by means of the TSEND_C and TRCV_C
instructions for data exchange over the integrated PROFINET interface of the S71200 CPU.
In STEP 7 V11 SP2 (TIA Portal) you will find the TSEND_C and TRCV_C
instructions in the "Instructions" task card in the "Communication > Open User
Communication" palette.
Table 1-1
Instruction
Description
TSEND_C
TRCV_C
Symbolic name
Description
OB100
Startup
Startup OB
OB1
Main
FC100
FC_SEND
FC200
FC_RECV
DB110
SEND_DATA
DB210
RECV_DATA
1 Introduction
Block
Symbolic name
Description
DB_FC_SEND
DB200
DB-FC_RECV
DB100
2 Sample Program
Sample Program
2.1
OB100
The OB100 is a startup OB and is run when the S7-1200 CPU is restarted (warm
start). The ISO-on-TCP connection is established in this OB with the marker M0.1
"TRUE" and job to receive data is enabled.
2.2
OB1
OB1 is called cyclically. The functions FC100 "FC_SEND" and FC200 "FC_RECV"
are called in OB1 with the marker M0.1 "TRUE" as EN parameter.
Figure 2-1
Figure 2-2
2 Sample Program
2.3
FC100 "FC_SEND"
The FC100 "FC_SEND" function calls the TSEND_C instruction internally to
establish a communication connection over ISO-on-TCP or UDP and send data
through the communication connection.
The following figure shows the call of the TSEND_C instruction.
Figure 2-3
2 Sample Program
2.3.1
Inputs
The table below gives an overview of
the inputs of the TSEND_C instruction and
the variables assigned to the inputs.
Table 2-1
Input
Data type
Variable
Description
BOOL
DB100.DBX0.0
"DB_FC_SEND".REQ
CONT
BOOL
DB100.DBX0.1
"DB_FC_SEND".CONT
Controls the
communication
connection:
0: Disconnects the
communication
connection.
1: Establishes and
maintains the
communication
connection.
If CONT=1, the
TSEND_C instruction
configures and
establishes a
communication
connection. Once the
connection has been
configured and
established, it is
maintained and
monitored automatically
by the S7--1200 CPU.
LEN
UINT
DB100.DBW2
"DB_FC_SEND".LEN
Maximum number of
bytes that can be sent
with the job.
Note
If you use purely
symbolic values at the
DATA parameter, the
LEN parameter must
have the value 0.
CONNECT
TCON_Param
DB2 "CONNECT"
REQ
2 Sample Program
Input
Data type
Variable
Description
DATA
Version
DB110.DBX0.0 BYTE 10
COM_RST
BOOL
DB100.DBX0.2
"DB_FC_SEND".COM_RST
Outputs
The table below gives an overview of
the outputs of the TSEND_C instruction and
Data type
Variable
Description
DONE
BOOL
DB100.DBX4.0
"DB_FC_SEND".DONE
BUSY
BOOL
DB100.DBX4.1
"DB_FC_SEND".BUSY
ERROR
BOOL
DB100.DBX4.2
"DB_FC_SEND".ERROR
STATUS
WORD
DB100.DBW6
"DB_FC_SEND".STATUS
2 Sample Program
2.3.2
Figure 2-4
2.3.3
2 Sample Program
2.3.4
LEN
The maximum number of bytes that can be transferred with a send job is stored in
the "DB_FC_SEND".LEN variable. In this sample program a maximum of 10 bytes
of data are transferred with one send job.
Figure 2-6
2.3.5
2.3.6
Send Area
In this sample program, the send area below is defined:
p#DB110.DBX0.0 BYTE 10.
This means that the send area is 10 bytes long and the data to be sent is
contained in data block DB110 starting at address 0.
2.3.7
Reset "DB_FC_SEND".REQ
If there is no send job running, the BUSY output of the TSEND_C instruction has
the value "0" and "DB_FC_SEND".REQ is reset to the value "0". This means that a
new send job can only be triggered once the previous job has been completed.
Figure 2-7
2.3.8
10
2 Sample Program
Figure 2-8
Figure 2-9
11
2 Sample Program
2.4
FC200 "FC_RECV"
The FC200 "FC_RECV" function calls the TRCV_C instruction to establish a
communication connection over ISO-on-TCP, TCP or UDP and receive data
through the communication connection.
The following figure shows the call of the TRCV_C instruction.
Figure 2-10
12
2 Sample Program
2.4.1
Inputs
The table below gives an overview of
the inputs of the TRCV_C instruction and
the variables assigned to the inputs.
Table 2-3
Input
Data type
Variable
Description
BOOL
DB200.DBX0.0
"DB_FC_RECV".EN_R
CONT
BOOL
DB200.DBX0.1
"DB_FC_RECV".CONT
Controls the
communication
connection:
0: Disconnects the
communication
connection.
1: Establishes and
maintains the
communication
connection.
If CONT=1, the
TRCV_C instruction
configures and
establishes a
communication
connection. Once the
connection has been
configured and
established, it is
maintained and
monitored
automatically by the
S7--1200 CPU.
LEN
UINT
DB200.DBW2
"DB_FC_RECV".LEN
Maximum number of
bytes that can be sent
with the job.
Note
If you use purely
symbolic values at the
DATA parameter, the
LEN parameter must
have the value 0.
CONNECT
TCON_Param
DB2 "CONNECT"
Pointer to the
connection description
used to establish the
communication
connection.
Detailed information
about the configuration
of the connection
description at the
CONNECT parameter
is available in section
2.5.
EN_R
13
2 Sample Program
Input
Data type
Variable
Description
DATA
Version
DB210.DBX0.0 BYTE 10
COM_RST
BOOL
DB200.DBX0.2
"DB_FC_RECV".COM_RST
Restarts the
instruction:
0: Irrelevant.
1: Complete restart of
the instruction which
clears down the
existing
communication
connection and
establishes a new
communication
connection.
Outputs
Data type
Variable
Description
DONE
BOOL
DB200.DBX4.0
"DB_FC_RECV".DONE
BUSY
BOOL
DB200.DBX4.1
"DB_FC_RECV".BUSY
ERROR
BOOL
DB200.DBX4.2
"DB_FC_RECV".ERROR
STATUS
WORD
DB200.DBW6
"DB_FC_RECV".STATUS
Status of the
instruction
RCVD_LEN
UINT
DB200.DBW10
"DB_FC_RECV".RCVD_LEN
Volume of data
actually received in
bytes.
14
2 Sample Program
2.4.2
2.4.3
The "DB_FC_RECV".CONT variable is set permanently to the value "1" when the
S7-1200 CPU is restarted (warm restart). The CONT input of the TRCV_C
instruction is set permanently to the value "1" by means of the
"DB_FC_RECV".CONT variable in order to establish and maintain the
communication connection.
If the S7-1200 CPU goes into STOP mode, the existing communication connection
is aborted and the configured communication connection is removed. You must
once again execute the TRCV_C instruction to reconfigure and re-establish the
communication connection.
Figure 2-12
2.4.4
LEN
The length of the data received is stored in the "DB_FC_RECV".LEN variable. In
this sample program a maximum of 10 bytes of data are received with one job.
Figure 2-13
15
2 Sample Program
2.4.5
2.4.6
Receive Area
In this sample program, the receive area below is defined:
p#DB210.DBX0.0 BYTE 10.
This means that the receive area is 10 bytes long and the data received is
contained in data block DB210 starting at address 0.
2.4.7
Figure 2-14
Figure 2-15
2.4.8
16
2 Sample Program
Figure 2-16
2.5
Connection Parameters
2.5.1
You define the connection parameters in the inspector window "Properties >
Configuration > Connection parameters".
Figure 2-17
17
2 Sample Program
No.
Action
1.
2.
3.
4.
5.
6.
7.
2.5.2
Note
18
2 Sample Program
Table 2-6
Byte
Parameter
Data type
Value
Description
BLOCK_LENGTH
UINT
64
2 and 3
ID
CONN_OUC
Reference to this
connection
Range of values: 0 to 4095
Note
You must specify the value
of this parameter at the
"ID" input of the TSEND_C
and TRCV_C instructions.
CONNECTION_TYPE
USINT
18
Connection type
17: TCP
18: ISO-on-TCP
19: UDP
Note
In this example,
communication is over an
ISO-on-TCP connection.
ACTIVE_EST
BOOL
TRUE
LOCAL_DEVICE_ID
USINT
0 and 1
51339682
7
LOCAL_TSAP_ID_LEN
USINT
Length of the
LOCAL_TSAP_ID
parameter used in bytes:
2 to 16 if connection
type = 18 (ISO-onTCP)
0 to 2 if connection
type = 17 (TCP)
2 if connection type =
19 (UDP)
REM_SUBNET_ID_LEN
USINT
19
2 Sample Program
Byte
Parameter
Data type
Value
Description
REM_STADDR_LEN
USINT
10
REM_TSAP_ID_LEN
USINT
Length of the
REM_TSAP_ID parameter
used in bytes:
2 to 16 if connection
type = 18 (ISO-onTCP)
0 to 2 if connection
type = 17 (TCP)
2 if connection type =
19 (UDP)
11
NEXT_STADDR_LEN
USINT
12 to 27
LOCAL_TSAP_ID
ARRAY [1..16]
of BYTE
B#16#49
B#16#53
B#16#4F
B#16#2D
B#16#31
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
28 to 33
REM_SUBNET_ID
ARRAY [1..6]
of USINT
34 to 39
REM_STADDR
ARRAY [1..6]
of USINT
REM_STADDR[1]
= 172
REM_STADDR[2]
= 16
REM_STADDR[3]
= 43
REM_STADDR[4]
= 30
REM_STADDR[5]
= irrelevant
REM_STADDR[6]
= irrelevant
20
2 Sample Program
Byte
Parameter
Data type
Value
Description
REM_TSAP_ID
ARRAY [1..16]
of BYTE
B#16#49
B#16#53
B#16#4F
B#16#2D
B#16#31
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
B#16#0
Partner address
component of the
connection
56 to 61
NEXT_STADDR
ARRAY [1..6]
of BYTE
62 to 63
SPARE
WORD
W#16#0000
Reserved
40 to 55
21