IMDTouchKnowledge BaseShop main store

How-to

Binding an HMI button command to a separate feedback color

HMI and touchscreens Published 7 min read

Short answer

Build each illuminated control as two independent bindings: a state or lamp object whose color reads a PLC feedback variable, plus a touch action that writes the command variable. The color then reports what the machine actually did, including a refused or delayed command, instead of echoing the last touch. Force each feedback bit against its command on the bench before release; any lamp that follows its own command fails.

On this page
  1. Why the color reads feedback, not the command
  2. Separate the two variables before you open the editor
  3. Pick an object that holds both bindings
  4. Configure both bindings on the object
  5. Worked example: binding count for a four-toggle screen with one alarm button
  6. Prove stale data before release
  7. Questions asked

The fix is to stop using the toggle-switch object. Place a state or lamp object, bind its color states to a PLC feedback variable, and attach a touch action that writes the command variable. Two bindings, two variables: the finger writes the request, and the machine's own feedback colors the button. On a rebuilt screen the color then reports what actually happened — a start accepted, delayed by an interlock, or refused — instead of echoing the last touch. The same split covers the alarm-presence button: red comes from an alarm summary condition, never from the fact that someone opened the alarm display. The sections below cover the variable roles, the object choice, the bindings, and the bench test that proves the split before the screen goes on the machine.

Why the color reads feedback, not the command #

A lit pushbutton on a hardwired panel has always worked this way: the lamp lands on the contactor's auxiliary contact, so green means the contactor pulled in, not that somebody pressed a button. Carry that rule onto the screen unchanged. The touch action and the color are two separate jobs with two separate variables.

When the color reads the command bit instead, three things go wrong on a real machine:

  • An interlocked or refused command shows green anyway, because the bit the finger wrote is the bit that colors the lamp.
  • A delayed start shows green before the machine moves.
  • A dropped connection freezes the last color, and a stale green reads like a fresh response.

The decision rule: if a color binding and its touch action point at the same variable, the object is miswired by design, even when it looks correct on the bench. Split them on every illuminated control.

Separate the two variables before you open the editor #

Inventory every illuminated control first. Each one needs:

  • A command variable: a writable BOOL in PLC memory. The touch action must land on memory or retained data bits, never on a physical input address; why an HMI toggle switch cannot write a physical PLC input covers that trap in detail.
  • A feedback variable: a BOOL that reports what the machine actually did — contactor auxiliary contact, drive running status, valve limit switch. If the legacy program never had one, add it: one rung that sets the bit from the real output state. Never let the command bit stand in as its own feedback.
  • Command semantics: decide who owns the toggle. If the PLC latches the state from a momentary request, the HMI writes the request and the PLC owns the maintained state. If the legacy contract is a maintained command that stays set until touched again, the HMI writes that command directly. The color reads feedback in both cases.

If the legacy project is gone, recover the roles from the controller code before drawing anything; rebuilding a lost HMI project from PLC tags and logic walks through that recovery. The finished inventory has this shape:

Screen object Touch action writes Color reads
Illuminated start toggle start command bit running feedback bit
Illuminated stop toggle stop command bit stopped feedback bit
Mode toggle mode request bit mode confirmed bit
Alarm-presence button navigation only alarm summary bit

Pick an object that holds both bindings #

Object sets differ between editors, which is why a small rebuild can stretch into days: on many platforms the switch or toggle object ties its appearance to the bit it writes and cannot display a second variable. Use a state, lamp or indicator object that also accepts an input event. The pattern exists under several names:

  • CODESYS visualization: the Button element's input configuration lets you assign a variable to the Tap or Toggle mouse events, while the displayed state comes from a separate binding.
  • Script-based platforms: InTouch touch push button links start action scripts, and action scripts set tags to specific values, so the script writes the command while a state object reads feedback for the color.
  • Property-based controls: the BasicButton control in the AdvancedHMI library exposes PLCAddressHighlight, which recolors the button from a second PLC address.
  • Split objects: where an editor separates a lamp object from a switch object, take the lamp and attach the touch action to the lamp itself.

This is not the same job as one button that reads and writes two PLC bits in a single action; here the second binding never writes, it only colors.

Configure both bindings on the object #

  1. List the command and feedback variables for every illuminated control, with types, write permissions and the toggle owner.
  2. Place a state or lamp object for each control and bind its value or state input to the feedback variable.
  3. Define the appearances, for example gray with feedback off and green with feedback on, and keep the mapping identical across all toggles on the screen.
  4. Attach the touch action and point it at the command variable. Match the write to the contract from the inventory: a momentary request gets a set-on-press or pulse action, a maintained command gets a toggle.
  5. Re-check the color binding before moving on. Some editors preselect the first variable you touched as the appearance source; confirm it still reads feedback.
  6. For the alarm-presence button, bind red to the alarm summary condition and make the touch action open the alarm display. Red belongs to alarms that demand a reaction — active or unacknowledged; keep history on the history page unless the legacy screen proved a narrower condition.
  7. Give every state object a distinct connection-loss appearance so unavailable data never looks like a real on or off state.
  8. On an isolated bench with verified test tags, force each feedback bit opposite its command bit and confirm the color follows feedback. Then trigger a condition the PLC refuses and confirm the color stays with feedback while the command changes underneath it.

Run these write tests on a bench or a locked-out machine only: the touch action writes a real command bit, and a live screen can start equipment.

Worked example: binding count for a four-toggle screen with one alarm button #

Inputs:

  • Four illuminated toggles and one alarm-presence button — the inventory of the small legacy screen being rebuilt, a typical case for this job.
  • Two bindings per toggle: one write to the command bit, one read of the feedback bit for the color.
  • Two bindings for the alarm button: one read of the summary condition for the red state, one navigation action.

Rule in words: a rebuilt screen needs two bindings per illuminated toggle plus two for the alarm button, and every color binding must read a feedback or summary variable, never its own command bit.

Arithmetic: 4 toggles × 2 bindings = 8; 1 alarm button × 2 = 2; 8 + 2 = 10 bindings, of which 4 are writes.

Result: the screen carries ten bindings.

Decision: count the bindings on your rebuilt screen. Ten means every control owns its pair. A count under ten means at least one color still rides its command bit — the chained rebuild of this same inventory counts six, because four toggles with one binding each give 4 × 1 = 4, plus the alarm pair — so find that lamp and rebind it. The pass criterion on the bench: all four command bits forced opposite their feedback bits, and all four lamps showing the feedback state. Any lamp that follows its own command fails the screen.

Prove stale data before release #

Finish with one controlled communication break on the bench: with a feedback bit forced on, drop the link between the HMI and the PLC. The lamp must switch to its connection-loss appearance and must not hold green through the break; on reconnect it must take the fresh value. A lamp that keeps its last color during a real outage will be read by the operator as a live response.

Pair the pass with the tag-by-tag migration checks — validating HMI variables during a software migration sets out how to confirm each binding reads and writes the intended address. When every lamp reports feedback and every touch writes its own command, the rebuild is finished.

Questions asked

Why does the button stay green after the PLC refused the start?

The color is following the command bit, which the touch action set. The feedback bit never moved, so gray is the truthful color. Rebind the lamp's state input to the feedback variable, repeat the refused-start test on the bench, and watch both bits in the PLC's online view: the color must track feedback while the command changes under it.

My editor has no lamp object that accepts a touch action. What are the options?

Overlay a transparent button on top of the indicator and give the overlay the write action, keeping the color on the indicator underneath. In a script-based editor, an action script can write the command while a separate state object reads feedback for the color. Either way you still end up with two bindings and two variables.

Should the PLC or the HMI own the toggle state?

Prefer the PLC when its program may be changed: it converts a momentary request into one maintained state, the HMI only sends the request and displays feedback, and a screen restart cannot lose the machine state. Keep the HMI-owned maintained command only where the legacy PLC contract expects it, because that bit must be rewritten after every power-up.

What should the alarm button show when the connection drops?

Treat the alarm summary like any feedback variable: the button should take its configured no-data appearance rather than freeze red or gray, because a frozen red is ambiguous and a frozen gray can hide a live alarm. After the link returns, confirm the button tracks the live summary again before the screen is released.

Can the color come from the command bit if there is no room for a feedback bit?

No. Without feedback the lamp can only report what was asked, never what happened, which defeats the indication. Add the bit in the PLC instead: one rung that mirrors the real output state is enough, and it costs nothing but one BOOL of memory.

Which write action suits a momentary request?

A set-on-press action that writes the request bit true on touch, cleared by the PLC once it has consumed the request, or a pulse action if the editor offers one. Avoid a toggle write for a momentary contract: the second touch then removes a request the PLC may never have processed.

Keep reading

  • How-to

    How WinCC Runtime Color Selection Reaches a VBScript

    No WinCC basic or Comfort panel ships a runtime color-picker control, but the operator does not need one. Configure each palette swatch as a screen object whose press event writes an assigned identifier to an internal HMI tag, and have the VBScript read that tag and resolve it to the destination color value.

    HMI and touchscreens

  • How-to

    Validating HMI variables during a software migration

    A converter promise with no release date is not a migration plan. Inventory every source variable with its name, type, address, read/write use and consumers; convert only a working copy or recreate variables from the inventory; then test each variable's reads, approved writes, screens, alarms and scripts against that inventory before commissioning.

    HMI and touchscreens

  • Troubleshooting

    Why a replacement HMI panel needs the recovered legacy project

    A swapped-in replacement panel is not a display-only exchange: the old HMI application must be uploaded with its documented legacy editor, checked to support both the exact source model and the new target, converted, and commissioned before download. Cutout, power and cabling checks run separately.

    HMI and touchscreens

Why stacked HMI controls break buttons and content pages fix it