An HMI panel that cannot read the MicroLogix ST string tag can still show the barcode. Copy the string element into a run of integer registers so each 16-bit word carries two ASCII characters, point the panel's ASCII text object at the run, and pad short scans with spaces. A 12-character barcode fills six registers and keeps its leading zeroes.
A panel that cannot read the MicroLogix ST string tag can still show the barcode. Move the characters, not the string: pack two ASCII characters into each 16-bit integer register, then point the panel's text object, set to ASCII format, at that run of registers. A 12-character barcode occupies 6 consecutive registers and every character, zeroes included, travels as a character code. The operand length or type error appears because an element move expects the same kind of data on both sides, and a string structure, a length word followed by character bytes, is not a 16-bit register. The missing leading zeroes are a separate failure: converting the label to numbers produces a value, and a value has no zeroes at the front. Pack the codes and both problems are gone.
Why the direct move fails
On this platform the string data file stores every element as a structure. The controller's instruction set reference documents the layout: the first word holds the character count, up to 82 characters per element, and the words after it hold the characters two per 16-bit word. A move instruction that sends one element to one destination checks both operands for type and length, and a string structure into an integer register fails both checks, which is the operand length or type error.
The file copy instruction, COP in the instruction set, is built for the mismatch. It copies a block word by word and accepts a different file type on each side, so copying the string element into an integer run delivers the length word first and the character pairs after it. The platform stores words big-endian, high byte first, so expect the earlier character of each pair in the high byte, and let the commissioning checks settle the order on your wiring before production labels. The panel side, pointing a text object at a run of plain registers, is the subject of display ASCII from integer words when the panel cannot map the PLC string file; this page adds the MicroLogix side: the copy, the byte order and the padding.
Pack the characters into integer registers
- Size the run from the longest label you scan: registers = characters / 2, rounded up. Twelve characters need 6 words, sixteen need 8.
- Reserve a fixed run in an integer file and never move it. The example below uses N7:40 for the length word and N7:41 to N7:46 for the six character words; put the same addresses in the copy and in the panel object.
- On scan complete, copy the string element to N7:40. The count lands in N7:40 and the character pairs land in N7:41 onward.
- Pad in the same routine: write 8224, the hex word 0x2020, two space characters, into every word the new label does not reach, and write 32, the space code, into an unused low byte when the label has an odd character count. A space renders as a blank character in an ASCII text object.
- Point the panel's text object at the first character word, set its character count to twice the word count, and select ASCII character format. The scan routine stays the only writer of the run, so two labels cannot end up mixed in the same words.
The byte arithmetic is the same one used to pack 2 bytes into 1 word on a MicroLogix 1500, and other controller families do the identical thing: an Omron FINS write carries two ASCII bytes per word for the same reason. Counting words like this is ordinary panel work, the same discipline as displaying a PLC float stored in two word registers.
Symptoms and what each points to
- Operand length or type error on the move. An element move is being asked to put a string structure into 16-bit registers. Use the file copy above.
- Zeroes missing at the front of the label. The label went through the string-to-number conversions: 001230 becomes the number 1230, and 1230 prints as 1230. Keep character codes and display text. Where a panel offers a leading-zero fill for numeric fields it lives in the object's format settings; a PanelView leading-zeroes configuration guide shows that setting on one platform, and displaying leading zeros on a split HMI numeric display covers the formatting behaviour itself.
- Pairs swapped, 21 where 12 belongs. The byte order of the packing and the byte order the text object assumes disagree. Correct the byte order in the object's format settings or swap the bytes in the copy, then retest.
- Characters left over after a shorter scan. The run was not padded. Add the padding writes to the scan routine.
- A stray character or a low number at the front of the text. The object starts at the length word. Move its start address one word later.
Worked example: a 12-character label in six registers
Scenario: the scanner reads 001230456789 into the string element, 12 characters with two leading zeroes, and the routine above copies it. The example uses the default integer file addresses N7:40 to N7:46; keep your own start address consistent across the copy, the padding and the object.
| Register | Contents | Hex | Decimal |
|---|---|---|---|
| N7:40 | length | 12 | 12 |
| N7:41 | 0 0 | 0x3030 | 12336 |
| N7:42 | 1 2 | 0x3132 | 12594 |
| N7:43 | 3 0 | 0x3330 | 13104 |
| N7:44 | 4 5 | 0x3435 | 13365 |
| N7:45 | 6 7 | 0x3637 | 13879 |
| N7:46 | 8 9 | 0x3839 | 14393 |
Check the second word by hand. The digit 1 is ASCII 49 and 2 is 50, and big-endian puts the first character in the high byte: 49 x 256 + 50 = 12594. The first pair checks the same way: 48 x 256 + 48 = 12336.
The text object starts at N7:41, reads 12 characters in ASCII format and renders 001230456789, leading zeroes in place, because no step on the path built a number. Then scan an 8-character label, 00123045: four pairs fill N7:41 to N7:44, the routine writes 8224 into N7:45 and N7:46, and the panel shows 00123045 followed by two blanks. Nothing from the 12-character scan survives. If the barcode must sit inside a longer line, for example PALLET 001230456789 LOADED, the same packed run feeds a message object; embedding a PLC variable in an HMI message string covers that construction.
Checks before you trust the display
- Scan a test label with a leading zero, changing neighbours and letters at the end; 0123456789AB works. A is ASCII 65 and B is 66, so the last word holds 65 x 256 + 66 = 16706 and must render as AB.
- Byte order: the word for the pair 12 must hold 12594 and display 12. If the panel shows 21, that word holds 50 x 256 + 49 = 12849 and the order is reversed somewhere in the chain.
- Scan your shortest label right after your longest. Every position past the short label must be blank.
- Scan a label at the full length the run was sized for. Every character must appear, which shows the object's character count matches the word run.
- Confirm the scan routine is the only writer of the run. A second writer can leave half of one label and half of the next in the same words.
The decision
Recommendation: When the panel cannot read the ST tag type, file-copy the string element into a fixed run of integer registers, two characters per word, and display the run as ASCII text. Size the run for the longest label you scan, pad every shorter scan with spaces in each spare word, and start the text object one word past the length word. A 12-character label needs 6 registers and no conversions, so its leading zeroes reach the screen. Keep the convert-to-integers route for labels that can never start with 0 and never change width, because a numeric display drops those zeroes before it draws anything.
Questions
How many registers does a longer or shorter barcode need?
Divide the character count by two and round up. A 16-character label uses 8 registers, a 24-character label uses 12, and a 13-character label uses 7, with the last word holding the 13th character in its high byte and a space code in its low byte: for a trailing 5 that word is 53 x 256 + 32 = 13600. Reserve the run for the longest label and pad shorter scans with 8224 per spare word.
When is the convert-to-integers route acceptable?
Only when no label can begin with 0 and every label keeps the same width. Numbers then display correctly and a numeric object can even do arithmetic on them. The first label that starts with 0 breaks the route, because the zero dies inside the conversion, before the panel is involved. Where that case exists, use character packing; the codes carry every character through untouched.
Does the packing change how the PLC program uses the string?
No. The string element keeps its characters, so any logic that compares, stores or transmits the barcode still works on it. The register run is a display copy only. Keep exactly one routine writing that run, triggered on scan complete, or two scans can end up mixed in the same words.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.