How-to
Setting a PLC bit when a WinCC flexible screen is left
Short answer
On a WinCC flexible 2008 panel, set a bit like stop1200 when the operator leaves a screen by assigning the screen's departure event a bit-setting system function on the connected Boolean tag. No script is needed. Hold the request until the PLC acknowledges it, and handle shutdown, communication loss and power loss in controller logic, never in the departing screen.

On this page
- Screen events versus object and button events
- Deciding what the bit has to mean
- Checking the tag before you wire the event
- Configuring the departure action, step by step
- Worked example: stop1200 on ISO_coneteneur with hold-and-acknowledge
- Testing every departure route
- Summary of the decision
- Questions asked
On a WinCC flexible 2008 SP2 project, the clean way to set a bit such as stop1200 when the operator leaves a screen like ISO_coneteneur is to select the screen itself, open its event configuration, and assign the departure event a bit-setting system function on the connected Boolean process tag. No script is needed: the event belongs to the screen, fires on navigation away from it, and the function writes through the configured PLC connection. What the event cannot do is fire when the runtime is shut down, the connection drops or the panel loses power, so those cases must be caught by PLC-side supervision instead.
Screen events versus object and button events #
A screen event is bound to the screen's life in runtime: one event fires when the screen becomes active, another when navigation leaves it. An object or button event fires only when that control is operated. A stop request configured on the sequence's stop button therefore does not cover the operator pressing a screen-change button, selecting another screen from a menu, or a PLC-driven screen change. Binding the request to the screen's departure event covers all navigation routes at once, because every route out of the screen passes through the same event.
One caution from how these events are defined: a departure event fires when the screen changes, not when an object loses focus, and not when runtime ends. If you later move the project to a different HMI platform, re-read that platform's event documentation before assuming the same behavior; some platforms explicitly do not run object deactivation actions on a screen change.
Deciding what the bit has to mean #
Before configuring anything, settle the control requirement, because two different meanings lead to two different designs:
- One-shot stop request. The sequence should stop when the operator leaves the screen. The HMI raises
stop1200, the PLC consumes it and stops the sequence, and the PLC clears the bit when the stop is confirmed. This is the common case and the one this article configures. - Operating permission tied to the screen. The sequence may run only while that screen is displayed. A departure write is the wrong tool here: it is a single event, not a maintained state, and it vanishes on comm loss. Build this as a PLC condition (screen number equals the sequence screen) with a PLC-side fallback that stops the sequence when the condition is lost.
A normal sequence stop raised from an HMI is not a safety function. Where stopping protects personnel, the validated safety system on the machine acts independently of screen navigation and of this bit.
Checking the tag before you wire the event #
Open the tag configuration and confirm three things about stop1200:
- It is a process tag, not an internal tag. An internal tag lives only in panel runtime; setting it never reaches the controller. The tag must point at the configured connection and a PLC address the sequence logic actually reads.
- It is Boolean-compatible. The bit-setting function writes a true value; the PLC logic must use that polarity. If your existing sequence expects a false value to mean stop, align the HMI action with the logic's convention rather than inverting the logic later.
- The PLC consumes it. Cross-reference the address in the controller program. If nothing reads it, add the consumption and reset logic first, otherwise the bit will simply sit true after the first departure.
Also find every other writer. If cyclic PLC logic or a second HMI element clears the same bit, you have a race between panel communication and controller scan; establish ownership instead: the HMI sets, the PLC acknowledges and clears.
Configuring the departure action, step by step #
Save a project backup and confirm the project's configured device matches the installed panel before you start.
- In the project window, select the screen
ISO_coneteneuritself, not an object placed on it. If you only see button and object events, the screen is not the selected element. - Open the screen's event list and find the event associated with leaving or deactivating the screen. Read its description in the editor so you pick departure, not activation.
- Add a bit-setting system function to that event and select the process tag
stop1200as its tag. On targets that offer one, use the simple set function, not a set-and-reset pair; two actions on consecutive events can produce a pulse shorter than one communication cycle, which the controller never sees. - Review the other actions already on that event and every other writer to
stop1200so nothing clears or reverses the request unintentionally. - Complete the PLC side: when the sequence accepts the request, it stops, then clears the bit under an agreed condition (for example, sequence stopped and the operator back on the screen with an acknowledged reset). Without a defined reset, the request stays true forever.
- Compile, resolve any configuration errors, and transfer to the panel with the normal transfer procedure. Test with hazardous motion prevented, per the machine's commissioning plan.
Note that an event action initiates the write; it does not confirm that the controller received it. The value shown on the panel, the value in the PLC and the sequence state are three separate observations, and only the third proves the stop.
Worked example: stop1200 on ISO_coneteneur with hold-and-acknowledge #
This is the reader's own case, wired as a request-and-acknowledgement handshake.
Inputs. Screen ISO_coneteneur and bit stop1200, both named in the project (WinCC flexible 2008 SP2, the thread's configuration). Polarity: true requests stop, taken from the project's existing stop-button logic. Reset condition: sequence stop confirmed, chosen here as an example design decision.
Rule in words. The screen's departure event sets stop1200 and never clears it. PLC logic reads the bit, commands the sequence stop, and clears the bit only after the sequence reports stopped. The HMI never writes a reset.
Arithmetic of the write window. A set-and-clear pair on departure, with no acknowledgement hold, leaves the bit true for at most the time between the two event actions on the panel, typically well under one communication cycle, so the PLC can miss it. With the hold design, the bit stays true for the entire interval from departure to sequence-stop confirmation. For an example sequence that reaches a stopped state within a few controller scans, the hold window is thousands of times longer than a single-scan pulse, so the request cannot be missed for timing reasons.
Result. Departing the screen raises stop1200; the sequence stops; the PLC clears the bit on confirmation; the next entry into ISO_coneteneur finds the request false and does not fire a stop on entry.
Decision and threshold. Use the departure-event set with PLC acknowledgement whenever the bit is a one-shot request the controller consumes. If the sequence must remain enabled only while the screen is displayed, do not use the departure write at all: the PLC must supervise the condition and stop on its loss. For request-hold designs where the operator station must complete its departure before the sequence moves on, the treatment in the article on exit constraints and station holds until departure applies the same principle from the station side. A related failure mode to avoid is putting the whole write in a long script; a screen that waits on a script freezes its own updates, as covered in the article on an HMI screen freezing while a script runs.
Testing every departure route #
Enter ISO_coneteneur and confirm stop1200 reads false; entering the screen must not issue a stop. Then leave through each configured route: the navigation button, the screen-selection menu, and a PLC-driven screen change if one exists. On each route, watch the PLC address go true, the sequence transition to stopped, and the bit clear on the agreed condition. Finally, kill the panel connection or power mid-sequence on the bench and observe: the departure write does not happen, which is exactly why the sequence's stop-on-communication-loss supervision in the controller is mandatory, not optional.
If a repair is ever not worthwhile and the panel itself is being replaced, a PC-based runtime is the usual fallback; the hardware kind for that move is covered under industrial panel PCs.
Summary of the decision #
For a single Boolean request on a WinCC flexible 2008 SP2 panel, configure the screen's departure event with a bit-setting function on the process tag, hold the request until the PLC acknowledges it, and let the controller own the reset. Reserve scripts for targets and cases the event mechanism cannot cover, and put every supervision case that depends on the HMI surviving long enough to write, shutdown, comm loss and power loss, in the PLC.
Questions asked
Does the screen departure event fire when the HMI runtime shuts down or the connection drops?
No. A departure event is a navigation event: it fires when runtime is running and the panel changes to another screen. A runtime shutdown, a communication failure or a loss of panel power ends execution before the event can run, so a write configured there cannot cover those cases. Supervision that must catch them belongs in the PLC, typically as a connection watchdog or a timeout on the request.
Why does my set bit disappear before the PLC sees it?
If the departure event sets the bit and a later event or another writer resets it, or if the panel sets and clears it in quick succession, the write window can be shorter than the panel's communication cycle, so the controller never samples it. Set the bit once on departure and let PLC logic clear it after the sequence confirms the stop.
Do I need a script for this in WinCC flexible 2008 SP2?
Usually not. A script only makes sense when the target device offers no screen event or no bit-setting function, or when several tags must be written in one departure with conditions between them. For a single Boolean request bit, the event action on the screen is simpler to configure, transfers cleanly, and cannot hang the runtime the way a long script can.

