TP1200 Comfort Button Not Working: VBScript Loop & Overlap Fix

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

On a SIMATIC TP1200 Comfort Panel (MLFB 6AV2 124-1MC01-0AX0) running a WinCC Comfort/Advanced runtime project, individual configured buttons intermittently stop responding to operator input after the project is transferred to the panel. The exact same buttons execute their events correctly when the project is opened in the TIA Portal PLCSIM/RT simulation on the engineering station. Typical reported symptoms include:

  • Pressed buttons do not fire the assigned VBScript function (no screen change, no tag write, no animation).
  • Screen-change buttons (Call function: ActivateScreen) freeze on the current screen.
  • Set-value buttons do not write the configured constant to the connected PLC tag, but read-only indicators still update.
  • The failure is selective: only a subset of buttons on one or more screens is affected, frequently the most recently edited or the most script-heavy ones.
  • Touching the affected area still produces an audible click feedback on the panel, but the script never returns and the screen does not change.

Because runtime behavior diverges from the simulation, the root cause is always a runtime-only defect that the TIA Portal compiler does not escalate to an error: a VBScript infinite loop, an overlap of graphical objects, or a button placed (even by one pixel) outside the active screen rectangle.

Affected Hardware and Software

Component Value / Range
Panel family SIMATIC HMI Comfort Panel, 4" - 22"
Specific device TP1200 Comfort, 12.1" widescreen, 1280 x 800 px, 16 M colors, touch
MLFB (TP1200 Comfort Touch) 6AV2 124-1MC01-0AX0
Runtime image WinCC Comfort V16 / V17 / V18 (matches TIA Portal version)
Engineering TIA Portal V16, V17, or V18 with WinCC Comfort / WinCC Advanced
Script engine VBScript (Microsoft Windows Script Host 5.8 on the panel's Windows CE / Windows Embedded Compact runtime)
Connection to PLC PROFINET, PROFIBUS, MPI (S7-300/400/1200/1500 supported)
Transfer path Ethernet (PN/IE), USB, MPI/PROFIBUS, or via SD card / USB stick

Refer to the SIMATIC HMI TP1200 Comfort operating instructions (Siemens ID 109746846) and the WinCC Comfort/Advanced V18 system manual (ID 109773260) for device and runtime reference.

Root Cause Analysis

Three runtime-only defect classes account for the overwhelming majority of "some buttons don't work on the panel but work in simulation" cases. Each is invisible in the editor and harmless in the local PLCSIM/RT simulation, but they manifest as soon as the project runs on the physical TP1200.

Cause 1: VBScript infinite loop or blocking call

WinCC Comfort executes VBScript on a single-threaded scripting host on the panel. If a function assigned to a button event enters an infinite loop, recursively calls itself, or performs a long blocking wait, the scripting thread is consumed and never returns control to the runtime event dispatcher. The runtime keeps handling the global event queue, but the event handler associated with the looping script never completes, so any button whose event relies on that script (or is dispatched after it) appears dead. The runtime can be recovered only by a power cycle or by a restart of the WinCC Runtime via the Control Panel.

Local RT simulation on the PC does not always expose this defect because:

  • The PC-side scripting host has a higher tolerance for long-running scripts.
  • Script timeout / watchdog behavior differs between the Windows desktop JScript/VBScript engine and the embedded WinCE engine used on the panel.
  • On the engineering station, an infinite loop only halts the simulation window, which the engineer closes; on the panel, it halts the visible runtime.

Cause 2: Overlapping graphical objects

TIA Portal allows two screen objects to occupy the same pixel area without error. At runtime, the TP1200 resolves touch input against the topmost object in the Z-order. If a transparent or inactive object (a rectangle, an invisible button, an I/O field, a graphic view) sits on top of a configured button, the touch is delivered to the topmost object, not to the button. The configured Click event never fires because the topmost object has no Click event configured (or has a different one).

The compiler raises a warning in the "Compile output" window ("Object '<Name>' overlaps with object '<Name>' at position x, y"), but warnings do not block project transfer.

Cause 3: Button placed partially off-screen

A button positioned with its left or top edge at exactly the screen origin (0, 0) or with its right/bottom edge at exactly the screen boundary can be drawn inside the visible area, but the touch hit-test region can be clipped by one pixel. The button is rendered visibly and even reacts to the TIA Portal design view, but the runtime's touch controller rejects the event because the hit box no longer meets the minimum gesture size. This is a documented TP/Comfort runtime behavior; the panel will not generate a Click event for an object whose hit rectangle has been reduced below the runtime minimum.

Diagnostic Flow

Some TP1200 buttons do not fire on the panel, but work in RT simulation Open TIA Portal Compile output Object overlapwarning present? Button X/Y is on thescreen edge (0/0 or N/M)? Script has Do/While,recursive call, or wait? Reposition objects (Z-order) Move button 2 px inside the screen Refactor / break the loop TIA Portal: Project > Compile > Software (rebuild all) Transfer project to TP1200, perform warm restart, verify all buttons All buttons fire correctly -> CLOSE

Diagnostic Steps

  1. Reproduce the failure on the panel, not the simulation. Note exactly which screens and which buttons are dead. Group them: are they on the same screen? Were they all created or modified in the same session?
  2. Open the TIA Portal compile output. In the project tree, right-click the HMI device > Compile > Software (rebuild all). Inspect every warning in the "Compile output" window. Filter on the word "overlap" or "position".
  3. Open the affected screens in the editor and toggle "Show hidden objects". This reveals transparent rectangles, I/O fields, and graphic views that may be sitting on top of the buttons.
  4. Read every VBScript assigned to a dead button. Search for Do ... Loop, While ... Wend, For ... Next with a variable that is never incremented, recursive calls, and Wait / Sleep calls longer than 1 s. The VBScript editor in WinCC does not statically analyze loops.
  5. Use the panel's System Information > Logs. On the panel, open the Control Panel (the loader) and check System > Logs for runtime errors, script aborts, and "Runtime stopped" entries. See Siemens FAQ: Diagnostic options for SIMATIC HMI panels (ID 109769624).
  6. Check the HMI tags window on the panel. Set a tag with the button and verify whether the write is reaching the PLC. If the tag is updated but the script does not, the issue is in the script; if the tag is not updated, the issue is event delivery (overlap / off-screen).

Solution 1: Eliminate the VBScript Infinite Loop

This is the most common resolution. The reported case in the field was a single looping VBScript that took down every script-driven button on the project. Replace the looping pattern with a state-driven or scheduler-driven approach.

Bad pattern (infinite loop)

' Button "Start" event
Sub Start_Click(ByVal Item)
    Do
        SmartTags("RunFlag") = 1
        If SmartTags("StopFlag") = 1 Then
            Exit Do          ' never reached if StopFlag is set in the same screen
        End If
    Loop
    SmartTags("RunFlag") = 0
End Sub

Good pattern (single-pass, scheduler in the scheduler task)

' Button "Start" event - just sets a flag, no loop
Sub Start_Click(Byval Item)
    SmartTags("RunFlag") = 1
End Sub

' Button "Stop" event
Sub Stop_Click(Byval Item)
    SmartTags("RunFlag") = 0
    SmartTags("StopFlag") = 1
End Sub

Place the cyclic logic in a WinCC scheduler (e.g. 100 ms task) that polls RunFlag. This pattern is documented in the WinCC Comfort/Advanced V18 system manual, section "Scheduling scripts with tasks".

Watchdog: For any script that performs I/O or long logic, add a counter-based bail-out so a misbehaving downstream tag cannot wedge the script:
Dim i, maxIters: maxIters = 1000
For i = 1 To maxIters
    If SmartTags("Done") = 1 Then Exit For
Next
If i >= maxIters Then
    ' Log to internal tag so the issue is visible in HMI logs
    SmartTags("ScriptErrorCode") = -1
End If

Solution 2: Fix Overlapping Objects

  1. In the TIA Portal screen editor, select View > Show hidden objects and View > Show grid.
  2. Select the dead button and read the X, Y, Width, Height in the Properties pane.
  3. For every other object on the screen, compare the rectangles. Two rectangles overlap if both X ranges intersect and both Y ranges intersect.
  4. Move the topmost (later Z-ordered) object at least 5 px in any direction, or use Arrange > Bring to front / Send to back so the button sits on top of any transparent objects.
  5. Re-compile the project and confirm the overlap warning has disappeared.

Recommended screen design rules for TP1200 Comfort (1280 x 800):

Parameter Recommended value
Minimum button size 80 x 30 px
Minimum gap between interactive objects 5 px
Safety margin from screen edge 2 px (avoid X=0 / Y=0 / X+W=1280 / Y+H=800)
Z-order policy Buttons always on top of decorative graphics

Solution 3: Reposition Off-Screen or Edge-Clipped Buttons

  1. Select the dead button in the editor.
  2. In the Properties pane, set Position X and Position Y to a value at least 2 px inside the screen, e.g. X=2, Y=42 (the 40 px allowance is for the project header).
  3. Confirm that X + Width <= 1278 and Y + Height <= 798 for a 1280 x 800 screen.
  4. Transfer the project again and verify.
The TP1200 Comfort has a 40 px tall title bar on top of each screen by default. Any button whose top edge is set between 0 and 39 is hidden behind the bar and will not receive touches. Disable the title bar in the screen properties, or place interactive elements below Y=42.

Procedure: Software (rebuild all) and Re-transfer

After any of the fixes above, force a full rebuild of the HMI project. This is the most reliable way to clear stale compiled resources on the engineering side.

  1. In TIA Portal, project tree > right-click the TP1200 device > Compile > Software (rebuild all).
  2. Wait for "Compile finished (warnings: x, errors: 0)" in the editor output.
  3. Right-click the TP1200 device > Download to device > Software (all).
  4. In the download dialog select Overwrite all and confirm the HMI goes into Transfer mode.
  5. After download completes, the panel restarts the runtime automatically.
  6. Verify all previously dead buttons now fire.

Procedure: Panel OS Update / Reset

If the issue persists after the rebuild, the panel's image itself may hold a corrupted runtime state. Update the operating system image from the TIA Portal installation media.

  1. Connect the engineering station to the TP1200 Comfort via PROFINET or directly via Ethernet.
  2. Set the panel's transfer mode: Control Panel > Transfer > Enable.
  3. In TIA Portal: Online > Accessible nodes, select the TP1200.
  4. Right-click > Update operating system. The panel reboots into the loader and the new image is flashed (approx. 5 - 10 min).
  5. After the image update, re-transfer the HMI project as described above.

The supported image versions for the TP1200 Comfort (6AV2 124-1MC01-0AX0) are listed in the TP1200 Comfort operating instructions, chapter "Image update". Always match the image version to the TIA Portal version in use (V16, V17, or V18); mixing an older image with a newer project is a common source of "buttons stopped working after a TIA upgrade".

Verification

After applying any of the fixes, validate the panel with this checklist before returning it to production:

  1. Power-cycle the panel and confirm the runtime loads without errors.
  2. Open every screen that previously contained dead buttons and tap each one. All Click events must fire.
  3. From the Control Panel > System > Logs, confirm no script abort or "script execution exceeded 5 s" entries appear over a 30 minute test cycle.
  4. From the connected PLC, force each tag written by the previously dead buttons. Confirm the value changes on the panel's I/O field within the configured update cycle (default 1 s).
  5. Open the panel's System Information screen and confirm the runtime version matches the TIA Portal version (e.g. V18.0.0.0).

Issue Matrix

Symptom Likely root cause Diagnostic step Fix
One specific button dead, no warning Off-screen / edge-clipped hit area Check X/Y in Properties pane Move 2 px inside the screen
Multiple buttons dead on one screen, overlap warnings present Transparent object on top View > Show hidden objects Re-Z-order, move the overlapping object
All script-driven buttons dead, Control Panel > Logs shows "Script aborted" One infinite-looping VBScript blocking the script thread Read every script, search for Do/Loop and recursion Refactor to scheduler pattern, add watchdogs
Dead buttons after TIA upgrade Mismatched panel image version Control Panel > System > Versions Update panel OS image to match TIA version
Dead buttons only after warm restart, fine after power cycle Stale runtime project on panel Re-transfer with overwrite Compile (rebuild all) + download all
Dead buttons only with a specific tag, fine for hard-coded value Tag quality BAD or address changed HMI tag diagnostics Re-link the tag, check PLC connection
Dead buttons only during a write-confirmation cycle Event "Execute on... release" or "on... press" misconfigured Button Properties > Events Set to "Click" or "Press" explicitly

Preventive Best Practices

  • Treat compile warnings as errors. Configure TIA Portal to display all warnings, not just errors, and add a project check to your release procedure. A single overlap warning is enough to disable a button at runtime.
  • Never use a Do...Loop construct inside a button Click event. Place cyclic logic in a WinCC scheduler task. The runtime is single-threaded for scripts.
  • Enforce minimum geometry. A 5 px gap between interactive objects and a 2 px safety margin from the screen edge eliminates 90% of overlap and off-screen defects.
  • Pin the runtime image version to the TIA Portal version. Store the image file (e.g. TP1200_Comfort_V18_Upd1.img) in the project folder and document the version on every HMI.
  • Test on the panel, not the simulation. The local PC simulation does not enforce the same VBScript timeout, the same touch hit-test minimum, or the same overlap Z-order. Always perform a final smoke test on the physical device before commissioning.
  • Use the System Information screen on the panel (Start Center > Settings > System Information) to capture runtime version, image version, and tag diagnostics in screenshots before any service call.

Related Siemens Documentation

Why do my TP1200 buttons work in TIA Portal simulation but not on the panel?

The PC-based RT simulation uses a more tolerant VBScript host and does not enforce the panel's minimum touch hit-test area or Z-order resolution. The three most common runtime-only defects are: a VBScript infinite loop consuming the script thread, an overlapping object on top of the button receiving the touch, or a button placed (even by 1 px) outside the active screen rectangle. All three are caught by rebuilding the project and reading the TIA compile output warnings.

How do I detect overlapping objects that block button events?

Open the affected screen in the TIA Portal editor, enable View > Show hidden objects, then perform a Project > Compile > Software (rebuild all). The Compile output window lists every overlap as a warning of the form "Object '<Name>' overlaps with object '<Name>' at position x, y". Use the listed coordinates to identify and reposition (or Z-order) the topmost object so the configured button sits on top.

How do I recover a TP1200 whose runtime is stuck because of a looping VBScript?

Power-cycle the panel or, if accessible, open the Control Panel and select Start Center > Runtime > Stop. Then transfer the project again after fixing the looping script. To prevent recurrence, move any cyclic logic out of button Click events and into a WinCC scheduler task (e.g. 100 ms) that reads a flag set by the button.

Which panel image version should I use with TIA Portal V17 / V18?

Always match the panel image version to the TIA Portal version that compiled the project. For a TP1200 Comfort 6AV2 124-1MC01-0AX0 the image is delivered under <Installation>\Support\Images\TP1200_Comfort\<Vxx>\. Check the installed version under Control Panel > System > Versions on the panel, and update via Online > Accessible nodes > Update operating system if the version is older than the TIA Portal build number.

My buttons were working yesterday and stopped after a TIA upgrade - what changed?

A TIA Portal upgrade typically changes the runtime image, the VBScript engine, and the compile output. First, update the panel image to match the new TIA version. Second, recompile with Software (rebuild all) and re-transfer with overwrite. Third, read the new compile warnings; if a button was previously at X=0, Y=0, the runtime version bump may have tightened the hit-test clipping rule and the button must be moved at least 2 px inside the screen.

Back to blog