Configuring Multiple Trend Curves in WinCC Online Trend Control

David Krause16 min read
HMI / SCADASiemensTechnical Reference
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

1. Overview

The WinCC Online Trend Control is a standard HMI/SCADA active-X widget shipped with the WinCC Graphics Designer. A single control instance can render N independent trend curves, each bound to its own tag, color, line type, scaling, and value axis. When the operator or engineer needs to monitor a homogeneous set of process variables – for example 8 furnace-zone temperatures, 10 vibration channels on a compressor, or 30 power-meter readings – the requirement becomes: configure the first curve to the desired look-and-feel, then replicate that configuration across every additional curve without manually re-entering each property.

This reference documents three field-proven methods to propagate trend-curve properties inside a single Online Trend Control, all of them based on the Index property exposed by the control:

  • C script inside the WinCC Global Script Editor for runtime initialization of all curves from one template curve.
  • VBA macro invoked from the Graphics Designer for design-time (PDL) property duplication.
  • VBScript attached to a button event for online edits while the runtime is running.

All three approaches are built on the same underlying mechanism: each property dialog (color, line width, time axis, value axis, archive selector, etc.) is internally redirected to the curve referenced by the Index property (0-based). Writing a script that walks Index from 0 to N-1 and applies the template's parameter set to every index is the canonical solution.

Note: The Online Trend Control is a legacy COM control (OCX) delivered with WinCC V7.x and TIA Portal WinCC Professional / RT Professional. Behavior described here is consistent with WinCC V7.4 SP1 through V7.5 SP2, and with TIA Portal V17..V20 WinCC Runtime Professional. For TIA-only installations without a WinCC installation, see the RT Professional trend and table view documentation.

2. The Online Trend Control Object Model

The control is exposed in the Graphics Designer as a single ActiveX instance named by default WinCC Online Trend Control. Underneath the COM veneer every "curve" is a row in the control's internal TrendCurves collection. The following properties and methods are relevant to property propagation:

Property / Method Type Read/Write Description
Index WORD (0-based) R/W Selects which trend curve the subsequent property dialog (Color, LineType, ValueAxis, …) acts upon.
TrendCurves Collection R Enumerates the curves currently configured in the control.
TagName BSTR R/W (per Index) Process tag whose values populate the currently indexed curve.
Color DWORD (RGB) R/W (per Index) Line color of the indexed curve.
LineType WORD (0..6) R/W (per Index) 0=Solid, 1=Dashed, 2=Dotted, 3=Dash-Dot, 4=Dash-Dot-Dot, 5=…, 6=…
LineWidth WORD R/W (per Index) Pixel width of the indexed curve.
ValueAxis WORD R/W (per Index) Index of the value axis (left/right or 1..N) used for the curve.
RelayCurves WORD R/W Bitmask flagging whether each curve relays its current values back to the archive (1=relay, 0=archive only).
GridLineValue FLOAT R/W Major gridline spacing on the value axis.
CommonY BOOL R/W 1=All curves share the same Y-axis scale; 0=independent axes.
CommonX BOOL R/W 1=Shared time axis; 0=independent (rarely used).
Autorange BOOL R/W (per Index) Auto-scale the value axis of the indexed curve.
TimeRange DOUBLE R/W Visible time window in seconds (e.g. 600 = 10 min).
TimeBase WORD R/W Time-axis base: 0 = time-of-day, 1 = relative.
RulerVisible BOOL R/W Show the on-trend ruler for coordinate readout.
TrendWindow WORD R/W Number of trend windows (sub-panels) the control is split into.

The full list of Trend Control properties is documented in the WinCC Information System under Working with WinCC > Visualizing processes > Displaying process values > Working with controls > WinCC Online Trend Control. Siemens Knowledge Base article 50353471 demonstrates ruler read-out, which uses the same Index-based property dispatch.

3. The Index Property Mechanism – Why It Works

Every property dialog opened on the Online Trend Control contains an internal curve selector. When the engineer selects curve #2 in the dialog and changes the color, the dialog writes the color value to TrendCurves[1].Color. The dialog itself does not store a "selected curve" instance – it stores only the index. This means a C, VBS, or VBA client can implement exactly the same pattern by setting Index first and then writing each property in turn:

Template curve (Index = 0) Read properties (into C struct / dict) Loop i = 1..N-1 SetPropWord Index=i Write each captured property back Bind TagName for curve i

The mechanism is officially documented in WinCC Information System under Online Trend Control > Configuring the Trend Display > Curve Selection. Setting Index is the only way to direct subsequent property writes to a particular curve without enumerating the TrendCurves collection directly (which is not supported in WinCC V7).

4. C Script Method (Global Script Editor)

This is the recommended approach for engineers who maintain a centralized function library in Global Script > C-Editor. The function can be invoked from any PDL on the project, making it ideal for projects with many screens that all need identically-configured trend controls.

4.1 Sample function – CopyTrendCurve

// CopyTrendCurve.cpp - WinCC Global Script (C-Editor)
// Source curve is always Index 0 (the template).
// Target curves are Index 1..N-1. The script copies every relevant
// property of curve 0 onto each subsequent curve, then re-assigns the TagName.
#include "apdefap.h"

void CopyTrendCurve(char* szScreen, char* szTrend, int iCurveCount)
{
    // 1. Snapshot template (Index = 0)
    SetPropWord(szScreen, szTrend, "Index", 0);

    DWORD  dwColor     = GetPropWord(szScreen, szTrend, "Color");
    WORD   wLineType   = GetPropWord(szScreen, szTrend, "LineType");
    WORD   wLineWidth  = GetPropWord(szScreen, szTrend, "LineWidth");
    WORD   wValueAxis  = GetPropWord(szScreen, szTrend, "ValueAxis");
    WORD   wRelayBits  = GetPropWord(szScreen, szTrend, "RelayCurves");
    float  fGridValue  = GetPropFloat(szScreen, szTrend, "GridLineValue");
    BOOL   bCommonY    = GetPropBool(szScreen, szTrend, "CommonY");
    BOOL   bAutorange  = GetPropBool(szScreen, szTrend, "Autorange");

    // 2. Replay onto curves 1 .. iCurveCount-1
    for (int i = 1; i < iCurveCount; i++)
    {
        SetPropWord (szScreen, szTrend, "Index",       (WORD)i);
        SetPropWord (szScreen, szTrend, "Color",       dwColor);
        SetPropWord (szScreen, szTrend, "LineType",    wLineType);
        SetPropWord (szScreen, szTrend, "LineWidth",   wLineWidth);
        SetPropWord (szScreen, szTrend, "ValueAxis",   wValueAxis);
        SetPropWord (szScreen, szTrend, "RelayCurves", wRelayBits);
        SetPropFloat(szScreen, szTrend, "GridLineValue", fGridValue);
        SetPropBool (szScreen, szTrend, "CommonY",     bCommonY);
        SetPropBool (szScreen, szTrend, "Autorange",   bAutorange);
    }

    // 3. Restore selection to the template curve
    SetPropWord(szScreen, szTrend, "Index", 0);
}

4.2 Assigning 8 temperature tags

// Called from a PDL open-event, e.g. "OnOpen" of screen "Trend_8Temperatures.pdl"
void OnOpen_PDL()
{
    const int N = 8;
    char* szScreen = "Trend_8Temperatures.pdl";
    char* szTrend  = "Trend_Control";

    // (1) Build the curve set – assumes TrendCurves 0..7 already exist
    //     and curve 0 is the fully-styled template.
    CopyTrendCurve(szScreen, szTrend, N);

    // (2) Re-bind TagName for curves 1..7 only
    char* taglist[8] = {
        "TEMPLATE_DO_NOT_BIND",   // curve 0 stays as visual reference
        "Furnace1_Temp",          // curve 1
        "Furnace2_Temp",          // curve 2
        "Furnace3_Temp",          // curve 3
        "Furnace4_Temp",          // curve 4
        "Furnace5_Temp",          // curve 5
        "Furnace6_Temp",          // curve 6
        "Furnace7_Temp"           // curve 7
    };

    for (int i = 1; i < N; i++)
    {
        SetPropWord(szScreen, szTrend, "Index", (WORD)i);
        SetPropChar(szScreen, szTrend, "TagName", taglist[i]);
    }
    SetPropWord(szScreen, szTrend, "Index", 0);
}

4.3 Parameter glossary for SetProp*/GetProp*

Function Data type WinCC type Used for
SetPropWord unsigned short WORD / INT Index, Color, LineType, LineWidth, ValueAxis, RelayCurves
SetPropFloat float REAL GridLineValue, MinY, MaxY, TimeRange
SetPropBool int (0/1) BOOL CommonY, CommonX, Autorange, RulerVisible
SetPropChar char* BSTR TagName, Caption, ServerName
GetProp* mirrors the setter — Read-back for template snapshot
Note on SetPropChar: In WinCC V7.5 the macro is SetPropChar; in earlier versions (V7.0..V7.3) the legacy name SetText is used. Functionally identical. Always confirm against the header file apdefap.h in your installed WinCC.

5. VBA Method (Design-Time, Graphics Designer)

Use VBA when the requirement is to build the PDL with N curves in the Graphics Designer and have all curves written into the picture file (so that the configuration survives a CS upgrade or a runtime re-installation). VBA operates on the in-process WinCC Graphics Designer automation model; it is the only way to perform mass property edits at design time without opening the property dialog 8 times.

5.1 Macro – DuplicateTrendCurves

' WinCC Graphics Designer - Tools > Macros > Visual Basic Editor
' Paste into a new module: "TrendMacros.bas"

Public Sub DuplicateTrendCurves(ctrlName As String, nCurves As Integer)
    Dim hm As HMIGO ' WinCC HMIGO automation handle (provided by WinCC VBA ext)
    Dim trend As Object
    Set trend = Application.ActiveDocument.HMIObjects(ctrlName)

    Dim i As Integer
    Dim colorRef As Long, lineTypeRef As Long, lineWidthRef As Long
    Dim valAxisRef As Long, gridValRef As Double, relayRef As Long

    ' Snapshot template (Index = 0)
    trend.Index = 0
    colorRef    = trend.Color
    lineTypeRef = trend.LineType
    lineWidthRef = trend.LineWidth
    valAxisRef  = trend.ValueAxis
    gridValRef  = trend.GridLineValue
    relayRef    = trend.RelayCurves

    ' Replay
    For i = 1 To nCurves - 1
        trend.Index = i
        trend.Color        = colorRef
        trend.LineType     = lineTypeRef
        trend.LineWidth    = lineWidthRef
        trend.ValueAxis    = valAxisRef
        trend.GridLineValue = gridValRef
        trend.RelayCurves  = relayRef
    Next i
    trend.Index = 0
End Sub

5.2 Macro execution

  1. Open the target PDL in the Graphics Designer.
  2. From the menu choose Tools > Macros > Visual Basic Editor (Alt+F11).
  3. Insert > Module, paste the code above, save the module as TrendMacros.bas.
  4. Back in the Graphics Designer, ensure the trend control has already had N curves added manually (curves are not creatable through VBA in WinCC V7; they must be pre-created or the macro can call a C-script helper).
  5. Run the macro: Tools > Macros > Run, pick DuplicateTrendCurves, supply "Trend_Control" and 8.
  6. Save the PDL. The curve properties are now persisted in the picture file.
Note: VBA cannot create new curve entries inside a trend control from scratch in WinCC V7.x – you must pre-add them via the property dialog or a C-script at startup. TIA Portal WinCC Professional / RT Professional, however, exposes the trend view as a fully scriptable COM object in TIA V17..V20 (see RT Professional trend and table view).

6. VBScript Method (Runtime, button event)

For operators who want to clone the current trend configuration at runtime – for example to swap the 8 temperature tags to 8 vibration tags without restarting the runtime – use VBScript attached to a button event:

' WinCC Graphics Designer - Button "Reconfigure" - Event > Mouse Click > VBS Action
' Re-bind all 8 curves to a different tag family.

Dim screenName, ctrlName
screenName = "Trend_8Temperatures.pdl"
ctrlName   = "Trend_Control"

Dim newTags(7)
newTags(0) = "Vib_Motor_1"
newTags(1) = "Vib_Motor_2"
newTags(2) = "Vib_Motor_3"
newTags(3) = "Vib_Motor_4"
newTags(4) = "Vib_Motor_5"
newTags(5) = "Vib_Motor_6"
newTags(6) = "Vib_Motor_7"
newTags(7) = "Vib_Motor_8"

' Snapshot the visual properties of curve 0 (template)
Dim tColor, tLineType, tLineWidth, tValueAxis, tGrid
tColor    = HMIRuntime.Tags("@TREND_" & ctrlName & "_Color").Read       ' indirect read - placeholder
' In VBS you can also call:
tColor    = ScreenItems(ctrlName).Color       ' if control is on the active screen
tLineType = ScreenItems(ctrlName).LineType
tLineWidth = ScreenItems(ctrlName).LineWidth
tValueAxis = ScreenItems(ctrlName).ValueAxis
tGrid     = ScreenItems(ctrlName).GridLineValue

Dim i
For i = 0 To 7
    ScreenItems(ctrlName).Index = i
    ScreenItems(ctrlName).TagName = newTags(i)
    ' Reapply template properties
    ScreenItems(ctrlName).Color         = tColor
    ScreenItems(ctrlName).LineType      = tLineType
    ScreenItems(ctrlName).LineWidth     = tLineWidth
    ScreenItems(ctrlName).ValueAxis     = tValueAxis
    ScreenItems(ctrlName).GridLineValue = tGrid
Next
ScreenItems(ctrlName).Index = 0
Tip: In TIA Portal V20, the equivalent property access uses the same names but operates on the modernized trend view. The property Copy lines in the runtime table view (see RT Professional trend/table documentation) exports selected rows to the clipboard, which can then be pasted into Excel for historical review.

7. Color and Line Type Reference

LineType Constant Visual Recommended use
0 Solid — Primary process variable
1 Dashed - - - Secondary PV, setpoints
2 Dotted . . . . Limits, thresholds
3 Dash-Dot - . - . Reference values
4 Dash-Dot-Dot - . . - Reserved / alarms

For 8-color curves the standard Microsoft Office 2016+ palette is recommended to maintain adequate contrast on black and white printers:

Curve # R G B Hex
1 31 119 180 0x1F77B4
2 255 127 14 0xFF7F0E
3 44 160 44 0x2CA02C
4 214 39 40 0xD62728
5 148 103 189 0x9467BD
6 140 86 75 0x8C564B
7 227 119 194 0xE377C2
8 188 189 34 0xBCBD22

8. Workflow Checklist for the 8-Temperature PDL

  1. Pre-flight. Verify WinCC V7.4 SP1 or later is installed and the trend control licence is present (WinCC/RC license, not just WinCC/CS).
  2. Create the PDL. In the Graphics Designer, insert a WinCC Online Trend Control, name it Trend_Control, size it to the screen.
  3. Add curves. In the property dialog open the Curves tab, add 8 curve entries. Configure curve 1 (Index 0) entirely – color, line type, width, time axis, value axis, archive selector, trigger tag.
  4. Author the C script. Open Global Script > C-Editor, paste CopyTrendCurve into a new project function, compile.
  5. Wire the script. Open the PDL, on the picture's Open event attach a C action calling CopyTrendCurve("Trend_8Temperatures.pdl","Trend_Control",8) followed by the tag-list re-binding.
  6. Compile the PDL. Use File > Check > Compile to detect syntax errors before activating runtime.
  7. Activate runtime. Start WinCC Runtime, navigate to the PDL, verify all 8 curves appear with identical visual properties but distinct tags.
  8. Validate. Right-click the trend, choose Online Configuration, and confirm curves 2..8 show the same Y-axis range, color, and line width as curve 1.
  9. Archive validation. Open the Tag Logging editor and confirm the 8 tag archives are correctly selected for each curve's archive-selector property.
  10. Ruler readout. Right-click the trend and toggle the ruler. Use the technique in Siemens Knowledge Base 50353471 to script the readout if it must be exported.

9. Verification Procedure

Verification consists of three checks:

  1. Visual check. At runtime the 8 curves must be visually identical in style except for color and tag values. Place a ruler at a known time and verify each curve reports the expected value.
  2. Diagnostic dump. In the C-Editor add a temporary line:
    printf("Curve %d Color=%u LineType=%u ValueAxis=%u\r\n", i, GetPropWord(...,"Color"), GetPropWord(...,"LineType"), GetPropWord(...,"ValueAxis"));
    Capture the WinCC diagnostic window output (Alt+PrtSc on the diagnostics viewer) and confirm the values for curves 2..8 match curve 1.
  3. Clipboard round-trip (optional). Right-click the trend, choose Copy (available since WinCC V7.3). The clipboard receives the values for all traces; paste into Notepad or Excel to compare the timestamps. The clipboard mechanism is described in Geo SCADA documentation for analogous trend export behavior, and in EcoStruxure Building Operation for trend log export – the WinCC Online Trend Control behaves identically: Edit > Copy or right-click Copy places tab-separated (curve/timestamp/value) rows on the clipboard.

10. Troubleshooting Matrix

Symptom Likely cause Diagnostic step Fix
All curves have the same color or the same tag Index not being set inside the loop, or template is being read while writing Add a printf inside the loop to print i and the color written Move the SetPropWord(..., "Index", i) call to the top of each iteration
Curve 0 changes when curves 1..N are modified Index is left at the last written value Inspect the trend after PDL close Reset Index = 0 at the end of the script
No curves appear in runtime The trend control has zero curve entries; the script cannot create them Check the property dialog in the Graphics Designer Manually pre-add N curves; do not rely on the script to create them
VBA macro fails with "Object variable not set" The PDL has not been saved after adding curves Verify Application.ActiveDocument points to the saved PDL Save PDL, then run the macro
Tag name shows in red text on the trend Tag does not exist or is not available to the runtime server Open Tag Simulation or the Tag Logging editor Create the tag, restart tag management, reactivate runtime
Curves render at the same Y scale even though different ranges are expected CommonY = 1 was inherited from the template Inspect CommonY in the script Set CommonY = 0 in the loop or configure per-curve ValueAxis with explicit min/max
Visual layout shifts after closing and re-opening the PDL The script only ran at OnOpen; picture file was saved before the script ran in runtime Examine PDL file timestamp Save the PDL only after the script has executed in runtime (use an output dialog or separate "initialize" PDL)
GetPropWord returns 0 even though the value was set Wrong function name (legacy vs. new API) Compile and check the header file Use the function names appropriate to the WinCC version: GetPropWord/GetPropFloat/GetPropBool/GetPropChar

11. Cross-Platform Notes (TIA Portal / RT Professional)

Engineers migrating WinCC V7 PDLs to TIA Portal V17..V20 should note the following differences when copying curve properties between trend views:

  • The TIA WinCC RT Professional Trend View and Trend/Table View expose an Automation Interface where the same property names exist but the curve collection is accessible through HMIGO.TrendView.TrendArea.TrendCurves instead of being hidden behind an Index property.
  • RT Professional supports a runtime Copy lines command in the trend/table view – the selected table rows (timestamps + values) are placed on the clipboard and can be pasted into Excel. This is documented at the TIA Portal V20 documentation portal.
  • RT Professional does not support the legacy SetPropWord C-API. The equivalent in TIA is the WinCC Unified / Professional JavaScript API, e.g.:
    HMIRuntime.UI.SysFct.TrendView_SetProperty(lpszPictureName, "TrendView_1", "Index", 0);
  • The clipboard mechanism for runtime trend export is conceptually identical to WinCC V7's Copy command and to the Schneider Electric Geo SCADA clipboard export – all three platforms produce a tab-separated rows of timestamp, curve1, curve2, …, curveN.

12. Field-Proven Caveats

  • CS upgrade wipes runtime-only properties. If the C script that propagates properties runs only on OnOpen in runtime (not at picture compile), a WinCC Configuration Studio re-deployment will discard the runtime values. Either re-run the C script after every CS deploy, or commit the values into the picture file by running the script in the Graphics Designer before saving the PDL.
  • Tag list order must match the curve order. The tag binding loop in section 4.2 assumes that curves 1..7 are physically the 2nd..8th entries in the control. If a colleague has reordered curves in the dialog, the binding will mis-align. Always re-bind by curve index, not by name.
  • RelayCurves is a bitmask, not a per-curve boolean. Writing SetPropWord(..., "RelayCurves", 1) in a loop for each curve will overwrite all bits. Use RelayCurves = (1 << i) or pre-compute the final bitmask once and apply it identically to every curve.
  • VBA cannot save if a project function has a compile error. Run a full Check > Compile before invoking VBA macros.
  • Ruler readout in WinCC V7.0..V7.2. The output window for ruler coordinates must be enabled via the registry key HKLM\SOFTWARE\Siemens\WinCC\RT\TrendControl\RulerOutput (DWORD = 1). Knowledge Base 50353471 lists the exact procedure.

How do I copy properties from one WinCC Online Trend Control curve to another?

Use the Index property to select the target curve, then write each property (Color, LineType, LineWidth, ValueAxis, RelayCurves, GridLineValue, CommonY, Autorange). The recommended approach is a C script in the Global Script Editor: SetPropWord(szScreen, szTrend, "Index", i); followed by SetPropWord/GetPropFloat/SetPropBool for every parameter. This avoids opening the property dialog eight times.

Can the C script automatically create new curves in the trend control?

No. In WinCC V7 the TrendCurves collection cannot be expanded through the scripting API. Add the desired number of curves manually through the Graphics Designer property dialog, then use the C script to propagate properties onto them. In TIA Portal RT Professional V17..V20 the trend view does expose a scriptable curves collection.

Does VBA in the Graphics Designer let me modify a trend control at design time?

Yes. Open the VBA editor (Alt+F11) from the Graphics Designer, reference the trend control via Application.ActiveDocument.HMIObjects("Trend_Control"), set .Index, and assign the same property values. The changes are persisted into the .pdl file when the picture is saved.

Why do all 8 curves render with the same color after my copy script?

Almost always because the Index setter call is missing or placed after the property writes inside the loop. The setter must be the first statement of each iteration. Diagnostic: add a printf("i=%d Color=%u\r\n", i, GetPropWord(...,"Color")); after the writes to confirm the values actually land on the intended curve.

What is the difference between RelayCurves and TrendCurves?

RelayCurves is a single WORD-sized bitmask where bit N corresponds to curve N; setting bit N to 1 enables the curve to relay its current value back to the connected PLC peer (used for soft-PLC cross-traffic). TrendCurves is the read-only collection of curve entries themselves. They are independent properties and must not be confused.

How do I export the trend values to Excel at runtime?

In WinCC V7.3 and later, right-click the trend and choose Copy; the data for every trace is placed on the clipboard as tab-separated rows (timestamp, value1, value2, …). Paste into Excel. TIA Portal V20 RT Professional offers an equivalent Copy lines command in the trend/table view.

Back to blog