VB6/PLC communication

D

Thread Starter

Devant

My current project revolves around connecting to an existing plc system and retrieving data for research from it. I would appreciate any help on how to make visual basic to 'cooperate' :)

Ok, before going into the details, let me summarize the system speicifications.

I am using visual basic 6, and the target PLC is LG, having a GM6 application inside. I am connecting with MPI (RS232) and have no chances for hardware upgrade (I requested ModBus but the module request was rejected).

The good thing is that the memory this PLC uses is divided into segments of 16 bits, without the fussy logic of Siemens' PLCs. Also, I get to read mostly booleans and a few integers (no DINTS, SINTS etc).

Now, I have the plc connected to COM1 of my pc, the program is running in the PLC, the GMWIN monitors the program and all is fine.

The question is: how can I make visual basic to read and write in the plc memory? I get to poll the pc for 72 booleans each 5-6 secs, 2 ints each 0.1 sec, and 6 ints each 10-12 secs. Take in mind that I am a programmer but I know next to nothing about PLCs.

I deducted that I need a VB control to take care of this, but everything I found on the net was about ModBus.
 
Hi!

I advise you to research the MPI communication. I suppose it is a master/slave communication too. If the VB6 will act as the master you should send a message to your slave with VB.net. This is really easy using the serial port object. Then listen to the port for the answer. The only trick is to set up the communication correctly, ex. pulling the DTR pin high (can be done from VB.net), etc.

So the only difficulty is to find good documentation on MPI protocol. You will need to know the exact format of the message to send!

Sorry if I did not help, I am a novice both in PC and PLC programming.
 
N

Nathan Boeger

Is writing the VB app your project or are you trying to analyze PLC data?

If you're trying to get the data from the PLC try a free evaluation of FactorySQL. You need an evaluation of an OPC Server. Kepware probably has a driver for KepServer Ex, which you can also evaluate for free. The vendor probably has one too. FactorySQL allows you to drag and drop the PLC registers to groups that will log the data to an SQL database of your choosing. Data mining from an SQL database should be easy enough.
http://www.inductiveautomation.com/products/factorysql/
http://www.kepware.com

I don't know how to use VB to talk to your specific PLC without OPC, but it's surely possible. If the program is the project, I would recommend looking into the OPC Foundation and OPC standard. You would still need an OPC server. The foundation and other companies have sample client code. The advantage is that a lot of potential headaches are taken care of for you and that you will be potentially interoperable with many other devices if necessary. Writting the code for your specific processor and application would most likely be a throw away deal (not very reusable code).

Hope this is a good starting point for you.

----
Nathan Boeger
Design Simplicity Cures Engineered Complexity
Inductive Automation
 
Top