PLC and Visual Basic

mayank

Member
Join Date
Sep 2002
Posts
1
Hello,

Can someone tell me how PLC is used with Visual Basic. Can you give examples? Can you provide me with some sample code? Are there any websites that teach how to use PLC with VB.

Thank you so much all.
 
Applications for PLC and visual basic?

It's a matter of using your imagination.

Usually though, VB is used on a PC associated in some way with a PLC, but not the PLC itself, and I don't know of any PLCs that actually use VB.

I have heard that some HMIs use visual basic, and although my favorite (Citect) doesn't, it's internal coding (Cicode) is now 1:1 compatable with VB (This was to increase the number of people able to write applications for this system).

I also heard that the original versions of Concept (Schneider) were written with visual basic, don't know if this is true though.

I have also been involved in a PC based vision system that used visual basic to convert and transmit data to a PLC.

I don't think this was what you're looking for, but it does reflect the current usage of VB with PLCs.

Doug
 
I'm not aware of any PLCs that allow you to write logic using VB or VB Script. If there are any, it would most likely be one that has implemented a structured text programming language, and even then I expect it would be a subset of VB. There really isn't much need inside a PLC for things like list boxes or radio buttons.

There are a number of SCADA and HMI software packages that include VB Script capabilities to enhance the functionality of the operator interface.

You could probably write a communications driver for reading and writing data to a PLC using VB.
 
Well I've got an application started right now. I am using VB to log data from a PLC through DDE. My application is five force load cells, and when the PLC triggers an event or bit I setup as a hot link DDE to VB to some txt box controls, my VB application will log the data from the PLC to an MS Access Database. Then I wanted to export from MS Access to Excel to generate reports. Sure RS View 32 can do all this out of the box, but this is personal thing, I want to say I know how to do it.

I am NOT DONE WITH THIS APPLICATION! And I am a VB newbie, plus this is really my first 100% stand alone VB app. So as long as you don't laugh at what I've got, I'll share what I've gotten done. Positive feedback is good, I'll take any suggestions :) Coding or otherwise.

Pre-configure requirements:

Set up a DDE link from your computer using RS Linx, with a topic called "DDE". Make sure RS Linx is running, and the topic is started.

Run this application. There is NO PASSWORD, just click "OK". I have a manual trigger setup, when a onchange event happens in the text boxes txtStat1Trigger, txtStat2Trigger etc...Or you can press the button "READ" and it will go out and get all the data from all five stations.

Make sure you have N7:1 thru N7:5 allocated in your PLC so DDE can find the registers. And B3:0 thru B3:1 words allocated in memory. To trigger using PLC, toggle B3:0/1 for Station 1, B3:0/2 for Station 2 etc.

What is NOT DONE with this code as of TODAY:

The data you read does not get put into the MS Access yet but displays in the VB application in the text box controls, but I do have it reading the database called qsi.mdb. Click on "DATA" then "Station 1" top menus when the application is running.

I do not have any of the EXCEL exports working yet.

Maybe in two weeks or so or whenever I get more time...., I'll have this finished, then I post my finished code at http://www.mrplc.com in the Download a Code section.

Good Luck with VB / PLC venture.
 
Vb-6.

Hi;

I have used VB plus Ingear's AB suite of active-X controls to pull Scaned part #'s from A SLC-5/4 and check them in an MS-Acces data base to find a lane number and pass the lane number back to the PLC so the part can be diverted to the right conveyor.

We chose active X because DDE was to slow to get the lane in time to divert. If this is what you have in mind then email me and I can send you the code.

Larry Edwards
[email protected]
 
Don't use DDE!

DDE is slow and troublesome. Goto http://www.opcfoundation.org, get the book and learn OLE for Process Controls (OPC). You can download the OPC DLL's you need from there as well. OPC is a bit of a piece of work to learn, but it works well. I can't remember for sure, but I beleive the OPC doc I printed out was a PDF from the OPC Foundation.

We have found the RSTools data control does not work well at all.

For data collection, RS View may work, but RSSQL, In my opinion works better. It does one thing only - collect data. I like Intelution better but RSSQL is easier for the non programing type.

OK, I will admit, if you do not need high speed data collection and/or large volumes of data, DDE is good enough. It is yesterday's technology though.

When writting to the PLC, I find that holding the connection to the PLC helps greatly. I am putting together an app now which has one executable to talk to the PLC and will hold the OPC connection open. This same executable acts also as a pipe server. The second executable is triggered from some external process (an RF Barcode Scanner) and is also a pipe client. The second one runs, sends data accross the pipe, returns a success/failure and closes. We found that, if we launched the Exe and connected, as much as a 30 second delay would result. Since we need access from multiple points (the mobile RF guns) the mulit-tier app works best.

I have some VB experience and have set up data collection for a 1/4 mile assembly line. However I have not written RLL yet. I am here to learn the RLL.
 
Use DDE! Simple to Use!

These guys are right about DDE from what I have learned in the past two weeks, but I'll tell you, my example above is only reading a whole FIVE words. And to stay on topic of your original question, you asked for an example for VB and PLC, so that's what I had on my plate at the time.

Maybe since OPC is much better, someone else can post an OPC example...hmm...novel
 
Learning OPC

To learn OPC, it may be best to start with a control which is dropped onto a VB, Excel, Access form. Other programming languages, i.e. Delphi work well too, I am told.

There is a demo at
http://www.4ce-industry.com/Home.htm
which never times out so you can take your time learning it. It is crippled though, limited to 10 data points and must be restarted every 2 hours of run time. The web page starts in French but simply click the American flag for English. (Apparently only Americans speak English?)

Another control can be found at
http://www.opcactivex.com/
This one has, as I recall, a 30 day license. This one is very easy to connect to other onscreen controls, i.e. a text box. One could quickly create RS View like apps using VB very easily with this one.

For those using AB, RSLinx is still needed. Set up the DDE/OPC topic as describe previously in this thread.

Remember OLE is DDE Version 3, basically. M$ renamed the technology to make it sound like a new technology rather than ad a version number. The progression is DDE, ActiveX, OLE. For those who started with DDE, your time was not wasted. There are differences but your learnings are still useful.

I see that SOAP is mentioned on the OPC Foundations web site as well. Therefore now is likely a good time for me to begin learning SOAP.

There is a small but reasonable amount of information on the WEB regarding OPC Programming. I will go through some old e-mails and see if I can find more info/resources to post here, if there is interest in data collection. I cannot post code from applications that I have written, since my employer disapproves donating resources for others to profit. However, I should be able to glean some samples, latter.
 

Similar Topics

Hi, i'm using SoMachine opc server (CoDeSys) for modicon M238 PLC, and I want to create application in VB (2010 or 2012) but when i try to read...
Replies
3
Views
2,318
hey anyone, I'm a student from Indonesia.. I have a project, It is about how to send and receive data by serial communication between PLC Omron...
Replies
2
Views
2,117
i want to make device on and off using visual basic button and communicating with plc 5/30 serial port.I am able to read data from plc serial port...
Replies
1
Views
3,076
Hi, I have virtualy no llc experience so please bear with me . I have a "dash board" application that reports data that i collect from various...
Replies
4
Views
2,065
Hello my friends, I plan to develop an application in vb6 allowing the user to control the process remotely. I want to know: 1 The...
Replies
2
Views
6,414
Back
Top Bottom