Category Archives: Uncategorized

MTConnect in 2016

Two years ago, when my research into MTConnect began, the landscape of industrial data collection was far different than it is today. There were a few Amazon, Google, Salesforce, IBM type companies driving deliverables online with a very small percentage profiting from the often large investments in data centers, and programming. Now, all industries from your local grocery store, banks and high tech startups are all driving to a singular goal, drive customer interaction online as either self-directed or end point delivered. Not only has the value in owning data been realized, but the costs in not owning data are being recognized. The need for large data viaducts, flexible processing power, and reliable, responsive data storage all while being instantly scalable created a business in cloud computing, and evolved many services to capitalize on business opportunity and necessity. Revisiting MTConnect today reveals a different use case than even two years ago.

The influx of switchboard applications such as nifi, fluentd, and flume has diminished the requirement for standards in machine interconnection. Almost any protocol can be made interoperable with any other protocol. Moreover, industry specific standards are now detraction from the myriad of possibilities for data analytics and big data logistics freely available to everyone as open source projects. MTConnect should now be recognized as an on premise connector rather than an end to end solution. This model is far more suited to modern business intelligence than a proprietary MTConnect endpoint. Importantly, MTConnect could then be looked at as the ‘universal’ adapter for IIoT to BI property because of its interoperability with nifi, fluentd and flume, etc.

Even though the standardization through the use of a schema is depreciated, many parts of MTConnect serve a solid anchor to base extract, transform and load (ETL) operations from. Specifically, the state buffer created by the MTConnect agent greatly reduces the data throughput required. Additionally, the trapped ‘UNAVAILABLE’ state assists with tristate data that can be on/off/unknown. Furthermore, through the implementation of XSLT stylesheets available to implement in MTConnect; JSON as well as the native XML are available for consumption to upstream processes greatly simplifying the ingress of data from shop floor to cloud infrastructure.

Most certainly, the driving factor behind using MTConnect in shop floor monitoring is no longer the standardization to a communication protocol. Instead, the decision made long ago to open source the reference material will carry far more weight, as the race to data dominance ends in one place… at the bottom.

MTConnect FANUC Adapter on Ubuntu Linux

 

The FANUC FOCAS shared library from the FANUC FOCAS CD A02B-0207-K737 version 4.1 or higher  must first be installed and registered in Ubuntu 14.04 LTS.

$ sudo cp libfwlib32.so.1.0.0 /usr/local/lib/libfwlib32.so.1.0.0
$ sudo ldconfig
$ sudo ln -s /usr/local/lib/libfwlib32.so.1.0.0 /usr/local/lib/libfwlib32.so

Next up we need to get the MTConnect adapter from GitHub.

$ cd ~ 
$ git clone https://github.com/mtconnect/adapter.git

We only actually need a limited subset of files from the adapter downloaded from GitHub.  For convenience in building the binary we will copy all the needed files to the same directory. (Note, so wildcards can be used more than the needed files are copied.)

$ mkdir fanuc
$ cp ~/adapter/fanuc/adapter.ini ~/fanuc/adapter.ini
$ cp ~/adapter/fanuc/fanuc.xml ~/fanuc/fanuc.xml
$ cp ~/adapter/fanuc/*.cpp ~/fanuc/
$ cp ~/adapter/fanuc/*.hpp ~/fanuc/
$ cp ~/adapter/src/*.cpp ~/fanuc/
$ cp ~/adapter/src/*.hpp ~/fanuc/
$ cp ~/adapter/minIni_07/*.c ~/fanuc/
$ cp ~/adapter/minIni_07/*.h ~/fanuc/

Once the files are in the ~/fanuc/ directory, we need to modify the source code.  The GitHub adapter was meant for Windows, and their are several functions that need to be modified.

$ sudo nano ~/fanuc/fanuc_adapter.cpp
  
    Remove: #include <excpt.h>
    Change: __try and __exception to try/catch(...)

    Change: Sleep(5000) to sleep(5)

    Change: _strnicmp() to strncasecmp()

    Add Before : short ret = :: cnc_allclibhndl3...

    long level = 3;
    std::string filename = "focas.log";
    const char * c =  filename.c_str();
    short log = ::cnc_startupprocess(level, c);

    Add After: cnc_freelibhndl....

    cnc_exitprocess();

Finally the header file for Linux from the FOCAS cd is copied to the directory.  Note the name change required as the source files refer to to Fwlib32.h.

$ sudo cp fwlib32.h ~/fanuc/Fwlib32.h

With the source code modified, its time to compile the binary.  Sorry for the sloppy g++ command, this could be cleaned up with a nice CMakeLists.txt.

$ cd ~/fanuc/
$ g++ minIni.c device_datum.cpp fanuc_axis.cpp fanuc_path.cpp service.cpp condition.cpp cutting_tool.cpp string_buffer.cpp logger.cpp client.cpp server.cpp adapter.cpp fanuc_adapter.cpp FanucAdapter.cpp -lfwlib32 -lpthread -o adapter

Finally setup the adapter.ini file with the appropriate settings for your machine and run the binary.

$ ./adapter debug adapter.ini

Conclusion I’m certain one day the source code for the Linux FANUC adapter will be available from GitHub as the code is just a slight adaptation from the Windows version.  Until then, I hope you enjoyed this tutorial!