KTP900 Basic HMI Activity Timeout Using Screen Number Pointer

David Krause14 min read
HMI ProgrammingSiemensTutorial / 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

Problem Definition and Goal

SIMATIC HMI panels - including the KTP900 Basic - do not expose a single public "screen touched" boolean that engineering code on the controller can read. The runtime internally tracks user activity to dim the backlight, drive the screensaver, and enforce user-administration logoff timers, but those internal values are not published as a system bit or system tag. Consequently, applications that want to "return to the root screen after N minutes of operator inactivity" cannot poll a dedicated signal. The activity must be reconstructed from data the panel does publish.

For the KTP900 Basic driven by TIA Portal V15.1 and WinCC Advanced, the cleanest deterministic signal is the Screen Number area pointer. Word 4 of the 5-word pointer is the current field number - the index of the I/O field, button, or symbolic field that most recently received focus on the active screen. By comparing that word to its previous value inside the PLC, every operator touch (and every screen change) generates a single-cycle edge. A TON timer driven by that edge becomes the inactivity watchdog, and an HMI tag bound to the timer output fires the ActivateScreen event for the root screen.

The procedure below assumes an S7-1200 (or S7-1500) controller on PROFINET, a KTP900 Basic PN panel (article number 6AV2 123-1MB03-0AX0), TIA Portal V15.1 Update 4 or later with WinCC Advanced V15.1, and panel firmware image V15.x. Variations for S7-300/400 controllers, PROFIBUS, or older TIA releases are noted where parameter assignment diverges.

KTP900 Basic Hardware Profile

Parameter Value
Article number (color PN) 6AV2 123-1MB03-0AX0
Display 9 in TFT, 800 x 480, 16 M colors
Touch Analog resistive, 4-wire
Keys None (pure touch)
Interfaces 1 x PROFINET (2-port switch), 1 x USB host
Configuration software WinCC Basic or WinCC Advanced (TIA Portal)
Firmware image recommended V15.1 (matches TIA V15.1 project)
User memory 10 MB
Recipe memory 256 KB integrated, expandable via SD card
Number of screens Up to 100
Tags / area pointers / scripts 2048 / 1000 / not supported on Basic

The "not supported" entry for scripts is the central constraint of this article: a Basic Panel cannot run VBS, C, or JavaScript behind an event, so any inactivity watchdog has to live on the controller side and use the limited public data interface between PLC and HMI.

Why the HMI Has No Native "In-Use" Bit

Three different activity signals exist in WinCC but none of them is a single system bit reachable from the PLC:

  1. Backlight / screensaver timer - configured per panel under Runtime Settings > Screen saver. The value is held internally; it cannot be read out, and it is not propagated to the controller.
  2. User-administration logoff timer - configured per user group. When the timeout elapses, the panel fires an internal "user changed" event and logs the current user out. The new (empty) user name is readable in the User View area pointer, but the timestamp is not. There is also no event that fires before the logoff to give the controller advance warning.
  3. Touch / key event log - logged in the alarm buffer only when explicitly enabled, and not available as a tag for cyclic polling.

The only deterministic, PLC-side read of operator activity is therefore the Screen Number area pointer, which the panel refreshes every acquisition cycle. Because the pointer holds both the screen number and the focused-field number, a single area pointer provides enough information to derive an activity edge.

Screen Number Area Pointer Layout

The Screen Number area pointer occupies five consecutive 16-bit words starting at the configured DB / MW address. The word layout is fixed by WinCC and cannot be reordered:

Word offset Name Meaning
+0 Current screen number Screen currently displayed. Updates only on screen change.
+1 Reserved Always 0. Do not evaluate.
+2 Reserved Always 0. Do not evaluate.
+3 Reserved Always 0. Do not evaluate.
+4 Current field number Field index of the I/O field, button, or symbolic field with current input focus. 0 when no field is selected.

Word 4 changes whenever the operator taps any input-capable element or when a screen change occurs (because the field-number sequence restarts on the new screen). It is therefore a strictly monotonic activity indicator from the controller's perspective: if Word 4 is the same this scan as it was last scan, the operator did nothing in between.

The reserved words (+1/+2/+3) are kept for compatibility with Comfort Panels and WinCC Professional, which do use them. On a KTP900 Basic they remain 0; reading them as if they were status would yield a false-positive "no change" condition and freeze the timer.

Prerequisites and Project Setup

  • TIA Portal V15.1 Update 4 or newer with WinCC Advanced V15.1 installed.
  • S7-1200 firmware V4.2 or newer, or S7-1500 firmware V1.8 or newer. The IEC timers used below (TON, CTU) require at least S7-1200 V4.0.
  • KTP900 Basic PN, article number 6AV2 123-1MB03-0AX0, firmware V15.1. A mismatch between project firmware and panel firmware prevents download.
  • Configured HMI connection in the project tree under HMI > Connections, bound to the S7-1200 PROFINET interface. Without a configured connection the area pointer cannot be assigned.
  • An HMI tag of BOOL type that the controller will set when timeout elapses; the tag's Value Change event must trigger ActivateScreen > RootScreen.
  • A globally unique DB on the controller (e.g. DB_HMI_Activity) with the tags listed in the next section.

HMI and PLC Tag Configuration

Step 1 - Enable the Screen Number area pointer

  1. In the project tree, open HMI_1 [KTP900 Basic] > Connections and double-click the S7-1200 connection.
  2. In the connection editor, switch to Area pointers.
  3. Tick Screen number. The default length is fixed at 5 words; the offset and DB address are user-configurable.
  4. Assign the pointer to DB_HMI_Activity.ScrnPtr, declared as ARRAY[0..4] OF WORD. A separate start address in MW memory works equally well but reduces symbol clarity.

Step 2 - Declare PLC-side tags

Create a globally accessible DB with the following tags. All tags except the pointer are user-defined; the pointer is the area pointer you assigned above.

Tag Data type Initial value Purpose
ScrnPtr ARRAY[0..4] OF WORD - Area pointer (must match Step 1)
OldFieldNo WORD 0 Field number from previous scan
CurrFieldNo WORD 0 Field number from current scan
EdgeActivity BOOL FALSE Single-cycle edge when CurrFieldNo <> OldFieldNo
TON_Inactivity IEC_TIMER / TON - Counts inactivity
TimeoutPreset TIME T#10m Inactivity threshold, editable from HMI
bReturnToRoot BOOL FALSE Set when timeout elapses; clears itself

Step 3 - Create the HMI "GoHome" tag

  1. In HMI Tags, add a new BOOL tag named GoHome connected to DB_HMI_Activity.bReturnToRoot.
  2. Open the tag's Properties > Events and add Value change.
  3. Set the function list to ActivateScreen and choose RootScreen. Only one function can be configured per value-change event on a Basic Panel.
  4. Open Properties > Settings on the same tag and set Acquisition mode to Cyclic continuous with Acquisition cycle = 100 ms. This is the fastest cycle WinCC Advanced allows for an HMI tag and is what guarantees the area pointer refresh matches the controller scan.
The GoHome tag must be cleared (FALSE) again by the controller before the operator can intentionally re-trigger it; the value-change event fires only on a 0->1 transition. The ladder logic below does this with a single reset coil.

Ladder Logic for Activity Timeout

The core of the application is four networks in OB1 (or a cyclic OB of appropriate priority). The example uses IEC timers and a positive-edge flag. Equivalent SCL is shown at the end of the section.

Network 1 - Mirror the pointer and compute the activity edge

// Mirror current field number from area pointer
L     DB_HMI_Activity.ScrnPtr[4]          // Word 4 = current field number
T     DB_HMI_Activity.CurrFieldNo        // Keep for diagnosis

Network 2 - Edge when the field number changes

A(                                      // Compare current vs stored
L     DB_HMI_Activity.ScrnPtr[4]         // Word 4 - current field number
L     DB_HMI_Activity.OldFieldNo         // Word 4 - previous scan value
<>I                                    // TRUE if different
)
FP                                    // Test positive edge
JCN   NOACT                              // Skip the set if no edge

SET
S     DB_HMI_Activity.EdgeActivity       // Single-scan pulse
L     DB_HMI_Activity.ScrnPtr[4]
T     DB_HMI_Activity.OldFieldNo         // Update stored value
JU    END1

NOACT:                                  // No edge this scan
CLR
=     DB_HMI_Activity.EdgeActivity       // Keep coil FALSE

END1: NOP 0

Network 3 - TON watchdog with auto-reset on activity

// Reset the timer on every activity edge
A     DB_HMI_Activity.EdgeActivity
R     DB_HMI_Activity.TON_Inactivity      // Reset IEC timer instance

// Drive the timer continuously
A     TRUE
L     DB_HMI_Activity.TimeoutPreset       // E.g. T#10m from HMI
SD    DB_HMI_Activity.TON_Inactivity      // Start as on-delay

Network 4 - Trigger return-to-root and self-clear

A     DB_HMI_Activity.TON_Inactivity.Q    // Q = TRUE when PT elapsed
S     DB_HMI_Activity.bReturnToRoot       // Pulse the HMI GoHome tag

// Auto-clear so next value-change event can re-fire
A     DB_HMI_Activity.bReturnToRoot
L     T#200ms
SD    T_PulseClear                         // Short off-delay
A     T_PulseClear.Q
R     DB_HMI_Activity.bReturnToRoot        // Reset ~200 ms after set

The same logic in SCL form, for projects that prefer structured text:

IF DB_HMI_Activity.ScrnPtr[4] <> DB_HMI_Activity.OldFieldNo THEN
    DB_HMI_Activity.OldFieldNo := DB_HMI_Activity.ScrnPtr[4];
    DB_HMI_Activity.EdgeActivity := TRUE;
ELSE
    DB_HMI_Activity.EdgeActivity := FALSE;
END_IF;

IF DB_HMI_Activity.EdgeActivity THEN
    "TON_Inactivity"(IN := FALSE, PT := DB_HMI_Activity.TimeoutPreset);
END_IF;

"TON_Inactivity"(IN := TRUE, PT := DB_HMI_Activity.TimeoutPreset);

IF "TON_Inactivity".Q THEN
    DB_HMI_Activity.bReturnToRoot := TRUE;
    "T_PulseClear"(IN := TRUE, PT := T#200ms);
END_IF;
IF "T_PulseClear".Q THEN
    DB_HMI_Activity.bReturnToRoot := FALSE;
END_IF;

Acquisition Cycle and Timing Considerations

The responsiveness of the watchdog is bounded by three independent cycles that must be aligned:

Parameter Typical value Effect
HMI tag acquisition cycle 100 ms (minimum on WinCC Advanced) How fast Word 4 reaches the PLC.
PLC cycle (OB1) 5-20 ms How fast the comparison runs.
TON preset T#10m (configurable) Inactivity threshold.
Value-change propagation One HMI cycle + PLC cycle Delay between bReturnToRoot=TRUE and ActivateScreen firing.

The combined worst-case detection latency is therefore tag cycle + 1 PLC cycle, i.e. ~120 ms - well below any human-perceptible delay. The TON preset is the only value that should be left editable from the HMI for an operator-facing application; expose it through an I/O field bound to TimeoutPreset and add a bounds check (e.g. 30 s <= t <= 60 min) before writing it back to the DB.

Setting the acquisition cycle below 100 ms on WinCC Advanced requires WinCC Professional; Basic Panels ignore the value and pin the minimum to 100 ms. Do not reduce the cycle expecting a faster response - the panel will quietly round up.

Basic Panel Edge Cases

Because the KTP900 Basic cannot run scripts, several edge cases that Comfort Panel or Runtime Advanced users take for granted must be handled explicitly in the controller:

Edge case Symptom Mitigation
Pop-up screens with no input fields Word 4 stays 0; the watchdog treats the pop-up as "no activity" and times out prematurely. Add an invisible symbolic I/O field to the pop-up, or freeze the watchdog by setting a "pop-up active" BOOL while the pop-up is open.
Alarm view or trend view open Word 4 updates only on filter changes; long quiet observation still resets to the same field. Disable the watchdog while AlarmViewActive or TrendViewActive is TRUE; you can derive these from the focused screen number.
Recipe view Same as alarm view; long silent review of a recipe still counts as inactivity. Freeze the timer when the current screen is a recipe screen, or use the area pointer's Word 0 (screen number) to whitelist specific screens.
Two operators, shared session One operator leaves, another resumes later; original session has "timed out". Combine the watchdog with the user-administration auto-logoff so both expire together.
Field focused but unchanged Operator touches a field, never edits, then walks away. Acceptable - the touch is genuine activity. If not acceptable, supplement with a "value changed" tag using the Value change event of each I/O field.

The cleanest production pattern is to gate the TON with an enabled BOOL: only count time when the operator is on a screen that should auto-return. Whitelist screens by their number in a small constant list, or invert the logic and freeze the timer whenever the current screen is a "long-view" screen (alarm / trend / recipe).

Alternative via User Administration Auto-Logoff

For applications where operator identity matters - GMP, FDA, or any audited environment - the user administration feature on the KTP900 Basic is more appropriate than a generic watchdog. Configure Automatic logoff after in the user group properties (typically 5 - 30 minutes). At expiry the panel clears the user name; the change is observable in the User View area pointer (5 words, similar layout to Screen Number):

Word offset Name
+0 Current user number (0 = logged out)
+1..+4 Reserved

Monitor Word 0 in the controller; when it transitions from non-zero to 0, fire the same GoHome tag. This approach is auditable, survives screen-less interactions, and matches the documented behavior of the panel.

Drawback: the controller cannot know how much time remains before the logoff, so it cannot warn the operator. A common hybrid is to run both - the watchdog returns to the root screen after, say, 9 minutes, and the user-administration logoff fires at 10 minutes, with the audit log recording both events.

Verification Procedure

  1. Download the project to the PLC and the HMI. Use a watch table on DB_HMI_Activity with the pointer visible to confirm Word 4 is changing on every operator tap.
  2. Open the root screen and start the HMI runtime. Touch any button - the pointer's Word 4 should change within one acquisition cycle (100 ms). The EdgeActivity tag should pulse TRUE for a single OB1 cycle.
  3. Set TimeoutPreset to a short value (e.g. T#30s) for the test. Leave the panel untouched. After 30 s the panel should switch to the root screen automatically.
  4. Restore TimeoutPreset to the desired production value (T#10m is typical for operator-facing HMI; T#2m for safety-relevant HMIs).
  5. Open a recipe screen and confirm the watchdog freezes there (if you implemented the whitelist). Tap any field - the watchdog should remain frozen if the field is on the long-view screen, unless you opted to allow it.
  6. Verify that pressing the manual Home button on every screen also navigates to the root screen - the watchdog should not interfere with explicit navigation. Test by tapping the button and confirming the root screen appears immediately and that the watchdog timer resets.

Troubleshooting Matrix

Symptom Likely cause Diagnostic step Fix
Word 4 stays 0 regardless of touches Area pointer not assigned, or wrong DB number HMI > Connections > Area pointers; verify DB number matches PLC tag address Re-assign the area pointer; recompile both HMI and PLC; download in the correct order (PLC first)
EdgeActivity toggles continuously Acquisition cycle faster than PLC scan; the same Word 4 value sampled twice as different states Check the HMI tag's acquisition cycle; should be 100 ms minimum Increase PLC scan determinism, or guard the edge with an additional cycle counter
Timer never elapses TON reset input held TRUE because EdgeActivity stays TRUE Watch table on EdgeActivity - must be single-cycle pulse Use FP (positive edge) on the comparator output; do not assign EdgeActivity as a sticky coil
Panel returns to root screen instantly GoHome tag fired by an earlier project, or value-change event triggers on every scan due to acquisition = "On change" with no hysteresis HMI tag properties; verify acquisition mode is "Cyclic continuous" not "On change" Change acquisition mode to "Cyclic continuous" with 100 ms cycle
GoHome fires but screen does not change Root screen not defined, or ActivateScreen event pointing at a renamed screen HMI tag event configuration; verify screen name Set "Root screen" in the project's Runtime Settings, then re-select it in the event
Watchdog works in simulation but not on the live panel Panel firmware image older than the project image ProSave > Panel Information; compare firmware to project Update the panel firmware to match the project (or downgrade the project image) before download
Operator gets logged out but the watchdog does not return the panel to root User View area pointer not enabled HMI > Connections > Area pointers; verify "User View" is ticked Enable the User View area pointer; assign it to a DB and add the Word 0 == 0 monitor logic

Frequently Asked Questions

Is there a system bit on the KTP900 Basic that says "HMI is in use"?

No. The KTP900 Basic does not expose a system bit or system tag that reports operator activity to the PLC. The closest equivalent is the Screen Number area pointer's Word 4 (current field number); whenever it changes, the operator has interacted with the panel within the last acquisition cycle.

What acquisition cycle should I use for the Screen Number area pointer?

100 ms is the minimum WinCC Advanced supports on a Basic Panel. Setting a smaller value in the project has no effect; the runtime clamps it to 100 ms. 100 ms is also fast enough for any human-scale activity detection.

Why does the watchdog fire on a screen with no input fields, like an alarm view?

Word 4 of the Screen Number area pointer stays at 0 when there is no field with focus, so the comparator sees "no change" between scans and the inactivity timer counts normally. Whitelist long-view screens (alarm, trend, recipe) by their screen number and freeze the timer while one of them is active.

Can I read the inactivity time remaining before the panel logs the user out?

No. The user-administration logoff timer is held inside the runtime and not exposed. You only see the post-event transition (current user name becomes empty). Use the Screen Number watchdog above if you need a lead-time warning.

Does the same procedure work on Comfort Panels and WinCC Professional?

Yes, and it is simpler: Comfort Panels expose VBS scripting, so the watchdog can run entirely on the HMI without any PLC tag at all. The area pointer mechanism, however, is identical and is still the recommended approach when the application runs on a Basic Panel or when a controller-side implementation is required.

Back to blog