Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • Products
  • Automation Systems
  • Machine Automation Controllers

Understanding Scrambled Strings Between CJ and Sysmac Series PLCs

Written by Arlo D'Cruz

Updated at November 6th, 2025

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Products
    Automation Systems Control Components Motion & Drives Quality control & Inspection Robotics Safety Sensing Services Software Switching Components
  • Amplify e-Store
    e-Store public
  • Public CSC
+ More

When sending string data between a CJ-series PLC and a Sysmac-series (NJ/NX) PLC via EtherNet/IP, users may notice that the received string appears "scrambled".

For example, if a CJ PLC stores the string "ABCD" in words D0 and D1, the Sysmac PLC may decode the same data as "BADC". This occurs because of differences in how strings are stored in memory between the two PLC families.


How Strings Are Stored in the CJ-Series PLC

In the CJ series, each word (16 bits) holds two ASCII characters, but the byte order is reversed compared to Sysmac PLCs.

For instance, consider the string "ABCD" stored as follows:

CJ Word Content Binary Representation Description
D0 41 42 01000001 01000010 “A” is stored in the upper byte (bits 8–15), “B” in the lower byte (bits 0–7)
D1 43 44 01000011 01000100 “C” is stored in the upper byte, “D” in the lower byte

How Sysmac Reads the Same Memory Area

When this data is read via EtherNet/IP, the Sysmac PLC interprets the data byte by byte, without accounting for the CJ byte order.
The mapping below shows how bytes are interpreted on the Sysmac side:

So in memory, D0 and D1 contain:

D0 = 4142h
D1 = 4344h
CJ Memory Location Character Sysmac Byte Index Notes
D0, byte 0 (bits 0–7) B Byte 1 Lower byte of D0
D0, byte 1 (bits 8–15) A Byte 2 Upper byte of D0
D1, byte 0 (bits 0–7) D Byte 3 Lower byte of D1
D1, byte 1 (bits 8–15) C Byte 4 Upper byte of D1

Thus, when the Sysmac PLC converts these bytes into a string, the result is:

When read as a contiguous byte array, the original string "ABCD" is stored in the STRING variable as "BADC".


How to Correct the Byte Order

To ensure strings are read correctly, the byte order must be swapped. This can be done either on the CJ or the Sysmac side.

Option 1: Swap Bytes in the CJ PLC

Use the SWAP(637) instruction to reverse the bytes within each word before transmission.

Example:

The resulting data will appear correctly as "ABCD" when read by the Sysmac PLC.

Option 2: Swap Bytes in the Sysmac PLC

On the Sysmac side, it’s recommended to read the data as a BYTE array instead of a STRING.
You can then use the Exchange() function to swap each byte pair before converting back to a string.

Example Structured Text:

// Swap each pair of bytes
Exchange(str_As_Byte_Ary[0], str_As_Byte_Ary[1]);
Exchange(str_As_Byte_Ary[2], str_As_Byte_Ary[3]);

// Convert to string
OutputString  := AryToString(str_As_Byte_Ary, 4);

 

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Prefixes in Cx-Programmer
  • Indirect addressing DM in CX-Programmer
  • How to Use Unions in Sysmac Studio

Definition by Author

0
0
Expand