IMDTouchKnowledge BaseShop main store

Troubleshooting

Why a WinCC Unified script cannot read an array of PLC UDTs

HMI and touchscreens Published 7 min read By IMDTouch engineering team

Short answer

A WinCC Unified script tag must resolve to one scalar leaf, so an HMI tag pointing at an array of PLC UDTs stays uninitialized and the debugger shows Object not properly initialized. The fix is one HMI tag per primitive member of each element the script reads, read by name, with the leaf bindings verified at the runtime debugger.

On this page
  1. Why does the HMITag object report Object not properly initialized?
  2. Which tags will a WinCC Unified script read and which ones fail?
  3. How do you confirm the cause in the runtime debugger?
  4. How do you expose UDT array members as tags a script can read?
  5. How many HMI tags does a 12-element UDT array need?
  6. How do you read all the leaf tags in one call?
  7. How do you verify the fix holds?
  8. What breaks the read again later?
  9. Questions asked

A WinCC Unified script in a v16 project that reads Int, Bool and WString tags but fails on an array of PLC user-defined data types is not missing an initialization call. The runtime never bound the HMITag object to a scalar value: a script tag must resolve to one leaf, and an array of structs is a composite parent. The debugger at http://localhost:9222 shows the object with the description Object not properly initialized. The fix is one HMI tag per primitive member of each element the script needs, read by name.

Why does the HMITag object report Object not properly initialized? #

The runtime never bound that tag object to a readable value: a script tag wraps exactly one runtime tag — one address, one scalar, one quality code — and an array of PLC structs is a composite parent with no scalar to return. There is no initialization call you skipped and nothing you can call on that object to repair it; change what the tag name points to.

The programming reference lists the properties of the Tag object as set "after successful initialization of the object", and the failing name never reaches that state: resolution finds a structure with sub-elements instead of a leaf, so the object stays uninitialized instead of raising a data-type error. Two layers each carry part of the chain:

  • Engineering layer: the HMI tag's access path must resolve to a specific member, one element index plus one member name. A tag created for the composite has sub-elements, which makes it a structure rather than a leaf.
  • Script layer: the script resolves a tag by name, and a name that points at the structure or array parent returns an object that is not a value holder.

The documented UDT support on the connection side is real: HMI tags can connect to DB instances of PLC user-defined data types. That support serves the tag table, not a composite value inside a script object, and the driver's own composite support is a separate question again — S7CommPlus UDT and array support on an HMI driver covers what that driver accepts.

Which tags will a WinCC Unified script read and which ones fail? #

Primitives and elements of primitive arrays read correctly; only the tag whose data type is the PLC UDT array fails, which tells you the connection is healthy and the struct element type is the cause. The pattern on a SIMATIC PC station with WinCC Unified SCADA RT and an integrated S7-1500 reads like this:

  • An Int, Bool or WString tag returns a value in the same script: syntax, runtime connection and PLC link are healthy.
  • An element of a primitive array returns a value: arrays themselves are readable, so the composite element type is the difference.
  • The UDT array tag fails on the line that reads it, not at compile time: the failure sits at tag resolution, not in the script text.
  • The failing tag sits in the tag table with a structure type and sub-elements: the object exists, but it points at a parent.

Keep this case apart from an HMI-side array: when the array is an HMI tag rather than a PLC UDT, the read hits its own limits, covered in why a WinCC Unified V19 script cannot read an HMI array at once.

How do you confirm the cause in the runtime debugger? #

Open the runtime debugger at http://localhost:9222, break on the line that reads the tag, and inspect the HMITag object: a healthy leaf shows a value and good quality, while the failing composite shows Object not properly initialized.

  1. In a test function, read one primitive tag and then the UDT array tag; a pass on the first with a failure on the second isolates the type as the cause.
  2. Set the breakpoint on the line that outputs or uses the tag, because the error appears at tag resolution and not at script load.
  3. Record the object's description at the breakpoint; the uninitialized text on the composite beside a populated value on the primitive is the proof.
  4. Open that same tag in the HMI tag table and check its data type column; a structure type with sub-elements confirms the name resolves to a parent.

How do you expose UDT array members as tags a script can read? #

Create or confirm one HMI tag per primitive member of each element the script uses, and read those leaf tags by their names; the documented UDT support connects HMI tags to DB instances, so leaf bindings are standard configuration, not a workaround.

  1. If the PLC UDT changed, recompile the PLC first so the HMI sees the current structure.
  2. In the HMI tag table, open the array-of-structs tag, expand it, and identify the elements and members the script needs.
  3. For each value the script uses, create or confirm an HMI tag that resolves to one primitive member of one element.
  4. In the script, read the leaf tags by their full names; when looping, build each name from the loop index and read the leaf, never the parent with an index into it.
  5. For large arrays, restructure the PLC side: place the values the HMI needs into arrays of primitives, one array per member, or into a compact interface DB, and bind the HMI tags to those.
  6. Compile the HMI, download to the PC station, and restart the runtime so the new bindings load.

How many HMI tags does a 12-element UDT array need? #

For example, a 12-element array of a UDT with three members the script uses needs 36 leaf tags: 12 elements times 3 members, while a screen that uses only one member needs 12. These are example inputs, not limits — substitute your own bounds and member list.

Take an array with bounds 0 to 11 and a UDT with six members, of which the script reads three: an Int, a Bool and a WString. Leaf tags = elements × members used = 12 × 3 = 36. Mirroring the whole UDT instead would be 12 × 6 = 72 tags, double the engineering and the runtime load for values the script never reads. The decision: create tags only for the members the script actually reads, and let the screens bind their own sub-elements.

How do you read all the leaf tags in one call? #

Initialize a TagSet object with the leaf tags and read them in one call: the documentation notes that access to multiple tags through an initialized TagSet demonstrates better performance than separate reads, which matters once one screen needs dozens of leaves.

Group the leaves into one set per screen or per function — the 36 leaves in the example form one TagSet, so a screen update issues one call instead of 36 individual reads. A TagSet addresses only tags that exist in the tag table, so a renamed or deleted leaf breaks the whole set until the name is corrected; keep the set's name list in step with the table.

How do you verify the fix holds? #

Read one member of the first element and the same member of the last element, then compare both with the PLC watch table: matching values with good quality prove the leaf bindings and the index mapping in two reads.

  • First element: the value matches the watch table with good quality.
  • Last element: element 11 in the example returns a valid value, which confirms the bounds mapping with no off-by-one.
  • Change in the PLC: modify one member online, and the script returns the new value on its next run, within the tag update cycle.
  • Debugger: break on the same output line; the HMITag object now carries a value and a quality instead of the uninitialized description.
  • Restart persistence: stop and restart the runtime and run the script again; identical results without re-creating tags show the binding is stored in the project, not held in a transient state.

Run the restart and the forced-value checks on a bench station or during a planned stop, not on the runtime that is running the line.

What breaks the read again later? #

Three edits and one habit reopen the failure: a changed PLC UDT without a recompile, loop names with no matching tag, a skipped runtime restart, and testing only primitive types.

  • Stale UDT copy: a PLC UDT edited without a recompile and a tag refresh leaves the HMI on the old layout, and mismatched members fail or read wrong offsets.
  • Built names with no tag behind them: a loop that concatenates an index fails on any element with no matching HMI tag; confirm every name the loop can produce exists in the tag table.
  • Skipped restart: binding changes on the PC station take effect after download and runtime restart, and a running instance keeps showing the old failure.
  • Primitive-only testing: a script that works on Int and Bool says nothing about the composite case; always test the exact type the code will read.

The decision in one line: one leaf tag per member per element the script reads, a TagSet for the reads, mirrored primitive arrays when the element count grows, and a fresh test of the exact type whenever the runtime version changes.

Questions asked

Can WinCC Unified screens still use the UDT array directly?

Yes. HMI tags can connect to DB instances of PLC user-defined data types, and screen objects bind the individual sub-elements, so a screen reads a member without any script. The initialization failure belongs to the script's Tag object, which expects a scalar leaf; display binding and script binding are separate checks.

Can the script write back to a UDT array member?

Yes, once that member has its own leaf tag and the tag's access mode allows writing. The script writes the leaf by name exactly as it reads it, and a TagSet can carry reads and writes for several tags in one call, so a setpoint written to one element reuses the same binding pattern as the reads.

Will a newer WinCC Unified version read the composite without leaf tags?

Not as a design assumption. Which composite types a script can read is a property of the installed version, and each version's documentation lists the supported data types. The leaf-tag bindings work on every version, so keep them; treat any composite read an upgrade adds as something to verify with the same debugger check.

What if the array has hundreds of elements?

Restructure rather than multiply. Move the values the HMI needs into arrays of primitives in the PLC, create one HMI array tag per member using the Array data type in the tag table, and read the elements one index at a time. A 200-element array with three used members then takes 3 array tags instead of 600 leaf tags, because 200 elements times 3 members is 600.

Keep reading

  • Explainer

    Why a WinCC Unified V19 script cannot read an HMI array at once

    In WinCC Unified V19 the Read method on an array tag is only supported for addressed elements, so Tags("ArrayVariable").Read() fails or gives unreliable results. Read Tags("ArrayVariable[2]") style elements in a loop, write complete arrays with a TagSet for consistency, and use the V20 BlockArrays type for documented whole-array reads.

    HMI and touchscreens

  • Troubleshooting

    Why the CP properties cannot be selected after a WinCC upgrade

    The message means the CP's parameters are owned by another tool: on a PC with SIMATIC NET, the station configuration's Communication Settings, not the Set PG/PC Interface dialog. After an upgrade, restore the missing SIMATIC OAM bin entry in the system Path and start the automation service that will not run before reinstalling anything, because a STEP 7 reinstall did not restore online access in the reported case.

    HMI and touchscreens

  • Troubleshooting

    What WinCC Runtime Advanced needs on an S7-1200 HMI PC

    A PC that only operates an S7-1200 needs one software package: WinCC Runtime Advanced, installed from the dedicated runtime setup, plus a compiled project and a working Ethernet path. SIMATIC NET is not required for this HMI connection; it enters only when the same PC also runs a Siemens software controller. The example station runs V13 SP1 Update 9.

    HMI and touchscreens

Why HMI Objects Show White Boxes Only on Populated Pages