Fetching PLC Tags on OMRON NX102 hardware

279 views
Skip to first unread message

gaurav...@gmail.com

unread,
Sep 28, 2022, 9:07:38 AM9/28/22
to libplctag
Hi Team,

This looks like a wonderful library and I was trying to fetch data from OMRON NX102 hardware. Later on, I have to try the same with CJ2M as well.

I can create and control all the tags and code in the PLC and I created a tag in the NX PLC as  ToPLC (4 Bytes) and FromPLC (4 Bytes). The PLC IP is configured to 10.0.0.1 and PC as 10.0.0.2.

I am using to libplctag-2.5.2 and using simple_cpp.cpp as my code and pre built libraries. After reading the conversation (shown in Italic below) I used my TAG_PATH as:

#define TAG_PATH "protocol=ab-eip&gateway=10.0.0.1&path=18,10.0.0.1&plc=omron-njnx&name=FromPLC"

but the code is throwing exception at line:

/* create the tag */
    tag = plc_tag_create(TAG_PATH, DATA_TIMEOUT);


#1 Can anyone please guide about what is wrong here? 
I had linked the libraries cli.lib, plctag.dll, plctag.lib, plctag_static.lib in an empty VS2019 solution and copied the code from simple_cpp.cpp and managed to compile and link successfully.

#2 Can someone also help me with  any instructions or any resources about how to compile the source code  (with visual studio 2019)? I used CMAKE tool and converted to VS2019 solution and then did build all. But it did not generate any dll or lib. 
I assume I need to generate cli.lib, plctag.dll, plctag.lib, plctag_static.lib for running a new project with custom code. I was not able to generate above with build all in VS.

Below is the conversation I was referring to.
conversation subject: trying to use the libplctag4j but PLCTAG_ERR_NOT_FOUND



May 21, 2022, 3:21:57 PM
to libplctag
Hi, thanks for using the library!

The path for Omron PLCs is a bit weird.  Your path is "0" which is definitely not going to work.  The path needs to have the IP address of the PLC in it as if you were using CIP bridging to it:

protocol=ab-eip&gateway=127.0.0.1&path=18,127.0.0.1&plc=omron-njnx&name=TestDINTArray

Replace the "127.0.0.1" with the correct PLC address.

Try this using the core library tag_rw2 test tool.   With that you can try different tag strings until you get it wright without having to recompile your code.

Let me know if this helps!

Best,
Kyle

Kyle

unread,
Sep 29, 2022, 11:22:35 AM9/29/22
to libplctag
Hi, thanks for looking at libplctag.

The C library does not throw exceptions.   Is it returning an error at the tag creation step?

Have you tried using the tag_rw2 tool?   That will let you test your tag string without having to recompile and can speed up development.   Use the debug flag to output a detail log with "--debug=4".   Please capture that log and post it here and I can try to help.

Unfortunately, Omron PLCs only partially support the full Rockwell CIP command set so there are things that do not work.  However, if all you are trying to do is read a couple of DINT tags, you should be fine.  

I do not have access to an Omron PLC to test.   I was hoping to get ahold of one before the pandemic but the company I was talking to went out of business :-(

Best,
Kyle
Reply all
Reply to author
Forward
0 new messages