IMDTouchKnowledge BaseShop main store

How-to

How to Make One HMI Button Read and Write Two PLC Bits

HMI and touchscreens Published 6 min read

Short answer

Enable the button's write/read offset address and point it at the HMI internal word 0. With the word at 0 the button reads and writes X0; with the word at 1 the same button reads and writes X1. The offset is resolved inside the HMI before any request reaches the PLC.

On this page
  1. How can one button read and write two different PLC bits?
  2. Which approach fits best: one offset button, stacked buttons, or a macro?
  3. Does the offset register use PLC communication time?
  4. How do you configure the button and its offset register?
  5. What should set the offset word, and who owns the register?
  6. What makes the offset hit the wrong bit or fail?
  7. How do you verify the button hits the correct bit?
  8. Questions asked

Yes. A single button reads and writes two PLC bits when its write/read offset address is enabled and pointed at an HMI internal word. In DIAScreen 1.4 the documented register for this is the internal word 0: with that word at 0 the button works on X0, and with the word at 1 the same button works on X1. The mechanism is identical for any consecutive pair — for an X1 and X2 target, set the base to X1 and the same two values of the word select X1 and X2. The offset is resolved inside the HMI before any request reaches the PLC, so the controller sees an ordinary one-bit access.

How can one button read and write two different PLC bits? #

Enable the button's write/read offset address and set the offset register to the HMI internal word 0: with the word at 0 the button reads and writes X0, and with the word at 1 the same button reads and writes X1.

DIAScreen 1.4 documents this through its write/read offset address setting: one button, a base address, and the internal word as the offset register. The documented example shows the state being read through the same button at both offsets, and because the option sits on the combined write/read address, the write on touch shifts with it. One object therefore covers both directions. For an X1 and X2 pair, set the base address to X1; nothing else changes.

Which approach fits best: one offset button, stacked buttons, or a macro? #

Use the offset button: it keeps one object, one touch area and one address to edit, while the stacked-button and macro designs double the object count or add a debugging surface.

Approach Objects on screen How the target bit is chosen Decision
Offset (indexed) address on one button 1 value of the internal word added to the base address use it; confirmed in DIAScreen 1.4
Two buttons stacked, visibility tied to a bit 2 which button is visible only when the two states need different labels or positions anyway
Macro that writes the target bit 1 plus a macro macro logic only if the project already carries macro logic

The decision follows the table: start with the offset address, fall back to stacked buttons where the states must look different on screen, and reach for a macro only when there is existing macro code to extend.

Does the offset register use PLC communication time? #

No. The internal word is HMI memory, so the runtime reads it locally, adds it to the base address, and only then builds the read or write request that travels to the PLC.

Worked example with the arithmetic, first for the documented pair and then for the X1 and X2 pair:

  1. The operator touches the button. The runtime holds the object's base address, X0.
  2. The runtime reads the internal word from its own memory — no communication hop, no serial or Ethernet traffic.
  3. It adds: X0 + 0 = X0 with the word at 0, and X0 + 1 = X1 with the word at 1. For the X1 and X2 pair, base X1: X1 + 0 = X1 and X1 + 1 = X2.
  4. The resulting address goes into the normal request, and the PLC answers an ordinary single-bit access.

Because the offset applies to the whole object, the read that drives the button's displayed state shifts with the write. When the offset word changes, the indicator reflects the newly selected bit on the next poll.

How do you configure the button and its offset register? #

Set the button's read/write address to the base bit — X0 for the documented pair, X1 if the targets are X1 and X2 — enable the write/read offset address in the same address dialog, enter the internal word 0 as the offset register, then compile and download.

  1. Place the button and set its read/write address to the base bit.
  2. Open the button's address settings and enable the write/read offset address option. Menu labels move between software releases, so look for the offset inside the address dialog rather than on a fixed menu path.
  3. Enter internal word 0 as the offset register.
  4. Decide what writes the word: a second button that sets or toggles it, a selector object writing to it, or an initial value when the choice never changes at runtime.
  5. Compile and download the project to the HMI.

What should set the offset word, and who owns the register? #

One writer only: reserve the internal word 0 for this selection in the project's address list and let a single selector own it, because a second writer produces intermittent wrong-bit behavior that is hard to reproduce.

Typical owners are a small toggle button or a selector object; a constant initial value works when the choice is fixed. Because the word lives in the HMI, the PLC program cannot see which bit the operator selected — when the logic needs to know, write a separate bit from the same selector to a PLC address and branch on that. One safety note belongs here: the touch area keeps its position while its meaning changes with the offset word, so make the selection visible to the operator, or the same press can act on the wrong bit.

What makes the offset hit the wrong bit or fail? #

Three things: the offset word holding a value other than intended, a base-plus-offset result that does not exist in the PLC's address range, and writes aimed at physical X inputs that the PLC refuses or overwrites each scan.

Symptom Cause Check
Button always acts on the base bit offset option not enabled on this object, or the internal word never changes display the word in a numeric object and watch it while operating the selector
Button hits a wrong, distant bit the internal word holds a value other than 0 or 1 limit the selector's input range to the values you intend
Communication error after switching the resulting address does not exist in the PLC's range confirm base + offset is valid for the PLC model
Indicator flips when the selection changes it now shows a different PLC bit, as designed read both bits in the PLC monitor and compare

Many PLC families number X points in octal, so there is no X8 and no X9: after X7 the next input is X10, and an offset of 8 or more can land where decimal arithmetic says it should not; confirm how the controller maps X addresses before using large offsets. A communication error right after switching usually means the resulting address is outside the PLC's range — the same failure you meet when fixing invalid bit address errors while adding HMI tags.

X points are physical inputs on many PLCs, and the controller may refuse a write or overwrite it on the next scan, which is why an HMI toggle switch cannot write a physical PLC input. When the button must write, point the base address at internal relays instead and keep X for reads.

How do you verify the button hits the correct bit? #

Watch both bits in the PLC's online monitor while switching the offset word between 0 and 1: each press must change exactly one bit, and the button indicator must follow whichever bit the offset selects.

  1. Open the PLC's online monitor with both target bits visible.
  2. Set the internal word to 0, press the button, and confirm only the base bit changes.
  3. Set the word to 1, press again, and confirm only the next bit changes while the first stays unchanged.
  4. With the word still at 1, force the selected bit from the monitor and confirm the button indicator follows it — this proves the read path uses the offset, not just the write.
  5. Return the word to 0 and confirm the indicator tracks the base bit again.

Questions asked

Can the same button select more than two bits?

Yes. The offset is added to the base address, so a base of X0 with the internal word set to 0, 1 or 2 reaches X0, X1 and X2 from one object. Limit whatever writes the word to the values you intend, and confirm the PLC's X numbering before using offsets above 7, because octal-addressed inputs have no X8 or X9.

How do you show the operator which bit is selected?

Add a numeric display object addressed to the internal word beside the button. It reads HMI internal memory directly, so it updates without adding a PLC request, and its value is the fastest way to see whether the selector or a stray write is changing the selection.

Can the PLC program see which bit the operator selected?

No. The internal word lives in the HMI's internal memory and never crosses the link. When the PLC logic needs the selection, write a separate bit or word from the same selector to a PLC address and branch on that, so both devices agree on the current target.

Does the offset work the same over serial and Ethernet links?

Yes. The offset is resolved in the HMI before the request is built, so the protocol and the medium do not matter; the PLC receives an ordinary single-bit read or write to the resulting address over either link.

Keep reading

  • How-to

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

    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.

    HMI and touchscreens

  • 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

  • How-to

    Connecting One NS-Series HMI to a Redundant CS1D and a CP1H

    Yes. One NS-series panel hosts both controllers: a duplex CS1D pair whose Ethernet units keep a single system IP address through CPU changeover, so the panel never selects a CPU, plus a CP1H reached through its CIF41 as a second host. Both links run FINS over Ethernet simultaneously.

    HMI and touchscreens