×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VB 2008 & Allen Bradley PLC

VB 2008 & Allen Bradley PLC

VB 2008 & Allen Bradley PLC

(OP)
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.

RE: VB 2008 & Allen Bradley PLC

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

RE: VB 2008 & Allen Bradley PLC

(OP)
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?

RE: VB 2008 & Allen Bradley PLC

You need at least a reference to the COM object RsiOPCAuto.dll  
Not sure of what else is needed.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources