IMDTouchKnowledge BaseShop main store

How-to

Enforcing HMI Setpoint Deviation Limits Outside the Panel

HMI and touchscreens Published 8 min read

Short answer

Run the deviation check in a Gateway Tag Change script, not a Vision client event, and compare the new value against the recipe value so setpoints cannot creep 100 to 124 in legal steps. Write the corrected value back once; with a recipe comparison the loop ends after one extra event. Move the band check into the PLC for any axis that cannot tolerate the poll-to-writeback window on a bad setpoint.

On this page
  1. Can a tag change script veto the write before it reaches the PLC?
  2. Where must the deviation script run?
  3. What should the new value be compared against?
  4. Why does the write-back fire the event again?
  5. Which corrected value should the script write back?
  6. How long is the process exposed to a bad setpoint?
  7. Which setpoints need the band check inside the PLC?
  8. How do you build the enforcement step by step?
  9. Questions asked

Run the band check in a Gateway Tag Change script that compares each new value against the recipe value and writes one corrected value back, put a Gateway Timer sweep behind it, and copy the check into the PLC for any axis that cannot sit on a bad setpoint for the poll-to-writeback window. No script vetoes a write: the value is already in the controller when the event fires, so everything downstream of the terminal is reaction with measurable latency. The four field failures this design kills are out-of-band values surviving with no client open, write-back loops, setpoints creeping through legal steps, and corrections that arrive after the process has already moved.

Can a tag change script veto the write before it reaches the PLC? #

No. The event fires after the controller already holds the new value, so nothing in the script can un-write it; the only action available is a second write that puts a corrected value back, one event later.

The terminal writes straight to the PLC tag and never passes through the SCADA project, so the gateway learns about the change from its OPC subscription, after the fact. Every decision downstream follows from that: you are choosing how fast and how cleanly you react, not whether you permit. The entry component commits whatever the operator entered — and an edit box can even display a value that was never written, a separate quirk covered in why an HMI edit box shows a value that was never set.

Where must the deviation script run? #

In an Ignition Gateway Tag Change script, not a Vision Client Tag Change Event: the gateway scope fires once per change with no client open at all, and a Gateway Tag Change script polls its tags at a configurable rate that defaults to 500 ms.

A Client Tag Change Event executes only inside an open Vision client. Overnight, or with the SCADA PC logged off, nothing checks anything — exactly when unattended values stick. With three clients open it is worse, not better: the script runs three times and makes three write-backs for one change.

Behind the change script, add a Gateway Timer script as the backstop, re-validating every setpoint on a fixed interval. Two entries made between polls arrive as one final value, and the first update after a gateway restart comes through marked as an initial change that most scripts skip; a 5 s sweep closes both gaps and costs almost nothing, because the limits are already loaded from the recipe query.

What should the new value be compared against? #

Against the recipe value, never previousValue: with a ±10 band on a recipe of 100, comparing each entry to the last tag value accepts 100 → 108 → 116 → 124, and 124 − 100 = 24, more than double the allowed deviation.

Each step is +8, inside ±10 of the value before it, so a previous-value comparison passes all three changes while the setpoint walks out the door. That is rate control with a one-step memory, not deviation control. The reference must be the recipe setpoint the band was specified around, and the band must be computed as recipe − devMin to recipe + devMax. The recipes live in SQL Server behind the database connection already configured in the project; pull the active one with a named query that takes the recipe ID as a parameter. Keep devMin and devMax as separate columns, one row per setpoint: the two sides of the band can differ, both can change after commissioning, and neither belongs as a constant in the terminal program.

Why does the write-back fire the event again? #

Because the corrective write is itself a tag change, so the event runs a second time; against the recipe value the corrected value is inside the band, validation passes, and the loop ends after exactly one extra event.

The runaway recursion comes from the same wrong reference. On the second event, newValue holds the old good value and previousValue holds the rejected one; the difference is still outside the band, so the script rejects its own correction and writes again, indefinitely. Saving a last-valid-value variable to break that loop treats the symptom — fix the reference and the loop cannot start. The check itself is four lines:

# Gateway Tag Change script. The event supplies newValue and previousValue;
# writeBlocking is the write-back call. Every other name below is this
# example's own, declared with its type and starting value.

recipeSp = 100.0           # float, active recipe value for this tag
devMin   = 10.0            # float, allowed decrease from the recipe value
devMax   = 10.0            # float, allowed increase from the recipe value
entered  = newValue.value  # float, what the operator wrote at the terminal

lo = recipeSp - devMin     # 90.0
hi = recipeSp + devMax     # 110.0

if not (lo <= entered <= hi):
    clamped = max(lo, min(hi, entered))  # 125 entered -> 110.0
    # one writeBlocking call, writing clamped back to the tag that fired

Prove it at the terminal: enter 125 with the recipe at 100 and ±10, and the tag settles at 110.0 after one extra event; enter 105 and no write happens, because 90.0 ≤ 105.0 ≤ 110.0. Close every client and repeat — identical behavior with no client open is the point of the gateway scope.

Which corrected value should the script write back? #

The clamp: write the nearest in-band value, so an entry of 125 against a 90–110 band writes back 110, needs no stored state, and ends the loop in the same single extra event as every alternative.

Correction Value written State to keep Operator sees
Clamp to the band edge 125 entered → 110 none entry lands at the limit
Revert to last good last accepted value one memory per setpoint entry snaps back
Revert to recipe recipe value none entry snaps to the recipe

All three end the loop, because each writes a value inside the band. Default to the clamp: the operator keeps the nearest legal number and the script stays stateless. Switch to revert-to-recipe only where the quality system wants every rejection to return the process to the documented value rather than to a number nobody entered.

How long is the process exposed to a bad setpoint? #

Roughly one tag poll plus two network transits and a controller scan: with the 500 ms default poll, an illustrative 10 ms each way on the link and a 20 ms scan, the correction lands about 540 ms after the operator's write.

500 ms + 10 ms + 20 ms + 10 ms = 540 ms, and only the 500 ms is a documented default — the network and scan figures are example inputs, so measure yours. The sequence is: the terminal writes, the controller acts at its next scan, the gateway sees the change at the next poll, the script writes back, the controller receives the correction. For that whole window the loop runs on the bad setpoint, and if the SCADA server or the network is down, the window has no end at all. A slow thermal mass or a display-only value tolerates that. A press or handling axis that can bend tooling or scrap product inside it does not, and that is the line the next section draws.

Which setpoints need the band check inside the PLC? #

The ones that can act harmfully inside the exposure window — on an aluminum extrusion line, that means the handling and press axes, while heater zones with minutes of thermal lag stay fine under the gateway script.

The move does not touch the terminal program. The terminal keeps writing the tag it always wrote; treat that tag as an entry tag and validate it in the controller. Name the tags for the pattern: Entry_SP is what the terminal writes, Recipe_SP, Dev_Min and Dev_Max are what the SCADA writes from the recipe database, and Active_SP is what the control logic reads. The copy logic moves Entry_SP to Active_SP only when Dev_Min ≤ Entry_SP − Recipe_SP ≤ Dev_Max. If the SCADA link drops, the controller keeps enforcing the last limits written instead of losing them — the whole argument for this placement. Two obligations come with it: repoint the control logic from the old terminal tag to Active_SP, and test that as the PLC change it is. A deviation band is process control, not a safety function; personnel protection stays in the controller's safety-rated logic regardless of where the band lives.

How do you build the enforcement step by step? #

Eight steps: put the limits in SQL, load them with a named query, run the check in a Gateway Tag Change script with a timer sweep behind it, split the placement by axis, then prove the chain with an out-of-band entry at the terminal.

  1. Add devMin and devMax columns to the recipe table, one row per setpoint, keyed by recipe ID and tag path.
  2. Retrieve the active recipe as a dataset with a named query that takes the recipe ID, so recipe values and limits index the same rows.
  3. Create the Gateway Tag Change script, list every setpoint tag path in it, and accept the default poll rate unless those tags already update faster.
  4. Inside the script, key the limits by tag path, compute the band, and clamp newValue into it with a single writeBlocking call, as in the example above.
  5. Add a Gateway Timer script that re-validates every setpoint every 5 s, closing the restart gap and the between-polls gap.
  6. Split the placement: heater and other slow loops keep steps 3–5; handling and press axes get the Entry_SP, Recipe_SP, Dev_Min, Dev_Max and Active_SP pattern in the controller.
  7. Repoint the affected control logic to Active_SP and test that change offline first.
  8. Prove the whole chain against the real controller, the way testing HMI simulation against a live PLC works through it: enter 125 with every client closed, then again after a gateway restart, and confirm the working setpoint never leaves the band.

Questions asked

How do you record who changed a setpoint?

Add an insert to an audit table inside the same gateway script: timestamp, tag path, entered value, corrected value, and the user if the terminal's login reaches the database. With PLC enforcement, log changes of Active_SP instead, which records only accepted values, and log rejected Entry_SP attempts from the gateway while the link is up.

What stops enforcing when the SCADA link goes down?

With gateway-only enforcement, everything: the tag change script, the timer sweep and the write-back all stop, so an out-of-band value runs until the link returns. With the entry-tag pattern in the PLC, the controller keeps enforcing the last limits Ignition wrote, because the check no longer depends on the gateway being reachable.

Why not put the limits in the operator terminal program?

Because the deviations vary per setpoint and can change after commissioning. Entry limits inside the terminal are constants in that program, so every limit change means editing and re-downloading terminal projects. Limits held in the recipe table reach both the gateway script and the PLC-supplied Dev_Min and Dev_Max without touching the terminal.

Should the deviations be stored as percentages?

No, store engineering units per setpoint row. A ±10 percent band widens with the recipe value — ±10 at a recipe of 100 but ±40 at 400 — while the process tolerance is usually a fixed number of degrees or units. Fixed devMin and devMax columns keep the band equal to what the process actually tolerates.

Keep reading

  • Explainer

    What WinCC Does in an HMI and SCADA System

    WinCC is Siemens' visualization and supervisory software: it draws operator screens, shows live controller values, manages alarms, logs history and sends operator requests to the PLC. It does not execute machine logic. The controller keeps permissives and protection, so every WinCC button is a request the PLC is free to refuse.

    HMI and touchscreens

  • Selection guide

    How to Select Lightweight HMI Software for Modbus I/O Control

    Select on three gates in order: a driver that speaks Modbus RTU (and Modbus TCP if the LAN path is required), a tag license at least 20 percent above your counted total, and a runtime that runs the exported project on a clean PC. A 56-device floor plan counts 154 tags, so a 150-tag edition already fails. Prove one floor plan, one popup, one live indicator and one write before you pay.

    HMI and touchscreens

  • Explainer

    Can an HMI Script Count PLC Bit Changes Reliably

    Yes, but only as an approximate, non-critical count. A runtime script sees the tag at discrete reads, so a bit that turns on and off between reads is missed; reported field experience treats signals held 2 s per state as reliable and anything below 500 ms as unusable. Any count that matters belongs in the PLC, displayed on the HMI.

    HMI and touchscreens