Troubleshooting TwinCAT HMI Combobox Binding to PLC Variables

Stefan Weidner9 min read
BeckhoffHMI / SCADATroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Problem Overview

Engineers integrating TwinCAT HMI with PLC programs frequently encounter a failure mode where a configured TcHmi.Combobox appears to operate correctly in the engineering preview but never writes the chosen value back to the bound PLC variable. The symptom is reproducible and silent: the drop-down opens, the operator picks an entry, the visual selection updates briefly, and the tag in the PLC project remains unchanged.

Symptom clusters reported in the field include:

  • Combobox does not write to the PLC tag at all, even though the symbol is resolvable from the HMI.
  • Selection persists only until the user navigates away from a content area; on return, the value is lost and the binding stops firing.
  • Single successful write after a configuration change, then no further updates until the HMI is reloaded.
  • Type mismatch warnings ignored at design time, but binding silently disabled at runtime.

These symptoms are not always a bug in the control. Most often they trace to one of three root causes: a type mismatch between the HMI element and the PLC symbol, a content area lifecycle issue that strips bound state, or an incorrect binding path that resolves at design time but breaks at runtime.

Root Cause Analysis

Three failure modes account for nearly every reported TwinCAT HMI Combobox binding failure. Each must be ruled out in sequence.

1. SelectedValue Data Type Mismatch

The SelectedValue property of TcHmi.Combobox must be the same data type as the bound PLC tag. If the HMI definition uses STRING and the PLC tag is UDINT, the control will accept a user selection without writing to the variable. TwinCAT HMI does not perform implicit numeric/text conversion in the binding layer.

Accepted pairings:

PLC Tag Type Combobox SelectedValue Type Typical Use
BOOL BOOL Toggle / two-state
INT, DINT, UDINT Number (mapped to INT) Enumerations, index selection
STRING STRING Free-text selection from a list
ARRAY OF ... Element type only Indexed lookup

If the list items in the Combobox carry text strings and value numbers, the SelectedValue must take the numeric type used in the value field, not the text field. A STRING SelectedValue only matches if the list items themselves store STRING values.

2. Content Area vs View Lifecycle

TwinCAT HMI distinguishes between Views (full pages managed in the navigation tree) and Content Areas (reusable regions that host fragments and are swapped in and out of a parent View). Content Areas are designed for embedded controls and templates; their instance lifecycle is shorter than a View's.

Consequences for Combobox state:

  • A Combobox inside a Content Area may lose its SelectedValue binding handle when the parent View re-initializes the Content Area.
  • If the binding was created in the Content Area's local XMAL and the symbol path references a parent symbol that has been garbage-collected, the write target is lost between navigations.
  • The first user action after a Content Area load can fire a write correctly; subsequent navigations to a different Content Area and back can break the subscription.

The correct architectural pattern is to bind to a fully-qualified PLC symbol (for example PLC1.MAIN.nCarColor) declared on a global scope, not on a transient Content Area control.

3. Binding Path Resolution

Binding paths in TwinCAT HMI are written as escape-wrapped expressions:

%i%PLC1.MAIN.sCarColor%/i%

For text bindings:

%s%PLC1.MAIN.sCarColor%/s%

A binding that resolves during engineering (because the project knows the symbol list) but fails at runtime (because the ADS route is not active, the symbol has been renamed, or the namespace differs) will read null on every cycle and never push user input back. Check the browser developer console (F12 in the HMI client) for Symbol not found or ADS Error messages.

Solution Procedure

Apply the following steps in order. Each step is independently verifiable, so if step N restores binding behavior, the root cause is identified and the remaining steps are still recommended as hardening.

Step 1: Verify Type Alignment

  1. Open the PLC project in TwinCAT 3 XAE.
  2. Navigate to the variable that the Combobox writes to (for example, MAIN.nCarColor : UDINT).
  3. Open the HMI page containing the Combobox in the TE2000 HMI engineering tool.
  4. Select the Combobox and inspect SelectedValue. Confirm it is a numeric type if the PLC variable is numeric, or STRING if the PLC variable is a string.
  5. If the list items define a value field, confirm the value is stored as the same numeric type as the PLC variable.

Note: TwinCAT HMI does not coerce between STRING and integer types. A list item like { "text": "Red", "value": 1 } requires SelectedValue to be a number type. A list item with value as a quoted string requires SelectedValue to be a STRING.

Step 2: Bind to a Globally-Resolved Symbol

  1. In the HMI engineering tool, right-click the SelectedValue property and choose Bind.
  2. Select the symbol from the project tree, using the fully-qualified path that matches the PLC program. Example: PLC1.MAIN.nCarColor.
  3. Confirm the binding syntax in the XAML reads as {Binding PlcSymbol="PLC1.MAIN.nCarColor"} or its inline equivalent, and not as a local control property reference.
  4. Build the HMI project. The build log should report no unresolved symbol warnings.

Step 3: Confirm ADS Route Availability

  1. On the runtime target, open TwinCAT Router and verify the HMI server has a route to the PLC runtime (NetId and port 801 or the configured ADS port).
  2. From the HMI client browser, open the developer console and run:
TcHmi.Symbol.readEx('%i%PLC1.MAIN.nCarColor%/i%');

The promise should resolve to the current value of the variable, not reject. A rejection confirms the binding target is invisible to the HMI server.

Step 4: Rebuild and Re-Deploy

  1. Clean the HMI build output.
  2. Rebuild the HMI project.
  3. Activate the configuration on the target.
  4. Reload the HMI client (Ctrl+F5 to bypass cache).

Combobox selections should now round-trip to the PLC on every change event.

Content Area vs View Selection Guide

Use the following matrix when deciding where to place a Combobox in a TwinCAT HMI layout:

Use Case Recommended Container Reason
Form that fills an entire HMI page View Full lifecycle, persistent bindings
Selection widget shared between multiple Views Content Area in a base View Reuse without duplication
Parameter panel that updates PLC state during navigation View with a small Content Area for the control State survives between navigation events
Modal dialog or popup User Control embedded in a View Lifecycle owned by parent View

Content Areas are not a problem in themselves. The failure mode arises when bindings inside a Content Area reference state that does not survive the Content Area teardown. Always bind Combobox SelectedValue to a globally-scoped PLC symbol whose lifetime exceeds the Content Area's lifetime.

Verification Checklist

Confirm each item before closing the issue:

  • Combobox SelectedValue type matches PLC variable type exactly.
  • Binding expression resolves at runtime in the developer console.
  • ADS route is active between HMI server and PLC runtime.
  • Symbol exists in the project tree at the exact path written in the binding.
  • PLC variable address is not optimized away (a {attribute 'TcDebugEnable'} or explicit AT %I* declaration may be required in heavily optimized POUs).
  • HMI client was reloaded with cache cleared after the build.
  • Selecting a value updates the variable in the PLC online view.

Common Pitfalls and Field Notes

Pitfall 1: Implicit conversion assumption. TwinCAT HMI uses strongly-typed bindings. A list { text: "1", value: 1 } passed to a STRING SelectedValue will not coerce 1 to the string "1" automatically. Match types exactly or pre-format list values as strings.

Pitfall 2: Ghost bindings after a Control Action edit. Editing the Action event handler of the Combobox can detach and reattach a binding handle. If the binding only works after a Control Action edit, the XMAL has likely lost its PlcSymbol declaration and the Action is the only remaining event path. Restore the explicit binding and remove the manual Action.

Pitfall 3: Multiple HMI clients on the same variable. TwinCAT HMI uses a single-write-wins model on the ADS layer. If two clients write the same variable in the same cycle, only one value is preserved. Use server-side state management for shared selection widgets.

Pitfall 4: Content Area state. If the Combobox is hosted in a Content Area, confirm the parent View is not destroying and recreating the Content Area on every navigation. Use a cache-friendly container such as a TcHmi.Region for short-lived fragments and a full View for forms that need persistent state.

Pitfall 5: Cached XAML. The HMI client may serve a cached XAML file after a build. Always reload with cache disabled (Ctrl+Shift+R in Chrome-based browsers) when verifying a binding fix.

Diagnostic Commands

Useful in-browser checks while the HMI client is loaded:


// Read the current binding value
TcHmi.Symbol.readEx('%i%PLC1.MAIN.nCarColor%/i%')
  .then(v => console.log('Current value:', v));

// Write a test value directly
TcHmi.Symbol.writeEx('%i%PLC1.MAIN.nCarColor%/i%', 2);

// List children of a symbol
TcHmi.Symbol.readEx('%s%PLC1.MAIN%/s%');

Successful round-trip in the developer console while the HMI Combobox does not write confirms a binding definition problem. Successful round-trip in both confirms a runtime or ADS route problem.

Reference: TwinCAT HMI Combobox Property Summary

Property Purpose Type
Items List of selectable entries Array of { text, value }
SelectedValue Currently selected value (writes to bound PLC symbol) Matches PLC tag type
SelectedText Currently displayed text STRING
DataSource Alternative source of items from a PLC list Symbol path
Enabled Operator enable state BOOL
Visible Render state BOOL

For full property documentation, refer to the Beckhoff TE2000 HMI Engineering documentation and the TwinCAT 3 HMI product page.

Why does my TwinCAT HMI Combobox selection not write back to the PLC variable?

The most common cause is a data type mismatch between the HMI's SelectedValue property and the PLC tag. If SelectedValue is declared as STRING but the PLC tag is a numeric type such as UDINT, the binding silently fails. Align the types exactly: numeric PLC tags require numeric SelectedValue, and STRING PLC tags require STRING.

Does the Combobox SelectedValue type have to match the PLC tag type exactly?

Yes. TwinCAT HMI performs no implicit conversion between STRING and integer types. A list item { "text": "Red", "value": 1 } requires SelectedValue to be a number type, and the PLC tag must be INT, DINT, or UDINT. If the list value is a quoted string, both the SelectedValue and the PLC tag must be STRING.

Why does the Combobox write once but stop working after navigating between content areas?

This usually indicates that the binding is anchored to a control or scope whose lifetime is shorter than the navigation cycle. Bind the SelectedValue to a globally-scoped PLC symbol such as PLC1.MAIN.nCarColor, and avoid bindings that reference local state inside a transient Content Area. A full rebuild and a hard browser reload (Ctrl+Shift+R) are usually required to clear the stale handle.

Should I host a Combobox inside a Content Area or a View?

Use a full View when the Combobox is part of a form that must hold state across navigation events. Use a Content Area only when the selection is purely local to the fragment or the bound PLC symbol has a lifetime that exceeds the Content Area's own. For form-style screens, prefer a View with an optional Content Area for embedded widgets.

How do I verify the Combobox binding is active at runtime?

Open the HMI client, press F12 to open the browser developer console, and run TcHmi.Symbol.readEx('%i%PLC1.MAIN.nCarColor%/i%'). The promise must resolve to the current value of the variable. A rejection or a null result indicates the binding path is not visible to the HMI server, typically because the ADS route is missing or the symbol was renamed.

Back to blog