Displaying Multiple Trend Curves in WinCC Online Trend Control from Faceplates - C-Script Archive Tag Assignment

Displaying Multiple Trend Curves in WinCC Online Trend Control from Faceplates - C-Script Archive Tag Assignment

When customizing standard or migrated PID controller faceplates in SIMATIC PCS 7 (such as transitioning from PCS 7 V7 classic faceplates to V8.0/V8.2 APL standards), the 'Save & Open Trend' function often displays only a single curve (typically the Process Value PV) on the WinCC Online Trend Control page instead of all three essential control loops (PV, Setpoint SP, and Manipulated Value MV). This occurs because the underlying ANSI-C script assigned to the trend invocation button only configures Trend Curve Index 0. To display multiple curves, the script must explicitly parameterize properties (Index, TagName, and TrendTagName) for each curve index (0, 1, and 2) before rendering the trend window.

Table of Contents

Faceplate Trend Invocation Architecture in PCS 7

In SIMATIC PCS 7, PID controller faceplates (such as CTRL_PID in classic libraries or PIDConL in the Advanced Process Library) provide built-in trend display capabilities. Operators rely on trend displays to observe control loop dynamics by tracking the interaction between the process variable (PV), the setpoint (SP), and the controller output (MV/Out).

When migrating faceplates between PCS 7 versions or customizing trend layouts, engineers frequently adapt the click event script on the 'Open Trend' button within the faceplate picture (@pg_*.pdl). In classic V7 faceplates, trends were often invoked via proprietary C-actions that hardcoded the curve assignment. If this script is ported to PCS 7 V8 without addressing the multi-curve index properties of the modern WinCC Online Trend Control, the control defaults to displaying solely Curve 0, leaving SP and MV unassigned.

WinCC Online Trend Control Object Model and Curve Indexing

The WinCC Online Trend Control (CCAxOnlineTrend) utilizes an indexed property model. To assign an archive tag or online tag to a specific visual line, the programmer must select the curve index first, followed by assigning the corresponding tag name and visual attributes.

Property NameData TypePurposeConfiguration ExampleTrendIndexlongSelects the active curve to configure (0-indexed)0 (PV), 1 (SP), 2 (MV)TrendTagNamechar*Defines the historical archive tag path"SystemArchive\\FIC101.PV_Out#Value"TrendNamechar*Label shown in the trend legend"Process Variable"TrendColorlongRGB line color for the selected curveRGB(0, 255, 0) (Green for PV)TrendVisibleBOOLToggles visibility of the indexed curveTRUETimeRangelongConfigures the default x-axis window duration3600 (Seconds)

If the C-script sets TrendTagName without changing TrendIndex, all tag assignments overwrite Curve 0 in rapid succession, resulting in only the final assigned tag being rendered on the display.

C-Script Modification for Multi-Variable Display (PV, SP, MV)

To configure all three curves dynamically when opening the trend picture, adapt the ANSI-C button action as follows:

#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
    char szTagPrefix[128];
    char szTrendTagPV[256];
    char szTrendTagSP[256];
    char szTrendTagMV[256];
    char* pszTargetPicture = "@Trend_Picture.pdl";
    char* pszControlName = "Control1"; // Name of WinCC Online Trend Control

    // Retrieve current block TagPrefix from faceplate
    GetPropChar(lpszPictureName, lpszObjectName, "TagPrefix", szTagPrefix);

    // Format archive tag names matching Tag Logging SystemArchive
    sprintf(szTrendTagPV, "SystemArchive\\%sPV_Out#Value", szTagPrefix);
    sprintf(szTrendTagSP, "SystemArchive\\%sSP#Value", szTagPrefix);
    sprintf(szTrendTagMV, "SystemArchive\\%sMV#Value", szTagPrefix);

    // Open the Trend Display Window
    SetPictureName(lpszPictureName, "TrendWindow", pszTargetPicture);

    // Configure Curve 0: Process Variable (PV)
    SetPropDouble(pszTargetPicture, pszControlName, "TrendIndex", 0);
    SetPropChar(pszTargetPicture, pszControlName, "TrendTagName", szTrendTagPV);
    SetPropBOOL(pszTargetPicture, pszControlName, "TrendVisible", TRUE);

    // Configure Curve 1: Setpoint (SP)
    SetPropDouble(pszTargetPicture, pszControlName, "TrendIndex", 1);
    SetPropChar(pszTargetPicture, pszControlName, "TrendTagName", szTrendTagSP);
    SetPropBOOL(pszTargetPicture, pszControlName, "TrendVisible", TRUE);

    // Configure Curve 2: Manipulated Variable (MV / Output)
    SetPropDouble(pszTargetPicture, pszControlName, "TrendIndex", 2);
    SetPropChar(pszTargetPicture, pszControlName, "TrendTagName", szTrendTagMV);
    SetPropBOOL(pszTargetPicture, pszControlName, "TrendVisible", TRUE);
}

This explicit index-switching pattern guarantees that the WinCC Trend Control binds each process variable to its independent curve channel.

Verification

Verify the multi-trend faceplate operation using the following procedure:

  1. Tag Logging Archive Verification: In WinCC Explorer -> Tag Logging, verify that the PV, SP, and MV tags for the PID controller are actively archived in SystemArchive.
  2. Faceplate Runtime Test: Open the modified PID faceplate in WinCC Runtime. Click the 'Save & Open Trend' button.
  3. Curve Rendering Check: Verify that the trend window launches and renders three distinct colored curves with independent scales or shared engineering unit axes. Confirm that legend values update dynamically.

Limitations and Operational Precautions

When implementing custom trend scripts, observe these operational safeguards:

  • Tag Prefix Syntax: Ensure that the tag prefix string formatting accounts for trailing slashes or dots depending on whether APL structure tags or classic flat tag naming is used.
  • Archive Naming Consistency: If the process tags are archived in an archive other than SystemArchive (such as a custom fast archive), the archive prefix string must match the exact WinCC Tag Logging archive container name.
  • Template Overwrites: Never modify standard @pg_*.pdl pictures in the global @PCS7Elements directory. Copy the picture into the local project GraCS directory before modifying scripts, preventing standard PCS 7 OS updates from overwriting custom code.

Engineer FAQ

Why does my script cause WinCC Graphics Designer to crash when compiling?

Ensure that string buffers (szTrendTagPV, etc.) have adequate memory allocated (at least 256 bytes) and that pointers passed into SetPropChar are null-terminated. Buffer overruns in ANSI-C scripts will crash pdlrt.exe.

Can I use VBScript instead of ANSI-C for configuring the trend control?

Yes. VBScript provides a cleaner object hierarchy: ScreenItems("Control1").TrendIndex = 0; ScreenItems("Control1").TrendTagName = "...";. However, if the existing faceplate framework is built in ANSI-C, staying in C prevents script engine switching overhead.

How do I configure separate Y-axes for PV and MV (e.g., 0-100% vs 0-500 Deg C)?

Assign different value axes using the TrendValueAxisIndex property. Set TrendIndex = 0, then assign TrendValueAxisIndex = 0. Then set TrendIndex = 2 (MV) and assign TrendValueAxisIndex = 1 referencing a 0-100% percentage axis.

Technical References

Related Articles

Related Tags

  • WinCC Graphics Designer
  • Online Trend Control
  • ANSI-C Script
  • PID Controller
  • APL Faceplates
  • Tag Logging
6 respuestas