Integrating .NET Windows Forms Chart Controls into SIMATIC PCS 7 WinCC Displays

Integrating .NET Windows Forms Chart Controls into SIMATIC PCS 7 WinCC Displays

In SIMATIC PCS 7 WinCC Graphics Designer, embedding Microsoft .NET Windows Forms controls—such as the Microsoft Chart Control for normal distribution histograms—often results in blank runtime windows due to 32-bit container execution constraints, uninitialized control properties, or missing Global Assembly Cache (GAC) registrations. Successfully displaying .NET charts requires parameterizing the control via VBScript during the OpenPicture event or utilizing the native WinCC Function Trend Control.

Table of Contents

Architecture of .NET Control Hosting in 32-Bit WinCC Runtime

Engineers often need advanced statistical visualizations (such as Gaussian normal distribution bell curves, histograms, or Six Sigma charts) that exceed basic bar graphs. In SIMATIC PCS 7 WinCC Graphics Designer:
* The graphic canvas supports embedding ActiveX controls, OLE objects, and .NET Windows Forms Controls (via the .NET Controls palette).
* Container Architecture: WinCC runtime (PdlRT.exe) operates as a 32-bit native Windows process. When hosting a .NET assembly, it initializes the Microsoft Common Language Runtime (CLR) via a COM-to-.NET interop bridge.
* While controls like System.Windows.Forms.DataVisualization.Charting.Chart render properties at design time in Graphics Designer, they do not automatically persist dynamic dataset arrays without runtime initialization scripts.

Root Causes of Blank Windows: Design-Time vs. Runtime Execution

When an engineer places a Microsoft Chart Control on a .pdl picture and activates runtime, the control frequently renders as an empty gray rectangle:
1. Lack of Runtime Data Binding: Unlike standard WinCC APL controls that bind directly to S7 tag structures, .NET controls do not natively read WinCC tag variables without custom script code.
2. Missing Series Initialization: The series, chart areas, and point collections defined in Graphics Designer property dialogs may fail to serialize into the binary PDL storage if the assembly lacks complete COM-serialization interfaces.
3. Bit Depth and Security Trust: If the .NET assembly was compiled for 64-bit architecture (x64) or targets an uninstalled .NET framework version, the 32-bit WinCC runtime host fails to load the assembly.
4. Assembly Registration in GAC: If the target assembly is not registered in the Windows Global Assembly Cache (GAC) on the runtime client, Windows blocks execution.

Implementation Workflow: Initializing Microsoft Chart Control via VBScript

To reliably display a normal distribution histogram using the .NET Chart Control:
1. Verify Assembly Availability: Ensure System.Windows.Forms.DataVisualization.dll (.NET Framework 4.x) is installed in the GAC or placed in the WinCC bin/ directory.
2. Insert Control in Graphics Designer:
* Open the target picture in Graphics Designer.
* Under Controls, select .NET Controls -> Chart. Drag the control onto the canvas and name it Chart_NormalDist.
3. Configure Runtime Script Initialization:
* Select the picture background, open Object Properties, and navigate to Events -> Picture Object -> Miscellaneous -> Open Picture.
* Add a VBScript action to programmatically define chart areas and inject data points upon screen load:

Dim objChart, i, x, y, mean, stdDev
Set objChart = ScreenItems("Chart_NormalDist")

' Configure Chart Area and Series
objChart.Series.Clear
objChart.Series.Add "NormalDistribution"
objChart.Series("NormalDistribution").ChartType = 3 ' 3 = SplineArea / Column
objChart.Series("NormalDistribution").Color = RGB(0, 120, 215)

mean = 50.0
stdDev = 10.0

' Generate Gaussian curve points
For i = 20 To 80 Step 2
    x = CDbl(i)
    y = (1.0 / (stdDev * Sqr(2 * 3.14159))) * Exp(-0.5 * ((x - mean) / stdDev) ^ 2)
    objChart.Series("NormalDistribution").Points.AddXY x, y * 1000
Next

Set objChart = Nothing
  1. Save the picture and activate runtime. The script executes on screen load and dynamically generates the Gaussian curve.

Native Alternatives: WinCC Function Trend Control (f(x)) vs. HTML5/WebBrowser

Because third-party .NET controls introduce maintenance overhead across OS client migrations, Siemens recommends two native alternatives:
* WinCC Function Trend Control ($f(x)$): The built-in WinCC control natively plots one process variable against another ($Y = f(X)$) or plots arrays from S7 data blocks without script overhead.
* WinCC WebBrowser Control (HTML5): Place the native WinCC WebBrowser control on the screen and point it to an internal HTML5/JavaScript dashboard using Chart.js or D3.js. This provides modern styling while eliminating .NET interop issues.

Verification

  • Activate WinCC runtime on the operator station.
  • Open the graphic screen: verify that the .NET Chart Control renders a smooth, color-filled Gaussian distribution curve.
  • In APDIAG Output Window, confirm that no VBScript runtime exceptions or COM interop faults are logged.
  • Close and re-open the screen across multiple clients: confirm that memory usage remains stable without GDI handle leaks.

Limitations and Operational Precautions

  • Third-party .NET controls must be compiled targeting the 32-bit x86 architecture to match the 32-bit WinCC runtime engine (PdlRT.exe).
  • Ensure all OS clients in the control room have the identical .NET Framework version and Chart assemblies installed.
  • Modifying .NET chart properties with high-frequency cyclic timers (e.g., 100 ms) will saturate client CPU cores; update statistical charts on demand or on batch completion.

Engineer FAQ

  • Why does the .NET Chart control display in Graphics Designer but appear empty in runtime?
    Design-time rendering uses Visual Studio designers; runtime requires explicit script data binding to populate series points.
  • What bit architecture does WinCC runtime require for .NET controls?
    WinCC Picture Runtime (PdlRT.exe) is a 32-bit application; all hosted .NET assemblies must support 32-bit execution.
  • Where should third-party .NET DLLs be stored on a WinCC workstation?
    In the Windows Global Assembly Cache (GAC) or in the WinCC installation directory under C:/Program Files (x86)/Siemens/WinCC/bin/.
  • Can the WinCC Function Trend Control display histograms without .NET?
    Yes, the native WinCC Function Trend Control plots X-Y curves directly from tag arrays without third-party dependencies.
  • What VBScript event is recommended to initialize .NET control data?
    The Open Picture event of the host .pdl screen.
  • How do I pass an array of data points from an S7-400 DB to the .NET Chart?
    Read the data block array into WinCC as a raw tag or structured tags, unpack in VBScript, and call Points.AddXY.
  • Can I use .NET controls on Web Navigator clients?
    No, WinCC Web Navigator thin clients do not support Windows Forms .NET controls; use standard WinCC controls or WebViewer HTML5.
  • What happens if an OS client PC lacks the required .NET assembly?
    The picture window will open, but the area containing the control will display an empty white box with a red cross (crash marker).
  • Does using .NET controls consume WinCC Process Objects?
    No, controls are graphical visualization elements and do not consume process object licenses.
  • How do I prevent GDI leaks when updating .NET charts dynamically?
    Always call Series.Clear or update existing point values in place before repopulating point collections.

Technical References

  • SIMATIC HMI WinCC V7.5 Graphics Designer Manual
  • Microsoft .NET Framework Windows Forms DataVisualization Guide
  • Siemens Industry Online Support Entry: Using .NET Controls in WinCC (Entry ID 299227)
  • SIMATIC PCS 7 OS Process Control System Operating Manual

Related Articles

Related Tags

PCS 7, WinCC, .NET Controls, Chart Control, Graphics Designer, VBScript, Histogram, Function Trend Control, PdlRT, Visualization

20 respuestas