Overview
When exporting tag data from Siemens WinCC through the Connectivity Pack OLE DB provider, the resulting Recordset exposes five fixed columns: ValueID, TimeStamp, RealValue, Quality, and Flags. Engineers consistently report confusion around the Quality column because the value is delivered as a raw 4-byte integer with no inline documentation. A value of 128 (decimal) is the most common observation and, once converted to hexadecimal (0x80), resolves to Good — the most desirable state, indicating the tag value is reliable and free of acquisition errors.
This reference consolidates the WinCC simplified quality codes, the underlying OPC quality byte layout, the sub-status bits, and the recommended handling logic for VBScript, VBA, C#, and SQL consumers reading tag archives via WinCC OLE DB or the RT/UNO archive providers.
Recordset Schema Reference
| Column | Data Type | Size | Description |
|---|---|---|---|
ValueID |
Integer (VT_I4) | 4 bytes | Unique identifier of the archived value within the archive segment. Use for delta-tracking and re-synchronization. |
TimeStamp |
DateTime (VT_DATE) | 8 bytes | Time the value was logged, in the configured archive time base (UTC by default for SQL archive; local for user archives). |
RealValue |
Double (VT_R8) | 8 bytes | Process value as floating point. Convert with CDbl() or Convert.ToDouble() before scaling. |
Quality |
Integer (VT_I4) | 4 bytes | WinCC quality code (simplified) in decimal. See tables below. 128 = 0x80 = Good. |
Flags |
Integer (VT_I4) | 4 bytes | Internal control parameter. Reserved for WinCC internal use; do not interpret in application code. |
Quality column is delivered as a decimal integer in script languages (VBScript, VBA) but is documented in hexadecimal in the WinCC Information System. Always convert to hex with Hex(quality) before comparing against the canonical code list, or bitwise AND with &HFC to mask the limit-status bits.WinCC Simplified Quality Codes
The following codes are returned in the Quality field of any Recordset produced by the WinCC OLE DB Provider for tag archives, alarms, and the Connectivity Pack CC_AlgRtHmiRuntime interface. The codes conform to the major quality byte of the OPC DA 2.0/3.0 specification.
| Decimal | Hex | Major Quality | Sub-Status | Meaning |
|---|---|---|---|---|
| 0 | 0x00 | Bad | Non-specific | Value is not usable. Source returned no valid data. |
| 4 | 0x04 | Bad | Configuration Error | Tag is misconfigured (wrong address, missing PLC connection, datatype mismatch). |
| 8 | 0x08 | Bad | Not Connected | Communication channel to the PLC is down. Often appears during HMI restart. |
| 12 | 0x0C | Bad | Device Failure | Underlying device (PLC, field instrument) reported a hardware fault. |
| 16 | 0x10 | Bad | Sensor Failure | Sensor is out of range or disconnected. Common with 4–20 mA loops. |
| 20 | 0x14 | Bad | Last Usable Value | Source has failed; last good value retained but flagged. |
| 24 | 0x18 | Bad | Communication Failure | Driver / channel reported a protocol-level error. |
| 28 | 0x1C | Bad | Out of Service | Tag is intentionally disabled in the project. |
| 64 | 0x40 | Uncertain | Non-specific | Value is usable but confidence is lower than normal. |
| 68 | 0x44 | Uncertain | Last Usable Value | Value frozen at last good reading. Typical after PLC stop / run transition. |
| 72 | 0x48 | Uncertain | Substitute Value | Value is a manually entered substitute, not a live reading. |
| 80 | 0x50 | Uncertain | Initial Value | Value is the configured initial value; source has not yet produced real data. |
| 84 | 0x54 | Uncertain | Sensor Not Accurate | Value outside the calibrated accuracy band of the sensor. |
| 96 | 0x60 | Uncertain | Engineering Units Exceeded | Value is outside the configured EU range. Check scaling factors. |
| 100 | 0x64 | Uncertain | Sub-Normal | Value is derived from multiple sources, not from a single primary measurement. |
| 128 | 0x80 | Good | Non-specific | Value is valid, fresh, and trusted. This is the most common code in normal operation. |
| 132 | 0x84 | Good | Local Override | Value has been forced manually by the operator. |
| 192 | 0xC0 | GoodLocal | Override | Value is sourced from the local HMI runtime, not the field device (typical of simulation mode). |
Bit-Level Quality Structure (OPC Mapping)
Although the Recordset returns the simplified byte, the full OPC quality word is 32 bits and follows this structure. The simplified codes above are the most significant byte (bits 31–24) when WinCC writes the full OPC quality word, which matters for clients using the OPC DA / OPC UA tunnel.
| Bits | Field | Values |
|---|---|---|
| 31–30 | Quality | 00 = Bad, 01 = Uncertain, 10 = Good, 11 = GoodLocal |
| 29–24 | Sub-Status | See table above; vendor-specific combinations allowed |
| 23–22 | Limit | 00 = Not limited, 01 = Low limited, 10 = High limited, 11 = Constant |
| 21–16 | Reserved | 0 |
| 15–8 | Vendor | Vendor diagnostic bits (Siemens often = 0) |
| 7–0 | Reserved | 0 |
To extract just the major quality category (Bad / Uncertain / Good) in a script, mask with 0xC0 (192 decimal) and shift right by 6:
major = (quality AND &HC0) \ 64 ' VBScript
major = (quality & 0xC0) >> 6 ' C# / VB.NET
major = (quality & 192) / 64 ' VBA
To extract major + sub-status (the simplified code column), mask with 0xFC (252 decimal) and shift right by 2:
qcode = (quality AND &HFC) \ 2
Where to Find the Official Documentation
Siemens publishes the canonical code list inside the WinCC Information System, the CHM help installed with every WinCC runtime and configuration client. The codes are not duplicated in the Connectivity Pack manual — they live in the shared Communication section. Navigate:
- Start → SIMATIC → WinCC → WinCC Information System (opens the consolidated CHM, including all installed WinCC options).
- Expand Communication.
- Open Communication — Diagnosis.
- Open Quality of Tags.
- Open Quality Codes of Tags — this is the canonical list of simplified codes. Codes are presented in hexadecimal.
The same list appears in the printed WinCC V7.x / WinCC Professional manuals under chapter Communication > Diagnostics > Quality Codes of Tags, and in the WinCC TIA Portal help under WinCC Runtime Professional > Communication > Quality Codes.
Quality Code 128 in Practice
A value of 128 means the tag was successfully polled, the value is within the configured engineering-unit range, the PLC connection is up, no operator override is active, and the archive segment accepted the value without substitution. In production telemetry dashboards this is the “all clear” state and no special handling is required.
Common reasons quality is not 128:
- 0 (Bad) — PLC powered down, S7 connection in OPFAULT, or the tag was removed from the project but the archive table still references it.
- 8 (Bad / Not Connected) — Channel diagnostics show the partner is unreachable. Check NetPro / connection configuration.
- 20 (Bad / Last Usable Value) — Driver is in “freeze last value” mode. Adjust the channel’s “Behavior on failure” setting.
- 64 (Uncertain) — Often a sign of a SIMATIC S7 stop / run transition; some drivers mark values Uncertain during the first scan after a restart.
- 72 (Uncertain / Substitute) — Operator used the “Set/Modify Tag” function to inject a manual value for testing.
- 96 (Uncertain / EU Exceeded) — Raw process value is outside the tag’s configured linear scale (e.g., -32000 to 32000). Investigate scaling or sensor over-range.
- 192 (GoodLocal) — HMI is in simulation mode. Confirm the runtime is talking to the real PLC before trusting the values.
Scripting Examples
VBScript / VBA — safe read for export consumer
Function IsValueUsable(quality)
Dim major, qcode
qcode = (quality And &HFC) \ 2
major = (quality And &HC0) \ 64
Select Case major
Case 3 ' 11 binary = GoodLocal
IsValueUsable = True
Exit Function
Case 2 ' 10 binary = Good
IsValueUsable = True
Exit Function
Case 1 ' 01 binary = Uncertain
IsValueUsable = (qcode <> 36) ' 36 = Initial Value
Exit Function
Case 0 ' Bad
IsValueUsable = False
End Select
End Function
C# / .NET — bitmask helper
public static class WinCCQuality
{
public enum Major { Bad = 0, Uncertain = 1, Good = 2, GoodLocal = 3 }
public static Major GetMajor(int quality)
=> (Major)((quality & 0xC0) >> 6);
public static bool IsUsable(int quality)
=> GetMajor(quality) >= Major.Uncertain
&& ((quality & 0xFC) >> 2) != 18; // 0x48 Substitute
public static string Describe(int quality)
=> $"Q=0x{quality:X2} major={GetMajor(quality)}";
}
SQL — filter archives to “Good only”
SELECT TimeStamp, RealValue, Quality
FROM dbo.Archive_<ProjectName>_LTG_<TagName>
WHERE (Quality & 0xC0) = 0x80 -- Good major
AND (Quality & 0xFC) = 0x80 -- No sub-status bits
AND TimeStamp >= DATEADD(hour, -24, GETUTCDATE());
TIA Portal / WinCC Unified — GraphQL — filter alarms by quality
query LiveQuality {
tags(name: "Tank1_Level") {
value { value quality }
}
}
// quality field returns the same simplified byte: 0x80 = Good
Troubleshooting Matrix
| Observed Quality | Likely Cause | First Check | Remediation |
|---|---|---|---|
| 0 (Bad) on startup | Channel not fully initialized | WinCC Explorer → Channel Diagnosis | Add startup delay or warm-up script. |
| 4 (Bad / Config Error) | Tag address or datatype mismatch | Tag properties → Address | Reassign DB offset; verify S7 data block length. |
| 8 (Bad / Not Connected) | PLC stop / cable fault | Channel diagnostics → State | Check NetPro connection, ping PLC, verify PG/PC interface. |
| 20 (Bad / Last Usable Value) | Driver policy: “Freeze last value” | Channel → Properties → Behavior on failure | Switch to “Initial value” or “Substitute value” if business logic requires. |
| 64 (Uncertain) after PLC restart | S7 RUN/STOP transition | WinCC alarm log → Connection state events | Filter one Uncertain scan, then trust subsequent Good values. |
| 72 (Uncertain / Substitute) | Operator simulation | Operator audit log / “Set tag” actions | Notify control room; require authorization to clear. |
| 96 (Uncertain / EU Exceeded) | Raw value out of range | Tag → Limits → Linear scale | Adjust linear scale or investigate field over-range. |
| 128 (Good) but trending wrong | Quality is fine; scaling is wrong | Tag → Linear scale / Tag → Conversion | Recalculate scale using (RawMax - RawMin) · (EUmax - EUmin)/100. |
| 192 (GoodLocal) in production | HMI in simulation mode | Project → Runtime → Settings → Simulation | Disable simulation on the runtime computer. |
| Quality never 128 even when PLC is healthy | Driver option “Use OPC quality only” unchecked | WinCC Information System → Quality of Tags | Enable “Provide full quality code” in the channel driver settings. |
Channel and Driver Settings That Affect Quality
Two project-level settings change how the simplified quality code is built and forwarded to the archive:
-
SIMATIC S7 Channel → Properties → “Provide full quality code”. When disabled, the channel collapses all sub-status into a single Bad / Uncertain / Good bit. When enabled, the full 8-bit sub-status reaches the archive and is what the connectivity pack then exposes in the
Qualitycolumn. -
Tag → Properties → Limits → “Upper/lower limit”. Crossing a configured high/low limit flips bit 23 (High Limited) or bit 22 (Low Limited) of the full OPC quality word, which in turn changes the simplified code to
0x88(Good + High limited = 136) or0x84(Good + Low limited = 132). Filter these out of compliance reports.
Verification Procedure
- Open the WinCC Information System at Start → SIMATIC → WinCC → WinCC Information System and confirm the CHM build number matches your installed WinCC version (e.g., WinCC V7.5 SP1 Update 4 ships help dated 2021-08).
- In the runtime, open the Tag Management editor and watch the “Quality” column while forcing a Bad condition (cycle PLC power).
- From a VBScript on the same HMI, open a
ADODB.RecordsetagainstCC_AlgRtHmiRuntimeand read theQualitycolumn into the immediate window:? Hex(rs("Quality"))should print80during normal operation. - Cross-check the OPC quality word using an OPC client (e.g., OPC Scout V10) on the same node.
- Document the observed codes per tag; the simplified code list above is the contract your downstream exporter (Power BI, Excel, SQL warehouse) must honor.
Quality is anything other than 0x80 / 0x84 / 0xC0 for interlock logic, SIL-rated calculations, or regulatory batch reporting. Quality codes are diagnostic — treat any non-Good code as a trigger for an operator review.FAQ
What does a Quality code of 128 mean in a WinCC export?
Decimal 128 is hexadecimal 0x80, the simplified WinCC quality code for “Good”. It indicates the tag value is valid, fresh, and was acquired without any error, substitution, or operator override.
Why does the WinCC documentation list quality codes in hex while my script returns decimal?
The WinCC Information System always shows the codes in hexadecimal to match the OPC DA quality byte layout. The OLE DB Recordset delivers them as a 4-byte signed integer in the script’s native decimal format. Convert with Hex(quality) in VBScript/VBA or quality.ToString("X2") in C# before comparing against the documentation.
How do I distinguish Good (0x80) from GoodLocal (0xC0) in an export?
Bitwise AND the value with 0xC0 (192) and shift right by 6. The result is 2 for Good and 3 for GoodLocal. GoodLocal means the HMI is supplying the value from a local source such as simulation or a forced override, not the field device.
Can a Good value (0x80) still be out of range?
Yes. A Good value can carry high or low limit flags in bits 23/22, producing simplified codes 0x88 (136, Good + High Limited) and 0x84 (132, Good + Low Limited). Mask with 0xFC (252) to read the pure major/sub-status, or check the limit bits separately if your application reports on the range itself.
Where in the WinCC Information System is the canonical quality code list?
Navigate to Start → SIMATIC → WinCC → WinCC Information System → Communication → Communication — Diagnosis → Quality of Tags → Quality Codes of Tags. The list is also printed in the WinCC V7.x Communication manual and the TIA Portal help under WinCC Runtime Professional → Communication → Quality Codes.