IMDTouchKnowledge BaseShop main store

How-to

How to Configure a Two-State Auto/Manual Switch in WinCC Flexible

HMI and touchscreens Published 6 min read

Short answer

Pair the functions on each switch event: the Manual event runs SetBit on M10.0 and ResetBit on M10.1, and the Auto event runs SetBit on M10.1 and ResetBit on M10.0. After every transition exactly one mode bit is high, which is the state the PLC mode logic expects.

On this page
  1. Map the selector positions to two PLC bits
  2. Pair SetBit and ResetBit on each switch event
  3. Why one function per event is not enough
  4. Worked example: three transitions
  5. Alternative: one request bit decoded in the PLC
  6. Test every transition before handover
  7. When the project moves to TIA Portal
  8. Questions asked

A two-position Auto/Manual selector must leave exactly one PLC mode bit high after every tap, and a single switch event function cannot do that by itself. The configuration that works pairs two functions on each event: the event that selects Manual runs SetBit on M10.0 and ResetBit on M10.1, and the event that selects Auto runs SetBit on M10.1 and ResetBit on M10.0. Both functions are added to the same event in the switch's properties in WinCC flexible 2008, so the PLC sees exactly one active mode request after every transition. The steps below cover the tag mapping, the event pairing, the single-bit alternative decoded in the PLC, and the transition test that proves the result.

Map the selector positions to two PLC bits #

Use two distinct memory bits for the two requests — here M10.0 is Manual and M10.1 is Auto, the mapping this application uses; any two bits the PLC program reserves for mode requests behave the same way. Create one HMI tag per bit on the PLC connection and keep the screen labels aligned with those tag names. Hand-typed bit addresses are where tag errors enter a project, so check for invalid bit address errors when adding HMI tags before you go further. Never point both positions at the same bit: a selector that writes one tag twice gives the PLC nothing to distinguish the modes.

Selector position M10.0 (Manual) M10.1 (Auto)
Manual selected 1 0
Auto selected 0 1

Pair SetBit and ResetBit on each switch event #

Switch and button objects in WinCC flexible expose events in their properties — the list includes Change, Switch On, Switch Off, Activate and Deactivate — and one event can carry several functions that run in sequence. For a two-position selector you use one event per position, and each event gets two functions from the bit-level list: SetBit and ResetBit.

  1. Place the switch on the screen, open its properties, and go to the Events section.
  2. Assume Switch On fires when the selector shows Manual, and open that event's function list.
  3. Add SetBit and assign it the Manual tag, M10.0.
  4. Add ResetBit to the same event and assign it the Auto tag, M10.1.
  5. Open the opposite event, Switch Off, and add SetBit with the Auto tag, M10.1.
  6. Add ResetBit with the Manual tag, M10.0, to that same event.
  7. Save, download the project to the panel, and go online with the PLC.
  8. Operate the selector once in each direction and read both bits. If the pattern comes out backwards, the assumption in step 2 was inverted — swap the two events and download again.

The same one-set-one-reset rule applies if the selector is later rebuilt as a scripted faceplate, the situation walked through in SetBit versus ResetBit in a VB script faceplate.

Why one function per event is not enough #

SetBit alone on the Manual event sets M10.0 but leaves M10.1 at 1 whenever Auto was the previous mode. The PLC then reads two active requests, and what happens next depends on how the mode logic is written: it may hold the last mode, raise an alarm, or run both code paths. The paired functions close that branch, because both belong to the same event and the panel writes the pair together on every transition.

Give the two bits a single writer. Once the HMI events own M10.0 and M10.1, no PLC code should set or reset them, because two writers race and the panel cannot win reliably. Holding one-of-two outputs high is the same discipline described in configuring mutually exclusive outputs.

Worked example: three transitions #

Step Operator action Functions executed M10.0 M10.1 High-bit count
0 Panel powered, no selection none 0 0 0 + 0 = 0
1 Tap Manual SetBit M10.0, ResetBit M10.1 1 0 1 + 0 = 1
2 Tap Auto SetBit M10.1, ResetBit M10.0 0 1 0 + 1 = 1
3 Tap Manual again SetBit M10.0, ResetBit M10.1 1 0 1 + 0 = 1

From the first selection onward the count of high bits is 1 in every row — 1 + 0 = 1 and 0 + 1 = 1 — and that is the acceptance rule: any transition that ends with a count of 2 or 0 has the pairing wired wrong. Row 0 is the deliberate exception. At power-up no mode is requested, and the PLC must define what the M10.0 = 0, M10.1 = 0 pair means — normally a safe no-mode state with both mode outputs off — instead of leaving it to whatever the code falls into.

Alternative: one request bit decoded in the PLC #

The second architecture writes a single bit from the panel and derives both modes in the PLC. The switch toggles one request bit, and the decode is two lines:

// Illustrative SCL; ModeRequest, AutoMode and ManualMode are
// example names for BOOL variables, not fixed identifiers.
ModeRequest : BOOL := FALSE;  // the one bit the HMI writes
AutoMode    : BOOL := FALSE;
ManualMode  : BOOL := TRUE;

AutoMode   := ModeRequest;
ManualMode := NOT ModeRequest;

Test it at both values: ModeRequest = TRUE yields AutoMode = TRUE and ManualMode = FALSE; ModeRequest = FALSE yields AutoMode = FALSE and ManualMode = TRUE. Each request value produces exactly one active mode.

Decide between the two on who owns the mode. Use the paired HMI writes when the panel is the only writer and the PLC consumes the bits as-is — that is the configuration that works on this selector type. Use the decoded request bit when the PLC must validate a change against permissives such as door closed or drive ready, because that validation belongs next to the decode. Do not run both architectures on the same bits. If a ResetBit is configured and the bit still never clears in the controller, the PLC-side causes are the ones behind an S7 bit reset that does not execute.

Test every transition before handover #

Run the tests with the machine in a state where unexpected motion is impossible — drives inhibited or the machine isolated — because a mode change transfers control the moment the event executes.

  1. Select Manual and read both bits: expect M10.0 = 1 and M10.1 = 0.
  2. Select Auto and read both bits: expect M10.1 = 1 and M10.0 = 0.
  3. Return to Manual and confirm the pair flips back, not just the graphic.
  4. Repeat the cycle with quick taps; no sequence may end with both bits high or both low after a selection.

You can run the screens from the engineering PC against the controller first by testing HMI simulation against a live PLC, then repeat the cycle on the panel itself.

When the project moves to TIA Portal #

The pairing is project content in the switch's event configuration, not panel firmware. When you migrate a WinCC flexible project to TIA Portal, re-open each switch's event list after the conversion and confirm that both functions — the SetBit and the ResetBit — came across on each event, and that the Activate and Deactivate events were mapped if the object was rebuilt with different event names.

Questions asked

Can I use InvertBit on both tags instead of SetBit and ResetBit?

No. InvertBit flips one tag every time it runs, so each tap toggles its own bit and nothing tells the opposite mode bit to follow. Two taps that get out of sequence leave both bits high or both bits low. SetBit plus ResetBit forces the pair into a known state on every transition, no matter what the previous state was.

After a panel restart the switch graphic does not match the PLC mode. Is that a fault?

Not by itself. Switch events run on operator touches, not at startup, so after a restart or a project download the drawn position can disagree with the bits. Treat the two PLC bits as the only truth: tie the switch graphic to the mode tag where the object offers that connection, or display the bits in a status field, and have operators confirm the mode there before acting on it.

Would SetBitWhileKeyPressed be a better function for the selector?

No. SetBitWhileKeyPressed is a WinCC Unified system function that holds a bit TRUE only while the user keeps the button pressed, then clears it on release. That suits momentary jog or inch commands. A mode selector must stay latched when the operator lets go, which is exactly what the SetBit and ResetBit pair delivers in a WinCC flexible project.

Both M10.0 and M10.1 are high after a change. Where do I look first?

Open the switch event configuration and confirm each event carries two functions and that every ResetBit targets the opposite mode tag; a reset aimed at its own tag leaves both requests set. Then search the PLC program for other writers of M10.0 and M10.1. If step logic also writes these bits, the two writers race and the panel pairing cannot hold; give the bits exactly one writer.

Keep reading

  • Troubleshooting

    Displaying a PLC Real Value Over Modbus on an HMI

    An INTEGER display that reads the register proves the link, station and address, so a blank REAL display is a 32-bit mapping fault. Declare the HMI variable as a 32-bit float on the register pair (40064/40065), set the device double-word order to Low Word First to match the PLC, and give the numeric field six integer digits for 628402.0.

    HMI and touchscreens

  • Explainer

    HMI OPC UA Server vs Client: Which Direction Works

    OPC UA support on an HMI spec sheet almost always means the panel runs a server that serves its tags to external clients. Reading PLC symbols by name needs an OPC UA client driver, a separate capability you verify in the driver list for your exact software release, target and license.

    HMI and touchscreens

  • Troubleshooting

    Why HMI Objects Vanish in Online Simulation Over Modbus

    Objects bound to Modbus vanish in Online Simulation because the simulation PC cannot complete the read each object needs before it can draw a state. A momentary switch still appears because a press issues a write with no prior read. Put the PC on the controller's subnet, confirm TCP port 502 is reachable, free the controller's client slot, and prove one read from the PC before changing the project.

    HMI and touchscreens

How to Access One Bit of a Word in Operator Terminal Expert