Decompressing WinCC TagCompressed Archive Segments (BinValues) Without Original Project

Decompressing WinCC TagCompressed Archive Segments (BinValues) Without Original Project

WinCC SQL archive segments (.mdf/.ldf) store historical process data as proprietary compressed binary BLOBs in the TagCompressed.BinValues column that cannot be decoded by raw SQL. To extract readable timestamps and engineering values into CSV or Excel without the original project, attach the database files to a system equipped with the WinCC OLE-DB Provider (via WinCC/Connectivity Pack or DataMonitor) and query data via ADO.

Table of Contents

Forensic Data Recovery and Binary Compression Architecture

In process forensic audits, equipment warranty claims, or plant litigation, engineering consultants often receive standalone Microsoft SQL Server database files:
* Primary data file: ArchiveName.mdf
* Transaction log file: ArchiveName.ldf
* Origin: SIMATIC PCS 7 / WinCC Tag Logging historical archive segments.
* Constraint: The originating engineering multiproject, source graphics, and WinCC project files (.mcp) are unavailable.

When an analyst attaches these files to a standard Microsoft SQL Server instance (using SQL Server Management Studio) and queries the historical tables, they find that instead of standard relational rows with floating-point values, data is stored inside a table named TagCompressed. Inside this table, the column BinValues contains dense binary large objects (BLOBs) consisting of raw hexadecimal streams.

Standard SQL queries such as SELECT Timestamp, BinValues FROM TagCompressed yield unreadable hexadecimal strings. The analyst requires a method to transform these binary archives into plain CSV or Excel tables containing exact UTC timestamps, floating-point process values, and quality codes.

Why Raw SQL Queries Fail on TagCompressed Tables

The inability of standard database tools to unpack historical values stems from Siemens proprietary compression algorithms:

  1. Swinging Door and Delta-Time Binary Compression:
    * To achieve high-speed logging (thousands of values per second) without saturating hard disk throughput, WinCC Tag Logging does not write individual SQL rows for each sample.
    * Instead, WinCC packages time-series blocks into compressed binary buffers (typically representing 1 minute to 1 hour of data per tag) containing header metadata, reference baselines, delta timestamps, and bit-packed floating-point increments.

  2. The Role of the WinCC OLE-DB Provider:
    * The decompression algorithm is embedded exclusively inside the WinCC OLE-DB Provider (WinCCOleDBProvider.dll).
    * When queried using WinCC OLE-DB syntax (TAG:R,...), the provider reads the binary BLOBs from TagCompressed.BinValues, parses the proprietary byte streams in RAM, reconstructs the time-series curve, and returns a standard relational schema with columns:

    • Timestamp (UTC DateTime)
    • RealValue (Double / Float)
    • Quality (Hexadecimal Status / Quality Code)
    • Flags (System Flags)
  3. Software Package Requirements:
    * Access to the WinCC OLE-DB Provider without running the full WinCC SCADA runtime requires one of two Siemens software packages:

    • SIMATIC WinCC / Connectivity Pack
    • SIMATIC WinCC / DataMonitor

Step-by-Step Data Extraction and Decompression Workflow

1. Attach Raw Archive Segments in SQL Server

  1. Copy ArchiveName.mdf and ArchiveName.ldf to the SQL Server data directory.
  2. In SQL Server Management Studio (SSMS), execute the attachment script:
    sql EXEC sp_attach_db @dbname = N'Archive_Segment_01', @filename1 = N'C:\WinCC_Data\ArchiveName.mdf', @filename2 = N'C:\WinCC_Data\ArchiveName.ldf';
  3. Inspect table ArchiveTagCatalog inside the attached database to view the internal TagID mappings corresponding to process tag names.

2. Prepare the Extraction Station

  1. Deploy a workstation running Windows with WinCC Connectivity Pack Client installed.
  2. Ensure the WinCC OLE DB Provider is registered.
  3. Verify that the SIMATIC WinCC/Connectivity Pack license is present in Automation License Manager.

3. Query Decompressed Data Using ADO / VBScript or Python

Create an extraction script that queries the attached archive segment via ADODB using the WinCC OLE-DB Provider:

Dim conn, rs, connStr, sqlQuery
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

' Connect to the attached SQL database catalog via WinCC OLE-DB
connStr = "Provider=WinCCOLEDBProvider.1;Catalog=Archive_Segment_01;Data Source=.\WINCC"
conn.Open connStr

' Query decompressed tag data across time boundary
sqlQuery = "TAG:R,(1;2;3),'2016-01-01 00:00:00.000','2016-01-02 00:00:00.000'"
rs.Open sqlQuery, conn

' Export to CSV file
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("C:\WinCC_Data\Exported_Data.csv", True)
outFile.WriteLine "TagID,Timestamp,Value,Quality"

Do While Not rs.EOF
    outFile.WriteLine rs("TagID") & "," & rs("Timestamp") & "," & rs("RealValue") & "," & rs("Quality")
    rs.MoveNext
Loop

outFile.Close
rs.Close
conn.Close

4. Alternative: Siemens Extended Technical Support

If your organization does not possess a WinCC Connectivity Pack license or an active WinCC engineering environment:
* Siemens Industry Customer Support offers an Extended Technical Support consulting service.
* Engineers can submit raw .mdf/.ldf segments to Siemens support specialists who decompress and convert the binary archives into customer-specified CSV or Excel datasets for an hourly professional service fee.

WinCC Data Extraction Architecture Comparison

Extraction MethodSoftware Tools RequiredDecodes BinValues?Original Project Needed?Typical Use CaseDirect SQL Query (SELECT)SQL Server Management StudioNo (Raw Hex Bytes Only)NoDatabase size auditing; cannot read valuesWinCC OLE-DB ProviderWinCC/Connectivity Pack or DataMonitorYes (Full Engineering Values)No (Only needs .mdf/.ldf)Forensic data analysis, reporting, historical auditsWinCC Tag Logging ExportFull WinCC Runtime SystemYesYes (Requires .mcp project)Standard plant operational data exportSiemens Extended SupportExternal Service EngagementYesNoOne-off forensic analysis without software investment

Verification

  1. Run the ADO extraction script against the attached database segment.
  2. Confirm the generated Exported_Data.csv contains human-readable timestamps and decimal values (e.g. 2016-01-01 04:15:30.125, 45.82, 16#80).
  3. Cross-reference the extracted values against known plant physical limits (e.g., tank capacity, temperature ranges).
  4. Verify that Quality Code 16#80 (Good) is maintained across valid operational records.

Limitations and Operational Precautions

  • Missing Tag Catalog Names: In standalone .mdf segments, tag names may be referenced only by numeric TagID. If ArchiveTagCatalog is unreadable or truncated, you must identify process variables by correlating TagID with electrical P&ID loop sheets.
  • Database File Version Compatibility: An .mdf file generated by WinCC V7.3 (SQL Server 2008 R2) cannot be attached to an older SQL Server 2005 instance. Always attach to an identical or newer SQL Server version.
  • Commercial and Licensing Compliance: The WinCC OLE DB Provider is commercially licensed under WinCC/Connectivity Pack (6AV6371-1DH07-3AX0). Using the provider in production without appropriate licensing violates Siemens End User License Agreements.

Engineer FAQ

Can I decompress BinValues using a custom C# or Python script without Siemens software?

No. The exact mathematical compression algorithm and bit-packing layout utilized in WinCC BinValues is proprietary and unpublished. External applications must invoke the WinCC OLE-DB Provider.

What is the difference between fast and slow archive segments?

Fast archives store high-frequency cyclical samples (< 1 minute), while slow archives store aggregated, compressed, or long-cycle data. Both utilize the same underlying TagCompressed schema.

How do I find which TagID corresponds to my instrument tag?

In SQL Server Management Studio, execute: SELECT * FROM ArchiveTagCatalog or query table CC_ArchiveTag inside the attached database segment.

Technical References

Related Articles

Related Tags

  • TagCompressed
  • BinValues
  • Connectivity Pack
  • OLE-DB
  • SQL Server
  • Forensic Analysis
6 respuestas