Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB 2008 & Allen Bradley PLC

Status
Not open for further replies.

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.
 
Replies continue below

Recommended for you

I borrowed this from someone's code, but it does work in VB 2008:

Code:
    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
 
I still get errors saying that the first 3 variables are not defined. These 3 RsiOPCAuto_OPCItem. Also OPC_Share is not recognized. Maybe I don't have something referenced?
 
You need at least a reference to the COM object RsiOPCAuto.dll
Not sure of what else is needed.

getfile.aspx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor