Industrial Automation
Industrial Automation | Europe

myKnowledge

Main > Product Type > Automation Systems > Networks
Minimize Text   Default    Enlarge Text
 

Print
E-mail

NJ/CJ Variable Alignment On EtherNet/IP


Both the NJ and the CJ series PLC can work with Structure datatypes.

A Structure can consist of:

  • BOOL, BYTE, INT, WORD, DWORD, LWORD, FLOAT.
  • Size is BIT, BYTE, WORD, 2 WORDS and 4 WORDS.

However the NJ and CJ controllers align the structures differently in memory. The CJ series controllers just place all members of a structure directly after each other.

A structure defined in a CJ controller consisting of a LWORD, WORD, LWORD is in total 8 bytes, 2 bytes, 8 bytes is 18 bytes in size. 
 

The NJ controllers handle structures differently. The alignment of the members of a structure is according to their size. It can be on a byte, word, 2 word or 4 word boundary.


 

The same structure of LWORD, WORD, LWORD allocates more memory in the NJ. In this example the total memory allocated is 24 bytes.

If such a structure is then transfered by means of variable name as tagname from a NJ controller to a CJ controller (or vice versa) over EtherNet/IP then this will fail with a size mismatch.

The reason is that EtherNet/IP only transfers a block of data. During opening of the IO connection there is no information exchanged on the structure. Therefore both nodes conclude that the size is different and they will not start to exchange data.

Workaround is to insert so called dummy members to fill the gaps of not used memory. In this way both structures will allocated the same amount of memory and now the structures can be exchanged over EtherNet/IP.




Comments (View All Comments / Add Comment)

Related Articles
No related articles found.
Created 2011-12-28
Modified 2014-07-01
Views 11333

 

You are not logged in.