Siemens offers useful tools for accessing both Simatic and SiMotion projects programmatically, in the form of registered COM Type Library DLLs. These tools offer many exciting possibilities (well, it does if you're like me, and get excited by things like automating automation tools). If you have Simatic Manager installed, the following DLLs are registered with it:
S7hcom_x 1.0 Type Library - The default location on my laptop is C:\Program Files (x86)\Siemens\Step7\S7BIN\S7HCOM_X.DLL)
Simatic 1.0 Type Library - C:\Program Files (x86)\Siemens\Step7\S7BIN\S7ABATCX.dll
Likewise, if you have SiMotion installed, the following DLL is registered with it:
SiMotion 1.0 Type Library - C:\Program Files (x86)\Siemens\Step7\S7BIN\U7WSCOAX.dll
With these libraries, PLC and SiMotion programmers can automate repetitive or difficult tasks in the familiar .NET development environment using the off-the-shelf Microsoft COM Interop tool.
Working withSimatic Manager
Using these DLL’s to mimic Simatic Manager is called using the Command Interface, and the object reference manual can be found on CD 2 of the Step 7 installation CD. After adding the DLLs as references in your project, getting started is as easy as the following:
Simatic Sim = new Simatic(); Project Proj = Sim.Projects.Add(@“C:\MyProject\MyProject.s7p”); Console.WriteLine("Project created on: “ + Proj.Created);
Working with SiMotion Scout
The parallel tool in SiMotion scout is simply called external scripting, and its object reference is in the standard Scout help interface. It’s pretty straightforward as well:
Application App = new Application(); Project Proj = App.Projects[@"C:\MyProject\MyProject.s7p"] Console.WriteLine("Compiling Project”); Proj.Build();
There it is. You can see how easy it is to access project data and remotely send commands to projects.
Implementation Ideas
As someone who works with Simatic Manager and SiMotion Scout on a daily basis, there are some interesting possibilities for automation using these tools. Here are a few ideas I am throwing around:
- Source control integration using SVN or similar tools. Currently Siemens does not offer a comprehensive source control solution for code, and third party tools are prohibitively expensive and do not offer the same merging, branching, and traceability features that are common in text-based programming languages. I could see DMC using these DLLs to automate exporting code source files into an SVN repo, and also importing them back into projects in order to have more sophisticated diff, merge, and trace capabilities in our Siemens projects.
- Automating repetitive programming tasks. For instance, oftentimes customers supply huge IO lists that need to be entered into a Siemens program, whether into the Symbol Table, data blocks, or code itself. These tools would let us automate these tasks to save a great deal of time, and reduce human error.
- Improving connectivity with other applications. We often have to export tag information from a Siemens data block to a CSV file in order to import it into some other company’s tool- an OPC server for instance. These DLLs give us a straightforward way to move data in and out of Siemens projects.
- Data acquisition from online data. Simatic Manager does not have a great trace feature like SiMotion does. These DLLs would allow a custom DAQ tool to collect data from the PLC without the need of an intermediary party’s driver, OPC server, etc.
I’m sure there are many more possibilities (and of course many may have been done already). Thanks for giving us these great tools, Siemens! And if anyone have any other insights or implementation ideas, be sure to let me know in the comments below.
Learn more about DMC's software and web development services.