Setting S7-1200/1500 PLC RUN/STOP from WinCC Unified HMI

David Krause11 min read
HMI / SCADASiemensTutorial / How-to
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

Overview

Operating state control of a SIMATIC S7-1200 or S7-1500 from a WinCC Unified Comfort Panel (or Unified PC Runtime) became natively supported in TIA Portal V18 Update 2 (V18.0.0.2). Prior to that release, the classic SetPLCMode function used on Comfort Panels (WinCC RT Professional / WinCC Advanced) was not implemented in the Unified HMI runtime, leaving engineers with only indirect options such as the PLC Webserver rendered inside a Web Browser control.

This reference documents the canonical mechanism introduced with V18: a system-defined HMI tag of the form @<ConnectionName>_PLC_OpStateCtrl that accepts discrete numeric values mapped to the SIMATIC operating-mode transitions defined in the S7-1500 system manual (STOP, RUN, startup, restart, reset to factory settings, etc.).

Safety notice: A STOP command issued from the HMI removes the PLC from cyclic program execution. All controlled outputs de-energise per the configured fallback strategy (substitute values). For machines subject to functional safety, gate this HMI command behind an ESPE/UMAC-restricted operator class and a confirmation dialog so unintended stops cannot be triggered by touch misfire.

Prerequisites

Component Required Version / Model Notes
TIA Portal V18.0.0.2 or later (V19, V20 supported) Engineering for both PLC and Unified HMI project
HMI Runtime WinCC Unified V18.0.0.2+ (Comfort Panel firmware or PC RT) Unified Comfort Panels from V18 firmware image
PLC SIMATIC S7-1200 (any current CPU, firmware >= V4.5) or S7-1500 (any current CPU, firmware >= V2.9) ET 200SP CPU also supported via PROFINET
Connection HMI tag connection of type S7-1500 (Unified channel) Use the integrated PROFINET interface, not legacy S7-300/400 channel
PLC protection UMAC / access level configured so the HMI connection is permitted to write to system data Full access (no password) or a known HMI password must be assigned on the PLC

Operating-State Tag Reference

The HMI project tree automatically exposes the following system tags once an S7-1500/1200 connection is configured. The @ prefix denotes a system-managed tag (not editable, address managed by the runtime). Replace <ConnectionName> with the exact HMI connection name from Devices & Networks > HMI connection > Properties > General.

HMI System Tag Direction Data Type Purpose
@<ConnectionName>_PLC_OpState Read INT Current PLC operating state (mirrors the CPU display LEDs)
@<ConnectionName>_PLC_OpStateCtrl Write INT Control word to request a state transition
@<ConnectionName>_PLC_OpStateLastChange Read DTL / String Timestamp of the last operating-mode change

OpState Read Values (@..._PLC_OpState)

Value Symbolic Constant Meaning
0 UNKNOWN Connection not yet established / status not determined
1 STOP CPU is in STOP mode
2 STARTUP CPU is performing OB100 / startup routine
3 RUN CPU is in cyclic RUN execution
4 HOLD CPU is held by test/debug breakpoint
5 DEFECTIVE CPU has internal fault; communication may be impaired
6 ERROR_SEARCH CPU is performing a diagnostic search
7 RESET_TO_FACTORY Factory reset in progress

OpStateCtrl Write Values (@..._PLC_OpStateCtrl)

Value Command Issued to CPU Equivalent STEP 7 Action
1 Conditional STOP (warm restart cancels) Same as toggling the physical STOP/RUN switch while running
2 Conditional STOP (RUN cancels) Hardware STOP selector position
3 Cancel current transition Abort pending state change
4 Unconditional STOP Equivalent to MRES or selector position STOP; CPU always enters STOP
5 Hot restart (S7-1500 only, where supported)
6 Cold restart
7 Warm restart
8 RUN Equivalent to selector position RUN; CPU starts when in STOP
9 Restart (OB100 then RUN)
10 Reset to factory settings (memory card wipe)
The most common engineering need - RUN from STOP and STOP from RUN - maps to write values 8 and 4 respectively. Use only those two values for operator controls; the others are administrative operations meant for commissioning engineers, not for production operators.

Step-by-Step Configuration

  1. Open the TIA Portal project containing the S7-1200/1500 station and the Unified HMI device. Confirm both devices are configured under the same project and that the HMI-to-PLC connection compiles cleanly.
  2. Verify the connection name. In the project tree, select HMI device > Connections. The default name is the PLC station name (e.g. S7_1500_Station_1). The system tag will use that name verbatim.
  3. Open the HMI tag editor (HMI device > HMI Tags) and use the filter to list only system tags. Confirm both @<ConnectionName>_PLC_OpState and @<ConnectionName>_PLC_OpStateCtrl exist. If they are absent, the engineering environment is below V18.0.0.2 or the connection is not of type S7-1500.
  4. PLC protection setup. In the S7-1500 device configuration, navigate to Properties > Protection & Security > Access level. The HMI connection must have full access (write access to system data is permitted). If a password is configured, ensure the HMI connection supplies that password. The HMI uses the connection password from Devices & Networks > HMI connection > Properties > Connection mechanism.
  5. Create screen controls. On the desired HMI screen, add two buttons: "STOP" and "RUN".
  6. Configure the STOP button event:
    • Event: Press
    • Function: SetValue
    • Tag: @<ConnectionName>_PLC_OpStateCtrl
    • Value: 4
  7. Configure the RUN button event:
    • Event: Press
    • Function: SetValue
    • Tag: @<ConnectionName>_PLC_OpStateCtrl
    • Value: 8
  8. Add an operator-confirmation dialog to each button via the Confirmation property to prevent accidental triggering, especially for the STOP action.
  9. Status visualisation. Add a symbolic IO field or text list bound to @<ConnectionName>_PLC_OpState so operators see the actual current state, not just the request outcome. Map the values 1, 2, 3 to "STOP", "STARTING", "RUN" text entries.
  10. Compile and download the HMI project. Compile the PLC project if the connection was newly created.

JavaScript / Scripted Alternative

For Unified PC Runtime projects that use the scripting interface, the same effect can be achieved in the runtime API. The snippet below uses the TIA Portal WinCC Unified Scripting (V18+) to issue a STOP command:

// Stop the PLC referenced by HMI connection 'PLC_1500'
let conn = HMIRuntime.UI.SysFct.GetTag("@PLC_1500_PLC_OpStateCtrl");
conn.Write(4);  // 4 = unconditional STOP

// Then verify
let state = HMIRuntime.UI.SysFct.GetTag("@PLC_1500_PLC_OpState");
let current = state.Read();
if (current !== 1) {
    HMIRuntime.Trace("STOP command did not latch. Current state: " + current);
}

Wrap such scripts in a user-rights check (UMAC) so only the Maintenance role can execute them.

Verification

  1. Download the HMI configuration to the panel and switch the panel to online operation.
  2. From the HMI, press the STOP button and observe:
    • The PLC STOP LED illuminates within < 2 seconds.
    • The @..._PLC_OpState tag transitions through 3 → 2 → 1 (RUN → STARTUP → STOP). On S7-1500 the transition can be near-instant; on S7-1200 it follows the OB100 startup time if it was started cleanly.
  3. Press RUN. The CPU executes the startup routine (if defined) and reaches state 3.
  4. On the PLC, monitor Online & Diagnostics > Operating mode to confirm the state change originated from the panel.
  5. Force a connection loss (disconnect PROFINET cable) and verify the HMI shows the state as UNKNOWN (0) - this proves the tag is being refreshed and not statically latched.
According to the WinCC Unified V20 documentation, stopping or restarting the PLC does not interrupt the HMI-to-PLC connection (the integrated connection survives a CPU STOP). Only stopping or restarting the HMI Runtime breaks the link. This is a key behavioural difference vs. Comfort Panels where a CPU STOP historically required re-initialisation on some configurations.

Status Display Pattern

Beyond the simple button pair, the recommended operator-screen pattern combines request and feedback:

  • Indicator lamp bound to the current state (RUN = green, STOP = red, STARTING/HOLD = yellow, DEFECTIVE = flashing red).
  • Two push-buttons (RUN, STOP) with operator confirmation.
  • Message in the HMI log triggered by a script that logs every state change with timestamp from @..._PLC_OpStateLastChange and operator user ID.
  • Disable buttons when the connection is lost: bind the Enabled property of both buttons to an animation that compares the connection status tag against 0 (UNKNOWN) so they grey out automatically.

Security and Access Protection

Operating-mode control is a privileged function. Apply layered protection:

  1. PLC side: assign the HMI connection a dedicated password and restrict CPU access so that only the HMI connection can write the system data. In TIA Portal, configure Protection & Security > Access level > Full access (no password) only if no protection is required by your safety case; otherwise issue a connection-specific password.
  2. HMI side: place the RUN/STOP buttons on a screen or in an overlay that is part of the Service or Maintenance UMAC group. Operators in the Operator role should not be able to execute state transitions.
  3. Audit trail: log every write to @..._PLC_OpStateCtrl with operator name and timestamp for GMP/FDA-regulated environments.
  4. Confirmation: the STOP button should always require a two-step confirmation.

Alternatives When V18 Is Not Available

For installations locked on TIA Portal V17 or earlier, the following alternatives deliver equivalent functionality without the native system tag:

Method Implementation Caveats
PLC Webserver inside Web Browser control Enable the S7-1500 Webserver; embed its URL in the Unified screen via the Webbrowser Control; operator uses the webserver buttons for RUN/STOP Two user surfaces; requires browser certificate acceptance; styling does not match the HMI design language
Dedicated PLC bit toggled by SCL Use an SCL routine inside the CPU that, when a flag is set, calls STOP / RTG from the system library Requires custom PLC programming and a handshake protocol; not vendor-supported
External trigger from a secondary controller A separate S7-1200 or third-party PLC writes the op-mode bit over PROFINET Adds hardware; defeats the purpose of having a unified HMI control

The Webserver approach is the most common workaround. To configure it:

  1. In the S7-1500 device configuration, enable Webserver > Activate web server; permit Run/Stop under User management.
  2. In the Unified screen, add a Webbrowser Control element. Set the URL to https://<CPU IP>/.
  3. Authenticate the webserver user inside the embedded browser; subsequent operator clicks use the standard CPU web interface.
When the PLC restarts (STOP → RUN or RUN → STOP → RUN), WinCC Unified Runtime does not drop the connection. This is documented behaviour as of WinCC Unified V20 and means the Webserver-based UI keeps working across state transitions.

Troubleshooting Matrix

Symptom Likely Cause Corrective Action
System tag @..._PLC_OpStateCtrl does not appear in tag editor TIA Portal or HMI firmware below V18.0.0.2 Update TIA Portal to V18 Update 2 or later; re-transfer the panel image to V18 firmware
Write succeeds in tag simulation but HMI shows no effect on the CPU PLC protection denies write access Remove password or assign the connection-specific password under Protection & Security
CPU transitions to RUN then immediately returns to STOP Existing error / OB not loaded / memory reset required Check PLC diagnostic buffer; resolve the underlying fault before retrying
HMI shows state UNKNOWN (0) Connection lost or wrong connection name in tag path Verify PROFINET link, IP address, and that the connection name in the tag matches Devices & Networks
Button click raises no event in trace Operator role lacks permission Add the screen/button to a UMAC group the operator belongs to
CPU STOP and RUN both work, but operator does not see status text update Status IO field bound to a static text instead of value Switch the IO field to Output mode and bind to @..._PLC_OpState with a text list

Compatibility With SetPLCMode (Legacy Comfort)

Engineers migrating from WinCC Comfort / RT Advanced should note that the legacy SetPLCMode function is not available in WinCC Unified runtime. The replacement is the @..._PLC_OpStateCtrl system tag described above. The numeric encoding differs from SetPLCMode:

Action SetPLCMode constant (Comfort) OpStateCtrl value (Unified)
RUN 1 8
STOP 2 4
Hot restart 3 5
Cold restart 4 6

Migrations that lifted Comfort panel logic into Unified must rewrite the constants accordingly.

Field-Commissioning Checklist

  • [ ] TIA Portal >= V18 Update 2 confirmed in the title bar.
  • [ ] HMI firmware image matches the engineering version (V18.0.0.2+).
  • [ ] PLC firmware supports S7-1500 unified channel (any current S7-1200 / S7-1500 firmware).
  • [ ] HMI connection password matches the PLC access-level configuration.
  • [ ] Both system tags @..._PLC_OpState and @..._PLC_OpStateCtrl visible in HMI tag editor.
  • [ ] RUN button writes value 8; STOP button writes value 4.
  • [ ] Confirmation dialog enabled on STOP.
  • [ ] Operator role cannot trigger state change; only Service role can.
  • [ ] Status indicator updates within 2 seconds of PLC transition.
  • [ ] Connection loss test: disconnect cable → state shows UNKNOWN.
  • [ ] Audit log entry recorded for each transition.

Which TIA Portal version first supported PLC RUN/STOP from a Unified HMI?

TIA Portal V18 Update 2 (V18.0.0.2) introduced the @<ConnectionName>_PLC_OpStateCtrl system tag that allows a Unified Comfort Panel to drive the S7-1200/1500 operating mode. Earlier Unified firmware releases did not expose any equivalent of the legacy SetPLCMode function.

What value do I write to put the PLC in RUN, and what to STOP it?

Write 8 to @<ConnectionName>_PLC_OpStateCtrl for RUN and 4 for unconditional STOP. Other values 1, 2, 3, 5, 6, 7, 9, 10 trigger transitional states (warm/cold/hot restart, factory reset) and should be reserved for commissioning engineers.

Does stopping the PLC drop the HMI connection?

No. Per the WinCC Unified V20 documentation, stopping or restarting the PLC does not interrupt the HMI-to-PLC connection; only stopping or restarting the HMI Runtime breaks it. This behaviour simplifies status polling and lets you keep the Webserver-based UI active across transitions.

How do I display the current PLC state on the Unified screen?

Bind a symbolic IO field or text list to @<ConnectionName>_PLC_OpState and map values 1 (STOP), 2 (STARTUP), 3 (RUN), 4 (HOLD), 5 (DEFECTIVE), and 0 (UNKNOWN) to operator-readable text entries. The tag updates whenever the CPU operating mode changes.

What alternatives exist if my TIA Portal is older than V18?

Enable the S7-1500 Webserver and embed it inside a Unified screen via the Webbrowser Control; operators then drive RUN/STOP from the CPU's web UI. This is the most common workaround, though it duplicates the user surface and requires accepting the Webserver certificate on the panel.

Back to blog