IMDHMIControls LibraryShop main store

How-to

Send string data to a CompactLogix packed in DINTs

Industrial networks Published 7 min read

Short answer

A cyclic EtherNet/IP connection carries raw data blocks, not Logix STRING tags. Pack string data into DINTs: one DINT for the character count, then one DINT for every four characters, packed four bytes each. Rebuild the STRING in the CompactLogix; skip CIP Generic — it needs a documented object on the UniStream, and the adapter's application variables have none.

On this page
  1. Why the STRING tag cannot ride the connection
  2. The payload layout to define
  3. Steps to send and rebuild the registration
  4. If the bytes arrive wrong
  5. What the Class field is asking for
  6. The decisions
  7. Questions asked

Keep the cyclic connection that already moves DINTs between the UniStream adapter and the Generic Ethernet Module: it is the transport, and it is the only documented one. A cyclic EtherNet/IP assembly carries raw data blocks, and neither end sees a Logix STRING type inside it. Send the registration text packed in DINTs — one DINT for the character count, then one DINT for every four characters — and rebuild the STRING in the CompactLogix's own tags. CIP Generic will not rescue this: an explicit message addresses an object the target documents, and the UniStream adapter publishes no object for its application variables, which is why no value you enter in the Class field can work. The steps below add a packed text payload to the working connection and rebuild the string at the receiver.

Why the STRING tag cannot ride the connection #

In a Logix controller a STRING is not one value on the wire. It is a structure with a LEN member held as a DINT and a DATA member held as an array of SINTs, 82 elements long in the default type. The Generic Ethernet Module knows none of that: its configuration sets an Input Size and an Output Size counted in elements of the selected data format, and it moves those blocks verbatim. It cannot turn a UniStream text variable into a Logix STRING, and the UniStream side exposes no named tags a scanner could reference in the first place. The other route, an explicit CIP Generic read, needs a class, instance and attribute that identify an object the target implements — covered below. The decision is fixed before any of it: keep the cyclic connection and define the text payload yourself.

The payload layout to define #

Write the payload down before touching either tool:

  • Element 0 carries the character count as a DINT.
  • Elements 1 onward carry the characters, four single bytes packed per DINT.
  • Byte order: the example packs the first character into the lowest byte of each DINT; whichever order you pick, use it at both ends.
  • Encoding: registration letters and digits are basic Latin, so one byte per character as ASCII. If a field can carry more than basic Latin, fix a single-byte encoding before treating one byte as one character.
  • A count of zero means an empty field; a negative count is invalid and rejected.

A maximum of N characters needs 1 + ceil(N / 4) DINTs: one length element plus the character elements rounded up. This article uses a maximum of 8 characters, so the payload is 3 DINTs, 12 bytes, mapped after the existing signals:

Element Content Example frame for AB12CD34
0 character count 8
1 characters 1 to 4, lowest byte first built below
2 characters 5 to 8, lowest byte first built below

Growing the connection is the same arithmetic as sizing a Generic Ethernet Module connection for WAGO 750 I/O: count the elements in the configured data format and leave every existing signal where it is.

The packing arithmetic for the first DINT #

Take characters A, B, 1 and 2 of AB12CD34 and pack lowest byte first:

  • 'A' is ASCII 65: 65 × 1 = 65
  • 'B' is ASCII 66: 66 × 256 = 16,896
  • '1' is ASCII 49: 49 × 65,536 = 3,211,264
  • '2' is ASCII 50: 50 × 16,777,216 = 838,860,800

The packed DINT is 65 + 16,896 + 3,211,264 + 838,860,800 = 842,089,025. The second DINT packs C, D, 3 and 4 the same way: 67 + 68 × 256 + 51 × 65,536 + 52 × 16,777,216 = 875,775,043. Because the DINT is signed, a byte of 128 or more in the top position turns the whole value negative; letters and digits stay at 127 or below, so these two read as positive numbers. Do not judge the bytes from the decimal value alone — recover the bytes and compare them with the character sequence.

Steps to send and rebuild the registration #

  1. Record the connection as it is. From the Generic Ethernet Module properties note Input Size, Output Size and the data format, and note which UniStream variables map to which elements. Seen from the CompactLogix scanner, the module's input image receives the adapter data and its output image drives the adapter.
  2. Prove the path with a plain integer. Write a test value, for example 123456789, into the UniStream variable mapped to the first free element of the direction that carries the registration, and watch the matching element of the CompactLogix input image: it must change, and neighboring elements must keep their values. A value in the wrong element means fix the offset first; a value that never arrives means fix the connection before touching text.
  3. Reserve the payload. Grow the sizes by 3 DINTs — 12 bytes, entered as 3 elements in DINT format or 12 in a byte-counted format — keeping Input Size and Output Size consistent at both ends and leaving every mapped signal in place.
  4. Pack on the UniStream. Read the text field character by character as byte values and write each into its byte position of the mapped DINT elements, first character lowest, with the byte-access or shift blocks your platform exposes. Clear the unused bytes so a shorter text leaves no stale characters.
  5. Publish the count and the bytes together. Check the count against the agreed maximum, write the whole frame in one update, and add a sequence value in the next element if the receiver needs to confirm it saw a complete frame.
  6. Unpack and rebuild on the CompactLogix. Reject a negative count and any count above the smaller of the payload capacity and the destination string capacity; the frame is untrusted until it passes, and text that keys a machine action must not reach consuming logic unvalidated. Extract the bytes — a COP of the received DINT array into a SINT array four times as long copies the raw bytes, lowest byte of each DINT into the first SINT of each group — then copy the accepted bytes into the destination STRING's DATA member with the rest zeroed and assign the count to its LEN member.
  7. Test with AB12CD34. The CompactLogix should read the count of 8 and the two packed DINT values shown in the worked example above. Reversed characters inside a DINT mean the ends disagree on byte order: move each character to the position the other end expects and change one end only.

If the bytes arrive wrong #

What you see Likely cause Fix
Characters reversed inside each DINT The ends pack in different byte orders Move each character to the position the other end expects; change one end only
Text starts at the wrong element Element offset or count placement differs Compare the mapped element indices at both ends
Old characters remain after a shorter text Unused bytes or the LEN member not refreshed Clear unused bytes and set LEN to the new count at the receiver
The count arrives huge or negative The count element is mis-mapped or byte-swapped Repeat the step 2 test on the count element alone
Letters correct, digits or symbols wrong A byte is being read as a number, not a character Keep one byte per character; converting a character byte to a value is its own step

That last row is common when a digit must be processed numerically: once the bytes arrive right, converting an ASCII character SINT to a numerical REAL in Studio 5000 covers that conversion as a separate step.

What the Class field is asking for #

The Class field wants a CIP object class number that the target device documents together with an instance and an attribute; service, class, instance and attribute together name exactly one operation on one object. Standard objects such as the identity and assembly objects exist on EtherNet/IP devices, but they are not your application variables. The UniStream documents its EtherNet/IP adapter as a cyclic interface and publishes no object that exposes an application variable to explicit messages, so no triple identifies the registration text and there is nothing correct to type.

A class number borrowed from another device either errors out or reads an unrelated object. If a future need really requires explicit messaging, match the request to a documented object the way reading EtherNet/IP module register data with explicit messaging shows, and until the UniStream documentation names such an object, the packed cyclic payload is the implementation.

The decisions #

Where each case lands:

  • Cyclic DINT path working, text needed: run the steps above; the 8-character registration rides in 3 DINTs, and any other maximum scales as 1 + ceil(N / 4) DINTs.
  • CIP Generic stuck on Class: that is the expected symptom, not a configuration mistake — there is no documented object to address, so use the cyclic payload.
  • Bytes reversed or offset: correct the layout at one end and leave the connection alone.
  • Text that drives machine behavior: the count and bytes pass validation before any consuming logic sees them.

Questions asked

How many characters does a default Logix STRING hold?

The DATA member of a Logix STRING is an array of 82 SINTs and the LEN member is a DINT, so the default type holds up to 82 characters. That size exists for legacy compatibility with older controllers, and you can define a custom string type with a longer DATA array when a field needs more. The packed DINT payload works with either type unchanged.

What goes in the Class field of the CIP Generic message?

Class, instance and attribute identify a CIP object that the target device implements, and the numbers come only from that vendor's object documentation. The UniStream documents its EtherNet/IP adapter as a cyclic interface and publishes no object for its application variables, so there is no correct class value for the registration text. A class number borrowed from another device addresses a different object and fails or returns unrelated data.

How many DINTs do I need for a longer field?

Use one DINT for the count plus one DINT for every four characters, rounding up. A 20-character field needs 1 plus 5, so 6 DINTs or 24 bytes; a 12-character field needs 4 DINTs or 16 bytes. Grow Input Size or Output Size in the units of the configured data format and keep every existing signal in its position.

Does the UniStream string variable map straight onto the packed bytes?

No. The UniStream text variable has its own internal storage, and the adapter mapping in this setup carries 32-bit elements. The packing step reads the characters out of the text field and writes each one into the mapped integer at its defined byte position, which keeps the UniStream's storage conventions — padding, terminators, encoding — out of the link.

Keep reading

  • Troubleshooting

    Why explicit writes to Omron assemblies fail over EtherNet/IP

    Your Set Attribute message carries service code E, which is Get Attribute Single, so it reads, succeeds and writes nothing — and the two codes are transposed, since Set Attribute Single is 10 hex. Even corrected, CS/CJ-series EtherNet/IP units do not accept explicit writes to assembly instances, because that service is optional in the specification. Carry the 240 bytes on a Generic Ethernet Module connection or use CIP Data Table Read and Write messages.

    Industrial networks

  • How-to

    Read EtherNet/IP module register data with explicit messaging

    The iR-ETN remote I/O adapter exposes each analog module's error code through its Module Register CIP object: class 112, instance set to the module's slot number, attribute 16. A Studio 5000 MSG explicit message reads it in 2 bytes; the cyclic I/O connection never carries this register.

    Industrial networks

  • How-to

    Set up a PSTX softstarter on EtherNet/IP with a ControlLogix

    Set parameter group 12 on the PSTX first: 12.02 FB interface connector to Anybus, 12.03 Fieldbus control to On, and a static address in 12.05, 12.06 and 12.07 with 12.08 DHCP OFF. Then add a Generic Ethernet Module in Studio 5000 with input assembly instance 100 at 12 words and output assembly instance 150 at 5 words; any other size and the starter rejects the connection.

    Industrial networks