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


DDE and PLCs

How do I use Visual Basic and DDE to get data out of an Allen Bradley PLC? by chakorules
Posted: 26 Dec 02 (Edited 27 Dec 02)

You'll need to make sure you have RS Linx running and a DDE topic created. In our example code below, our DDE topic is called "DDE".

Open a new project in Visual Basic.

Use this sample code provided to try some COLD DDE linking to a text box control in Visual Basic.

<<<<<<<<<<<<BEGIN SAMPLE CODE>>>>>>>>>>>>>>>>>>>>>

Public Const DDETOPIC As String = "DDE"

Sub DDEreadStation1()
On Error GoTo MessageRSLinxDead:

    'make sure the DDE Channel is Closed before we define a Topic channel
    txtStat1Force.LinkMode = 0
    txtStat1Status.LinkMode = 0
    'set the Application and Topic of the Control Property
    'DDETOPIC is a Public Constant in MainSubs Module
    'I might use a configuration file later and let the user set this
    txtStat1Force.LinkTopic = "RSLinx|" & DDETOPIC
    txtStat1Status.LinkTopic = "RSLinx|" & DDETOPIC
    'set the Address of the PLC we want to read
    txtStat1Force.LinkItem = "N7:1"
    txtStat1Status.LinkItem = "B3:1/1"
    'set the DDE mode to COLD Link, we will request the data manually
    txtStat1Force.LinkMode = 2
    txtStat1Status.LinkMode = 2
    'tell VB to get the data from the PLC NOW!
    txtStat1TimeStamp.Text = Now()
GoTo SkipMessage

    MsgBox ("RSLINX is not running. Can not continue!")

End Sub

Back to Programmable logic controllers (PLC) FAQ Index
Back to Programmable logic controllers (PLC) Forum

My Archive


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close