×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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!
    txtStat1Force.LinkRequest
    txtStat1Status.LinkRequest
    txtStat1TimeStamp.Text = Now()
    
GoTo SkipMessage

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

End Sub

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

My Archive


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

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