Problem Details
On a WinCC Professional V13 (TIA Portal V13) runtime station, a process screen contains a f(t) trend view whose archive tags are attached dynamically at runtime by a button script. After the user clicks the button, the trend window correctly displays the requested logging tag. The defect appears the moment the operator leaves the trend screen and later returns to it: the curve is gone, the trend area is empty, and the operator has to click the configuration button again to reattach every tag.
The minimal failing pattern is reproducible on any WinCC RT Professional station where the trend is added by VBScript using the HMIRuntime.ActiveScreen.ScreenItems collection, for example:
Sub OnClick(ByVal item)
Dim a
Set a = HMIRuntime.ActiveScreen.ScreenItems("level_trend")
a.TrendIndex = 0
a.TrendTagName = "Data_log_1\Logging_tag_1"
a.TrendColor = vbYellow
a.TrendVisible = True
End Sub
The behavior is not a project fault and it is not an archive fault: the WinCC Professional V13 system manual explicitly defines the trend view as a screen-bound ScreenItem whose configuration is part of the screen instance. When the screen is unloaded during navigation, the configuration written at runtime is discarded together with the screen object.
Root Cause
WinCC Professional V13 (TIA Portal V13, SIMATIC WinCC Professional V13 SP1 / Update 5 and earlier) treats every picture window, every screen, and every faceplate type as a runtime object with its own lifetime. The trend control exposed on a screen is a ScreenItem referenced by name through the collection HMIRuntime.ActiveScreen.ScreenItems("..."). Three lifetime rules apply to that object:
- Picture lifetime. The trend object exists only while its parent screen is the active screen or a picture window ancestor of the active screen.
-
Configuration lifetime. Properties that the user or a script writes at runtime (
TrendIndex,TrendTagName,TrendColor,TrendVisible, etc.) are kept in the in-memory copy of the screen object. They are not persisted to the compiled project on the HMI device. - Navigation lifetime. As soon as the screen is closed, the in-memory copy is destroyed. The next time the screen is opened, a fresh object is created from the compiled default; runtime modifications are lost.
For this reason, any property written through a button script is volatile by design. The trend is not "deleted" from the archive; the historical data is intact. What is lost is the link between the trend control object and the archive tag the operator selected. WinCC cannot redraw the curve because the curve's tag binding no longer exists on the new object instance.
Siemens documents this behavior in the f(t) trend view (RT Professional) reference. The reference lists the runtime-persistent properties under Properties > Properties > Security > Persistence; the default value disables persistence for user-defined trends.
Affected Versions and Components
| Component | Version | Status |
|---|---|---|
| TIA Portal | V13 / V13 SP1 | Trend configuration by script is volatile; no built-in persistence |
| WinCC Professional | V13.0 + Upd. 1..5 | Screen-bound ScreenItem lifetime applies |
| WinCC Professional | V14 / V15 / V15.1 / V16 | Persistence property still off by default; same defect if not enabled |
| WinCC Professional | V17 / V18 / V19 / V20 | Properties > Security > Persistence available; same root cause |
| WinCC Comfort / RT Advanced | V13..V20 | Not affected (uses tag logging, not ScreenItem configuration) |
| SIMATIC Panel (Comfort / Unified) | All | Not affected by this defect |
The defect is not version-specific. It is the documented default behavior of the WinCC Professional trend control. Newer TIA Portal versions (V17 and later) expose additional persistence properties that earlier versions do not.
Solution Overview
There are three valid ways to keep a script-driven trend visible after navigation. Choose one based on the project layout, the number of trends, and the operator's expected workflow.
- Enable the Persistence property on the trend view (TIA Portal V17 and later). Available as Properties > Properties > Security > Persistence on the f(t) trend view in RT Professional, as documented in the f(t) trend view (RT Professional) manual.
-
Re-attach the trend in a startup script tied to the trend screen. This is the recommended solution for WinCC Professional V13 because V13 does not expose the persistence property. Use the screen's
OnOpenevent to reapply the trend configuration that the user selected before navigation. - Move the trend to a permanently visible picture window opened at runtime start. The trend ScreenItem never goes out of scope, so configuration written at runtime survives any screen change. This is the cleanest long-term design and is the pattern recommended in the WinCC Professional V13 engineering manual for trend-heavy HMI projects.
Solution 1: Re-attach Trend on Screen Open (WinCC Professional V13)
Because WinCC Professional V13 has no Persistence property, the only path that does not require a TIA Portal upgrade is to reapply the trend configuration whenever the screen is opened. The implementation has three parts: a global tag array that stores the trend selection, a button script that writes the selection, and a screen event that reads the selection and reconfigures the trend control.
Step 1: Declare the selection tags
In the TIA Portal project tree, open HMI Tags and create a string array large enough for the maximum number of trend curves you intend to support. A practical size for a single trend window is 4..8 curves:
HMI Tag : TrendSel_01 Type: WString Length: 255 Connection: Internal
HMI Tag : TrendSel_02 Type: WString Length: 255 Connection: Internal
HMI Tag : TrendSel_03 Type: WString Length: 255 Connection: Internal
HMI Tag : TrendSel_04 Type: WString Length: 255 Connection: Internal
HMI Tag : TrendColor_01 Type: UInt Length: 1 Connection: Internal
HMI Tag : TrendColor_02 Type: UInt Length: 1 Connection: Internal
HMI Tag : TrendColor_03 Type: UInt Length: 1 Connection: Internal
HMI Tag : TrendColor_04 Type: UInt Length: 1 Connection: Internal
Use vbYellow color constants where useful, but persist them as numeric values so the screen-open script can map them without COM lookups.
Step 2: Store the operator selection in the button script
' Button: "Show level trend"
Sub OnClick(ByVal item)
Dim a
Set a = HMIRuntime.ActiveScreen.ScreenItems("level_trend")
a.TrendIndex = 0
a.TrendTagName = "Data_log_1\Logging_tag_1"
a.TrendColor = vbYellow
a.TrendVisible = True
' Persist for re-attach on next screen open
SmartTags("TrendSel_01") = "Data_log_1\Logging_tag_1"
SmartTags("TrendColor_01") = vbYellow
End Sub
Each additional button repeats the same pattern with TrendIndex = 1, 2, 3, ... and the corresponding TrendSel_0n tag. The SmartTags collection is documented in the WinCC Professional V13 VBScript reference.
Step 3: Re-attach on screen open
Open the trend screen in the TIA Portal graphics designer, select the screen background, and open Properties > Events > Open. Add the following VBScript:
' Screen event: OnOpen of trend screen
Sub OnOpen(ByVal item, ByVal bOpen)
If Not bOpen Then Exit Sub
Dim a, i, sel, col, vis
Set a = HMIRuntime.ActiveScreen.ScreenItems("level_trend")
For i = 0 To 3
sel = SmartTags("TrendSel_0" & (i + 1))
col = SmartTags("TrendColor_0" & (i + 1))
vis = (sel <> "")
a.TrendIndex = i
a.TrendTagName = sel
If vis Then
a.TrendColor = col
a.TrendVisible = True
Else
a.TrendVisible = False
End If
Next
End Sub
The loop forces a clean reconfiguration of every index 0..3 on every screen entry. The archive data is read by the trend control from the configured tag, so historical data is unaffected.
Step 4: Handle a reset of the trend selection
Provide a dedicated "Clear trends" button that writes empty strings to the selection tags so the next screen entry produces a blank trend window:
Sub OnClick(ByVal item)
Dim i
For i = 1 To 4
SmartTags("TrendSel_0" & i) = ""
Next
' Re-trigger OnOpen to wipe the trend right now
Dim a
Set a = HMIRuntime.ActiveScreen.ScreenItems("level_trend")
For i = 0 To 3
a.TrendIndex = i
a.TrendTagName = ""
a.TrendVisible = False
Next
End Sub
Solution 2: Permanent Picture Window Pattern
If you have many trend views and want a single design that survives every navigation, place the trend control inside a permanent picture window that is created at runtime start and never closed. The picture window floats above every other screen and the ScreenItem lifetime becomes application-lifetime rather than screen-lifetime.
- In the TIA Portal graphics designer, add a picture window named
PicTrendon the Start screen (or any permanently resident root screen). Configure Picture =TrendView.pdl, Adapt size = on, Independent window = off, Closable = off. - Inside
TrendView.pdl, place the f(t) trend view. Name itlevel_trend. - To address the trend from any script regardless of the active screen, use the picture window path:
HMIRuntime.Screens("StartScreen").ScreenItems("PicTrend").ScreenItems("level_trend"). - All button scripts that previously used
HMIRuntime.ActiveScreen.ScreenItems("level_trend")must be updated to traverse the picture window path.
This pattern is fully supported in WinCC Professional V13 and later. The trend object is created once at runtime start and persists until the runtime is closed, so the operator's configuration is preserved across every navigation event.
Solution 3: Enable Persistence (TIA Portal V17+)
From TIA Portal V17 onward the trend view exposes a Persistence group of properties. The path is:
- Select the f(t) trend view on the screen.
- Open Properties > Properties > Security > Persistence.
- Enable the persistence properties that match the operator workflow. The exact property names are listed in the f(t) trend view (RT Professional) reference for the target TIA Portal version.
Verification
After applying Solution 1, perform the following checks on the WinCC RT Professional runtime station:
- Compile and download the modified project to the HMI device. Start WinCC RT Professional in Runtime mode.
- Navigate to the trend screen and click the button that adds Data_log_1\Logging_tag_1. Confirm the curve is drawn.
- Navigate to the main screen (screen 1). Wait 5 seconds.
- Navigate back to the trend screen (screen 2). The curve must reappear without clicking the button.
- Repeat the cycle five times to confirm the OnOpen event consistently reattaches the configuration.
- Click "Clear trends". The trend window must be empty on the current screen and on the next entry.
- Configure a different trend and confirm the new tag persists across navigation. The TrendSel_0n tags must reflect the new value.
For Solution 2 (permanent picture window), the verification is similar but simpler: trigger a navigation storm (10+ screen changes) and confirm the trend remains drawn the whole time.
Edge Cases and Field Notes
-
Multiple trend controls on one screen. The OnOpen script must address each control by its full screen path. Use
HMIRuntime.ActiveScreen.ScreenItems("ControlName")when the control is on the active screen, or the picture window path otherwise. - Tag logging restart. If the operator restarts the data log runtime, all SmartTags used for persistence are reset to their initial value. The next OnOpen event will show no trend until the operator reselects. Reset the initial values in the project to match the most common configuration, or design the OnOpen to fall back to defaults.
- Cross-client scenarios. SmartTags are client-local in WinCC Professional multi-client setups. Each client has its own selection array. This is the desired behavior for operator-specific selections, but it is the wrong behavior for global defaults. Use a server-side text list or a PLC tag if a global default is required.
-
Color persistence. VBScript color constants (
vbYellow,vbRed, etc.) are 32-bit integers in the OLE_COLOR format. Store the integer value in the TrendColor_0n tag and apply it witha.TrendColor = CLng(SmartTags("TrendColor_01"))to avoid a type-mismatch warning at runtime. -
Index reuse. Avoid reassigning
TrendIndexfrom a non-sequential set. WinCC expects indices 0..(n-1) for a trend window with n curves. Gaps produce empty rows but the configuration is preserved. -
Tag name format. The
TrendTagNameproperty accepts both the qualified archive name (Data_log_1\Logging_tag_1) and the bare tag name. The qualified form is recommended for clarity and matches the value exposed in the HMI tag browser. - Time base. When the same archive is read from multiple trend controls, configure a single Time base in the project. Mismatched time bases produce visually different curves for the same data.
- Security and operator rights. If the operator account does not have Trend configuration rights, runtime modification of the trend control is rejected. Check User administration > Authorization in TIA Portal if the button script silently fails.
Comparison of Solutions
| Criterion | Solution 1: OnOpen re-attach | Solution 2: Permanent picture window | Solution 3: Persistence property |
|---|---|---|---|
| Minimum TIA Portal version | V13 | V13 | V17 |
| Engineering effort | Low (one event + 4 tags) | Medium (extra picture window + path update in every script) | Low (one property toggle) |
| Runtime overhead | None (event-driven) | Minimal (one extra object) | None |
| Multi-client safe | Yes (per-client tags) | Yes (picture window is per-window-station) | Yes (per-client) |
| Survives project recompile | Yes | Yes | Yes |
| Survives runtime restart | No (selection tags reset) | No (in-memory only) | No (in-memory by default) |
| Suitable for V13 projects | Yes | Yes | No (requires upgrade) |
| Code complexity in scripts | Medium | Medium-High (full path required) | None |
Related Objects with the Same Defect
The same lifetime issue applies to every runtime-configurable object in WinCC Professional. If your project uses any of the following, apply the same pattern:
-
OnlineTrendControl (the WinCC Online Trend Control OCX). Configuration written through
TrendIndex/TrendTagNameis lost on screen change. - OnlineTableControl. Column configuration done at runtime is lost on screen change.
- AlarmControl. Column hiding or sorting applied by a script is lost on screen change.
- FunctionTrendControl. Trend configuration is screen-bound.
For all of these, the same three solutions apply: reapply on OnOpen, host in a permanent picture window, or enable the persistence property in TIA Portal V17+.
Diagnostic Checklist
| Symptom | Most likely cause | Action |
|---|---|---|
| Trend disappears after one navigation | Screen-bound ScreenItem lifetime | Apply Solution 1 or 2 |
| Trend never appears even on first load | Operator lacks configuration rights or archive tag not configured | Check user administration; verify tag logging in TIA Portal |
| Trend appears on the original screen but not on a popped-up screen | Script uses ActiveScreen while trend lives on a different root |
Use full picture window path |
| OnOpen re-attach throws VBScript error | SmartTag name typo or wrong type conversion | Check spelling and CLng on color values |
| Multiple clients show different trends on the same screen | SmartTags are client-local | Move the selection tags to the PLC if global defaults are required |
| Trend fades back to blank after a few seconds | Archive retention is shorter than expected | Check Archive configuration > Sequence and Retention |
Safety and Operational Notes
Trends are observation tools, not safety barriers. Removing a trend during runtime cannot remove a safety function: protective logic must remain in the PLC. Avoid placing the only operator-visible indication of a critical process variable in a screen-bound trend. A bar graph or a numeric I/O field on a permanent root screen is the safer pattern.
If the trend is the primary indication of a controlled variable (level, pressure, temperature), design the OnOpen re-attach to default to the critical tag if the selection array is empty. The default curve appears as soon as the operator opens the trend screen, even if the previous selection was cleared.
FAQ
Why does my WinCC Professional V13 trend disappear when I switch screens?
Because the trend view is a ScreenItem bound to the lifetime of its parent screen. When the screen is closed, the in-memory configuration written by your VBScript is destroyed. WinCC reloads a fresh ScreenItem from the compiled project the next time the screen is opened, and that fresh object has none of the runtime modifications. The historical archive data is intact; only the binding between the trend control and the archive tag is lost.
Does TIA Portal V13 support the Persistence property for the f(t) trend view?
No. The Persistence property group was introduced in TIA Portal V17 and is documented in the f(t) trend view (RT Professional) reference. On V13 you must reapply the trend configuration in the screen's OnOpen event or move the trend into a permanent picture window.
Can I use a single OnOpen script to handle multiple trend controls on the same screen?
Yes. Address each control by name with HMIRuntime.ActiveScreen.ScreenItems("ControlName") and reapply the corresponding TrendIndex, TrendTagName, TrendColor, and TrendVisible values. Loop through an index range or maintain a tag-driven table of selections for clarity.
Is the permanent picture window pattern supported on WinCC RT Professional V13?
Yes. Picture windows with a fixed parent screen and "Closable = off" keep the embedded ScreenItem alive for the entire runtime. This is the cleanest long-term pattern when many trends must survive every navigation. The only cost is updating existing scripts to traverse the picture window path.
What happens to my trend selection if WinCC RT Professional is restarted?
SmartTags used for persistence are reset to their initial value at runtime start, so the trend will revert to the compiled default. To preserve the selection across runtime restarts, write the selection to a PLC tag (DB) and reload it during startup, or accept the reset and have the OnOpen script fall back to a default tag.