1. 先在本地模拟一个PLC

2. 打开PLC工具,操作值

 

vb代码去读取数值,用的是S7协议

 

翻一下之前的代码, 还有一个用Siemens OPC DAAutomation来读写的.

 'AddServer
    Set MyOPCServer = New OPCServer           ' Create OPCServer Object
    Call MyOPCServer.Connect("S7200.OPCServer")  ' Disconnect from OPC Server

    'AddGroup
    Set MyGroups = MyOPCServer.OPCGroups        ' Get OPCGroups Collection Object from MyOPCServer
    
    MyGroups.DefaultGroupIsActive = 500   ' Set Default Group Update Rate to 500 ms
    MyGroups.DefaultGroupIsActive = False ' Set Default Group Active State to Inactive
    Set MyGroup = MyGroups.add("Group1")   ' Add a new Group to the Group Collection
    ' Set Group Properties
    MyGroup.IsSubscribed = True  

  查了一下OPC的资料,原来是一个通用的PLC的驱动, 类似数据库的ODBC,

从这个意义上来讲,做MIS时,下面的PLC 种类众多时,用OPC是好的选择, 但只有一两个PLC就没必要了.

posted on 2020-04-14 11:01  Gu  阅读(1061)  评论(0编辑  收藏  举报