Moving Data into a PC

Moving-Data-into-a-PC
One of the hats I wear here at RTA is the “I’ve got a weird question – can you help me” hat. I get all the strange and oddball application questions that Drew doesn’t want to answer.

One of the ones that I see a lot is how do I get data from “here” into my PC application where “here” can be a PLC, a Modbus flow meter, a CANopen pump or pretty much anything else. The guy usually wants to simply archive some data or get it into Excel and create a graph. [The more advanced ones want to do Automation using one of the cool Automation tool but it’s still the same general case]

There’s lots of ways to go on this and I have my preference as you will see.

In the bad old days we did this using the serial port. We would have to write a driver and then build a CSV file (comma delimited file) and then open the CSV file with Excel. That won’t fly anymore for lots of reasons but mostly because most PCs no longer have serial ports. Few people want to take the time to write software like that. It’s not fun and it’s a maintenance nightmare.

But if we did go that route now would we use the USB port or Ethernet port? If writing code is an option, you can code a driver to operate over either of these ports or buy one from somebody like us. Your code could then integrate into the Microsoft architecture and pass live data to programs like Excel or Word.

With the USB port you would probably buy one of those USB to serial converters for about $50 or so and your code would send and receive to the device over a serial link. The USB port would look like a serial port to your code. If your device is Ethernet based, you would do much the same thing only you would send and receive over a Sockets interface using the TCP/IP stack.

There are several ways to link your program to Excel once you are sending and receiving messages to your device. I am not an expert on Windows interprocess communication so I’ll leave that part of it to others. Heavens knows there are enough books and web pages dedicated to that topic.

But there is a best way. It’s been the best way for about 10 years now. That’s to use an OPC Server. An OPC server contains the application layer protocol interface for an external device and an interface to DCOM; one of Microsoft’s interprocess communication standards.

All Microsoft products have a DCOM interface and it’s easy to point an entry in a MS product like Excel at some piece of data in the OPC Server and have it show up in your excel spreadsheet. Really simple. Just a matter of getting the syntax of the link correct.

Now the downside of the OPC Server is that it’s going to cost you anywhere from $300 to $1200 every time you want to setup a new PC with this data capture mechanism. If you’re shipping a lot of these it could add up to real money.

It’s in these high volumes where the cost of doing your own interface which accomplishes all the same function as an off-the-shelf OPC server is more cost effective. Your best bet in these cases is to buy a royalty free Modbus TCP Client, a Royalty Free Modbus RTU Master or something more sophisticated. Check with me if you’re not sure what you need.

Attention: Our office will be closed on Friday, July 3rd in observance of Independence Day. Normal business hours will resume on Monday, July 6th. Have a safe and happy holiday! Thank you.