InTouch QuickScript Best Practices: PLC Control vs HMI Logic

Karen Mitchell15 min read
Best PracticesHMI / SCADAWonderware
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

InTouch QuickScript Best Practices: PLC Control vs HMI Logic

In a typical municipal water distribution system, ten well pump stations and three elevated storage tanks report to a central InTouch HMI over a fiber backbone using Allen-Bradley ControlLogix or CompactLogix PLCs. Once operators get comfortable with the HMI, the natural follow-up question becomes: "Can InTouch scripts just run the pumps for us?" The architectural answer is almost always no, and the operational reasons for that answer are the subject of this reference.

This document covers the InTouch built-in scripting language (QuickScript), its execution categories per the AVEVA InTouch HMI documentation, the role of DAServer Manager (DASABCIP) in bridging EtherNet/IP devices, and the field-proven pattern of keeping deterministic control in the PLC while reserving InTouch for supervision, alarming, and setpoint adjustments. The intended audience is control engineers commissioning a Wonderware / AVEVA InTouch application that is migrating from a legacy SCADA radio network to a fiber IP infrastructure.

1. Architectural Principle: Why Control Belongs in the PLC

An InTouch View application is, by design, a supervisory layer. It is built on top of Windows and is subject to operating-system patching, anti-virus scans, user logon events, screen-saver interactions, GDI resource exhaustion, and unplanned power cycles on the HMI station. None of those events are acceptable triggers for a pump to stop or a tank to overflow. The PLC, by contrast, scans deterministically in the 5–50 ms range, retains its logic across HMI outages, and continues to enforce interlocks regardless of what the supervisory computer is doing.

Rule of thumb: If a failure of the HMI station must not stop the process, the control logic for that process must live in the PLC. InTouch is the window into the process, not the brain of the process.

For a water well station, the failure modes that demand PLC-resident control include:

  • Loss of the supervisory Ethernet link to the HMI.
  • HMI application crash, ViewApp stop, or Windows reboot.
  • Loss of the DASABCIP tunnel (DAServer host reboot, port-blocked firewall).
  • Operator workstation locked for shift change.
  • Anti-virus quarantine of a WindowViewer executable.

A well pump controlled from an InTouch script that calls PLC.PumpStart = 1; on a tag from a DASABCIP topic will latch off the moment the tag subscription times out — usually after 5 to 15 seconds depending on the Update Interval and Keep Alive settings. The pump either stops unexpectedly or, worse, the script's last write is held by the PLC's output-coil-retentive behavior and the well cannot be remotely shut down during an emergency.

2. InTouch QuickScript Fundamentals

QuickScript is the C-like interpreted language embedded in WindowMaker / WindowViewer. It supports local variables, tag references, mathematical operators, conditional branching, looping, and built-in functions for tag I/O, string manipulation, math, and file access. According to the AVEVA script language reference, every script is compiled at edit time and stored in the application database; at runtime, scripts execute in the InTouch process under the WindowViewer thread.

2.1 Script Type Categories

The AVEVA InTouch documentation on script types identifies the categories summarized in the table below. Each category is triggered by a specific event in the runtime engine.

Script Type Trigger Typical Use Execution Period
Application WindowViewer startup / shutdown Initialize tags, restore setpoints, log session start Once per ViewApp start and stop
Window Window open or close event Populate screen-specific values, lock operator fields Once per transition
Key Operator presses a configured key Navigate screens, acknowledge alarms Sub-millisecond, blocking the UI thread
Touch Pushbutton (Mouse Down / Up / While Down) Operator presses a button on a screen object Manual pump start, setpoint entry Per event; "While Down" repeats at scan rate
Data Change Any tag listed in the script's condition changes value Generate derived tags, debounce noisy inputs On change, asynchronous to scan
Condition (Periodic) Fixed time interval set in script properties Calculations, totalizer accumulation, watchdogs Configurable from 0.1 s to minutes
ActiveX / .NET Control Method External control invokes a method Bridge to third-party ActiveX widgets Event-driven
QuickFunction Call from another script Reusable subroutines Call-time only

Note the absence of a "guaranteed periodic at scan time" category. The closest is the Condition script with a fixed interval, but the interval is measured by Windows messages and can be delayed by a busy UI thread. This is the first of several reasons not to use InTouch as a real-time controller.

2.2 Built-in Functions Used in Water SCADA

Function Syntax Purpose
TagRead TagRead(TagName) Read a memory or I/O tag value as a variant
TagWrite TagWrite(TagName, value) Force a tag value (subject to access security)
GetTag GetTag(TagName, &retValue) Read a tag by reference, returns success boolean
SetTag SetTag(TagName, value) Write a tag value, returns success boolean
GetTime GetTime(Format, TimeString) Format $Date, $Time, $DateTime
SQLConnect / SQLInsert / SQLSelect ODBC-based Write historical events to SQL Server
WWControl WWControl(Action, WindowName) Open / close / maximize a window
PostLogEvent Logs to InTouch logger Operator audit trail

3. DAServer Manager and the DASABCIP Bridge

For Allen-Bradley ControlLogix, CompactLogix, MicroLogix, and PLC-5 controllers, the standard I/O Server is DASABCIP, an AVEVA (formerly Wonderware) suite component that speaks EtherNet/IP and CIP to the PLC. It runs as a Windows service named ArchestrA.DASABCIP.3 on either the HMI station or a dedicated terminal server.

3.1 Communication Topology

The data flow for a single well site is:

ControlLogix PLC CIP / EtherNet/IP DASABCIP ArchestrA Service InTouch ViewApp WindowViewer DAServer Manager (MMC) configures topic

3.2 Required Topic Configuration

Each PLC appears as a topic in DAServer Manager. A typical well-site topic uses the parameters below.

Parameter Recommended Value Notes
Topic Name WELL_nn_LGX Matches PLC tag prefix
Bridge / Server DASABCIP Default for EtherNet/IP
Node / Host 10.40.12.51 etc. Static IP per well
Path 1,0 (backplane, slot 0) For Logix Designer EN2T module
Update Interval 500 ms Matches scan class typical
Keep Alive Timeout 3000 ms Fails fast on link loss
Read/Write Permission Read/Write for control tags, Read-only for telemetry Defense in depth
Slot / CPU Type 1756-L85E (ControlLogix), 5069-L320ERM (CompactLogix) Drives the CIP object library

3.3 Tag Import into InTouch

Tags are bulk-imported via Tagname Dictionary → Import → DAServer or through DBDump / DBLoad for batch deployment. The naming convention Well01.Level, Well01.PumpRun, Well01.PumpCmd, Well01.Fault is preferable to flat names so that QuickScripts can build loops with Well + integer index.

4. Why InTouch Scripts Must Not Run Closed-Loop Control

There are six classes of reasons; each is detailed below.

4.1 Single Point of Failure

Unlike the PLC, the HMI is not redundant in most small municipal installations. A hard-drive failure, Windows update that requires a reboot, or a domain policy that forces a logoff will take the entire InTouch application offline. During that window, an InTouch-based control loop is dead, whereas a PLC scan continues.

4.2 Non-Deterministic Execution

InTouch Condition scripts run on Windows messages. Under CPU pressure, scan rates of 250 ms can stretch to several seconds. PLC PID loops execute in the controller's deterministic scan.

4.3 Data-Quality Blinding

If a tank level transmitter fails, the PLC can hold the last good value, ramp to a safe state, or alarm. An InTouch script may interpret the bad quality as a real zero and command a pump to start, dry-cycling the well.

4.4 Audit and Forensic Limitations

PLC tag changes are recorded in the controller's audit log. InTouch QuickScript writes through a Windows service and are difficult to correlate to the operator who initiated them, especially when user accounts are shared.

4.5 No Onboard Redundancy

AVEVA System Platform and InTouch redundant pairs are expensive and not common in water/wastewater. PLC redundancy (e.g., ControlLogix Hot Backup) is a mature, cheaper option for the same well.

4.6 Regulatory and Operator Acceptance

Many state primacy agencies (for example, TCEQ in Texas, TCEQ-equivalents elsewhere) expect critical processes to operate under PLC control, with the SCADA acting as a thin operator interface. Skipping the PLC in favor of HMI scripting complicates compliance audits.

5. Reference Architecture for a 10-Well, 3-Tank System

The figure below is a recommended topology. The InTouch station only writes setpoints, mode selections, and acknowledgments. Every start / stop / interlock lives in the PLC ladder or structured text routine.

Well 1–10 PLCs Tank 1–3 PLCs L3 Managed Fiber Ring IGMP snooping, QoS DASABCIP Service InTouch ViewApp Allowed InTouch writes: Setpoint, Mode (Auto/Manual/Off), Ack, Reset PLC-owned: Start/Stop, Interlocks, Lead/Lag, Alternation, Dry-Run, Overpressure InTouch monitors: Level, Flow, Pressure, Runtime, KWh, Last-Start timestamp

5.1 PLC Tag Conventions

Tag Prefix Direction Owner Example
Well_nn.Lvl_FT In PLC Analog 0–100 % from level transducer
Well_nn.Lvl_Q In PLC CIP quality bit, 0 = Good
Well_nn.Pump_Run In PLC True when motor contactor is closed
Well_nn.Pump_Cmd Out PLC latches from HMI setpoint Operator-driven, no direct start
Well_nn.SP_Fill Out (HMI→PLC) HMI Target tank level percent
Well_nn.Mode Out (HMI→PLC) HMI 0 = Off, 1 = Auto, 2 = Manual
Well_nn.Fault In PLC Bit-packed: over-temp, dry-run, seal leak
Well_nn.Runtime_Hr In PLC Totalized in PLC, not InTouch

5.2 Sample PLC Structured-Text Rung (ControlLogix)

// Rung: Well 1 Auto-Fill Logic
// Inputs:  Well01.Lvl_FT (REAL), Well01.Mode (DINT), Well01.SP_Fill (REAL)
// Outputs: Well01.Pump_Cmd (BOOL)

IF Well01.Mode = 1 AND               // Mode == Auto
   Well01.Lvl_Q   = 0 AND            // Level signal quality good
   Well01.Fault.0 = 0 AND            // No dry-run trip
   Well01.Permissive_OK THEN BEGIN
   IF Well01.Lvl_FT < (Well01.SP_Fill - 1.5) THEN
       Well01.Pump_Cmd := 1;         // Run
   ELSIF Well01.Lvl_FT > (Well01.SP_Fill + 0.5) THEN
       Well01.Pump_Cmd := 0;         // Stop on hysteresis
   END_IF;
END_IF;

The InTouch side only writes the setpoint and mode. The PLC owns every transition.

6. Allowed InTouch QuickScript Patterns

QuickScript is the right tool for several supervisory tasks. Examples below assume a tagname dictionary with the prefixes from §5.1.

6.1 Application Script: Initialize Setpoints at ViewApp Start

// Application Script — runs once when WindowViewer starts
INT i;
FOR i = 1 TO 10 DO
    IF Well0{i}.SP_Fill < 20.0 OR Well0{i}.SP_Fill > 95.0 THEN
        Well0{i}.SP_Fill := 75.0;    // Safe default
    END_IF;
    Well0{i}.Mode := 1;              // Default to Auto
END_FOR;
PostLogEvent("Startup: Setpoints validated", 0);

6.2 Condition Script: Tank Level Aggregation

// Periodic: every 5 s — compute average tank level for header display
REAL total, avg;
INT i;
total := 0.0;
FOR i = 1 TO 3 DO
    total := total + Tank0{i}.Lvl_FT;
END_FOR;
avg := total / 3.0;
Plant.AvgTankLevel := avg;
Plant.Trend_LastUpdate := $DateTime;

6.3 Data Change Script: Pump-Start Audit Trail

// Trigger: any Well_nn.Pump_Run transition
// Body (executed on rising or falling edge via discrete tags):
STRING s;
s = Well01.Name + " pump " + 
    IIF(Well01.Pump_Run, "STARTED at ", "STOPPED at ") + 
    GetTime("hh:mm:ss", s);
PostLogEvent(s, IIF(Well01.Pump_Run, 1, 0));
SQLConnect("DSN=Historian", "user", "pwd");
SQLInsert("EventLog", "Source,Event,TimeStamp",
          "Well01", s, $DateTime);
SQLDisconnect();

6.4 Touch Pushbutton: Operator Setpoint Entry

// While Down on a slider object — write setpoint with bounds check
REAL sp;
sp = Well01.SP_Fill_Slider;
IF sp >= 25.0 AND sp <= 95.0 THEN
    SetTag("Well01.SP_Fill", sp);
ELSE
    Show "Setpoint_OutOfRange";
END_IF;

6.5 What Should Never Be a QuickScript

Anti-Pattern Risk Correct Location
SetTag("Pump_Cmd", 1) in a periodic script Pump runs while HMI scans; stops on ViewApp crash PLC seal-in circuit
Lead/lag alternation in a Condition script Drift between two operators' stations PLC tag Lead_Lag_State
PID loop in QuickScript Non-deterministic, no bumpless transfer PLC PIDE / PI instruction
Flow totalization in QuickScript Lost on script abort, no power-fail retention PLC totalizer tag
Alarm suppression in QuickScript May silently mask a real fault PLC tag + alarm routing

7. Migration from SCADA Radio to Fiber

When a system migrates from a licensed-radio SCADA network to a private fiber ring, the supervisory stack changes substantially even though the field I/O is unchanged.

7.1 Differences in Latency and Reliability

Attribute Legacy Radio SCADA Private Fiber Ring
Typical scan latency 1–8 s (poll-based) 50–500 ms (EtherNet/IP)
Bandwidth 9.6–19.2 kbps 100 Mbps–1 Gbps
Determinism Low, dependent on terrain High, switch-managed QoS
CIP routing Not supported (Modbus/RTU typical) Native EtherNet/IP
Power budget Site runs on solar / battery Often PoE from cabinet
Cabling distance Up to 30 miles line of sight 2 km multimode, 10–80 km singlemode

Once the migration is complete, the historical justification for "control from the SCADA host" disappears, because the deterministic control now sits on a real-time Ethernet fabric. The PLC is the right place to run logic whether the HMI link is radio or fiber.

7.2 IP Addressing and VLAN Plan

A minimal but field-proven scheme for 10 wells and 3 tanks:

Subnet VLAN Use
10.40.12.0/24 12 Well PLCs (.51–.60)
10.40.13.0/24 13 Tank PLCs (.51–.53)
10.40.14.0/24 14 DAServer and InTouch station
10.40.15.0/24 15 Historian, Alarm Logger, time server (NTP)

Inter-VLAN routing is restricted to the SCADA HMI host; wells cannot talk to each other or to the office network. IGMP snooping is enabled on the ring to keep multicast CIP traffic off access ports.

7.3 Time Synchronization

Set the PLC and HMI clocks from a single NTP source (e.g., a GPS-disciplined Meinberg or the Wonderware Time Sync service). Event correlation across the 10 wells is impossible without sub-second time alignment.

8. Failure-Mode and Effects Summary

Failure PLC-Owned Control InTouch-Scripted Control
HMI PC power loss Control continues; alarms queued in PLC All controlled devices freeze at last state
DASABCIP service crash Control continues; HMI shows "Comm Loss" All writes stop, devices may lock on last coil
View application stops for edit No impact on field All control suspended
Windows update reboot No impact on field All control suspended
Bad level transmitter PLC alarm, hold-last-value, optional safe-shutdown Script may interpret bad quality as 0 % and start pump
Operator logs off PLC continues; HMI requires re-login All scripts tied to user name may pause
Two operators on different workstations PLC has single source of truth Scripts may fight; no arbiter

9. Verification Procedure After Configuration

  1. Open DAServer Manager; verify each topic is Running and shows a green CIP connection status. The Last Error field should be empty.
  2. From Logix Designer, set a test bit in a tag and confirm WindowViewer reflects the change within one scan class (default 250–500 ms).
  3. From the HMI, change Well01.SP_Fill from 50 to 60. The PLC should accept the value and the rung above should respond within one PLC scan.
  4. Disable the HMI's WindowViewer process (End Task). Confirm the well continues to run in Auto mode based on PLC setpoint.
  5. Stop the ArchestrA.DASABCIP.3 service. Confirm PLC continues to control; HMI shows "Comm Loss" alarm.
  6. Re-enable both. Confirm tags resubscribe without operator intervention.
  7. Pull the fiber SFP on the well. Confirm the PLC falls back to its local control rules (lead/lag alternation paused) and the HMI shows a fiber-fault alarm within the keep-alive timeout (≤ 3 s).

10. Common InTouch Scripting Pitfalls

  • Forgetting the comma in SetTag arguments. SetTag("X", 1) is correct; SetTag("X" 1) silently fails.
  • Using {i} outside of a name that supports it. String substitution only works in tagname literals, not in memory tag references.
  • Writing to read-only access tags. Configure tag access in InTouch's Access Name security; otherwise, the script will fail at runtime with no log line.
  • Running heavy logic in a Key script. Key scripts block the UI; move long calculations to a Condition script.
  • Assuming $Second increments at exactly 1 Hz. It can skip under CPU load; use GetTime with a DateTime string instead.
  • Not accounting for tag quality. Always check Tagname.Q (or the equivalent PLC-published quality tag) before using a value in a write-back decision.

11. Further AVEVA Learning Resources

For engineers ramping up on the language itself, AVEVA offers the InTouch Scripting Introduction (Rev B) eLearning course on the AVEVA Learning Academy. It is a 1-hour 45-minute module that walks through the script editor, condition scripts, and data-change scripts, with hands-on exercises in the InTouch emulator.

12. Field-Proven Recommendations

  1. Place the start/stop seal-in, lead/lag, dry-run, overpressure, and runtime totalization in the PLC. Period.
  2. Use InTouch QuickScript for: trending, setpoint entry, mode selection, alarm acknowledgement, batched log events, and operator-driven reporting.
  3. Use PLC-produced tags as the single source of truth; never let two InTouch stations write the same output tag.
  4. Configure DASABCIP keep-alive timeouts at 3 s or less for fail-fast behavior on fiber breaks.
  5. Document the architectural decision in the project's Functional Specification so the next commissioning engineer does not reintroduce the anti-pattern.

The InTouch built-in scripting language is powerful for supervisory, advisory, and operator-interface functions. The PLC is the engine of the process. Treat them accordingly, and the migration from radio to fiber becomes a one-time exercise rather than a recurring fire.

FAQ

Can InTouch QuickScript run PID loops for a water well?

Technically yes, but it should not. InTouch Condition scripts run on Windows messages with non-deterministic intervals (250 ms to seconds under load), and PID is the canonical example of a control loop that must execute in a deterministic PLC scan. Use the ControlLogix PIDE or CompactLogix PI instruction and let InTouch only change the setpoint (SP) and remote setpoint tracking bits.

What is the role of DASABCIP in a Wonderware-to-Allen-Bradley system?

DASABCIP is the AVEVA / Wonderware I/O Server that bridges EtherNet/IP (CIP) traffic between an InTouch ViewApp and Allen-Bradley ControlLogix, CompactLogix, MicroLogix, and PLC-5 controllers. It runs as the ArchestrA.DASABCIP.3 Windows service and is configured per PLC topic in DAServer Manager; recommended update interval is 500 ms and keep-alive timeout is 3000 ms for fail-fast behavior on fiber breaks.

Why does the documentation distinguish Application, Window, Key, Touch, Data Change, and Condition scripts?

The AVEVA InTouch script-type reference classifies scripts by their trigger — start/stop, screen open/close, key press, button press, tag-value change, or fixed periodic interval. Choosing the correct category keeps logic off the UI thread and avoids starving other scripts of CPU time.

If the HMI crashes, what happens to PLC control of the wells?

Nothing, provided the control logic lives in the PLC and not in QuickScript. The PLC continues scanning at its configured rate, the seal-in circuits hold the last commanded state, and the HMI's next start will simply re-subscribe to the existing tags. The InTouch alarms will queue on the HMI side and surface when WindowViewer is back online.

How do I migrate from a radio SCADA to a fiber ring without rewriting all my control?

Keep the PLC program untouched and replace the radio modem with a managed Ethernet switch and a fiber uplink. The PLC's EtherNet/IP module (1756-EN2T, 1756-EN3TR, or 5069-EN2TR for CompactLogix) talks to the new ring exactly as it did on copper. Update the DASABCIP topic in DAServer Manager with the new static IP and the new EN2T path (typically 1,0 for backplane, slot 0). InTouch scripts that read from the existing tag names continue to work without code changes.

Back to blog