Troubleshooting
Why an OPC UA item shows N/A for an S7-300 CHAR array
Short answer
A Siemens STRING of n characters is n+2 bytes: a maximum-length byte, an actual-length byte, then the characters. The OPC UA driver validates that header, and a raw CHAR array has none, so the item shows N/A. Copy the characters with SFC20 into a true STRING[5] in a second data block, write the header bytes 5 and 5, and read it with an item such as DB103,STRING0.5.

On this page
- A Siemens STRING carries two bytes a CHAR array lacks
- Check 1: prove the path with a numeric item
- Check 2: use the data-block item syntax
- Check 3: read a true STRING to confirm the cause
- The fix: copy the characters into a true STRING with SFC20
- The alternatives, and when each wins
- Verify the repair
- The decision
- Questions asked
Your connection and your item are both fine; the data is the wrong shape. A Siemens STRING of n characters occupies n+2 bytes — a maximum-length byte, an actual-length byte, then the characters — and the Ignition OPC UA module's Siemens driver checks that header before it returns anything. DB102 holds a bare CHAR array, so DB102,STRING2.5 hands the driver the characters a and b as length bytes, and the item shows N/A. The DA server worked only because its item was pointed two bytes before the characters. The checks below prove this at the bench, and the committed fix is an SFC20 copy of the five characters into a true STRING[5] in a second data block, with the program writing the header bytes 5 and 5.
A Siemens STRING carries two bytes a CHAR array lacks #
A Siemens STRING[n] is n+2 bytes long: byte 0 holds the maximum length, byte 1 the actual length, and the characters follow in ASCII from byte 2. The type holds at most 254 characters. A CHAR array is payload only — one ASCII character per byte, no header anywhere.
Run the numbers on your data. The gauge sends abc.d: five characters, stored as five CHAR bytes at DB102 offsets 2 through 6, and 6 − 2 + 1 = 5 bytes. The item DB102,STRING2.5 requests a 5-character string at offset 2, so the driver reads 7 bytes there — the header plus five characters — and interprets the first pair as lengths:
- Byte 2 holds 'a', ASCII 97, taken as a maximum length of 97.
- Byte 3 holds 'b', ASCII 98, taken as an actual length of 98.
An actual length may never exceed the maximum, and 98 exceeds 97, so the pair cannot be a header and the driver has nothing valid to return — N/A. The driver expects the Siemens STRING format, and Check 3 proves the dependency on your own bench in minutes. Because one CHAR byte carries exactly one ASCII character, anything outside ASCII arrives as a question mark, a separate failure covered in S7-300 Chinese characters display as question marks in CHAR.
The DA item S7:[G_arm]DB102String0.5,1 worked because it deliberately stopped short of the characters, at DB102 offsets 0 and 1, so whatever sat there played the header for the DA server. The UA item pointed at the characters themselves, which is why the same bytes failed on the second attempt.
Check 1: prove the path with a numeric item #
Read one numeric item from the same DB102 — a byte or integer the program updates — on the same device, [G_arm_UA]:
- A good, changing value means the connection, the DB access and the item path are fine. Go to Check 2.
- A bad value means the fault is upstream of string handling. Check the device status, the IP address, the rack and slot numbers and the network path. An S7-300 has no optimized blocks, so absolute DB access needs no extra CPU permission — a bad numeric item is a broken connection, not a string problem.
Check 2: use the data-block item syntax #
The driver builds an address from a device name plus a tag address, and the comma belongs only to data blocks: DB number, comma, type, offset, dot, length. The manual's own example for another area, ISTRING24.50 — a 50-character string at offset 24 in the Inputs area — carries no comma. The DA-style body you carried over does not parse here.
| Item path tried | Verdict |
|---|---|
[G_arm_UA]DB102String0.5,1 |
DA syntax: type, offset and count with a trailing comma. Not a UA address. |
[G_arm_UA]DB102C0.5,1 |
The same DA-style body with a different type token. |
[G_arm_UA]:DB102String0.5,1 |
An extra colon, and still the DA-style body. |
[G_arm_UA]DB102,STRING2.5 |
Correct DB syntax — STRING, offset 2, length 5 — and still N/A, so the cause is the data layout. |
The fourth path was well formed and still showed N/A, and that is the useful outcome: syntax is eliminated, and the only variable left is the data itself.
Check 3: read a true STRING to confirm the cause #
- Create a fresh data block — DB103 in this example — with one STRING[5] element.
- From the program, write a 5-character literal into it, for example abc.d.
- Point the item at the element's first byte, the header:
[G_arm_UA]DB103,STRING0.5.
A good value of abc.d proves the driver needs the Siemens STRING format and that the bare CHAR array is the entire problem — go to the fix. A bad value here means the offset or length argument is wrong: the offset must land on byte 0 of the element, the header, not the first character, and the length must match the declared STRING[5].
The fix: copy the characters into a true STRING with SFC20 #
Leave DB102 and every line of existing gauge code untouched, and give the driver a real string to read.
- Create DB103 (the example number) with one STRING[5] element: 7 bytes, header at bytes 0 and 1, characters at bytes 2 through 6.
- In OB1 or the gauge-handling FC, call SFC20 (BLKMOV) — every scan, or on the new-data bit. Source pointer: the five CHAR bytes at DB102 offsets 2 through 6. Destination pointer: byte 2 of the DB103 element, the first character byte after the header.
- Write the header from the program: 5 into byte 0 (maximum length) and 5 into byte 1 (actual length). SFC20 moves bytes and never writes the header.
- Read it with
[G_arm_UA]DB103,STRING0.5.
If the PLC also writes back to the gauge, copy in the reverse direction and leave the header bytes untouched.
The alternatives, and when each wins #
| Option | Mechanism | When it wins |
|---|---|---|
| A. SFC20 copy into a second DB | The program copies the characters and writes both header bytes; the driver reads a true STRING. | The default: existing CHAR logic untouched, no DA software at any plant. |
| B. Header ahead of the characters | Write the header pair into the DB102 bytes just before the characters and read [G_arm_UA]DB102,STRING0.5. |
Only when those bytes are spare — your DA trick made deterministic. |
| C. Numbers instead of characters | Read the five bytes as numeric items and decode in a gateway script. | Only where the PLC may not hold a STRING at all; decode logic lands at every plant. |
| D. Keep the DA server | The shifted DA item keeps working. | Nowhere new: it reinstalls the OPC software you are removing at every plant. |
Option B deserves one look before you build Option A: the DA item already proved that a header-shaped pair at DB102 offsets 0 and 1 gives a readable string, and writing 5 and 5 there turns coincidence into a valid STRING[5]. If anything else in the program uses those bytes, take Option A without hesitation. Where a plant later wants one UA front end for several S7-300 CPUs, an S7-1200 as an OPC UA gateway for S7-300 data is a cleaner shared path than a DA server per plant.
Verify the repair #
- Compare a watch table on DB102 with the item value: identical five characters, abc.d.
- Change the gauge reading: the item follows within the PLC scan plus the tag's update period. Whether that period comes from polling or subscription changes only the latency, a difference set out for another server in reading PLC values from a TwinCAT OPC UA server: read vs subscribe.
- Quality stays Good — never Bad, never N/A — through one STOP-to-RUN cycle and one device reconnect.
- If the message length can vary, the program writes the true count into byte 1 rather than a constant: send a shorter reading and confirm the value ends at the last real character, with no stale tail.
The decision #
- Numeric item bad: the connection is the fault. Repair the IP address, rack, slot or network path first; nothing else here applies until a numeric item reads well.
- Numeric good, true STRING good, CHAR item N/A: layout confirmed. Commission Option A — DB103 with its STRING[5], the SFC20 copy, header bytes 5 and 5, item
[G_arm_UA]DB103,STRING0.5— and roll the same block and call out to every plant. - The bytes before the characters provably spare: take Option B instead — write the same header pair at DB102 offsets 0 and 1 and read
[G_arm_UA]DB102,STRING0.5, the least runtime work of all. - Run the DA server only until the copy is commissioned on each machine. After that no plant needs the Siemens OPC software, which was the point of moving to UA.
Questions asked
How long a CHAR array can one STRING item carry?
A Siemens STRING holds at most 254 characters, so one STRING[254] covers a 254-byte array: 254 characters plus its header, 256 bytes in the element. A longer array is split across two or more STRING elements in the same block and read as separate items, with the program writing each element's actual-length byte from its own character count. The five-byte gauge message here is far below the ceiling, so one element is enough.
Can I read the characters as numbers and skip strings entirely?
Yes. Read the five bytes at DB102 offsets 2 to 6 as five numeric byte items and join the codes in a gateway script: ASCII 97, 98, 99, 46, 100 decodes to abc.d. The method works whatever a driver does with string headers, but it puts decode logic at every plant, so use it only where the PLC cannot hold a STRING at all. For most machines the SFC20 copy is less work.
Does the S7-300 need PUT/GET permission or a special block setting?
No. Every S7-300 data block is a standard block with absolute addressing, so the driver reads the new STRING block as soon as it is loaded. On S7-1200 and S7-1500 CPUs the same read needs a non-optimized data block and remote PUT/GET access permitted in the CPU protection settings. Nothing in this fix changes the CPU's protection level on any of them.
What if the gauge sends fewer than five characters in some cycles?
Then byte 1 must carry the true count, not a constant 5. The program writes the number of characters received in that cycle, while byte 0 keeps the declared maximum of 5 because that is the longest message the item will ever read. A reading of ab.d is four characters: byte 1 gets 4 and the item shows exactly four characters, with no stale tail from the previous cycle.


