How-to
WinCC Unified momentary pushbutton press and release events
Short answer
WinCC Unified has no set-bit-while-pressed function, so a momentary command is two event actions on one button: SetzeBitInVariable on the press event and RücksetzeBitInVariable on the release event, aimed at the same tag. Verify the pulse on the PLC value, not on the button graphic.

On this page
WinCC Unified has no single set-bit-while-pressed function, so a momentary pushbutton is built from two event actions on the same button: the press event runs SetzeBitInVariable and the release event runs RücksetzeBitInVariable, both aimed at the same command tag. The classic SetzeBitWährendTasteGedrückt entry is not in the Unified function list at all. Configure both events, aim both at the same tag and bit, and prove the pulse on the PLC value rather than on the button graphic. The steps below take a jog command from declaration to a bench-verified three-state test.
Why the while-pressed function is gone #
SetzeBitWährendTasteGedrückt belongs to the classic panel generation and does not exist in WinCC Unified. The manuals for the older Basic and Comfort panels and for RT Advanced already warned against it: when the controller supports BOOL variables, they point you to SetzeBit instead, because a bit pushed into a packed variable is the wrong shape for a controller that can address a plain Bool. Unified dropped the while-pressed entry altogether, and the supported replacement is SetzeBitInVariable on the press event plus RücksetzeBitInVariable on the release event. The decision is fixed: a momentary request in Unified is two actions on two events, never one action on one event.
Configure the momentary pushbutton #
Work with the runtime stopped and the machine prevented from moving until the bench test at the end has passed.
- Read the PLC declaration first: the exact tag the program watches, its data type and, when the command lives inside a word, the bit position. A dedicated Bool is the first choice; a packed bit is for a fixed legacy word map.
- Bind the button to that tag and confirm the binding resolves over the HMI connection to the controller tag, not to a similarly named internal HMI tag.
- Open the button's Events list, select the press event and add
SetzeBitInVariable. Point it at the command tag and, when the tag is a word, at the command bit. - Select the release event on the same button and add
RücksetzeBitInVariablewith exactly the same tag and bit. A mismatched reset is the most common way a momentary turns into a stuck command. - Leave click and toggle actions off the button. A click is a completed press-plus-release and a toggle flips the value on every activation; neither expresses a held request. If you actually want a command that stays on until a second action clears it, the WinCC library push button that latches press and release does that in one element.
- Start runtime on the bench and verify the three states at the controller before the machine is allowed to run.
Press, click and release are not the same transition #
The press event marks the start of the operator's hold, the release event marks the end of it, and a click is both completed as one gesture. The momentary relationship - request true while held - exists only between press and release, so both writes belong on those two events. A set action on the wrong transition appears as a jog that starts late or never, the cousin of the fault described in the article on a PanelView Plus 1500 momentary pushbutton that triggers on release.
Worked example: a jog request carried by one bit of a control word #
The inputs are declared for this example, not measured: the controller program exposes a 16-bit word tag called JogWord with an initial value of 0 and reads bit 3 of it as the jog request, and the HMI button writes JogWord over the HMI connection. This packed-bit form is for a fixed legacy word map where the controller offers no spare Bool.
The rule in words: setting bit n of a word whose remaining bits are 0 writes the decimal value two to the power n, and resetting that bit removes exactly the same amount. The arithmetic: two to the power three is 2 x 2 x 2 = 8, so the press action writes 0 + 8 = 8 and the release action writes 8 - 8 = 0. The result: the controller sees JogWord go from 0 to 8 when the button goes down and back to 0 when it comes up, for a hold of any length.
The decision and its threshold: this arrangement holds only while the button is the sole writer to those bits and no Bool is available; the moment either condition breaks, give the request its own Bool tag and aim both events at it. Both events must also name the same tag and the same bit - a press on the command bit with a reset on a neighboring bit leaves the request latched with no release.
When the release never arrives #
An HMI write is a one-shot transaction and nothing in the panel schedules the reset. If the runtime stops, the screen changes or the connection drops between press and release, the request stays TRUE at the controller until some other logic clears it. Give the PLC the ownership: permissives checked in the program, a command expiry the program applies, and the operator request kept separate from the accepted command so a later diagnosis can tell intent from execution. Two panel-side patterns help. Clear the request in the screen-exit event, the approach laid out for classic runtime in the article on setting a PLC bit when a WinCC flexible screen is left. And let the PLC watch communication health through a heartbeat, the live bit that WinCC Unified needs two scheduled tasks to produce.
One limit stands above all of this: an ordinary HMI pushbutton and its release reset are not a safety function. Hazardous motion stops through the machine's safety-related controls, never because a panel event fired.
Bench test before the machine moves #
Run the acceptance pass on an isolated bench with verified test tags, machine outputs forced off, and the request tag visible in the PLC. Judge the pulse by timestamped values at the controller; the button graphic and the tag update on different schedules, so a changing animation proves nothing about the write.
With the button untouched, the request reads FALSE. Press and hold: it reads TRUE and stays TRUE, with no unexplained PLC-side resets. Release: it reads FALSE once the reset write has been processed. Then repeat the sequence while leaving the screen, stopping the runtime and pulling the connection, because those are the cases that leave the bit stuck.
| Observation | First check | What it usually is |
|---|---|---|
| Request never goes TRUE | Binding and press event | The set action sits on a click instead of the press event, or the tag is an internal HMI tag |
| Request stays TRUE after release | Release event and destination | The reset event is empty, or aims at another tag or bit |
| Request TRUE, machine idle | PLC logic | Permissives refuse the request; the panel did its part |
Configured this way the button is momentary by construction: one write on the start of the hold, one on its end, both proven at the controller.
Questions asked
Does the WinCC Unified press event react to touch, mouse and keyboard?
Yes. The TIA Portal documentation for Unified runtime states that the Press event can be triggered with the left or right mouse button, on the touchscreen, or through keyboard operation. One configuration therefore serves a touch panel, a mouse-connected station and a keyboard operator, provided all three act on the same button object.
Is there one WinCC Unified function that holds a bit set while pressed?
No. The Unified function list has no while-pressed entry. The classic function is called SetzeBitWährendTasteGedrückt in German projects and appears as SetBitWhileKeyPressed in English documentation, and neither name has a Unified successor; the supported route is the two-event pair on the button.
Can scripts set and reset the command bit instead of system functions?
Yes. Unified runtime scripting provides Tag.SetBit() and Tag.ResetBit() for setting and resetting single bits. Put the SetBit call on the press event and the ResetBit call on the release event of the same button, aimed at the tag the controller watches. The discipline is identical: two events, one destination, and the pulse proven at the PLC.


