Communicating with PLC Using Visual C++


Thread Starter

Tichaona Mungadze

I would like to be able to retrieve data from a PLC and make it available to Visual Basic. Do I use Visual C++? Is there an easy way of doing it? If you have any information, source code, manuals etc., please mail them to the following email address : [email protected]. Thank you.
There is no reason I know of to use Visual C++ to port data to Visual Basic. What you need to do is determine the PLC you want to communicate to. Then settle on what hardware to use (ie the PLC has an RS232 serial port), then get the communication parameters (ie send and receive string formats and such) from the PLC vendor or manufacturer.

I have used Omron PLCs this way, essentially as an IO card for my computer. It can be handy to get data from a conrol system into a data acquisition system.
I think my previous message might have gone out unfinished....

Anyway, forget Visual C++ (unless you just like it) and get familiar with a serial comm function in Visual Basic (I have used MSComm in VB5). Get the communication parameters from the PLC manufacturer, and you're about set.... to do a little learning about RS232 in the VB environment. Its not bad.

When you get this far along, email me and I can help point you down the road.

Good luck!

sphelps - RPD Abbott Laboratories

You may want to be more specific in your requirements. What brand of PLC? How is the PLC and Computer going to be connected? Etc...

A good place to start for VB/VC++ software tools/drivers is (

If you are connecting to AB or Modicon, my personal favorites are INGEAR ActiveX PLC Controls ( This drivers are very fast and reliable.

The industry is going to a more open standard for communictation called OPC. You can fined out more about OPC at ( There are many OPC servers on the market, I am sure there is one available for your specific PLC. OPC allows you to use Microsoft OLE/COM to talk to PLC's. IF you need speed, reliablity and security, I would stay away from OPC and go with a more direct interface.


patrick long

i have tried to send the mscomm strings to my omron plc's with no luck. could you send me a sample of a simple read and write? my string that i send looks something like this "@08rd00550001*chr$(13). thanks!
//transmits data to omron PLC trought serial port CString sz_StringToEmit; LPWSTR text= new WCHAR[100]; //********** Emision de datos al automata por el port serie ************* VARIANT var; sz_StringToEmit= "@_node_......."; MultiByteToWideChar(CP_ACP,0,sz_StringToEmit,100,text,100); var.vt=VT_BSTR; var.bstrVal = ::SysAllocStringLen(text,100); m_Link.SetOutput(var); //**************** fin emitir datos m_Link is an MSCommControl objetc (I am using VC++6.0 ). I have implemented also functions that calculates the FCS termination for emision and the receiving data validation. If you need more info email me at [email protected] ..... and sorry for my poor english
I have used Omron PLCs this way, essentially as an IO card for my computer. It can be handy to get data from a control system into a data acquisition system.