“I know exactly what is happening on my plant floor.” At the [MC]2 2013 conference last week I was introduced to what were called Turner’s Five Laws of Manufacturing. One of those laws: whenever someone tells you that, don’t believe them.
Better yet, try the following. Ask them to pull out their smartphone. They do have one, right?
- Ask them how the S&P is doing. (As I write this, it’s -26.33 for the day to 1,548.24.)
- Now ask them for this evening’s weather forecast. (Low 60°F, 30% chance of rain.)
- Now ask them for the part count, hourly efficiency, and downtimes of their machines since 8am today.
Dave Edstrom and John Turner made this point in the conference lectures. We live in an age when Siri can give us directions to the nearest Applebee’s. How many machine operators receive a notification when one of their machines goes down? The penetration of machine monitoring packages on the shop floor is still surprisingly low.
The repeated MTConnect mantra has been “different devices, common connection”. As evidenced last week at [MC]2, multiple companies are working to provide solutions to all sorts of problems in the machining realm: live monitoring, fault notification, fault prediction and trending, efficiency reporting, and so on. With so many solutions available, any shop ought to benefit from at least one of them.
But all of this work on the software side comes down to one question: does your CNC speak MTConnect?
Is an MTConnect Adapter available?
What’s an adapter? It’s not exactly part of the MTConnect standard, but an adapter is a module that sits somewhere between your CNC and the MTConnect agent.
You can think of it as a translator or converter: it takes the data your CNC provides and converts it into a format that the MTConnect Agent can understand. The MTConnect Agent, in turn, outputs MTConnect-compliant XML data that is understood by any of the existing MTConnect software applications.
Modern Machine shop has a good explanation of both Agents and Adapters in its article “Understanding MTConnect Agents and Adapters”.
An MTConnect adapter can be hardware (a “converter box”) or software. The MTConnect site on GitHub has an adapters project that includes sample adapters for various machine tools. Another place to check is with your distributors, or with the machine builder directly.
If an MTConnect adapter is available for your CNC, your CNC can use it to speak MTConnect — which means it can talk to any of the numerous MTConnect-compliant software packages that have been and are being developed.
If no adapter is available
So you’ve checked the MTConnect GitHub page, talked to your distributors, even emailed your machine tool builder directly. None of them are able to provide you with an MTConnect adapter for your CNC. That’s a bummer.
As time goes on and the standard gains support, more machine tool builders will start providing MTConnect solutions for their CNCs.
In the meantime, all hope is not lost. If you have a vendor-provided API for getting CNC data in software, it’s reasonably easy to write your own MTConnect adapter. You will need to have at least a little software development experience.
C++ Adapter Template
If your vendor provided you with an API, it’s probably a library written in C, and probably a Windows dll or a set of Windows dlls.
You’ll need the API documentation or developer’s reference. This will explain the basics of how to use the API, such as how to connect to your CNC (through ethernet, serial, etc.), and which functions will return what data.
Check GitHub for an MTConnect adapter template in C++. The documentation is a little sparse, but there are several example implementations that you can use for reference.
C++ isn’t your language? Mine, neither. Maybe you’re a .NET developer? Maybe the API supplied by your vendor is a .NET assembly?
At this year’s [MC]2 conference, Will Sobel hosted a lecture on developing MTConnect adapters. He provides a walkthrough written in C# along with the lecture materials.
The completed materials include a complete, working example along with classes that can be used for developing your own adapter. It’s pretty well documented — switch the output to “class library”, and you have a DLL containing an MTCAdapter class that you can reference in your own adapter project. Word at the lecture is that if Will Sobel sees enough interest, he’ll package up the code as a toolkit.
You’ll need Visual Studio 2010 or higher in order to work with the AdapterLab solution. Visual C# 2010 Express can be downloaded from Microsoft free for evaluation purposes. If you’re more into open-source, SharpDevelop is a free open-source development environment for .NET.
Translated AdapterLab for VS2008
Some of you might be in the same position I’m in: still working with Visual Studio 2008. Corporate upgrades are a slow process, aren’t they? We just recently started targeting .NET 3.5 for our builds.
The AdapterLab solution is written for VS2010. You can force it to load in VS2008 by opening the .sln file in Notepad and changing a couple of lines (change the version from 11.0 to 10.0, and 2010 to 2008), but then you run into a funny problem.
C# did not have optional parameters until the VS2010 release. I say this is funny, because if you load the AdapterLab solution in VS2008, you’ll see something like this:
“Default parameter specifiers are not permitted.” So the C# compiler knows of default parameters, and even knows what the syntax of them would be if it did support them, but it doesn’t support them. Cute, eh?
I could have rewritten the methods using default parameters by splitting them up into multiple overloaded methods, but here’s the other funnier thing: instead of doing that, it’s easier just to translate the whole project into VB, which has supported optional parameters since before .NET was a thing.
In the unlikely chance that you’re stuck with Visual Studio 2008 and would like a version of the AdapterLab project that will work in that version, contact me. I can send you an AdapterLab solution translated into VB.NET.
Other languages and platforms
If neither C++ nor .NET will suit your needs, you can roll your own adapter code. An MTConnect adapter is just a very simple TCP server. It listens for connections on a specified port, and sends status data to any connected clients.
This data is sent in a format known as SHDR. I’m not sure if it’s intended to be pronounced “shader”, “shedder”, or “seder”. In my head, I can’t help but hear it as “shadder”, or “shadow” with a country accent. Someone please help me.
Regardless, SHDR is a very simple pipe-delimited text format. There’s a specification for it along with the adapter project on GitHub: look for the MTC_SHDR.docx document in the root directory. You can even use the existing code as a reference for how to structure an adapter in your chosen language.
So whether your language is Java, Pascal, Python, Intercal, or something else, as long as you can listen on a TCP port, collect your CNC status, and put together a string, you can create an adapter.
When there is no API
Not only can you not find an adapter for your CNC, you can’t even get your hands on an API. Maybe there’s not an API for your CNC. Maybe the quote your distributor gave you for upgrading your CNC with a network interface card would blow your budget. Maybe the vendor’s API was written by a lone wolf developer who quit his job five years ago, sold all his possessions, changed his name, and moved to Manila without documenting any of his code.
Whatever the case, you’ve done the research and can’t find any way of accessing your CNC data in software.
There are a few companies that provide “black box” hardware for MTConnect. The hardware hooks up to your CNC, and runs its own MTConnect Adapter or Agent. Installing hardware tends to be a CNC-specific integration task. Someone will have to research your CNC, check wiring diagrams or PLC ladder logic, then shut it down, install the box, configure it, etc.
For older CNCs, or CNCs whose manufacturers charge for the API or for connectivity upgrades, this may still be the least expensive path to getting your CNCs to speak MTConnect.
MTConnect is not just another language: it’s the new Rosetta stone of the machining world, and teaching your CNC to speak it opens up plenty of possibilities for monitoring your shop floor.
Newer CNCs may already support MTConnect, but even if there is currently no support for your CNC, it may be possible to create an MTConnect adapter inexpensively and easily. Even for older machines, there may be options for getting your CNC to provide enough data for basic monitoring of status.
So, if your CNC doesn’t speak MTConnect, why not?