09-22-2016 10:29 AM
I'm glad this issue has had some traffic. My need, communicating with 12 daisy-chained MTS Magneto-strictive sensors, RHU0050UD561N101, was never solved, just back-burnered. And interestingly, is just recently coming back to front burner. I figured I would have to work with MTS to find some very small, very simple PLC that could interface between TCP/IP and Ethernet/IP.
Moxa, I believe, makes an interface box, but there is so much I do not know about the low level protocol, I never got anywhere with that.
09-23-2016 10:46 AM
This is a very rough start from some code that I had done in LabVIEW to communicate with a Keyence sensor that offered an Ethernt/IP interface as one of the possible options. The LabVIEW code did work but this here was never finished! So beware, it will require some more debugging for sure and looking at other implementations like https://github.com/EIPStackGroup/OpENer/tree/master/source/src/cip (which is an example device implementation in C, so the other side of what you want to do here, but it can still help to understand the actual protocol) or https://eipnet.codeplex.com/ (which is another server implementation but in C# so not directly applicable for CVI either).
One thing that put me off is the callback handling of the data that the CVI TCP library requires. That makes everything kind of tricky, although as long as you don't execute this code in a seperate thread it should probably be fine. Otherwise you will quite likely run into trouble with the callback and the EthernetIP_Read() function accessing the data in the connection resource in parallel and possibly conflicting.
This is very simplicistic! Ethernet/IP consists of many more messages, quite a bit is devoted to cyclic messaging and setting up periodic update messages by the device itself. This library only implements the RegisterSession, UnregisterSession for establishing and tearing down of a session and the RequestResponse command for acyclic command/response messages. This should be enough for simple IO based devices but will fail for many other classes of Ethernet/IP devices.
And the most important thing, just like with Modbus you do have to have documentation about what serviceCode, classID, instanceID and attributteID you need to use to access a specific item (register) in the device and what datatype the possible data value is supposed to be. So while the Ethernet/IP part is basically handled (albeit never fully tested in the CVI case) you will need to implement something along the lines of what is shown in example.c for your own device. And that means your device will need to come with documentation for this. If you can't get that documentation or you do not know how to apply the information from it, this library will still do absolutely nothing for you.
09-23-2016 11:29 AM
Thanks for your help, Rolf. I will start working with your code right away. Have a great day, and a Happy Friday!
09-23-2016 11:31 AM
Please post your results back here. I am waiting for the been-counters to give me a charge number before I can dive into this for the Magneto-strictive sensors.
06-28-2020 08:54 PM
Try www.sybera.de