| |
---|---|
(点击题目可以 在互联 网中搜索该题 目的相关内容) 日期:2006-7-10 22:34:27 来源: 作者: 点击: | |
如何通过VB以DDE方式与AB PLC进行通讯? 如何使用Excel通过 DDE VBA方式访问Allen Bradley PLC? 首先必须先安装RS Linx创建DDE topic. 比如我们定义一个topic名叫“N1” <<<<<<<<<<<<开始>>>>>>>>>>>>>>>>>>>>> Public Const DDETOPIC As String = "DDE" Sub DDEreadStation1() On Error GoTo MessageRSLinxDead: make sure the DDE Channel is Closed before we define a Topic channel txtStat1Force.LinkMode = 0 txtStat1Status.LinkMode = 0 set the Application and Topic of the Control Property DDETOPIC is a Public Constant in MainSubs Module I might use a configuration file later and let the user set this txtStat1Force.LinkTopic = "RSLinx|" & N1 txtStat1Status.LinkTopic = "RSLinx|" & N1 set the Address of the PLC we want to read txtStat1Force.LinkItem = "N7:1" txtStat1Status.LinkItem = "B3:1/1" set the DDE mode to COLD Link, we will request the data manually txtStat1Force.LinkMode = 2 txtStat1Status.LinkMode = 2 tell VB to get the data from the PLC NOW! txtStat1Force.LinkRequest txtStat1Status.LinkRequest txtStat1TimeStamp.Text = Now() GoTo SkipMessage MessageRSLinxDead: MsgBox ("RSLINX 没有运行,连接失败!") SkipMessage: End Sub |
|
上一篇: 如何在Excel中通过DDE以VBA方式访问AB PLC? 下一篇: 紧急求助:配置SLC500通讯…… |