Troubleshooting
HMI session language variable stays empty in PLC over OPC UA
Short answer
An HMI session language variable stays empty in a PLC over OPC UA when one of four runtime prerequisites is missing: OPC UA node exposure with write access, a write-capable binding mode with initial change events enabled, a registered binding file driven by an active client session, or matching UTF-8 string types and buffer length. Isolate the failing stage through the HMI server diagnostics page on HTTPS port 443 and the visualization and communication logbooks before changing PLC code.

On this page
- Why does a compiled HMI session language binding leave the PLC tag empty?
- How must the PLC variable be exposed in the OPC UA server for writes?
- Which binding direction and startup event setting send the language code to the PLC?
- Why do inactive sessions, unregistered bindings, or text namespaces block updates?
- What string type and buffer length does an OPC UA LocaleId need in the PLC?
- How do you isolate the fault with the Server Info page and HMI logbooks?
- How do you verify the language binding safely on an isolated bench?
- Questions asked
Yes, an HMI can pass its active per-client language code (such as ::SYSTEM:clientInfo.languageId in B&R mapp View) into a PLC variable over OPC UA; a clean project build checks only syntax, not live delivery. When the PLC string stays empty ('') while screens run normally, one of four runtime gates is missing: OPC UA node write exposure, a write-capable binding with startup change events, a registered binding driven by an active client session, or compatible UTF-8 string sizing. The /Server/Info diagnostics page and the visualization and communication logbooks isolate the broken gate quickly.
Why does a compiled HMI session language binding leave the PLC tag empty? #
Compilation checks XML syntax and symbol names, while live updates fail silently whenever any of four runtime gates is missing: OPC UA node write exposure, a write-capable binding with startup events, a registered active session, or compatible UTF-8 string sizing.
Passing a browser-scoped language code to a cyclic task crosses the OPC UA server boundary and relies on client-side event delivery. Isolate the fault layer by layer rather than editing cyclic PLC code first, using the same separation applied when diagnosing whether an HMI value fault sits in the driver, the tag, or the screen.
Check these four gates in sequence because an upstream block stops every layer behind it:
- OPC UA server exposure: Hidden or read-only PLC tags reject client writes with no compile warning.
- Binding direction and startup trigger: Default
oneWaybindings read from the PLC instead of writing back, and startup values need initial change events enabled. - Session lifecycle and file registration: An unregistered
.bindingfile or zero connected browser clients leaves the session variable inactive. - String coding and cyclic overwrites: Wrong encoding, short buffers, or cyclic resets clear the PLC value.
How must the PLC variable be exposed in the OPC UA server for writes? #
Automation Studio hides PLC process variables from the OPC UA address space by default, so you must turn OPC-UA System to On, activate the tag in the .uad Default View with write access, and set string coding to UTF-8.
In a web HMI setup, the controller hosts the OPC UA server and the visualization connects as an OPC UA client, a direction explained in how HMI OPC UA server and client roles control write direction. Declaring a global or task-local variable in the PLC program does not expose it to client writes.
Per B&R Automation Studio Help for OPC UA Default View setup, confirm four server settings:
- Set
OPC-UA SystemtoOninPhysical View. - Add or open the OPC UA Default View (
.uad) underConfiguration View > Connectivity > OpcUA. - Run
Enable Tag(Ctrl+Shift+T) on the targetSTRINGorWSTRINGvariable and verify write access is enabled. - Set
Physical View > CPU > Controller > Network/Security > OPC UA > Advanced properties > Conversion / String codingtoUTF-8.
For projects migrated from AS 4.12 and mapp View 5.x to Automation Studio 6 and mapp View 6.x, also replace legacy OPC UA Information Model V1.00 (urn:B&R/pv/) namespace settings; leaving that old namespace active causes runtime bindings to fail silently or display "XX".
Which binding direction and startup event setting send the language code to the PLC? #
Keep the PLC OPC UA node as the binding source, point the target at ::SYSTEM:clientInfo.languageId with mode set to oneWayToSource or twoWay, and set Initial ValueChanged events to TRUE for startup sync.
In B&R mapp View, OPC UA nodes (xsi:type="opcUa") serve as binding sources rather than direct targets. Leaving mode at oneWay copies the empty PLC string toward the HMI instead of sending session state to the controller. Propagating .svar session variables or ::SYSTEM:clientInfo.languageId into PLC variables requires oneWayToSource (or twoWay when the PLC also writes back).
Binding mode |
Runtime data direction | Result on PLC language tag |
|---|---|---|
oneWay |
Source (PLC OPC UA) to target (HMI) | PLC tag stays empty |
oneWayToSource |
Target (HMI session) to source (PLC OPC UA) | Client language writes to PLC |
twoWay |
Bidirectional between source and target | Client and PLC stay synchronized |
Bindings live in .binding files using the mapp View binding engineering v2 XML schema inside <BindingsSet id="binding_0"> and <Bindings>. Below is the documented B&R Automation Studio Help XML structure for an OPC UA-to-widget entry showing the exact xsi:type, refId, attribute, and mode attributes required at runtime:
<BindingsSet id="binding_0" xmlns="http://www.br-automation.com/iat2015/binding/engineering/v2">
<Bindings>
<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::Program:intVariable" attribute="value" />
<Target xsi:type="brease" contentRefId="content_0" widgetRefId="NumericOutput1" attribute="value" />
</Binding>
</Bindings>
</BindingsSet>
Select ::SYSTEM:clientInfo.languageId as <Target> through the binding editor rather than hand-typing attributes, and confirm <Binding> uses mode="oneWayToSource" (or twoWay). Because standard OPC UA subscriptions do not emit a ValueChanged event for an initial startup value, enable Initial ValueChanged events (TRUE) in the mapp View OPC UA client configuration so the first connected client pushes its startup language without waiting for a button press.
Why do inactive sessions, unregistered bindings, or text namespaces block updates? #
Because ::SYSTEM:clientInfo.languageId exists per connected browser session, the PLC variable stays empty until at least one client opens an active visualization whose configuration registers the .binding file and loads valid multilingual text namespaces.
A session variable has no controller-wide value when zero clients are connected, so watching the PLC immediately after download always shows ''. Once a client attaches, its session drives the binding until disconnect or expiry, which makes implementing per-client OPC UA server session timeouts directly relevant whenever controller logic relies on active operator session state.
Binding multiple operator stations to one scalar PLC string creates a last-write-wins race whenever clients select different languages. Separate language state by station or keep text translation on the HMI when panels run independently.
Check three remaining project omissions:
- Unregistered
.bindingfile: Compiling a.bindingfile in the project tree does not execute it unless the active visualization configuration references that binding set. - Missing
IATnamespace inTMXfiles: Leaving aTMXtext file outside theIATnamespace hides localized elements and breaks language switching, alongside the setup dependencies covered in how multilingual HMI project language configuration coordinates three separate parts. - Cyclic PLC overwrite: Confirm no cyclic Structured Text routine resets the bound string back to
''every scan.
What string type and buffer length does an OPC UA LocaleId need in the PLC? #
Declare a single-byte STRING[16] variable with OPC UA string coding set to UTF-8 for standard LocaleId codes, and choose 2-byte WSTRING only when the same PLC string path also carries non-ASCII Unicode text.
OPC UA Part 3, Section 8.4 defines LocaleId per RFC 5646 (BCP 47) as a two-letter ISO 639 language code with an optional hyphen and two-letter ISO 3166 region code, plus permitted legacy and special forms -CHS, -CHT, mul, and qst. OPC UA Part 6 encodes every String on the wire as UTF-8 preceded by the byte length of the UTF-8 code units. Automation Runtime STRING holds single-byte ASCII/ANSI characters (1 byte per character plus 1 null-terminator byte), whereas WSTRING holds 2-byte UTF-16 code units (2 bytes per code unit plus 2 null-terminator bytes).
Worked sizing example (documented LocaleId inputs versus illustrative PLC buffers): Every legal LocaleId character is 7-bit ASCII (1 UTF-8 byte per character). Comparing "de" (2 characters) against "zh-CHS" (6 characters) gives exact requirements:
"de": Wire payload =2 characters * 1 byte/character = 2 bytesbefore the length prefix; exact-fitSTRING[2]uses(2 + 1) * 1 byte = 3 bytes, andWSTRING[2]uses(2 + 1) * 2 bytes = 6 bytes."zh-CHS": Wire payload =6 characters * 1 byte/character = 6 bytes;STRING[2]falls short by6 - 2 = 4 charactersand truncates the region suffix.- Illustrative
STRING[16]versusWSTRING[16]:STRING[16]holds"zh-CHS"with16 - 6 = 10 charactersspare in(16 + 1) * 1 byte = 17 bytes, whereasWSTRING[16]uses(16 + 1) * 2 bytes = 34 bytesfor identical character capacity.
Decision: Use STRING[16] with server UTF-8 conversion for LocaleId-only tags to hold both short and six-character regional codes at half the memory footprint of the wide-string equivalent; switch to WSTRING only when non-ASCII Unicode text shares that PLC string interface.
How do you isolate the fault with the Server Info page and HMI logbooks? #
Turn on the mapp View diagnostic page on HTTPS port 443, sign in at /Server/Info with a role-assigned service account, and compare the live binding table against the visualization and communication logbooks to isolate the failing layer.
Verify what the HMI server instantiated before altering PLC logic:
- In the mapp View configuration, set
Activate diagnostic pagetoon, assign a role toRole 1, and map a service user account to that role. - Open
/Server/Infoover HTTPS on that port at the controller's address (for example, loopback127.0.0.1during local simulation, or the panel IP on a bench network) and sign in. - With a browser client open to the visualization, inspect the active session and binding entries on
/Server/Info. - Enable the visualization and communication logbooks in the logger, trigger one language switch, and read new fault records.
Map the observation directly to the fix:
- Binding absent on
/Server/Info: Register the.bindingfile in the active visualization or open a live client session. - Source resolution or access fault: Run
Enable Tagin.uad, grant write access, or clear legacyurn:B&R/pv/migration settings. - Binding healthy while PLC stays
'': ChangeoneWaytooneWayToSourceortwoWay, enableInitial ValueChanged events, verifyUTF-8coding, and check the communication logbook for conversion or cyclic-overwrite faults.
How do you verify the language binding safely on an isolated bench? #
Run all writes, language switches, and disconnect tests on an isolated bench using declared illustrative test tags and timestamped intermediate reads before tying HMI session language state to any machine logic.
Never drive machine interlocks, motion permits, or protective outputs from an HMI session string; keep safety functions in rated safety logic. Declare isolated illustrative PLC variables (explicitly separated from the documented ::SYSTEM:clientInfo.languageId source) and bind exHmiLanguageId in .uad and .binding:
VAR
exHmiLanguageId : STRING[16] := ''; (* Illustrative OPC UA target tag *)
exLastLanguageId : STRING[16] := ''; (* Illustrative previous-scan latch *)
exLangChangeCount : UDINT := 0; (* Illustrative transition counter *)
END_VAR
IF exHmiLanguageId <> exLastLanguageId THEN
exLastLanguageId := exHmiLanguageId;
exLangChangeCount := exLangChangeCount + 1;
END_IF;
Prove runtime behavior in four checks:
- Zero-client baseline: Start the PLC with no browser connected and confirm
exHmiLanguageIdstays''andexLangChangeCountremains0. - Startup sync proof: Open one browser client with
Initial ValueChanged eventsenabled; record a timestamped read showingexHmiLanguageIdupdates to the startup code (for example'en') andexLangChangeCountequals1. - Intermediate transition check: Switch from
'en'to'de'and back to'en', logging timestamped intermediate reads after each click rather than only the final counter, since the final counter measures catch-up while intermediate timestamps verify update delay and confirm no transition dropped. - Disconnect and recovery check: Close and reopen the browser separately to measure loss detection and recovery against your actual driver timeout, retries, data quality, and HMI refresh cadence.
Acceptance decision: Deploy only when startup sync fires without an operator click, every intermediate switch increments exLangChangeCount by 1 with matching exHmiLanguageId text, and /Server/Info plus both logbooks stay error-free. If only startup sync fails, fix Initial ValueChanged events; if manual switches also fail, recheck .uad write exposure, binding direction, and UTF-8 coding.
Questions asked
How does Siemens WinCC Unified represent client session language compared with BCP 47 strings?
Siemens SIMATIC WinCC Unified represents the active client language through HMIRuntime.Language as a 32-bit unsigned integer LCID (for example, 1033 for English and 1031 for German) rather than a two-letter BCP 47 string. From TIA Portal V18 onward, an internal current-language system tag exposes that numeric LCID to client-side JavaScript, which reads the system tag and writes to the target PLC tag. If the PLC program expects text rather than a UInt32 value, your script must convert the numeric LCID into a string explicitly before writing.
How does Beckhoff TwinCAT HMI translate PLC text without writing the client locale back to the controller?
Beckhoff TwinCAT HMI (TE2000) reads and changes client locale strings such as en-US or de-DE through its client API functions GetLocale, SetLocale, SetLocaleEx, and GetRegisteredLocales. Rather than pushing raw translated strings or session language codes into the PLC, you bind a PLC STRING symbol containing a localization key into the Beckhoff.TwinCAT.HMI.Functions GetLocalizedText function binding. Each connected browser resolves that key against its own active locale locally, avoiding multi-client overwrites on a single controller tag.
Can browser cookie expiry or NTP time jumps break session variable bindings in mapp View 6.x?
Yes. Automation Studio 6 and mapp View 6.x moved session and user login management onto an OPC UA backend instead of legacy RBAC or MpUserX mechanisms. In earlier 6.x releases, Chromium 400-day session cookie expiration and NTP clock jumps could drop client sessions silently, a defect resolved under QCAS-1454 in mapp View 6.4.0. Release notes for 6.x also document QCAS-5071, which fixes type-conversion errors when binding BOOL session variables to Brease properties expecting INT.
How can an OPC UA client inspect active session locales without relying on HMI bindings?
OPC UA Part 5, Section 12.11 defines SessionDiagnosticsDataType, which exposes each active session's localeIds array alongside sessionName, serverUri, and endpointUrl directly in the server diagnostics space. Under OPC UA Part 4, Section 5.7.3, the ActivateSession service submits localeIds in priority order with the first entry highest, and passing a null or empty array on a subsequent ActivateSession call retains the session's existing locales rather than clearing them.


