Retaining TP1200 Comfort Internal Tags After Power Failure

David Krause17 min read
HMI ProgrammingSiemensTroubleshooting
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

Retaining TP1200 Comfort Internal Tags After Power Failure or Runtime Stop

Internal tags on a SIMATIC TP1200 Comfort panel can lose their values when the panel is power-cycled or when WinCC Runtime is stopped and restarted. This is one of the most common configuration errors when migrating from WinCC Flexible 2008 to TIA Portal / WinCC Comfort V13 SP1 and later. The root cause is rarely a panel defect and almost always a missing Retentive property on the HMI tag, combined with an inadequate handling of the integer-to-REAL conversion that is being performed in a Visual Basic script on the panel.

This article covers the exact retention mechanism inside WinCC Comfort (TIA Portal), the differences between Internal and External tag retention, the role of the system event PowerFail / RuntimeStop, and a working script skeleton that preserves a converted REAL value across a cold start. It also explains the coordination problem that appears when a third-party PLC (non-Siemens S7) is paired with the TP1200, and provides a verification procedure you can run on the bench.

Hardware scope. The retention procedure described here applies to the SIMATIC HMI Comfort line, including 6AV2124-1ACxx (TP700), 6AV2124-1BCxx (TP900), 6AV2124-1MCxx (TP1200), 6AV2124-1QCxx (TP1500) and 6AV2124-1UCxx (TP1900). It is also valid for KP / TP Comfort INOX and for the second-generation Comfort Panels released with TIA Portal V17 (6AV2 648-xxxx). Refer to the SIMATIC HMI Comfort Panels device manual for panel-specific flash memory size and write-cycle limits.

1. Problem Description

Typical symptoms reported in field service reports:

  • TP1200 Comfort boots, WinCC Runtime starts, all Internal tags report 0 (zero) even though the value was on screen just before the power loss.
  • After Stop Runtime on the Control Panel and a manual Start Runtime, the same zeroing occurs.
  • An integer value coming from a third-party PLC is converted to REAL on the HMI (decimal point scaling, e.g. 999.9). The original integer is retained on the PLC side but the HMI internal copy is lost.
  • A VBScript that performs the integer-to-REAL conversion re-runs on the first cycle after start and writes 0.0 into the REAL tag, briefly overwriting the last known good value.

The user typically sees the wrong value for one scan, then sees a value of 0.0 (because the third-party tag is also being polled at zero on the HMI cold start, before the PLC finishes its first scan), and only after the next cycle does the value settle. Operators perceive this as "data loss" even though the value will eventually catch up if the PLC variable is changing slowly.

2. Root Cause Analysis

WinCC Runtime uses a 16 MB to 64 MB internal flash area (panel-dependent; see Siemens Support Entry 109751520 — SIMATIC HMI Comfort Panels operating instructions) to persist certain tag values across power cycles. Only tags that have been explicitly declared retentive are written to that area on every configured save cycle. There are three distinct retention scopes:

Scope Where the data lives Survives power fail? Survives project download? Survives operating-system update?
Volatile RAM Working memory of Runtime No No No
Retentive HMI tag Flash-backed file in /home/retent partition Yes No (overwritten on download) No
Recipe / data log Flash-backed file in /home/data partition Yes No (overwritten on download) No
PLC retentive area (S7-1200/1500) Remanent DB or M area Yes Yes (if not initialized) Yes

The default value of the property Acquisition mode / Retentive on a new HMI tag is Not retentive. The engineer must set it to Retentive explicitly. This is the single most common reason for the reported problem.

The second reason is a runtime-ordering issue. WinCC Runtime processes its tag-update cycle, scheduled tasks, and VBScripts in a defined order. On a cold start, the scheduled VBScript runs before the tag connections from the third-party PLC have completed their first poll. The script therefore reads a 0 from the source integer and writes 0.0 into the destination REAL tag, blowing away the persisted value before the PLC ever gets a chance to send a fresh one.

The third reason is a declared retentive tag that is being initialized in the project with a non-zero default in the Properties dialog. WinCC always writes the configured start value into a retentive tag on every cold start before the saved value is restored. If your start value is 0, the user sees 0 for the first scan.

3. Solution A: Make the Internal Tag Retentive

This is the basic fix and should be in place regardless of the script-level work in Solution B.

  1. Open the TIA Portal project that is deployed to the TP1200.
  2. Expand PLC > HMI Tags in the project tree and select the Default tag table (or the table that contains the integer source tag and the REAL destination tag).
  3. Click the row of the destination REAL internal tag that is losing its value (e.g. ScaleValue_Real).
  4. In the inspector window, switch to the Properties tab.
  5. Expand Settings and find the Retentive property. The dropdown shows three values: Not retentive, Retentive, and Retentive in area pointer (used with PROFINET name-of-station data). For standalone HMI tags, select Retentive.
  6. Confirm the Initial value field is empty or set to a value that is safe to display on the very first commissioning (typically 0).
  7. Compile the project, transfer it to the TP1200, and restart Runtime.
Flash wear. The flash memory on a Comfort Panel is rated for approximately 100 000 write cycles per sector. WinCC groups retentive writes into a single transaction and flushes them at the Save trigger you configure under HMI device > Properties > Retentivity > Save. Do not configure a save interval shorter than 1 second and do not link a save trigger to a tag that changes every PLC cycle. Use a 60-second timer or a manual SaveDataRecord / Flush call instead. See SIMATIC HMI Comfort Panels operating instructions, section "Retentive data on the HMI".

4. Solution B: Avoid the Cold-Start Race in the VBScript

The minimal VBScript pattern that causes the problem looks like this:

' Problematic pattern - runs unconditionally on every cycle
Sub Convert_Int_To_Real()
    Dim iValue, rValue
    iValue = SmartTags("PLC_Integer_Value")
    rValue = CDbl(iValue) / 10.0           ' scale 1234 -> 123.4
    SmartTags("Display_Real_Value") = rValue
End Sub

On a cold start, PLC_Integer_Value has not yet been polled, so the HMI returns 0 and the script overwrites the persisted Display_Real_Value with 0.0. The fix is to (1) detect that the HMI is in a cold-start phase, (2) only run the conversion once the PLC partner has been confirmed to be alive, and (3) never touch the destination tag if the source is still zero after a configurable warm-up window.

Use the WinCC system tags to drive the gating logic:

System tag Type Meaning
@RuntimeStarted Bool Set to TRUE on the first scheduled tick after Runtime start
@ConnectionState_X Bool One per configured connection; TRUE means the named connection is up
@LocalMachineName String Name of the HMI for log messages
@CurrentLanguage Int Active language index

The full list of system tags is documented in the TIA Portal help under WinCC > Working with WinCC > System functions and tags > System tags. The relevant section is part of the SIMATIC HMI Comfort Panels operating instructions.

Replace the script with the following pattern, which is also a useful template for any third-party PLC where the connection-up bit is the only signal you have that the partner is producing real data:

' Retention-safe integer-to-REAL conversion
Const WARMUP_TICKS As Long = 5            ' ignore source for first 5 scheduled ticks
Dim g_TickCounter As Long                  ' module-level state in a global .bas module

Sub Convert_Int_To_Real_Safe()
    Dim bRuntimeReady As Boolean
    Dim bConnUp As Boolean
    Dim iValue As Long
    Dim rValue As Double
    Dim rCurrentReal As Double

    bRuntimeReady = SmartTags("@RuntimeStarted")
    ' Replace "PLC_Connection_1" with the actual connection name from the project tree
    bConnUp = SmartTags("@ConnectionState_PLC_Connection_1")

    If Not bRuntimeReady Or Not bConnUp Then
        ' Runtime or partner not ready - do NOT touch the retentive tag
        Exit Sub
    End If

    g_TickCounter = g_TickCounter + 1
    If g_TickCounter <= WARMUP_TICKS Then
        Exit Sub                                ' allow the connection to settle
    End If

    iValue = SmartTags("PLC_Integer_Value")
    If iValue = 0 Then
        ' The third-party tag is genuinely 0 OR it has not been polled yet.
        ' Read the current retentive REAL and only overwrite it if we have
        ' evidence that a real poll has occurred. The connection-up bit plus
        ' the warm-up window is sufficient evidence for most projects.
        rCurrentReal = SmartTags("Display_Real_Value")
        If rCurrentReal <> 0 Then
            Exit Sub                            ' keep the last known good value
        End If
    End If

    rValue = CDbl(iValue) / 10.0
    SmartTags("Display_Real_Value") = rValue
End Sub
Where to put the module-level counter. VBScript in WinCC Runtime is interpreted, but a global script function defined in the project tree under Scripts > VB Scripts > Global definitions retains its variables for the lifetime of Runtime. Do not declare g_TickCounter inside the scheduled function — that would reset it to 0 on every tick. Place it in a standard .bas module in the same folder. This is documented in the TIA Portal help under Scripts > VBScript > Global declarations.

5. Solution C: Coordinate the Cold Start With the Third-Party PLC

When the TP1200 talks to a non-Siemens controller (Allen-Bradley CompactLogix / ControlLogix, Schneider M340, Omron NJ/NX, Mitsubishi FX5, ABB AC500, etc.) over EtherNet/IP, Modbus TCP, PROFINET or OPC UA, there is no built-in startup handshake the way an S7 connection provides TCON status. The HMI sees the socket come up, but it cannot tell whether the PLC has finished its first scan or whether the variable is actually zero. Three patterns that work in the field:

5.1 PLC "heartbeat" toggle

Reserve one bit in the third-party PLC that the controller toggles every 100 ms (or 1 s, depending on cycle). The HMI script only treats a sample as valid if the heartbeat has changed since the last sample. The last good value is kept when the heartbeat is stale. The reference for toggling a bit is the specific controller manual — for an Allen-Bradley CompactLogix L33ER see 5069-UM001 — CompactLogix 5380 User Manual, chapter on producing tags. For Modicon M340 see Schneider Electric documentation portal and the BMX NOE 0100 / BMX NOE 0110 user manual.

5.2 Handshake handshake + initial value

Have the PLC write a known sentinel value (for example, the integer value 12345) into a designated warm-up tag on its first scan and clear it after 1 s. The HMI script ignores all values until it sees the sentinel and then takes the next sample as the first valid value. This is the most robust approach for slow-cycling processes.

5.3 PROFINET / EtherNet/IP application relation status

If the connection is PROFINET and the third-party PLC is acting as a PROFINET IO Device, the HMI's PROFINET stack reports the application-relation (AR) state through the connection-state system tags. Wait for @ConnectionState_... to be TRUE and additionally poll a vendor-specific slot for at least two IO cycles before trusting data. The PROFINET AR state machine is defined in IEC 61784-2 (available from IEC Webstore).

6. Solution D: Use a System Event for Power-Fail Cleanup

WinCC Runtime raises a configurable system event when the panel detects an imminent power loss (TP1200 has a hardware signal on the X80 connector, pin 14, that is asserted by the 24 V supply supervisor). Configure the event under HMI device > Properties > Events > PowerFail. Tie a VBScript to it that calls SmartTags("Display_Real_Value").Flush if the tag is held in RAM by a non-WinCC component, or simply lets the periodic save cycle do its job. The hardware-level PowerFail signal is documented in the SIMATIC HMI Comfort Panels operating instructions, section "Power supply and power-fail behavior".

For diagnostic purposes, the underlying Windows Event Log entry on a SIMATIC Panel PC is Event ID 41 — "The system has rebooted without cleanly shutting down first". This is the same Microsoft event ID you will see on any Windows Embedded Standard 7 / Windows 10 IoT Enterprise panel that lost power abruptly. The official description is on Microsoft Learn — Event ID 41 Kernel-Power troubleshooting. Filter the panel event log on this ID to confirm the next boot was caused by a power loss and not by a stop error.

7. Verification Procedure

Run this sequence on the bench with a TP1200 6AV2124-1MC01-0AX0 connected to a third-party PLC and a variable DC supply that can be switched off cleanly.

  1. Compile and load the modified TIA Portal project. Confirm that the project tree shows a green check next to Tag table > Retentive for Display_Real_Value.
  2. Set a known value: force PLC_Integer_Value = 1234 from the PLC side. The HMI should show 123.4.
  3. Trigger a save on the HMI: either wait for the configured save interval (default 60 s on Comfort Panels) or call SmartTags("Display_Real_Value").Write from a button.
  4. Power-cycle the TP1200 by removing the 24 V supply for at least 30 seconds.
  5. Re-apply power and watch the HMI tag Display_Real_Value in the online watch table of TIA Portal. The value must read 123.4 immediately after Runtime start, without waiting for the PLC to send a new sample.
  6. Hold the PLC offline by unplugging the network cable from the third-party PLC while the HMI stays on. The HMI should continue to show 123.4. The script must not overwrite the value with 0.0.
  7. Reconnect the PLC. Verify that the next sample taken after the connection state goes to TRUE is processed by the script and the display follows the live value.
  8. Stop and start Runtime from the Control Panel of the TP1200 (Start > Stop Runtime). The HMI tag must retain 123.4 across the restart.

If step 5 or step 8 fails, return to Section 3 and verify that the Retentive flag is set. If the flag is set and the value is still lost, check Section 4 and confirm the gating conditions in the script are correct.

8. Parameter Reference

Property / Tag Location in TIA Portal Recommended value Effect
Retentive HMI tag > Properties > Settings Retentive Persists tag value in flash across power cycles
Initial value HMI tag > Properties > Settings 0 (or empty) Written on first commissioning; replaced by saved value on subsequent starts
Acquisition cycle HMI tag > Properties > Cycle 500 ms (third-party poll) Sets HMI poll period; the source integer updates at this rate
Save interval HMI device > Properties > Retentivity 60 s Flash write period; shorter values wear out flash faster
Trigger for save HMI device > Properties > Retentivity Tag or scheduled task Optional manual save in addition to the interval
Scheduled task cycle Scripts > Scheduled tasks 1 s How often the VBScript runs; do not go below 100 ms with retentive writes
Connection state tag System tags Use to gate the script Prevents the script from writing 0.0 on cold start

9. Troubleshooting Matrix

Symptom Most likely cause Confirm by Fix
Value 0 on first start, correct after one scan Start value initialized to 0 Inspect the HMI tag in online > Diagnostics > Tag Leave Initial value empty, or set it to a known sentinel
Value 0 always after power cycle Retentive flag not set HMI tag > Properties > Settings > Retentive Set to Retentive, recompile, retransfer
Value correct in display, 0 in log file Data log uses non-retentive buffer Check the storage location of the log Set log to /home/data or external storage
Value correct, but reverts to 0 after project download Download resets the retentive area Read out the tag in online after the download Re-set the value, document the download procedure
Value flickers between 0 and the live value Script writes 0 before the PLC has been polled Trace the script Use Solution B gating
All HMI tags are 0 after a firmware update OS update wipes the /home partition Check the panel's Control Panel > System Export the retentive values to a backup file before update
Power-fail events do not trigger the script PowerFail event is not assigned Look at the Events tab in the HMI device properties Assign the script to PowerFail as in Section 6

10. Edge Cases and Field-Proven Caveats

  • TP1200 with PROFINET to a Siemens S7-1500. The default connection state is reliable; you do not need the heartbeat pattern from Section 5.1. The PowerFail script from Section 6 is still recommended because S7-1500 may take 2-3 s to come back online.
  • CompactLogix over EtherNet/IP. The implicit CIP connection can take 10-15 s to establish. Increase the WARMUP_TICKS in Solution B to 20 or 30.
  • Recipe data vs. tag retention. Recipes are saved under /home/data and survive a panel reset, but they are overwritten on project download. Use recipes for operator-settable setpoints, not for implicit conversion results.
  • TP1200 with second-screen IPC. If the TP1200 is acting as a second screen for a SIMATIC IPC, the HMI Runtime lives in the IPC's working memory; retentivity is handled by the IPC and not by the panel's flash. Configure the retain path in the IPC's project.
  • 24 V supply with brown-out. A brown-out that is shorter than the panel's hold-up time (typically 5 ms for a TP1200) may not trigger PowerFail but can corrupt a flash write that is in progress. Use a UPS or a 24 V buffer module (6EP1331, 6EP1332 or 6EP1333 from the SITOP line) on the supply to the panel.
  • Decimal-point scaling. If your only requirement is to display an integer such as 1234 as 12.34, do not convert to REAL on the HMI. Configure the HMI tag with the Decimal places property set to 2 and the Length property set appropriately. WinCC will display 12.34 in the I/O field without storing a REAL anywhere. This is the most efficient fix for the "convert to REAL" pattern.

11. Safety and Commissioning Checklist

  1. Verify the 24 V supply to the TP1200 is within the range 19.2 V to 28.8 V (the panel shuts down below 19.2 V and may corrupt the flash during the slow decay).
  2. Confirm the PROFINET/EtherNet/IP cable is shielded and the shield is bonded to the cabinet ground at both ends with low-impedance clamps.
  3. Document the retentive tag list in the project documentation; the HMI device properties export a CSV that can be pasted into the maintenance manual.
  4. Add the PowerFail event handler to the FAT (factory acceptance test) procedure and demonstrate that a power-cycle restores the last good value.
  5. Include a step in the SAT (site acceptance test) that pulls the network cable from the PLC while the HMI is on and verifies that the last value stays on screen for at least 5 minutes.

12. FAQ

Why does my TP1200 Comfort show 0 for all internal tags after a power cycle?

The default for a new HMI tag in TIA Portal is Not retentive. Open the tag table, select the internal tag, and set Properties > Settings > Retentive to Retentive. Recompile and retransfer the project. The saved value is written to the panel's internal flash on every save cycle, default 60 seconds.

Can I keep an integer value on the HMI and only display it with a decimal point, without converting to REAL?

Yes. Configure the HMI tag as INT or DINT, then in the I/O field properties set Decimal places to the number you want (for example 1 for 999.9). WinCC scales the display at the I/O field level only; the underlying tag stays an integer. This eliminates the conversion script and the cold-start race entirely.

How long is the flash memory on a TP1200 rated for retentive writes?

The internal flash used for /home/retent on a Comfort Panel is rated for approximately 100 000 write cycles per sector. WinCC groups writes and flushes them at the configured save interval. Do not shorten the save interval below 1 second. If you need to capture fast-changing values, write them to a recipe or a CSV log on a different partition.

My PLC is a third-party controller (Allen-Bradley, Schneider, Omron, Mitsubishi, ABB). How do I know the HMI connection is up?

Each configured connection in WinCC has a system tag named @ConnectionState_<connection_name> that is TRUE when the underlying transport is open. Read this tag in your script and gate the integer-to-REAL conversion behind it. For slow protocols such as Modbus TCP, also implement a 5-30 second warm-up window before trusting the first sample, because the connection-up bit fires before the first poll completes.

Does a project download erase the retentive tag values?

Yes. A download from TIA Portal to the TP1200 reinitializes the runtime project, which overwrites the retentive area with the project's current start values. Document this in the change-management procedure and re-enter the setpoints after every download. Recipes stored under /home/data behave the same way unless you explicitly back them up first.

Is there a system event I can use to detect a power loss on the TP1200?

Yes. WinCC Runtime raises a PowerFail event when the panel's 24 V supply supervisor detects a drop below the safe operating threshold. Assign a VBScript to this event in HMI device > Properties > Events to flush any non-WinCC buffers. The same event leaves a Kernel-Power Event ID 41 in the Windows event log, which you can filter on for diagnostics — see Microsoft Learn — Event ID 41.

Back to blog