How-to
How to Make One HMI Button Read and Write Two PLC Bits
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
- How can one button read and write two different PLC bits?
- Which approach fits best: one offset button, stacked buttons, or a macro?
- Does the offset register use PLC communication time?
- How do you configure the button and its offset register?
- What should set the offset word, and who owns the register?
- What makes the offset hit the wrong bit or fail?
- How do you verify the button hits the correct bit?
- 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:
- The operator touches the button. The runtime holds the object's base address, X0.
- The runtime reads the internal word from its own memory — no communication hop, no serial or Ethernet traffic.
- 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.
- 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.
- Place the button and set its read/write address to the base bit.
- 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.
- Enter internal word 0 as the offset register.
- 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.
- 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.
- Open the PLC's online monitor with both target bits visible.
- Set the internal word to 0, press the button, and confirm only the base bit changes.
- Set the word to 1, press again, and confirm only the next bit changes while the first stays unchanged.
- 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.
- 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.