Archiving STRING Data Types in SIMATIC PCS 7 - S7_archive Limitations and Alternative Storage Solutions

Archiving STRING Data Types in SIMATIC PCS 7 - S7_archive Limitations and Alternative Storage Solutions

In SIMATIC PCS 7 and S7-SCL, the system attribute 'S7_archive' (used to flag block parameters for automated WinCC Tag Logging cyclic archiving) is strictly restricted by design to elementary numeric and binary data types: BOOL, BYTE, WORD, DWORD, INT, DINT, and REAL. Attempting to assign 'S7_archive := shortterm' or 'longterm' to a STRING data type in SCL source code will result in the attribute being silently deactivated or ignored upon block update in CFC, because WinCC Tag Logging does not support cyclic trend archiving for text strings. To archive string variables (such as batch IDs, serial numbers, or recipe names), engineers must utilize WinCC User Archives, log strings as associated values in WinCC Alarm Logging messages, or export them via WinCC IndustrialDataBridge to an external SQL database.

Table of Contents

The S7_archive System Attribute and Supported Data Types

In SIMATIC PCS 7, technological block interfaces authored in S7-SCL incorporate system attributes that automate human-machine interface (HMI) generation during OS compilation:
- S7_m_c := 'true': Designates the variable for Operator Control and Monitoring (OCM), automatically creating a corresponding WinCC runtime tag.
- S7_archive := 'shortterm' or 'longterm': Flags the variable to be automatically inserted into the WinCC Tag Logging archive during OS compilation, creating an archive tag for trend visualization.

However, the PCS 7 AS-OS compilation engine enforces strict data type validation on S7_archive. The attribute is valid only for elementary scalar types:
- Binary: BOOL
- Bit strings: BYTE, WORD, DWORD
- Integers: INT, DINT
- Floating-point: REAL

If an engineer applies { S7_archive := 'shortterm' } to a STRING[32] variable in an SCL block, the compiler ignores the attribute without throwing a syntax error. Upon updating the block type in CFC, the Archive checkbox on the block I/O properties remains greyed out or unselected.

Why STRING Tags Cannot Be Cyclically Archived in WinCC Tag Logging

The architectural limitation stems from the underlying storage mechanism of WinCC Tag Logging:
- Circular Time-Series Compression: WinCC Tag Logging compresses continuous process telemetry into fixed binary segments using mathematical algorithms (Swinging Door, Boxcar). These compression algorithms operate exclusively on numerical values to calculate slopes, deadbands, and deltas.
- Variable Length Storage: In S7 CPUs, a STRING consists of a 2-byte header (maximum length and actual length) followed by ASCII character bytes. Variable-length textual data cannot be stored in fixed-width circular time-series tables without causing severe database fragmentation and performance degradation.
- Trend Control Rendering: The WinCC OnlineTrendControl displays numeric Cartesian coordinates ($Y$-axis value vs $X$-axis time). It possesses no native graphical capability to render multi-character alphanumeric text strings as a trend line.

Alternative 1: Archiving Text via WinCC User Archives

The standard and most robust solution for storing string data in PCS 7 is WinCC User Archives:
- Structured Relational Storage: User Archives allows creation of custom SQL tables containing alphanumeric text fields (STRING up to 255 characters), integers, timestamps, and floating-point values.
- PLC Synchronization: Data exchange between the S7 controller and User Archives is coordinated via handshake tags (Job_ID, Trigger_Bit, Status_Word).
- Use Cases: Tracking batch identifiers, barcode scan results, operator notes, and material lot numbers alongside process conditions.

Alternative 2: Embedding Strings into Alarm Messages (Associated Values)

When string changes occur intermittently upon specific operational events (e.g., when a recipe changes or a new lot begins), embedding the string into an alarm message provides historical tracking with zero extra licensing:
1. In the SCL block, declare an ALARM_8P instance (FB19).
2. Connect the string variable to one of the associated value inputs (SD_1 to SD_10).
3. In the message configuration in SIMATIC Manager / Process Object View, insert the string placeholder into the Event Text:
text Recipe Loaded: @1%s@
4. When the alarm triggers, WinCC Alarm Logging permanently archives the exact string text into the SQL message database, visible in the historical alarm journal.

Alternative 3: WinCC IndustrialDataBridge / External Database Export

For continuous enterprise reporting where strings must be correlated with enterprise databases:
- Use WinCC/IndustrialDataBridge (IDB) to automatically export string tags cyclically or on event triggers to an external Microsoft SQL Server or CSV file.
- The external database table can use standard NVARCHAR(MAX) columns to store unbounded string data without impacting the OS Server runtime performance.

Technical Comparison: String Storage Solutions in PCS 7

The table below compares methods for archiving text strings in SIMATIC PCS 7:

Storage ArchitectureArchiving MechanismWinCC Trend DisplayLicensing RequirementRecommended Use CaseS7_archive (Tag Logging)Time-Series ArchiveNo (Unsupported)Standard WinCC RTNot Possible for StringsWinCC User ArchivesRelational SQL TablesGrid / Table ViewUser Archives LicenseBatch recipes, lot tracking, QC logsAlarm Logging (SD_x)Historical Alarm JournalAlarm Table ViewIncluded with WinCCEvent-based text logging (SOPs, shifts)IndustrialDataBridgeExternal SQL DatabaseExternal Web / BIIDB Package LicenseEnterprise MES/ERP data exchange

Verification

To confirm that string storage is operating correctly:
1. User Archive Table Inspection: Open the WinCC User Archive table control in runtime; trigger a string write from the AS and verify that the new text record appears with valid timestamp.
2. Alarm Journal Verification: If using ALARM_8P associated values, trigger the block event; open the WinCC Alarm Journal and verify that the %s placeholder resolves to the actual string content.
3. External Database Audit: If using IndustrialDataBridge, execute a SQL query on the external database to verify that string records match the PLC string variable.

Limitations and Operational Precautions

Engineering teams must observe the following constraints:
- Do not attempt to break a string into individual BYTE or CHAR arrays simply to force Tag Logging archiving; this consumes excessive archive tags and produces unreadable trend lines.
- WinCC User Archives standalone is an optional package; ensure the runtime license is installed via Automation License Manager.
- Always validate final license quantities and MLFBs against the applicable Siemens catalog and authorized distributor quotation when ordering WinCC options.

Engineer FAQ

Can a single CHAR variable be archived with S7_archive?

No. While a CHAR represents an 8-bit ASCII value, the AS-OS compiler does not support CHAR types for Tag Logging archiving. If converted to a BYTE, it can be archived as a numeric ASCII code, but WinCC Trend Control will display the number rather than the character.

How many characters can be passed in an ALARM_8P associated value?

An ALARM_8P associated value can transfer a string of up to 32 characters in standard configurations, depending on total message telegram length limitations.

Is Advanced Process Functions (APF) required to use User Archives in PCS 7?

No. User Archives can be used standalone with custom VBS/C scripts or standard User Archive controls. However, PCS 7 APF provides standardized technological blocks that simplify User Archive integration for dosing and material management.

Technical References

Related Articles

Related Tags

  • S7-SCL
  • S7_archive
  • WinCC Tag Logging
  • User Archives
  • String Data
6 respuestas