Wonderware InTouch Left Key Down Script: Permissive Logic
When building a motor start permissive on an HMI, AVEVA (formerly Wonderware) InTouch provides several mouse and keystroke event triggers. The On Left Key Down and While Left Key Down actions fire on button press, while On Left Click fires on release. For interlock checks such as pressure must be less than or equal to 10 and fault count must equal zero before the operator can start the motor, QuickScript is wired to the button's action property. This reference covers the script syntax, event trigger selection, Modbus tag configuration, and the architectural decision of whether to place permissive logic in the PLC or the HMI.
1. Overview of the Permissive Pattern
A motor start permissive is a guard condition that must evaluate true before the HMI releases the start command downstream to the controller. The most common permissive fields are:
- Process variable confirmation (pressure, temperature, level, flow)
- Fault aggregation (no active faults, drive ready bit, E-stop clear)
- Mode selection (Remote/Local, Auto/Manual, In Remote)
- Operator authentication (key-switch, user level, two-step confirm)
When the source data arrives over Modbus/TCP into InTouch IO tags, the HMI becomes the natural place to evaluate the permissive because the PLC tag may not be writable from the operator console. When the data is backplane-routed from a ControlLogix, CompactLogix, or PLC tag server, the permissive is best evaluated in the PLC and surfaced to the HMI as a single permissive_ok tag.
2. Prerequisites
| Item | Detail |
|---|---|
| Software | AVEVA InTouch 2014 / 2017 / 2020 / 2023 with WindowMaker |
| Runtime | WindowViewer on the operator station |
| License | Development license for WindowMaker; runtime for WindowViewer |
| Data source | Modbus/TCP PLC, Modbus/RTU bridge, or DAServer via SuiteLink |
| Configured Access Name | Linked to a running DAServer topic or ArchestrA galaxy attribute |
| IO tags |
pressure (real/float), faults (integer), start_cmd (discrete, writable) |
| Window | Existing button object on a motor faceplate window |
| Security | InTouch Access Control set for the operator role that can press Start |
3. Event Trigger Comparison: On Left Click vs On Left Key Down vs While Left Key Down
AVEVA InTouch exposes three mouse event triggers on button objects. Choosing the wrong trigger changes when the permissive fires and how often the script re-evaluates while the operator holds the button.
| Trigger | When the script runs | Typical use | Run mode |
|---|---|---|---|
| On Left Click | Once on mouse release | Discrete operator commands (Ack, Stop, Mode toggle) | Edge-triggered (release) |
| On Left Key Down | Once on mouse press (key-down edge) | Start commands, jog-press, one-shot actions | Edge-triggered (press) |
| While Left Key Down | Repeatedly while the key is held | Incremental ramps, jog-while-held, watchdog ticks | Periodic, 1-360000 ms |
According to AVEVA's While Left Key Down / While Key Down reference, the periodic trigger accepts a Frequency parameter expressed in milliseconds with a valid range of 1 to 360000. A typical value for a permissive re-check is 100-500 ms. AVEVA's Configure an action script animation with a mouse-down event guide also clarifies that mouse-down events trigger two separate signals, and the script should be idempotent to handle both safely.
4. Configuring the Button in WindowMaker
- Open WindowMaker and load the window containing the motor faceplate.
- Double-click the Start button to open the Button Properties dialog.
- Switch to the Action tab (or Touch Links / Animations on older builds).
- In the Mouse or Touch/Click section, click the cell next to On Left Key Down (or While Left Key Down for a held check).
- Select QuickScript as the action type and click Edit.
- Paste the permissive script (see Section 5) and click OK.
- Save the window. Run WindowViewer to test.
5. QuickScript Syntax for the Permissive
The original control logic the operator wants is:
If pressure <= 10 AND faults = 0 THEN start = 4
In InTouch QuickScript, the equality comparison is == (double equals), the assignment operator is = (single equals), and logical conjunction is the keyword and. The corrected syntax is:
If pressure <= 10 and faults == 0 then
start = 4;
EndIf;
The trailing semicolon is optional but recommended. The EndIf keyword terminates the block. Whitespace and case (If/if) are flexible, but AVEVA's editor will normalise casing on save.
5.1 Writing to a Modbus Coil or Holding Register
If start is an IO tag pointing at a Modbus holding register, the assignment start = 4; writes the value 4 to that register. To start a motor, a more idiomatic write is to a discrete coil (0 or 1):
If pressure <= 10 and faults == 0 and not motor_running then
start_cmd = 1;
EndIf;
For a one-shot pulse (rising edge, auto-reset), use the InTouch ! operator or a memory discrete tag:
If pressure <= 10 and faults == 0 then
start_pulse = 1;
EndIf;
Reset the pulse on the next scan or after a Wait timer.
5.2 Adding Operator Feedback (Disable Animation)
To make the button visibly disabled when the permissive fails, wire a Disable animation on the same button object:
- Select the button, choose Animation Links > Disable.
- Set the expression to
pressure > 10 or faults != 0. - Enable the Disable color override (typically gray fill).
The button is now grayed out when the permissive fails, providing a visual cue that the operator should not press it.
5.3 Full Example with Logging
{ This script runs on On Left Key Down of the Start button }
If pressure <= 10 and faults == 0 then
start_cmd = 1;
last_start_reason = "OK";
Else
If pressure > 10 then
last_start_reason = "BLOCKED: High Pressure";
EndIf;
If faults != 0 then
last_start_reason = "BLOCKED: Active Faults";
EndIf;
EndIf;
6. Reading Modbus Data into InTouch
When the source data is a Modbus slave (PLC or remote RTU), configure an Access Name in the InTouch Access Names dialog:
| Field | Value (example) |
|---|---|
| Node Name | MODBUS_PLC |
| Application Name | DASMBTCP |
| Topic Name | PLC_A |
| Update Interval | 0.5 s |
| Keep Alive | Enabled |
The IO tag definitions then reference the Access Name and the Modbus address:
| Tag name | Type | Access Name | Item (Modbus address) |
|---|---|---|---|
| pressure | Real | MODBUS_PLC | 40001 (HR1) |
| faults | Integer | MODBUS_PLC | 40010 (HR10) |
| motor_running | Discrete | MODBUS_PLC | 00005 (Coil 5) |
| start_cmd | Discrete | MODBUS_PLC | 00001 (Coil 1) |
The DAServer (such as DASMBTCP for Modbus/TCP or DASMBRTU for Modbus/RTU) polls the device at the configured rate and publishes updates to InTouch via SuiteLink. Writes from QuickScript propagate back to the slave through the same channel.
7. PLC vs HMI Permissive Logic
The trade-off between placing interlock logic in the PLC and evaluating it in the HMI is one of the recurring questions in supervisory control design.
| Criterion | PLC | HMI (InTouch) |
|---|---|---|
| Determinism | Hard real-time, scan-based | Best-effort, OS-scheduled |
| Survives HMI restart | Yes - interlock remains active | No - operator must re-press |
| Network outage | Continues to interlock locally | Stale data risk; button may stay enabled |
| Operator override | Requires engineering change or force in PLC | Direct script edit by developer |
| Audit trail | PLC audit log, sequence of events | HMI alarm log, script trace |
| Write security | Full controller security model | Subject to InTouch security model |
| Multi-station consistency | One source of truth | Each HMI evaluates independently |
Recommendation: Place safety-critical and process-critical interlocks in the PLC. Reserve HMI permissives for operator ergonomics - hiding the start button when not in remote, disabling the button when a known fault is active, or requiring a two-step confirm for high-energy equipment. For SIL-rated functions, follow IEC 61511 and keep the safety loop in the safety PLC; do not rely on the supervisory HMI for safety.
8. Verification and Testing
-
Tag Watcher. Open the DbDump or Tag Viewer in WindowViewer. Verify
pressure,faults, andstart_cmdare updating at the expected scan rate. -
Permissive positive path. Force
pressure = 8.0andfaults = 0in the Watcher. Click the Start button. Confirm the value4is written to thestarttag and the slave device receives the write. -
Permissive negative path. Force
pressure = 12.0. The script'sIfcondition is false; no write should occur. Confirm via the Watcher and the slave's diagnostic page. -
Animation verification. The button should be enabled (normal color) when the permissive is true and disabled (gray) when the permissive is false. Toggle
faultsbetween 0 and 1 to confirm the visual state flips. -
Event log. If the script writes to
last_start_reason, view the value in the Watcher to confirm the correct branch is being taken. -
Network loss test. Disconnect the PLC network cable. The InTouch tag should mark
$AccessFaultfor the Access Name; the button should be disabled and the script should not fire on click.
9. Troubleshooting Matrix
| Symptom | Likely cause | Corrective action |
|---|---|---|
| Button does nothing when pressed | Script not saved; WindowViewer cached old window | Save window, close and reopen in WindowViewer; restart the view process |
| Script runs but no write reaches the PLC | Tag is read-only or Access Name is one-way | Open tag definition, set Read/Write; verify DAServer is running and topic is started |
Condition faults == 0 is always false |
Tag is an integer holding a bit-packed word; only bit 0 is the actual fault | Use faults_bit0 == 0 or map the bit to a discrete tag |
Script editor shows red squiggles under ==
|
Old QuickScript (pre-7.0) used EQ or single =
|
Confirm InTouch version; QuickScript 7.x and later use == for comparison |
| Permissive sticks after a brief fault clears | No one-shot edge; script re-evaluates on every click but the operator must release and re-press | Add a one-shot rising-edge memory tag to latch the start command |
| While Left Key Down runs too fast or too slow | Frequency parameter not tuned | Set Frequency to 100-500 ms for typical permissive checks; 1-10 ms only for continuous jog |
| Button enabled in editor, disabled at runtime | Disable animation expression evaluates false | Verify the expression in the Animation Links dialog; test with Tag Viewer forcing values |
| Stale pressure value, permissive evaluates as OK | Modbus polling paused; $AccessFault is not being checked |
Add and not $AccessFault to the If condition; or surface PLC health into a tag and include it in the check |
| Operator can press button but no motor response | Write going to wrong address, or write blocked by PLC security | Verify Item field in the tag definition matches the target Modbus address; check PLC write privilege |
10. Operational and Migration Notes
- Avoid placing permissives on the HMI in SIL 2 / SIL 3 paths. Use a safety PLC and a dedicated safety I/O loop for those functions.
- Use QuickScript > Conditional scripts for one-time events, Data Change scripts for state-transition triggers, and Active window scripts for window-level behavior.
- When migrating from InTouch 2014 to 2020 R2 or later, scripts that use
EQ,NE,GT,LTmay need rewriting to==,!=,>,<. The legacy operators are deprecated but still parse. - Keep the script body short. Long QuickScripts on On Left Key Down can stall the WindowViewer redraw thread on slow panels.
- Always pair the permissive write with an InTouch alarm that fires when the script blocks the action. This gives the operator a log entry that explains why the start command was suppressed.
11. Frequently Asked Questions
What is the difference between On Left Click and On Left Key Down in InTouch?
On Left Click fires once on mouse release (the click event). On Left Key Down fires once on mouse press (the key-down edge). For motor start commands where you want immediate action, use On Left Key Down; for confirmation dialogs or commands that should ignore a drag-through, use On Left Click.
Why is my equality check always false when I write if faults = 0?
Single equals is the assignment operator in QuickScript, not a comparison. if faults = 0 assigns 0 to faults and the If branch is then evaluated against that new value. Use double equals == for comparison: if faults == 0 then.
How do I make the Start button visibly disabled when the permissive is not met?
Add a Disable animation link to the button. The disable expression is the negation of the permissive: pressure > 10 or faults != 0. Set the Disable color to a gray fill. The button now appears disabled whenever the operator cannot legally start the motor.
Should permissive logic live in the PLC or the HMI?
Safety-critical and process-critical interlocks belong in the PLC because the PLC is deterministic and continues to run during HMI outages. HMI permissives are appropriate for operator ergonomics - disabling buttons when out of mode, hiding commands outside operator scope, or visual feedback. For SIL-rated functions, follow IEC 61511 and keep the safety loop in the safety PLC.
What Frequency should I set on While Left Key Down?
AVEVA's reference allows 1 to 360000 ms. For a permissive re-check tied to a held button, 100-500 ms is a good default - fast enough that the operator feels the response, slow enough to avoid saturating the WindowViewer thread. Use 1-10 ms only for continuous jog commands on motion axes.