Run PLC logic only on the HMI current screen number tag

5 min read · Published November 3, 2026

Your panel publishes a system tag that holds the number of the screen it is displaying. Map that tag to one PLC register, gate the rung with an equality compare against the setup screen's number, and the stepper setup logic runs only while that screen is shown.

Your panel already knows which screen it is showing, and it will tell the PLC. The panel's tag database lists two system tags for this: Current Screen Number, which holds the number of the screen displayed right now, and Current Screen Name, which holds its name. Assign one PLC register to the number tag, download the panel project, and gate the rung with a single equality compare. Your stepper setup math then runs only while the setup screen is up. One register, one contact, and the job is done.

What the panel already publishes

Open the panel project and look in the tag database under system tags. Two entries report where the operator is:

System tag Direction Type Holds
Current Screen Number panel to PLC integer the number of the screen displayed right now
Current Screen Name panel to PLC string the name of the screen displayed right now

The panel refreshes these on its own update cycle, so the register always lags a screen change by one update. The tag setup also runs the other direction: assign a register as the change-screen command, and the panel jumps to whatever screen number the PLC writes into it. The pair makes a handshake. The PLC writes 4 to call up the setup screen, and the switch is confirmed when Current Screen Number reads 4 back.

How the operator got there, HMI function key screen navigation or a touch button, makes no difference to the register. It follows whatever screen the panel lands on.

Map the screen tag to a PLC register

You need the panel project, the PLC program, and the panel-to-PLC link already carrying tags. Then:

  1. Find the system tags in the panel's tag database. Current Screen Number and Current Screen Name are in that list.
  2. Assign Current Screen Number an address in the PLC: one unused integer register. Name it ScreenNo in the PLC program.
  3. Download the project to the panel. The panel writes the displayed screen number into that register on every update cycle.
  4. Leave Current Screen Name unassigned unless your screens get renumbered often. Using it costs a string register in the PLC and a string compare on the rung.

Gate the rung with one compare

The gate is one equality compare against a constant: ScreenNo = 4, if 4 is the setup screen's number. Put the compare output in series ahead of the rungs you want gated, as a permissive contact. Delete nothing. The contact decides when the math executes.

For the stepper screen, the gated block is the scaling math that turns the operator's entries into counts per millimetre, velocity and acceleration values. Show those values on the screen the same way you show any PLC configuration values in a visualization; the gate controls when the PLC computes them, and the screen displays them like any other tag.

If the math should load saved parameters the moment the screen opens, run that load once on the rising edge of the compare, with a one-shot.

If an edit must run to completion once started, do not gate it away. Latch a bit from a button on that screen; in a structured text project that is calling a method from a visualization button. Clear the bit when the write finishes. The screen compare gates the entry points, and the PLC owns the exit.

The gate is about the operator panel only. A status board the whole crew reads from across the aisle is a different screen, and shop-floor and andon-style boards are that subject on their own.

Example: setup screen 4 on a 10 ms scan

A machine has a setup screen, screen 4, where the operator trims stepper velocity and acceleration. The PLC scans in 10 ms. The gate is the compare ScreenNo = 4 feeding the parameter math.

While screen 4 is displayed, the rung solves every scan: 1 s / 10 ms = 100 executions per second. That rate is fine for scaling math, a handful of compare and move instructions.

The operator presses Back and lands on the run screen, screen 2. The panel writes 2 into ScreenNo on its next update. Assume that write lands within 250 ms of the key press, and measure yours once by watching the register while you press. The compare goes false on the first scan after the write, so the math stops at worst 250 ms + 10 ms = 260 ms after the screen change. In that window it executes 250 ms / 10 ms = 25 more times, which is harmless: the operator has left, and the math only reads the entry registers and writes the scaled values.

Arriving works in reverse. The screen paints, the panel writes 4 within the same update, and the math starts about a quarter second after the screen appears. On a setup screen nobody notices. If you load saved parameters on entry, the one-shot fires once at that rising edge.

If the link between the panel and the PLC drops, the register stops updating and holds its last value. The PLC reads screen 4 forever, and the gated math keeps running on values nobody is looking at. The same silence has a display-side twin, why an HMI can show nothing while the PLC still runs.

Gate convenience logic only: parameter math, screen-specific polling, help text. Never gate a motion permission, an interlock or a stop function on a screen number. Those rungs run regardless of what the panel shows.

Check it worked

  1. Put ScreenNo in an online watch table and cycle through every screen. The register takes each screen's number as the panel lands on it.
  2. Sit on the setup screen: the gated math output coil is on. Press Back: the coil drops within about a second.
  3. Write 4 to the change-screen register from the PLC. The panel opens the setup screen and ScreenNo reads 4 back. That is the handshake working end to end.

Recommendation: map Current Screen Number to one integer register and gate with a single equality compare whenever the logic is convenience work such as stepper setup math. Keep interlocks and motion permissions out of the gate entirely. Add the screen-name tag only if you renumber screens often, and add the change-screen handshake only when the PLC must drive the operator to a screen.

Questions

Does the current screen number tag update when a pop-up window opens?

The documented tags report the screen the panel is displaying. Pop-up windows are their own object, so treat the pop-up case as unknown until you watch it: open the pop-up on the live panel with the register in a watch table and see whether the number changes. If it holds steady, gate the pop-up logic with a bit the pop-up sets on open and clears on close.

How do I make the panel change screens from the PLC?

Write the target screen number to the panel's change-screen register, then watch the current screen number tag until it reads the same value back. The match confirms the switch actually happened. Use the same handshake to sequence a guided setup: the PLC commands the setup screen, waits for the readback, then enables the entry fields.

Is it better to compare the screen name instead of the number?

Use the number. An integer compare is one instruction and its scan cost is close to nothing. Switch to the name tag only when screens get renumbered often, and accept the string register and the string compare on the rung. Keep the number in a named constant so a renumber breaks at one visible place instead of hiding inside the rung.

Can I make gated logic fall off safely if the panel goes offline?

Yes, on a polled link. When a transaction to the panel reports failure, move 0 into the screen register from that error rung. Every equality compare then goes false and all gated logic stops, which is the state you want when nobody can see the screen. On a link that reports health as a status word, use that word the same way.

Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.

Keep reading

Build your signAsk for a quote