Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interfacing .NET with Siemens PLC S7 200

I'm trying to interface .NET (C# or VB doesn't matter) with a Siemens PLC S7 200. I can't however get a connection set up. I'm working on a Win7 64bit machine but can't seem to get it working on 32bit either. I got two files:

Interop.OPCSiemensDAAutomation.dll Siemens_s7-200.dll

From another project which I'm trying to migrate to a newer system. However I get a com exception all the time.

Retrieving the COM class factory for component with CLSID {01704EBD-44B5-11D3-9C09-00105A3DD3AC} failed due to the following error: 80040154.

I've already tried libnodave and can't seem to get that working either. Can somebody provide me with some pointers (please no XKCD humor on that one) to where to look?

I couldn't get Siemens PC-Access to install on this machine, will try on a WinXP 32bit later. I read something about I need an OPC server or something on the machine?

Please bear with me, first time interfacing with a PLC :/

like image 320
Henrik Avatar asked Feb 23 '23 11:02

Henrik


2 Answers

The COM exception is a fairly generic error that indicates that the COM library itself or one its dependencies could not be loaded. Some things I would check are:

  • Is the COM library registered on the machine? You can use regsvr32 to register a COM dll.
  • Does the COM library require other dependencies that may not be on the machine? You can use dumpbin /dependents to figure this out.
  • Does the Siemens PC-Access software have to be installed on the machine? You said that you could not get it to install which probably explains why the COM library could not be loaded.

Unfortunately this about all the help I can provide in solving your specific problem. However, I can point out that you can use the following products which act as OPC servers and have drivers that are compatible with the Siemens S7. These would be alternatives to using the Siemens OPC server.

  • Matrikon
  • Kepware

I have used both products in the past and I am pretty sure I used one of them (I cannot remember which one) to talk to a Siemens S7.

Also here is a really good website with information about using OPC in .NET.

like image 100
Brian Gideon Avatar answered Feb 26 '23 02:02

Brian Gideon


I've looked into doing this type of thing before. If you try to get at the controller directly, you could run into all kinds of proprietary issues. Automation software companies tend to keep a very tight reign over their protocols. If it's only the data you're after, then OPC is probably the best way to go. However, from what I've found, that's not free either. The OPC Foundation (opcfoundation.org) has a .NET API that's available at a cost in the $1-2K range I believe.

like image 40
jwatts1980 Avatar answered Feb 26 '23 02:02

jwatts1980