一台工控机如何通过OPC与两个PLC通信? 点击:3545 | 回复:5



风清扬

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:3帖 | 2回
  • 年度积分:0
  • 历史总积分:62
  • 注册:2003年5月12日
发表于:2009-11-20 21:14:05
楼主
各位大侠,想用一台工控机同时与两台PLC通信,采用OPC方式,如何实现?



[明月夜]

  • 精华:3帖
  • 求助:0帖
  • 帖子:114帖 | 3593回
  • 年度积分:0
  • 历史总积分:7688
  • 注册:2008年3月16日
发表于:2009-11-20 23:52:43
1楼

可以呀,工控机以OPC客户方式访问PLC,

组点时,分别组两个OPC SERVER的点的路径就可以;

PLC型号呢?

风清扬

  • 精华:0帖
  • 求助:0帖
  • 帖子:3帖 | 2回
  • 年度积分:0
  • 历史总积分:62
  • 注册:2003年5月12日
发表于:2009-11-21 19:52:08
2楼

我是说用VB编程,PLC是西门子s7-200,似乎OPC服务器的名字是唯一的。下面是西门子OPC通信的例子,明月兄能否给个例子?

Set MyOPCServer = New OPCServer    ‘ Create OPCServer Object
Call MyOPCServer.Connect("S7200.OPCServer")           ‘ connect to OPC Server
‘ PLCAddress = "2"
Dim CID As Long    ‘ CancelID, servergenerierter Wert, mit dem die Transaktion identifiziert

‘add groups
Set MyOPCGroups = MyOPCServer.OPCGroups          ‘ Get OPCGroups Collection Object from MyOPCServer
‘ Set Default Properties for Group Collection
‘ These Properties are used to set the Properies for new Groups
MyOPCGroups.DefaultGroupIsActive = 200                ‘ Set Default Group renew Rate to 500 ms
MyOPCGroups.DefaultGroupIsActive = False            ‘ Set Default Group Active State to Inactive
Set GroupWrite = MyOPCGroups.Add("GWrit")          ‘ Add a new Group to the Group Collection
‘ Set Group Properties
GroupWrite.IsSubscribed = True              ‘ Enable Callbacks
GroupWrite.IsActive = True
Set WritItems = GroupWrite.OPCItems            ‘ Get OPCItems Collection Object from MyOPCServer

 


[明月夜]

  • 精华:3帖
  • 求助:0帖
  • 帖子:114帖 | 3593回
  • 年度积分:0
  • 历史总积分:7688
  • 注册:2008年3月16日
发表于:2009-11-21 22:50:50
3楼

你可以在VB里再连接另一个OPC SERVER呀,两个对象各采各的,

我不是用的VB,VB访问OPC的方法相对要简单,网上的例子多,可以搜到

风清扬

  • 精华:0帖
  • 求助:0帖
  • 帖子:3帖 | 2回
  • 年度积分:0
  • 历史总积分:62
  • 注册:2003年5月12日
发表于:2009-11-22 19:33:44
4楼
是呀,就是这个:连接另一个OPC SERVER,具体怎么连,给个例子。

alou

  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 107回
  • 年度积分:0
  • 历史总积分:410
  • 注册:2004年2月07日
发表于:2010-11-22 13:41:46
5楼
我是说用VB编程,PLC是西门子s7-200,似乎OPC服务器的名字是唯一的。下面是西门子OPC通信的例子,明月兄能否给个例子?

Set MyOPCServer = New OPCServer ‘ Create OPCServer Object
Call MyOPCServer.Connect("S7200.OPCServer") ‘ connect to OPC Server
‘ PLCAddress = "2"
Dim CID As Long ‘ CancelID, servergenerierter Wert, mit dem die Transaktion identifiziert

‘add groups
Set MyOPCGroups = MyOPCServer.OPCGroups ‘ Get OPCGroups Collection Object from MyOPCServer
‘ Set Default Properties for Group Collection
‘ These Properties are used to set the Properies for new Groups
MyOPCGroups.DefaultGroupIsActive = 200 ‘ Set Default Group renew Rate to 500 ms
MyOPCGroups.DefaultGroupIsActive = False ‘ Set Default Group Active State to Inactive
Set GroupWrite = MyOPCGroups.Add("GWrit") ‘ Add a new Group to the Group Collection
‘ Set Group Properties
GroupWrite.IsSubscribed = True ‘ Enable Callbacks
GroupWrite.IsActive = True
Set WritItems = GroupWrite.OPCItems ‘ Get OPCItems Collection Object from MyOPCServer



 Set MyOPCServer 1= New OPCServer ‘ Create OPCServer Object
Call MyOPCServer1.Connect("S7200.OPCServer") ‘ connect to OPC Server
‘ PLCAddress = "3"
Dim CID As Long ‘ CancelID, servergenerierter Wert, mit dem die Transaktion identifiziert

‘add groups
Set MyOPCGroups = MyOPCServer.OPCGroups ‘ Get OPCGroups Collection Object from MyOPCServer
‘ Set Default Properties for Group Collection
‘ These Properties are used to set the Properies for new Groups
MyOPCGroups.DefaultGroupIsActive = 200 ‘ Set Default Group renew Rate to 500 ms
MyOPCGroups.DefaultGroupIsActive = False ‘ Set Default Group Active State to Inactive
Set GroupWrite = MyOPCGroups.Add("GWrit") ‘ Add a new Group to the Group Collection
‘ Set Group Properties
GroupWrite.IsSubscribed = True ‘ Enable Callbacks
GroupWrite.IsActive = True
Set WritItems = GroupWrite.OPCItems ‘ Get OPCItems Collection Object from MyOPCServer




热门招聘
相关主题

官方公众号

智造工程师