如何在两个S7-300 PN CPU之间建立一个open TCP 通讯连接,以及如何进行数据交换?
显示订货号
6ES7315-2EG10-0AB0CPU315-2 PN/DP, 128KB
6ES7317-2EJ10-0AB0CPU317-2 PN/DP, 512KB
active下载6ES7318-3EL00-0AB0CPU319-3 PN/DP, 1.4MB
6ES7414-3EM05-0AB0CPU414-3 PN/DP, 2.8 MB, 3 INTERFACES
6ES7416-3ER05-0AB0CPU416-3 PN/DP, 11.2MB, 3 INTERFACES
6ES7416-3FR05-0AB0CPU416F-3 PN/DP, 11.2 MB, 3 INTERFACES
说明:
下面通过例程来说明在两个CPU315-2 PN/DP之间如何通过集成的PROFINET接口进行连接并通过open TCP/IP 通信方式进行数据交换。
( 36 KB )
图01:两个CPU315-2 PN/DP 进行以太网通讯
CPU 的PN口的TCP通讯不是在NetPro中组态,所需的组态参数都保存在以UDT65("TCON_PAR")为模板生成的DB块中。通过调用功能块 FB65 ("TCON") 来建立连接,一旦连接建立后,可以通过调用FB63 ("TSEND") 和 FB64 ("TRCV") 进行数据交换。通过调用FB66 ("TDISCON") 可以中止连接。 open TCP/IP 通信方式和通信功能块的特点:
•通信是面向连接的,只有当与通讯对方建立连接后,数据才可以进行传输
•所有连接所需要的设置(例如:IP地址等等)必须保存在以UDT65 为模板生成的DB块中•如果一个连接被建立,则CPU将对连接进行监控,一旦连接(例如:通信电缆断线)中断CPU将自动重新恢复该连接
•所有4个功能块异步工作,甚至可以持续若干个OB1的循环周期
•在一个连接下,TSEND 和 TRCV 可以同时进行通信
•发送和接收的最大字节数是1460个字节
•通信用的功能块均保存在 "Standard Library -> Communication Blocks" 目录下
例程的描述:
例程中根据连接建立的方式(主动 active / 被动 passive)分为两个独立的项目。下述中将主动建立连接的站称为主动站,反之称为被动站。需要说明的是这种命名对数据交换并没有任何影响,无论是主动站还是被动站都可以发送或接收数据(包括在同一个所建的连接下)。
连接设置保存在通过open TCP/IP 通信向导生成的数据块DB5 ("CON settings") 中,open TCP/IP 通信向导和指南可以参考条目ID25209116.
下表中除IP地址外,哪些参数必须在主动站点和被动站点设置。
主动站点被动站点
本地IP 地址140.140.140.62 140.140.140.64
子网掩码255.255.0.0 255.255.0.0
远端 IP 地址140.140.140.64 140.140.140.62
本地TSAP/端口(2000) 2001
远端TSAP/端口2001 (2000)
("TDISCON")。
图. 02
断而造成的非法的数据帧,因而建议通常在调用Pn_cpu_a.zip
FB101的背景数据块。
Pn_cpu_p.zip
How is an open TCP communication connection established between two S7-300 PN CPUs, and how is data exchanged?
Display part number
6ES7315-2EG10-0AB0CPU315-2 PN/DP, 128KB
6ES7317-2EJ10-0AB0CPU317-2 PN/DP, 512KB
6ES7318-3EL00-0AB0CPU319-3 PN/DP, 1.4MB
6ES7414-3EM05-0AB0CPU414-3 PN/DP, 2.8 MB, 3 INTERFACES
6ES7416-3ER05-0AB0CPU416-3 PN/DP, 11.2MB, 3 INTERFACES
6ES7416-3FR05-0AB0CPU416F-3 PN/DP, 11.2 MB, 3 INTERFACES
Instructions:
The attached sample program shows how two ST-300 stations with the CPU315-2 PN/DP are connected via the integrated PROFINET interface and how data can be exchanged with the aid of ope
n TCP/IP communication.
( 36 KB )
Fig. 01: Communication between two CPU315-2 PN/DPs via Ethernet
The connection on the PN CPU is not configured in NetPro. The requisite parameters are saved in a user-defined structure (UDT) in a data block. The connection is established in runtime by calling the FB65 ("TCON") function block. Once the connection with the partner station is established, data can be exchanged by means of the FB63 ("TSEND") and FB64 ("TRCV") function blocks. The FB66 ("TDISCON") function block disables the connection again.
Features of communication and of the function blocks for open communication:
•Communication is connection-oriented, i.e. data transfer does not occur until (and only for as long as)
a connection is established with the partner station
•All the requisite connection settings (e.g. IP address) must be saved in a data block whose structure is specified by the UDT65
•If a connection has been established, it is monitored by the CPU and, if it is interrupted, reconnection occurs automatically
•All four function blocks work asynchronously and can last several OB1 cycles
•TSEND and TRCV can communicate simultaneously via one connection
•Data blocks up to a size of 1460 bytes can be sent and received
•The blocks are contained under "Standard Library -> Communication Blocks"
Description of the sample program:
The sample program comprises two separate projects. The projects are separated in terms of the
("TDISCON") can be found in this FB. Fig. 02
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论