From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Industrial Communications

cancel
Showing results for 
Search instead for 
Did you mean: 

Ethernet IP toolkit Omron CJ2M PLC

Has anyone successfully gotten the Ethernet IP toolkit to work with an Omron CJ2M-CP31 PLC? 

I have been told that all I need to do is to place a simple EthernetIP Tag Read vi to read a tag from the PLC and a simple EthernetIP Tag Write to write to a tag. I was also told that it is not even necessary to create a session. I have attached a simple vi for demo purpose. I think my problem maybe in setting up tags on the Omron PLC. I have been able to get a Cognex barcode scanner to communicate with the CJ2M via EthernetIP by using the Omron Network Configurator and installing the eds file provided by Cognex. Then it was simply creating tag sets and assigning the PLC tags with the Cognex ones. The problem with going this route with PC/Labview is that there is not a eds file. I have tried using the Omron Data Link Tool, but was not successful. It would be great if anyone could give me some guidance on both the Labview and PLC side.

Thanks,

Rick

0 Kudos
Message 1 of 23
(20,083 Views)

Hi rpage,

 

I don't think Omron PLC supports Tag Read/Write. (Rockwell PLC does.)

 

For explicit messaging, I suggest you use Get/Set Attribute Single.vi. Please refer the examples Access Assembly Instance Data (Explicit).vi and Access Identity Attribute (Explicit).vi.

 

For implicit messaging, you probably need an EDS file. (Rockwell uses a template - Generic EIP Module for devices without EDS file.)

NI EIP toolkit does not provide a standard EDS file due to its flexiblity nature. But you can take reference from this page to customize an EDS of your own.

For the VI adapter part, you should refer to the example Create Assembly Instance.vi.

0 Kudos
Message 2 of 23
(20,072 Views)

Thanks for the info. I've looked at the "Setting up Implicit Ethernet/IP messaging between an Omron PLC and Vision Builder AI" and tried modifying the eds file. My problem is my lack of knowledge with dealing with eds files and using EZ-EDS. I found another very simple communication adapter eds file off of the odva.org website, but I didn't see anything about assebly instances in it. So I will continue my search.

 

Has anyone created an eds file based off of the EIP toolkit example "Create Assembly Instance.vi" with using the default assembly instance IDs of 100 and 150? It would have been nice if NI had included an eds file to go with the example. But, then again, maybe it is not that simple.

 

This is my first time exploring EthernetIP and I have to use an Omron PLC as I work for Omron (not in the Omron Automation and Safety Division). I find it very frustrating that the majority of the info available is for Rockwell. Yes, I'm aware the that Rockwell - Allen-Bradley is the most popular, but it is not the only option out there.

 

Anyways, thanks again for the info. The more I learn the better my questioning will get.

Rick

0 Kudos
Message 3 of 23
(20,058 Views)

Well for the assembly instance, please refer to the attached screenshot - it's actually a path.

eds path.JPG

The 96 and 64 are actual in hexdecimal, so they translates to 150 and 100 in decimal.

0 Kudos
Message 4 of 23
(20,035 Views)

Hi LewisL,

This looks very promising. Can I use your eds file as a base? The one that I have been trying to modify appears to be too simple and the NI Smart Camera Ethernet IP adapter eds file looks too complex.

Thanks,

Rick

0 Kudos
Message 5 of 23
(20,025 Views)

Hi Rick,

 

Sure you can. I can not guarantee that all the parameters are correctly set. Some of the parameters may be required to be of certain value by the PLC, so I suppose for those kind of settings, the Omron PLC manual should have the answers.

Anyway, attached is the EDS file.

 

0 Kudos
Message 6 of 23
(20,015 Views)

Thanks again for your help LewisL. I was not successful with using the eds file. However, I was able to create a vi that can read from the PLC. Here is what I did.


1. In CX Programmer I created a symbol called Data2Labview, Bool, Net. Variable publication.
2. In Labview, created a blank vi and added EthernetIP Read Tag
3. Network Path: 192.168.250.1,1,0
    Tag Name: Data2Labview
    Type: Raw
(Unfortunatel when I had originally set type to BOOL, Labview complained about incorrect data type request.

 

I receive an array of 4 elements: 193, 0, 0, 0. When I change the value on the PLC side for Data2Labview, I found that array element 3 changed accordingly.


Does anyone have any information on what 193 is? Or any information what the other array elements represent?

 

I tried replicating the same steps to write to the PLC. Of course, I created a new symbol on the PLC side called DataFromLabview in a different memory location and used a EthernetIP Write Tag. Again, I tried using a type BOOL with no success. When I changed the type to RAW and attached a data array size 1 with a value of zero, I get the following Error message:
Error Code: -251723760
EthernetIP Tag Write Raw.vi;
Details: CIP Error - Extended status may be available
CIP Status: 0x13 (Not enough data)

I then tried changing my data array to match that which I received from the PLC, 193, 0, x, 0 (where x is a 1 or 0), and still receive the same error message.

Does anyone have any suggestions or can direct me to some documentation that can explain what I should be sending?
Thanks for your assistance.
Rick

0 Kudos
Message 7 of 23
(19,990 Views)

My quest continues on. I found an excerpt from this book, "Industrial Communication Technology Handbook" both first and second edition, the following info:

Data Types:

1 bit (encoded into 1 byte) Boolean, Type Code 0xC1 (193 decimal)

1 byte, Type Code 0xD1, oxC6 or 0xC2 depending on if it is bit string, unsigned or signed.

....

 

So now I know that the first byte I received (193, 0, x, 0), 193 is the Data Type Code and through experimenting x is my bit from PLC. Now I just need to find more information on the packet information. Then I think I will be able to generate the necessary packets to write from Labview to the PLC.

 

If anyone is familiar with reading and writing raw bytes according to CIP specification, I'm open ears... Or in this case, open eyes.

Thanks,

Rick

 

Update, you can also find the info on ODVA.org's website, http://www.odva.org/Portals/0/Library/Publications_Numbered/PUB00123R0_Common%20Industrial_Protocol_...

0 Kudos
Message 8 of 23
(19,986 Views)

Hi Rick, 

 

You are right about the data type code.

 

The CIP spec Appendix C-6 explains it.

Our example Write Raw Tag & Read Tag.vi is an example of it, adapted to Rockwell's convention (e.g., the boolean type in Rockwell is actually is DWORD, rather than an actual bit)

0 Kudos
Message 9 of 23
(19,980 Views)

I am now able to read and write BOOL between Omron CJ2M PLC and Labview using the EthernetIP Toolkit. I'll document some of my steps here just in case anyone else needs it or finds it helpful. Thanks to the combine efforts of LewisL, Mano (Omron Automation Applications Engineer) and NI Support.

 

As I stated in an earlier post, I am able to read from the PLC to the Labview application. I did find out a little bit more about the 4 bytes I am receiving.

Byte[0] = 193 (0xC1) => Data Type Code BOOL found in Appendix C-6 in the CIP spec

Byte[1] = 0

Byte[2] = 0/1 => This is the BOOL value

Byte[3] = 0

 

I did not found anything that fully explains the formatting of this response, so I don't know what Byte[1] or Byte[3] represent.

 

As for being able to write from the Labview application to the PLC, I determined that the PLC is looking for 6 bytes of data. Here is how I came up with that number.

First, I looked at the example code provided for Writing Raw Data and saw that it was using the following bytes to send BOOL data:

Byte[0] = D3 => Data Type Code DWORD

Byte[1] = 0

Byte[2] = variable 'number of BOOL'

Byte[3] = variable 'BOOL data'

 

A big thanks to LewisL for explaining why D3 and not C1 was used.

 

When I tried sending (D3, 0, 1, 1) I got the following error message:

EthernetIP Tag Write Raw.vi; Details: CIP Error - Extended status may be available CIP Status: 0x13 (Not enough data)

 

I then started experimenting by increasing the number of bytes being sent until I received a different error message. This is the error message I got after increasing the number of bytes from 4 to 6.

EthernetIP Tag Write Raw.vi; Details: CIP Error - Extended status may be available CIP Status: 0x20 (Invalid parameter) CIP Extended Status: 0x8022 (Unknown Error)

 

Now instead of the error telling me that there was not enough data, it was telling me that there was an invalid parameter and an unknown error. Mano, with Omron Automation, had told me that the Boolean is actually 16 bits and to setup my symbol with an array size of 16. So I tried changing the data type code from 0xD3 (DWORD) to 0xD2 (WORD), but I still got the same error.

 

I had been digging through the CIP spec trying to find anything that would tell me the formatting of the data that needed to be sent and came across several Data Type Codes for 16 bit data types.  Here is the list:

C3 = INT

C7 = UINT

D2 = WORD (16-bit string)

 

When I looked up the ext error code 0x8022 0f error code 0x20, I found this explaination in the Omron NJ Ethernet Driver Manual. "The data type specified in the request service data does not agree with the tag information. The AddInfo Length in the request service data is not 0. After sevral more attempts at trial an error and researching, I came across this document, https://www.yumpu.com/en/document/view/19341321/nj-series-cpu-unit-built-in-ethernet-ip-port-users-m... and it looks like DWORD is a fixed-length 2-byte data. This actually comes out to 5 bytes in the packet. But I found if I reduced my data packet to anything less than 6, I got the not enough data error message.
Here is the data packet format.
Byte[0] = Data Type
Byte[1] = 0x00
Byte[2] = Num of Elem (0x00 or 0x01)
Byte[3] = Data (L)
Byte[4] = Data (H)

 

Now comes the point where I finally got it working.

I first had to edit the BOOL symbol in CX Programmer by double clicking on it and then clicking on the advance settings button and uncheck Array Symbol.
I then followed the Boolean Data example in the "NJ-Series CPU Unit Built-In Ethernet/IP Port User's Manual"
Here is the example:
Byte[0] = 0xC1
Byte[1] = 0x00
Byte[2] = 0x01 => Num of Elem
Byte[3] = 0x01 (TRUE) or 0x00 (FALSE) => Status byte
Byte[4] = 0x00 (Not Forced) or 0x01 (Forced) => Forced status information. Specify 0 when writing data.

 

It did not call for Byte[5] so I just left it as 0x00 in my Labview application.

When I tried changing Byte[3] from 0x00 to 0x01 to see if my BOOL was changing on the PLC side, I got the following error:
EthernetIP Tag Write Raw.vi;
Details: CIP Error - Extended status may be available
CIP Status: 0x20 (Invalid parameter)
CIP Extended Status: 0x8017 (Unknown Error)

Error 0x8017 being: More than one element was specified for a variable that does not have elements.

So I changed Byte[3] backed to 0x00 and continued to the next byte. I found that if I changed Byte[4] from 0x00 to 0x01, Then I saw my PLC memory location for symbol DataFromLabview change to a 1. And if I changed it back to 0x00, then I saw it change to 0 on the PLC side.

 

So my next question is Is there a slight difference in data formatting between NJ series and CJ2M CPU? I'm still looking for more concrete information and going to try and get the other data types working.

 

Sorry for the long winded response, but I thought it would be helpful to follow through some of the experimenting I did.

 

Thanks for everyone's help

Rick

Message 10 of 23
(19,964 Views)