Before data can be transferred with open user communication, a connection must be established to the partner device (in the case of TCP native and ISO-on-TCP) or Fig. 17.11 Principle of open user communication
PLC station PLC station
Ethernet subnet
Data transfer with the TCP native and ISO-on-TCP protocols
Data transfer with the TCP native and ISO-on-TCP protocols
Establish and clear connection Establish and clear connection Operating
system Operating
system
Re- sources Re-
sources
TSEND TRCV TSEND
TRCV TCON TDISCON
Data
Data TCON_PAR
Data
Data
TCON_PAR
TADD_PAR TADD_PAR
Open user communication
Data transfer with the UDP protocol
Data transfer with the UDP protocol TUSEND
TURCV
TUSEND TURCV
TCON TDISCON
to the communication layer of the operating system (in the case of UDP). You can use the following standard blocks for this purpose:
b TCON (FB 65)
Establish connection to the communication partner or the communication layer of the operating system
b TDISCON (FB 66)
Terminate communication connection
The communication functions can be found in the program elements catalog under Communication > Open user communication. The graphic representation of the block calls is shown in Fig. 17.12.
Fig. 17.12 Graphic representation of blocks for open user communication TCON
Instance data
TSEND Instance data
TUSEND Instance data
TDISCON Instance data
TRCV Instance data
TURCV Instance data FB 65
Establish connection
FB 63
Send data with logic connection
FB 67
Send data with UDP
FB 66
Terminate connection
FB 64
Receive data with logic connection
FB 68
Receive data with UDP Standard blocks for open user communication
REQ
REQ
REQ
REQ ID
EN_R
EN_R ID
ID LEN
LEN DATA
DATA ADDR ID
ID
ID CONNECT
LEN
LEN DATA
DATA ADDR
DONE
DONE
DONE
DONE
NDR
NDR BUSY
BUSY
BUSY ERROR
ERROR STATUS
STATUS RCVD_LEN
RCVD_LEN ERROR STATUS BUSY
ERROR STATUS
BUSY
BUSY ERROR
ERROR STATUS
STATUS
TCON Establish connection
TCON creates the conditions for open user communication. The parameters re- quired for this are located in a data area that has the structure of the data type TCON_PAR.
When using the TCP native and ISO on TCP protocols, a connection is established to the communication partner. The station for which “Active connection setup” is en- tered establishes the connection. The partner station must then be designated as
“passive”. This designation is independent of the direction of transfer of the data.
The connection is monitored and maintained by the CPU's operating system. In the event of a break in connection, the active partner attempts to re-establish the con- nection without having to call TCON again. TDISCON terminates the communica- tion connection with the CPU at STOP or in the case of POWER OFF/ON.
If the UDP protocol is used, TCON sets up a local communication access point that represents the connection between the user program and the communication layer of the operating system. No connection is made to the connection partner.
Designate the communication connection by assigning the ID parameter. The spec- ification must correspond to the variable id in the connection data. You specify the connection data with the pointer at the CONNECT parameter.
In the initial state, the REQ, BUSY, DONE, and ERROR parameters have signal state
“0”. A rising edge at the REQ parameter starts the establishment of the connection.
While the job is running, BUSY = “1”. The job has been successfully completed if BUSY = “0”, DONE = “1”, and ERROR = “0”. If the job contains errors, then BUSY =
“0”, DONE = “0”, and ERROR = “1”. The error is then specified at the STATUS parameter. BUSY, DONE, and ERROR are reset to “0” if REQ is returned to “0”.
TDISCON Terminate communication connection
TDISCON terminates the requirements for open user communication. The connec- tion to the communication partner is terminated or the communication access point is closed. Designate the communication connection by assigning the ID parameter. The specification must correspond to the variable id in the connection data.
In the initial state, the REQ, BUSY, DONE, and ERROR parameters have signal state “0”. A rising edge at the REQ parameter starts terminating of the connection.
While the job is running, BUSY = “1”. The job has been successfully completed if BUSY = “0”, DONE = “1”, and ERROR = “0”. If the job contains errors, then BUSY =
“0”, DONE = “0”, and ERROR = “1”. The error is then specified at the STATUS parameter. BUSY, DONE, and ERROR are reset to “0” if REQ is returned to “0”.
TCON_PAR Structure of the connection data
The data type TCON_PAR (UDT 65) contains the structure of the connection data ei- ther for the communication connection to the partner device (protocols TCP native
and ISO-on-TCP) or for the connection to the communication layer of the local op- erating system (UDP protocol).
You require a data block with this structure for each connection. For each connec- tion, you can use your own type data block by creating the data block based on TCON_PAR, or you can combine the data blocks in a shared global data block (Table 17.2).