pbinvers477
Electrical
- Aug 22, 2008
- 2
How do you get Vb 2008 to talk to a Allen Bradley PLC, using RSLinx? I have tried the link data and such that is in the FAQ, and it doesn't recognize the language. Some help please.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Function strGetPLCData(ByVal strAddress As String) As String
Dim OpcServer As New RsiOPCAuto.OPCServer
Dim OpcGroup As RsiOPCAuto.OPCGroup
Dim OpcItem As RsiOPCAuto.OPCItem
Dim vItem As String = ""
Try
OpcServer.Connect("RSLinx OPC Server")
' Add this group to the shared topic
OpcGroup = OpcServer.OPCGroups.Add(MY_GROUP)
OpcGroup.IsSubscribed = False
OpcGroup.IsActive = False
OpcGroup.UpdateRate = 250
OpcGroup.OPCItems.DefaultAccessPath = OPC_SHARE
OpcGroup.OPCItems.AddItem(strAddress, 1)
OpcItem = OpcGroup.OPCItems.Item(1)
OpcItem.Read(2, vItem)
OpcItem = Nothing
OpcServer.OPCGroups.RemoveAll()
OpcGroup = Nothing
OpcServer.Disconnect()
OpcServer = Nothing
'Add and Error the list box
Catch ex As PlatformNotSupportedException
MsgBox("Error In Get Plc Data: " & ex.Message)
End Try
Return vItem
End Function