IMDTouchKnowledge BaseShop main store

Troubleshooting

Why a QR Scanner Needs Focused IO Field Input in WinCC Unified

HMI and touchscreens Published 6 min read By IMDTouch engineering team

Short answer

A USB QR scanner in keyboard mode delivers its scan only to the IO field that currently owns keyboard focus, so pre-focus that field with the SetFocusOnElement system function and commit the scan with a suffix. Blocking manual entry completely is not achievable, because scanner and typed input share one keyboard event stream; validate in the PLC instead.

On this page
  1. How the scan reaches the field
  2. Pre-focus the IO field with SetFocusOnElement
  3. Why a scanner-only field cannot be guaranteed
  4. Troubleshooting checklist
  5. Prove the manual-focus baseline first
  6. Worked example: make the scan commit and stay
  7. The decision
  8. Questions asked

The scan lands only in the IO field that currently owns keyboard focus, because a USB scanner in keyboard mode is not a data source — it is a typist. Pre-focus the field with the documented SetFocusOnElement system function, attach it to the right event, and give the scan a termination suffix so the field commits. You cannot make that field scanner-only: typed input and scanner input arrive through the same operating-system keyboard event stream, so a read-only property blocks both and nothing documented blocks one while passing the other. Enforce scan-only behavior with validation in the PLC. On a Unified Basic panel, confirm the focus function in the device's performance-features tables and test it at runtime before you build the screen logic on it.

How the scan reaches the field #

A scanner such as a PM9600 connected over USB in keyboard mode converts the decoded QR value into ordinary keystrokes. WinCC Unified receives those keystrokes through the same input route used by the panel's on-screen keyboard and any USB keyboard, which is why the fix for a missing on-screen keyboard from scripted input dialogs starts at that same input stream. Only the focused, editable control consumes the characters; a control without focus ignores them.

Two IO field properties matter here. A field configured in Output mode accepts no input at all, and it cannot trigger the Input finished event, so it can never be your scan target. And the CPU downstream of the HMI cannot tell which keyboard produced a value: to the PLC, a scan and a typed entry look identical, which is the root of the validation problem below.

Pre-focus the IO field with SetFocusOnElement #

SetFocusOnElement is the documented system function for giving focus to a named screen object in WinCC Unified RT, and for a step-by-step walkthrough setting focus to IO fields with SetFocusOnElement covers the call in detail. Two documented conditions apply: the target must be visible and operable, and it must be an input-capable object. Siemens documents one working pattern in the Unified Panel notes: configure the function at the Input finished event of the source IO field and select the screen object that is to receive the focus. Attaching it to the event that fires when the target screen opens is the generic way to have the field ready before the first scan.

Test the call on a plain button before wiring it into screen events, because a button separates function execution from screen-lifecycle timing. In this example IOField_ScanInput is my name for the scan field; use your object's own screen name:

// Give keyboard focus to the scan field.
HMI.System.SetFocusOnElement("IOField_ScanInput");

Press the button, then scan without touching the screen. If the characters arrive, move the same call to the screen-opening event or to Input finished of the field that finishes before the scan field is needed. If the button does nothing, the delayed retry will not help either — a timer re-issue such as the following is only a diagnostic, and 500 ms is an example value, not a documented WinCC timing:

// Diagnostic retry: re-issue after an example delay of 500 ms.
setTimeout(function() {
  HMI.System.SetFocusOnElement("IOField_ScanInput");
}, 500);

When the direct call fails, the object name is wrong, the object is invisible or non-operable at that moment, the event did not execute, or the deployed runtime does not provide the function — not the HID input itself.

Why a scanner-only field cannot be guaranteed #

There is no documented setting in WinCC Unified that makes an IO field accept keystrokes from a scanner while rejecting the on-screen keyboard or a physical keyboard. Both are the same keyboard events at the operating-system level. Setting the field read-only or switching it to Output mode blocks both sources equally. A programmable on-screen keyboard restriction, where one exists, restricts typing paths but does not authenticate the remaining keystrokes.

The practical options are validation and interface choice. Validate in the PLC: check the received string against the expected length, character set or checksum before the batch or step accepts it, so a typed fake fails the same check a misread would. If the application genuinely requires source authentication, move the scanner off keyboard emulation to an interface that addresses the controller directly rather than the keyboard stream.

Treat this as a real risk, not a convenience detail: if the scanned value verifies an operator's identity, a batch code or a safety-relevant selection, an unvalidated typed entry defeats that check.

Troubleshooting checklist #

Run these checks in order; each one isolates one link in the chain from scanner to tag.

  • A scan appears only after you touch the field — the scanner works and focus is not assigned automatically. Prove the manual-focus baseline below, then program the focus call.
  • A scan produces no value even with the field touched — check HID routing, field editability, character mapping and the tag binding before touching any focus logic. Scan into another editable control to confirm the scanner types at all.
  • Characters arrive but the value is not committed — the scanner sends no termination key the field recognizes. Configure and test an Enter or Tab suffix.
  • Wrong or garbled characters — this is keyboard-layout or scanner-encoding behavior, not a focus failure. Fix the scanner's emulation settings first.
  • The focus call has no visible effect — instrument the event to confirm it fires, verify the exact screen object name, and confirm the object is visible and operable when the call runs.
  • Focus works once, later scans go elsewhere — a suffix, dialog or operator touch moved focus. Reapply focus from the completion event once the focus function is proven on the panel.

Prove the manual-focus baseline first #

Open the target screen, touch the scan IO field once, and confirm it shows an active edit state. Scan one QR code: every character should land in that field without another touch. Then scan a second time without touching anything. If the second scan fails, the first scan's suffix committed the input and released focus — that is the configuration problem to solve in the next section. If even a manually focused field accepts nothing, stop debugging focus and correct the USB connection, field mode or tag type first.

Worked example: make the scan commit and stay #

Configure the scanner in USB HID keyboard mode and pick the suffix from how the IO field commits data. Take an example QR payload of 24 characters. The scanner decodes it into 24 keystrokes and appends the configured Enter suffix, so the field receives 24 + 1 = 25 keystrokes: the first 24 fill the field and the 25th commits the input. Enter leaves focus where it is, so the next scan's 25 keystrokes land in the same field again.

Switch the suffix to Tab and the same 25th keystroke instead moves focus to the next control in the tab order. The field is now empty of focus and the next scan has nowhere to land until something reassigns it — either by touch or by a proven SetFocusOnElement call from the Input finished event. For repeated scans into one field, Enter is the cleaner suffix; measure the actual commit behavior on your screen rather than assuming it.

The decision #

  • You want hands-free scanning into one IO field: assign focus with SetFocusOnElement at the screen-opening event or at Input finished, following the documented Unified Panel pattern, give the scanner an Enter suffix, and prove both on the deployed panel — on a Unified Basic device, check its performance-features tables before relying on the function.
  • You want the field to accept only scanner data: not achievable with keyboard emulation. Validate the string in the PLC, and if source authentication is a hard requirement, change the scanner interface instead of the HMI configuration.
  • The focus call does nothing on the panel: the function is not available or the object is not focusable in that runtime; fall back to operator touch selection and validation, or move the application to hardware whose documented function list covers the call.

Questions asked

Can the scanner write into an IO field while typed entry is blocked?

No, not on the field itself. The scanner emulates a keyboard, so its characters and an operator's typed characters arrive as the same keyboard events at the panel. Setting the field read-only blocks both sources. Enforce scan-only behavior in the PLC by validating length, character set, or a checksum before the value is accepted.

Does SetFocusOnElement work on a Unified Basic panel?

The function is documented for WinCC Unified RT, but Basic panels carry a reduced feature set. Check the performance-features tables for your exact panel and firmware, then prove the call at runtime on that device with a test button before you build the screen logic around it.

Which termination suffix should the scanner send after a scan?

Enter is usually the right choice: it commits the input without moving focus, so the next scan lands in the same field. Tab normally advances focus to the next control, which fights repeated scans into one field. Match the suffix to how the IO field is configured to complete input, and test it on the deployed panel.

Keep reading

  • Troubleshooting

    Why a Bad USB Flash Drive Freezes a Touchscreen HMI

    When a touchscreen HMI ignores taps, answers only after long delays, and reports that no USB device is present while a flash drive is inserted, suspect the drive first. Remove it and tap: if input recovers, the touch hardware is fine and the drive gets replaced with a known-good unit formatted the way the controller documentation specifies.

    HMI and touchscreens

  • How-to

    Why a WinCC Unified live bit needs two scheduled tasks

    A live bit pair proves the partner's code is executing, not just that the link is up: each side increments an integer counter and the partner checks it changed within a window at least twice the increment period, for example 1 s increments against a 2 s or longer evaluation. In WinCC Unified the HMI half is two time-triggered scheduled tasks, one to increment and one to evaluate.

    HMI and touchscreens

  • Troubleshooting

    Is WinCC Unified compatible with an S7-1200 CPU

    Yes. Siemens documents WinCC Unified HMI connections to S7-1200 and S7-1500 CPUs, and an S7-1200 runs against a Unified Comfort Panel today. An inactive runtime button in TIA Portal is a license or target-selection problem, not CPU incompatibility: a PC station needs its own WinCC Unified PC Runtime license.

    HMI and touchscreens