PC与PLC(S7-300)通讯地址表连接示例
- 格式:xls
- 大小:118.50 KB
- 文档页数:6
基于VB实现台达PLC与PC串行通讯随着工业自动化控制技术的不断发展,可编程逻辑控制器(PLC)与上位机之间通讯的应用越来越广泛。
在PLC与上位机组成的集散控制系统中,PLC作为下位机完成现场各种信号和数据的采集、运算和完成对系统的底层控制,上位机则可提供人机交互界面,实现数据的处理以及现场数据的实时显示等监视和远程控制等功能。
为实现面向产品全生命周期的数字化远程服务经营理念的制造装备的远程监测、诊断与维护技术,随着移动通讯市场的迅速扩大,GSM 无线数字蜂窝通讯网络在我国得到了高速的发展,不但拥有较高的覆盖率,而且相继开放了SMS(短消息)、FAX(传真)、DATA(数据)等业务,为选择高效、廉价的数据传输提供了新的思路。
各种组态软件,如:iFix、MCGS、组态王等虽然可以实现PLC的远程监控,但不能实现PLC Modbus通讯协议与GSM模块的通讯协议的转换。
本文就是基于这点考虑,运用VB编制操作界面和通信功能,完成台达PLC与PC机串行通讯,这是实现GSM模块与PLC通讯的关键技术所在。
1通讯硬件及协议简介1.1通讯硬件组成台达PLC自带有两个通讯串口(EH系列可扩展第三个通讯口RS-485或RS-422)COM1和COM2。
COM1采用标准RS-232接口,它是一种近距离、低干扰、点对点的通讯协议。
该接口在下载完PLC程序后一般都处于闲置状态。
COM2是标准RS-485接口,可用于用抗干扰能力强、可多台串接组网的通讯方式。
在该生产线的控制系统中,COM2已用于PLC与变频器之间的通讯,而一般PC机都自带标准RS-232接口。
因此PC机与PLC之间通讯采用COM1(RS-232)接口,连接线采用台达PLC的编程电缆DVPACAB230。
1.2通讯协议介绍Modbus 协议是应用于电子控制器上的一种通用语言。
通过此协议,控制器相互之间、控制器经由网络(例如以太网)和其它设备之间可以通信。
它已经成为一通用工业标准。
3.9 Digital input module SM 321; DI 16 x DC 24 V; (6ES7321-1BH02-0AA0) Wiring and block diagrams of SM 321; DI 16 x DC 24 V① Channel number② Status display - green③ Backplane bus interfaceTechnical specifications of SM 321; DI 16 x DC 24 VTechnical specificationsDimensions and weightDimensions W x H x D (mm) 40 x 125 x 117 Weight ca. 200 g Module-specific dataSupports isochronous mode noNumber of inputs 16Cable length∙unshielded ∙shielded max. 600 m max. 1000 m3.7 Digital input module SM 321; DI 32 x DC 24 V; (6ES7321-1BL00-0AA0) Wiring and block diagrams of SM 321; DI 32 x DC 24 V① Channel number② Status display - green③ Backplane bus interfaceTerminal assignment of SM 321; DI 32 x DC 24 VThe figure below shows how channels are assigned to addresses (input byte x up to inputbyte x+3).[ [ [[3.37 Programmable digital IO module SM 327; DI 8/DO 8 x DC 24 V/0.5 A (6ES7327-1BH00-0AB0) Wiring and block diagram of SM 327; DI 8/DO 8 x DC 24 V/0.5 A, programmable① Channel number② Status display - green③ Backplane bus interfaceTechnical specifications of SM 327; DI 8/DO 8 x DC 24 V/0.5 A, programmableTechnical specificationsDimensions and weightDimensions W x H x D (mm) 40 x 125 x 120Weight ca. 200 gModule-specific dataSupports isochronous mode noNumber of inputs 8 digitalNumber of inputs/outputs 8, can be programmed separatelyCable length∙unshielded ∙shielded max. 600 m max. 1000 m3.26 Digital output module SM 322; DO 8 x DC 24 V/2 A; (6ES7322-1BF01-0AA0)Use of the module with high-speed countersPlease note when using the module in combination with high-speed counters:NoteWhen using a mechanical contact to switch on the 24-V power supply to SM 322; DO8 x DC 24 V/2 A, the module outputs will carry a "1" signal for the duration of ca. 50 µs dueto the circuit structure.Wiring and block diagram of SM 322; DO 8 x DC 24 V/2 A① Channel number② Status display - green③ Backplane bus interface3.22 Digital output module SM 322; DO 16 x DC 24 V/ 0,5 A; (6ES7322-1BH01-0AA0) Wiring and block diagram of SM 322; DO 16 x DC 24 V/ 0.5 A① Channel number② Status display - green③ Backplane bus interfaceSM 322; DO 16 x DC 24 V/0.5 A - Technical specificationsTechnical specificationsDimensions and weightDimensions W x H x D (mm) 40 x 125 x 117Weight ca. 190 gModule-specific dataSupports isochronous mode noNumber of outputs 16Cable length∙unshielded ∙shielded max. 600 m max. 1000 m3.32 Relay output module SM 322; DO 8 x Rel. AC 230 V; (6ES7322-1HF01-0AA0) Wiring and block diagrams of SM 322; DO 8 x Rel. AC 230 V① Channel number② Status display - green③ Backplane bus interfaceSM 322; DO 8 x Rel. AC 230 V - Technical specificationsTechnical specificationsDimensions and weightDimensions W x H x D (mm) 40 x 125 x 117 Weight ca. 190 gModule-specific dataSupports isochronous mode noNumber of outputs 8Cable length∙unshielded ∙shielded max. 600 m max. 1000 mVoltages, currents, electrical potentialsRated power supply L+ to the relays 24 VDC Total current of outputs (per group) max. 4 A3.31 Relay output module SM 322; DO 16 x Rel. AC 120/230 V; (6ES7322-1HH01-0AA0)Reaction to a shutdown of the power supplyNoteThe internal 200-ms buffer capacitance discharges sufficient power after power off to allowthe user program to set a defined relay state.Wiring and block diagrams of SM 322; DO 16 x Rel. AC 120/230 V① Channel number② Status display - green③ Backplane bus interface6.6 Analog input module SM 331; AI 8 x 13 Bit; (6ES7331-1KF02-0AB0)Wiring: Voltage measurement① Voltage measurement (± 5 V, ±10 V, 1 V to 5 V, 0 V to 10 V)② Voltage measurement (± 50 mV, ± 500 mV, ± 1 V) (note the input resistance defined in the technical data)③ Equipotential bonding④ Internal supply⑤ + 5 V from backplane bus⑥ Logic and backplane bus interface⑦ Electrical isolation⑧ Multiplexer⑨ Analog digital converter (ADC)⑩ Current sourceFigure 6-10 Block diagram and terminal diagramWiring: Voltage measurement and current output① Internal supply② Analog-to-Digital Converter (ADC)③ Inputs: Voltage measurement④ Outputs: Voltage output⑤ Digital-to-Analog Converter (DAC)⑥ Backplane bus interface⑦ Equipotential bonding⑧ Functional groundFigure 6-50 Wiring and block diagramsWiring: 2 and 4-wire connection for voltage output① 2-wire connection: no compensation for line impedance② 4-wire connection: with compensation for line impedance③ Equipotential bonding④ Functional ground⑤ Internal supply⑥ Electrical isolation⑦ Backplane bus interface⑧ Analog-to-Digital Converter (ADC)Figure 6-48 Wiring and block diagramsAnalog modules6.14 Analog output module SM 332; AO 4 x 12 Bit; (6ES7332-5HD01-0AB0)Wiring: 2 and 4-wire connection for voltage outputThe following Fig. represents the 2-wire connection with no compensation for line resistorsand the 4-wire connection with compensation for line resistors.① 2-wire connection, no compensation for line resistors② 4-wire connection, with compensation for line resistors③ Equipotential bonding④ Functional ground⑤ Internal supply⑥ Electrical isolation⑦ Backplane bus interface⑧ Analog-to-Digital Converter (ADC)Figure 6-46 Wiring and block diagramsS7-300 Module dataManual, 08/2009, A5E00105505-06 405。
在实际应用过程中,某些时候可能会采用VB/DELPHI/VC等高级语言,自主编程与西门子PLC进行通讯,这类帖子、论文在网上都可以找到,在此总结一下。
1、Prodave通讯Prodave是西门子提供的一个软件包,为高级语言编程和plc通讯提供接口通讯接口:MPI因为MPI口是每块cpu的编程口,所以plc不需要另外添加通讯模块,这个方案就比较经济,而且prodave软件包里面附带了example和详细的说明,用起来应该比较简单和方便(本人只匆匆看过文档,没有实验过)。
这方面的资料在百度上很多。
当然,mpi的速度是有限的,如果采用普通的pc adapter连接pc和plc,最高速度也就38.4kbps,我不知道prodave能否支持mpi卡(5611之类的话),如果可以的话速度可以达到187.5kbps。
2、串行通讯看到过一些论文,采用串行通讯的方法实现pc和plc通讯。
这种情况存在几点要求:a、需要为plc添加一块串行通讯模块,比如300的话就需要cp340或者cp341(前者便宜些);b、plc里面需要对串行通讯进行编程,其实也就是接收报文和发送报文,调用fb2/fb3(cp340的话)。
c、串行通讯的速度是有目共睹的,而且cp340或者cp341的数据吞吐量也是有限的,即报文长度是有限制的,因此个人认为通讯数据量大的话采用串行通讯就不合适了。
d、报文格式的话就比较自由,但是也应当合理,我虽然没有具体实验过,但是个人认为可以参考modbus的报文结构来编程,甚至就采用modbus的规范,不过这样的话要求编程者对pc和plc侧的modbus编程都要熟悉。
3、OPCOpc是这些年来很流行的东西,其实我很讨厌opc的安全认证的设定。
不过采用opc编程来访问plc真的是一件非常轻松惬意的事情。
你需要做的就是了解opc 的结构和编程,尤其是采用vb来编写opc简直是件傻瓜化的工作当然也牺牲了很多。
前面我实验了用vb通过opc(以太网)来访问300,包括用西门子的simaticnet 提供的opc接口和第三方的kepserver采用opc接口编程的优点:通讯速度快,编程简单。
探讨OPC技术的PC与S7-300PLC的实时通信0 引言西门子 S7-300/400 PLC 通信接口只有多点接口MPI 和分布式外设接口DP,分别使用MPI 协议和Profibus 协议。
但是这两种协议都不公开, 使得该系列PLC 与PC 机通信实现变得困难[1]。
因此采煤机远程监控系统中,如何采集数量和种类不断增多的现场信息以及解决通信兼容是其关键技术之一。
由于不同的厂商提供的协议不同,甚至同一厂商的不同类型设备和计算机通信的协议也不相同[2]。
在计算机系统中,不同的编程语言对驱动程序的接口有不同的要求,所以每一个客户的应用程序在从数据源读取数据时,由于软件或硬件的不一致性,对于不同的设备都要开发不同的驱动程序,这就导致了软件开发商的大量重复性劳动[3],并且由于可能存在多个应用程序同时访问同一设备带来访问冲突,导致系统崩溃。
OPC技术的出现,很好的解决这一问题。
1 OPC 技术OPC 建立在OLE 规范之上,它为工业控制领域提供了一种标准的数据访问机制。
OPC规范包括OPC 服务器和OPC 客户端两个部分,其实质是在硬件供应商和软件开发商之间建立了一套完整的“规则”,只要遵循这套规则,数据交互对两者来说都是透明的,硬件供应商无需考虑应用程序的多种需求和传输协议,软件开发商也无需了解硬件的实质和操作过程。
1.1 OPC 规范OPC 规范主要包括:DA (Data Access) 规范、AE(Alarm and Event) 规范、HAD (Historydata access) 规范、Batch 规范、Security 规范以及XML -DA 规范等。
目前应用最为广泛的是OPCDA 规范,该规范提供了服务器和客户端之间实时数据的存取方法[4]。
1.2 OPC 主要包含两种接口OPC 主要包含两种接口:CUSTOM 标准接口和OLE 自动化标准接口。
自定义接口是一组COM 接口,主要采用C++语言的应用程序开发。
西门子S7-300系列PLC一、建立硬件连接使用PC/MPI电缆(6ES7 972-0CA23-0XA0)建立个人PC与CPU之间MPI的通信。
标有MPI/DP的接头连接到PLC端,标有PC的接头连接到笔记本。
二、通讯设置1.点击Simatic---STEP 7---设置PG-PC接口,打开“设置PG/PC 接口”对话框。
2.选中“PC Adapter(MPI)”,点击“属性”按钮。
3.在“MPI”下的为默认值即可。
4.在“本地连接”的“连接到(C):”中设置PC的COM口,如果使用的是USB线,则选择USB。
5.点击“确认”,返回到“设置PG/PC接口”对话框,点击“确认”,在跳出的路径更改对话框里点“确认”,完成设置。
三、使用STEP7编程软件上载程序1.打开STEP 7编程软件“SIMATIC Manager”。
2.点击“CANCEL”按钮即可,出现如下画面:3.点击“新建”按钮,建立一个新的项目。
4.输入新的项目名称,建立一个新的空项目例如“yyz”,然后点击“OK”按钮。
5.在“yyz”项目下,选择“PLC”菜单下的“Upload Station to PG”条目:6.出现上传选择对话界面,点击“VIEW”按钮,开始扫描。
选择在“Accessible Nodes”出现的CPU,再点击“OK”开始上传。
四、使用STEP7编程软件下载程序1.打开STEP 7编程软件“SIMATIC Manager”。
2.点击“Cancel”按钮。
3.点击“打开”,打开要下载的项目。
4.点击“SIMATIC 300(1)”,再点击“Download”图标。
再点击点击5.出现“Download”对话框,点击“Yes”,完成程序下载。