×
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

PLC Interfacing using Visual Basic and RSLinx
4

PLC Interfacing using Visual Basic and RSLinx

PLC Interfacing using Visual Basic and RSLinx

(OP)
Hello Guys

I am new to PLCs so please bare with me on this.

I am working on (or at least trying to) an application that uses a PLC. I will be communicating to this PLC via the ethernet and RSLinx.

I am assuming that RSLinx will be setup with the address or IP address of the PLC, is this correct?

Inside of RSLinx will be a data table that I can query somehow from within Visual Basic to get the status of some event or possible start an event by setting a bit or byte
am I on the right track so far?

How would I go about addressing the PLC and the data tables?
Does any one out there have an example of how I might do this?

Thank You

Gary

RE: PLC Interfacing using Visual Basic and RSLinx

Hello;
     It is a little more complicated than that. First you must have either the OEM or the professional version of RSlinx. You then configure the "Ethernet devices" driver with the IP address of your PLC.
     Then you can access the data either via DDE or a method called OPC. In your case you must access the data via DDE using the VBA native DDE functions. I do not know what the exact syntax is, and will be quite complicated.

RE: PLC Interfacing using Visual Basic and RSLinx

(OP)
Thank You for your Reply.

Gary

RE: PLC Interfacing using Visual Basic and RSLinx

You might want to look at Parijat for their ActiveX control which is only $699 and they have them available for the A-B Ethernet.  Go to http://www.parijat.com for more info.

http://www.ktech-usa.com

RE: PLC Interfacing using Visual Basic and RSLinx

You must have RSlinx Prof V2.3 or greater, once you set up rslink to read the ethernet gateway or direct to the PLC The DDE stuf is easy. Just assign an topic to your target PLC in RSLinks OPC/DDE setup.
Now to access data in let's say excell it is simple:
DDE(application, topic, item)
=DDE(rslinx, PLC1, "N7:1"

Now in VB and VBA not so quick I hope you are familiar with these because you will need to do things like open a channel to rslinx before  DDE reads and DDE pokes.

I found if you are going this method make sure the data you need is lined up tight. I have some bad examples of this stuff if ya need.

RE: PLC Interfacing using Visual Basic and RSLinx

If you want to try DDE to Excel you can download my example here:

http://www.mrplc.com/cgi-bin/code/filedisplay.cgi?category=excel

Called:
Allen Bradley SLC500 DDE Link to Excel Logger 1.4

You'll need atleast RS Linx Single Node, configure a DDE topic in RS Linx. Then you can use Excel to get either Hot Links or Cold Links from the PLC. If you need to get alot of information, you might want to check into OPC. RS Linx Single Node is an OPC server and you can get information out of the PLC using OPC if you prefer.

Or if you want to see a VB 6.0 version of DDE. I'll let you have what I got, but I don't have the MS Access database write function working yet.

Chris Elston
Automation & Controls Engineer
http://www.mrplc.com
Download Sample PLC Ladder Logic Code
at MrPLC.com

RE: PLC Interfacing using Visual Basic and RSLinx

Oh yeah..

Here is a short sample code:

Warning...The above reference:

DDE(application, topic, item)
=DDE(rslinx, PLC1, "N7:1"

Will only work in Excel or you have to enable Excel reference in your library to use that call in VB 6.0. The native VB calls for DDE are below.

Please also look at this post here:
http://www.plctalk.net/qanda/showthread.php?s=&threadid=1093&highlight=dde

I asked alot of questions and most of the leg work I am telling you know, I just found out myself.

<<<<<<<<<<<START 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

Chris Elston
Automation & Controls Engineer
http://www.mrplc.com
Download Sample PLC Ladder Logic Code
at MrPLC.com

RE: PLC Interfacing using Visual Basic and RSLinx

Hello,

Another option for low cost ActiveX DLLs to communicate with your PLC is http://www.vhmiautomation.com

The ActiveX DLLs can be used in VB, VBA, C++, Delphi, etc...

Regards,

Phil Covington

RE: PLC Interfacing using Visual Basic and RSLinx

(OP)
Thanks everyone for your replies

I have another question

Has anyone out there ever used a DLL from rockwell software called rsiopcauto.dll?

This DLL allows me to communicate using OPC to RSLinx single node version.

I was given some sample VB code by rockwell software that showed how it was possible to communicate to a PLC using OPC and RSLinx.

The code that I was given all resided within a VB form and it seamed to work just fine.

I then put this code into a class and found that when I tried to communicate to the PLC it did not seam to communicate very well by that I mean whenever I would try to read from a same memory location the value would vary from time to time eventhough it never changed on the PLC itself.

I was kinda thinking that maybe I should have left the code in the form and used that instead of putting it into a class module?

Can somebody out there please help me with this?

Thank You

Gary






RE: PLC Interfacing using Visual Basic and RSLinx

Hi Gary

I have a lot of experience programming in Visual Basic with the RSLinx OPC Automation interface and would be happy to help you out if I can. Its really easy once you get your head round the basics.

I programmed all of my OPC communications code in Class modules and it functions just fine so you didn't make any mistakes there.

I'm guessing that you need to work out what type of OPC group connection you need. OPC can support three general types of data read; Sync, Async and Subscribed. I would need to understand a little bit more about what you are trying to do and then I could give you some examplecode.

I also have a compiled HTML help file which gives details about the properties, methods and events of the RSLinx OPC interface. I'm not sure how to upload it here 'cos I'm new so I can send it by email if you like.

Keith

RE: PLC Interfacing using Visual Basic and RSLinx

Hi Gary
  i am new to PLCs. i have a project to control view the status of the rslogix5000 and display status in visual basic. Actually the vb is controlling the downloading of program in rslogix. So vb monitors the status in rslogix. i am actually extracting the status by identifying the colour for run,prog mode from the rslogix. But i feel it is not so stable. my customer keeps complaning about it. i want to improve on this project. Is there any way i can get the status of rslogix by querying or reading any registers from vb. i need to find out Battery at fault,run mode, rem run, programmode, nocontroller,io not reponding etc i mean all the status.in any of the fault conditions i have to display error or may be stop downloading
 it would be very helpfull if you could help me
thanks
roopa

RE: PLC Interfacing using Visual Basic and RSLinx

The function I think you require is the @MODE function. This is available directly from the RSLinx application and does not require the use of RSLogix 5000

Try this:
In RSLinx, create an DDE/OPC topic pointing to your processor. For this example call it ModeTest
Now open Excel and insert the following string in one of the cells;
=RSLINX|ModeTest!'@Mode,L1,C1'

This will return a string stating the mode of the processor (Remote Program / Run etc.)

I've used these functions a lot in the past but only by using DDE in VB, not OPC. This is easily achieved. Create a new VB project. Create a Textbox. Set the LinkTopic property to RSLinx|ModeTest (where ModeTest is the name of your topic). Set the LinkItem to @Mode. Set the LinkMode to Automatic. The textbox should now show the mode.

I will look into whether this works also in OPC and contribute later.

There are also a lot of other @ functions available although all do not work on all controller platforms. You can find out more by looking at the online help.

RE: PLC Interfacing using Visual Basic and RSLinx

FAO - KiethMcr

I am going to try and pull out the rung comments from an slc5/03 so that by documenting the plc code ie
Step 1 Advance CAn Clamps
Step 2 Wait Operator Accept
Step 3 Can Table Forward

we would have a system specification updated when we save the plc code and comments

and would like to use RSLinx OPC Automation Interface in order to pull the data from the plc to MS Word

Have you any ideas

I would be interested in you sending me your OPC sample programs to peter.j.orford@bnfl.com

Regards
Pedro

RE: PLC Interfacing using Visual Basic and RSLinx

KeithMcr
  you told me i can use @Mode function to access the status of the plc.is there any other function for all the io,battery,whether rslogix is downloading to processor,and at some contidition like if the processor is switched to remrun mode i must stop donwloading etc. if there is where can i get the list of functions.
Actually i am not able to test whether it will work here as i do not have the setup and rslinx with me. So i must be quite sure it works when i go down to customers place(oversea's).if you can help me how and where can i find the documentation for all this it will be very helpfull.

thanks
roopa

RE: PLC Interfacing using Visual Basic and RSLinx

I have the following versions of software

RSLogix Professional V5.20.00
RSLogix Gateway V2.40.01 (Build 16)

I have connected channel 0 of an SLC 5/03 through RSLinx and all works fine


I have created a form in VBA through RSLogix 500 and created some command buttons and text boxes onto it


I want to be able to click a command button on the VBA form and set an bit in the the SLC 5/03

I want to be able to read an integer register from the plc N7:00 and display it in a text box

Can the above be achieved using RSLogix 500 and RSLinx


Regards
Peter Orford
Control Engineering Group
WestingHouse

RE: PLC Interfacing using Visual Basic and RSLinx

(1) Pedro / Peter.
The RSLinx OPC Automation Interface CANNOT be used to upload or download either PLC Code or Documentation. RSLinx OPC can only allow upload/download/subscription to data-table points and arrays. The only way I know to access the type of information you are talking about is by using the RSLogix Automation Interface. This effectively allows you to control the RSLogix application 'remotely'. I could imagine a scenario where you use this interface to upload the program and then either convert the program to a text format or export the comments. You could then parse the text document to find the data you need. Alternatively, it may be possible to upload the program and then navigate the COM object model of the automation interface to find the data you need. Both are possible ways to achieve what you wish however they are relatively complex. Either way, RSLinx OPC Automation will not help you here.

(2) Roopa
I found the following information in the current RSLinx release notes reagrding the @ functions

"RSLinx can obtain general processor information or trigger events using DDE/OPC predefined items.The following predefined items can be used with all PLC types:

@Mode returns the current mode of the processor as a string (Run, Program, Remote Run, or Remote Program).
@ProcessorName returns the name of the program running in the processor.
@Revision returns the firmware version of the processor as a string.
@PLCType returns the processor type as a string.
@Status returns the current status of the processor as a string (Ok or Faulted).
@StatusNumber returns the current status of the processor as a number.
@SwitchTopic is used to switch between alias topics in OPC clients.

The following predefined items are used with Logix5000 family processors:
@FreeMem returns total unused memory (I/O + data table + general).
@FreeMemDT returns unused data table memory (not applicable to 1756-L1).
@FreeMemGM returns unused general memory (applicable to 1756-L55M16 only).
@FreeMemIO returns unused I/O memory.
@TotalMem returns total available memory (I/O + data table + general).
@TotalMemDT returns total available data table memory (not applicable to 1756-L1).
@TotalMemGM returns total available general memory (applicable to 1756-L55M16 only).
@TotalMemIO returns total available I/O memory.
@CLTagUpdateAddressSpace forces RSLinx to update its' Logix5000 tag database.
@RedundancyMode monitors the processor state in a ControlLogix redundant system.
@IsPresent allows you to check if your ControlLogix processor is available prior to performing reads or writes. The time out value is consistent with the communications timeout value in the configured PLC-5 topic."

More help should be available on each of these points either via the RSLinx help files or via online RSI resources: http://www.software.rockwell.com

(3) Peter / Pedro (?)
I will email you a sample VB6 application in the next few minutes as I don't know how to upload here.

Keith

RE: PLC Interfacing using Visual Basic and RSLinx

Might I suggest using an activex control from Consolitech Corporation. I have a lot of experience using this software and it works really well. I was able to send data from A SLC 500 PLC to Excel incuding time and date stamping of data. I was also able to send data to Word and perform comparisons of data entered by user to that of data in an Access data base. There is no need for RS linx when using this software. This software allows you to map to every register within the SLC 500, including the s registers which provide status information about the CPU such as faults etc. plcsavvy  

RE: PLC Interfacing using Visual Basic and RSLinx

Thanks a lot for your replies
roopa

RE: PLC Interfacing using Visual Basic and RSLinx

HELLO, EVERYBODY,
WOULD YOU HELP[ ME TO SOLVE THIS PROBLEM. lAST TIME I USING hizac PLC FROM hitachi. But i want to print out the ladder from cpu, with RS 232. Maybe somebody tell me how to connect from cpu to printer (dot matrix).

thanx.

Hasan.

RE: PLC Interfacing using Visual Basic and RSLinx

Hi Guys,
Im new to this forum so bare with me. I have been reading all the info ye have supplied in relation to VB accessing PLC data through RS Linx(OPC)/gateway setup. Im in the process of trying to set this up on a test system, with little VB experiance im finding it difficult to start off on the right foot!
Keith, you have presented what i think is the answer to my problem, could i see a sample of what you have spoken about, im sure it will help me a lot as I am new to the VB field but have extensive PLC experiance.
Thanx in advance

RE: PLC Interfacing using Visual Basic and RSLinx

Keith,
I'd also like a peek at your VB code.
As others are, I'm looking at building an application to monitor a couple of tags and record them to MS Access or a flat file. A second application will read a user selectable span of data, display it, and optionally export it.

Thanks in advance.

RE: PLC Interfacing using Visual Basic and RSLinx

You should look at OPCWare Client Developer (http://www.opcware.com), which makes logging OPC data to a database or flat file a snip. The demo includes examples of logging OPC data to an access database, logging to a csv file, and logging to a database via ODBC/DSN.

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! Already a Member? Login


Resources

White Paper - Considerations for choosing a 3D printing technology
The adoption of 3D printing into major companies’ product development life cycles is a testament to the technology’s incredible benefits to consumers, designers, engineers and manufacturers. While traditional production methods have limitations in manufacturability, 3D printing provides unparalleled design freedom due to the additive method of building parts layer by layer. 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