Beruflich Dokumente
Kultur Dokumente
FB66 "TDISCON" in order to use the ISO-on-TCP protocol for data exchange by way of the integrated
PROFINET interface of a CPU or by way of the CP443-1 Advanced?
Display part number
Description
You can use the open communication over Industrial Ethernet for data exchange by way of the
integrated PROFINET interface of a CPU or by way of CP4431 Advanced, for example. The
protocols below are supported for this:
TCP
ISO-on-TCP
UDP
The following communication blocks are available for open communication over Industrial Ethernet
using ISO-on-TCP Protocol:
These communication blocks are available in the Standard Library -> Communication Blocks.
Copy the latest versions of the above-mentioned communication blocks from the standard library
into your user program and then call them in your user program.
The connection parameters for establishing the ISO-on-TCP connection are saved in a data
structure. In this example, the data structure UDT65 "TCON_PAR" is used, which is parameterized
by the user. The ISO-on-TCP connection is not configured in NetPro.
Description of the sample program
The S7 program contains the call of the FB65 "TCON" and the data structure UDT65 "TCON_PAR"
with the connection parameters for establishing the ISO-on-TCP connection. The S7 program also
includes the call of the communication blocks FB63 "TSEND" and FB64 "TRECV" from the Standard
Library -> Communication Blocks. The FB63 "TSEND" is for sending data to an S7 station or to an
S5 station, to a PC station or to a third-party system. The FB64 "TRECV" is for receiving data from
another S7 station or an S5 station, from a PC station or from a third-party system.
First create the hardware configuration for your S7-300 station. Configure Marker byte 10 as clock
marker. The send request is triggered by this clock marker. Save and compile the hardware
configuration of your S7-300 station and load it into the CPU.
The STEP 7 program consists of blocks OB100, OB1, FB400, DB400, FB420, UDT65 and FB63,
FB64, FB65 and FB66.
OB100
The OB100 is a restart OB and is run when the CPU is restarted (warm start). In this OB the first
communication trigger is enabled with marker M0.3.
OB1
OB1 is called cyclically. The FB400 is called in OB1 with the instance data block DB400 and marker
M0.3 as INIT_COM parameter. The marker M0.3 is reset in OB1 after the FB400 has been called.
Fig. 01
FB400
The FB400 is called cyclically in OB1. The following function blocks are called in FB400:
FB420 "SET_ISO_PARAM"
FB65 "TCON",
FB63 "TSEND",
FB64 "TRECV",
FB66 "TDISCON"
Fig. 02
Using the input parameters of the function FB420 "SET_ISO_PARAM" you define the local and
remote parameters of the ISO-on-TCP connection.
Input parameters
Data type
Description
ID
Word
Connection number
DEV_ID
Byte
ACTIVE
Bool
TSAP
Struct
IP_ADDR1
Int
IP_ADDR2
Int
IP_ADDR3
Int
IP_ADDR4
Int
Table 01
The input parameter "TSAP" of the Struct data type is structured as follows:
Parameter
Data type
Description
LOC_RACK_SLOT
Byte
LOC_TSAP
String
CP_RACK_SLOT
Byte
REM_RACK_SLOT
Byte
REM_TSAP
String
communication partner
Table 02
The CPUs below support the ASCII format for the TSAPs.
TCP-1
TCP-1
E0.02.54.43.50.2D.31
54.43.50.2D.31
Table 03
In the interface parameterization of FB400, you change the value of the local and remote TSAP in
accordance with your configuration (see Fig. 04). In the "T_TSAP" structure, for the "LOC_TSAP"
and "REM_TSAP" parameters you enter the local and remote TSAP of your configuration as initial
value.
If the first two bytes of the local TSAP in the CPU are to be defined with the values 0xE0 and 0x02,
then you change the interface parameters of FB400. In the "T_TSAP" structure, you define the initial
value "B#16#2" for the "LOC_RACK_SLOT" parameter.
If the first two bytes of the remote TSAP are to be defined with the values 0xE0 and 0x02, then you
change the interface parameters of FB400. In the "T_TSAP" structure, you define the initial value
"B#16#2" for the "LOC_RACK_SLOT" parameter.
Fig. 03
Define connection number
You can change the connection number separately. Change the connection number in network 2 of
FB400 in accordance with your configuration. The connection number is stored in a static tag and so
in the instance data block DB400.
The connection number "1" is defined in this example.
Fig. 04
Connection setup
Establishing a connection is started by a positive edge in the "REQ" input parameter of the FB65
"TCON". The data structure UDT65 "TCON_PAR" with the connection parameterization is
incorporated in the instance data block of the FB400.
On the input parameter "CONNECT" of the FB65 "TCON", the memory area is specified that
contains the connection parameterization.
The connection is set up at system start and remains until it is disabled with FB66 "TDISCON", or
the CPU goes into STOP mode, or the power supply is switched off.
Fig. 05
The send request is triggered by a positive edge at the input parameter "REQ" of the FB63
"TSEND". The send job trigger is controlled by clock marker M10.6 and the "C1.SEND_BUSY" tag. If
the send job is running, "C1.SEND_BUSY" is set. It is then not possible to trigger a new send
request.
You specify the memory area that contains the data to be sent at the input parameter "DATA".
You enter the number of bytes to be sent at the input parameter "LEN".
The output parameters "DONE", "ERROR" and "STATUS" are required for job evaluation.
Fig. 06
If the send job is successfully completed, "C1.SEND_BUSY" is reset. A new send job can now be
triggered.
If the send job is completed with an error, then "C1.SEND_BUSY" is likewise reset and the value of
the output parameter "STATUS" of FB63 is saved for error analysis.
Fig. 07
Fig. 08
The data can be received as soon as the ISO-on-TCP connection is established.
At the input parameters "DATA" and "LEN" you specify the address and length of the data area
where the received data is saved.
Fig. 09
The output parameter "NDR" is for showing that new data has been received. The "RECV_LEN"
output parameter indicates the length of the data received.
If the data is received successfully, then the value of the "RECV_LEN" output parameter is saved.
Fig. 10
If the data is not received successfully, then the value of the "STATUS" output parameter is saved
and evaluated.
Fig. 11
You can clear down the ISO-on-TCP connection with FB66 "TDISCON". You start the request to
clear down the ISO-on-TCP connection with a positive edge on the "REQ" input parameter of FB66
"TDISCON".
Sample_open_ISO.zip ( 52 KB )