1. Problem Definition and Engineering Goal
Pharmaceutical, water/wastewater, and food-and-beverance plants governed by FDA 21 CFR Part 11, EU GMP Annex 11, or ISA-88 batch standards require the HMI to log both the incoming and outgoing timestamps of every operator-relevant alarm. In addition, when the alarm is generated by an analog limit violation (high/low/high-high/low-low), the engineer must record the actual process value that triggered and the process value that cleared the condition. The legacy approach of using a single Dword bit-mapped word on the PLC and toggling a corresponding HMI tag produces only the arrival event; the cleared event is invisible to the operator and to the audit log.
This reference details a working configuration on a SIMATIC TP900 Comfort panel running WinCC Advanced V13 SP1 with an active Audit Trail runtime license. It explains:
- How the integrated alarm archive captures the
StateAftercolumn and how to interpret its values. - How to embed a live process variable in the alarm text so the recorded value travels with the event.
- How to size the archive, locate the on-board CSV file, and export it for external review.
2. Prerequisites and Licensing
| Component | Required Version / Order Number | License |
|---|---|---|
| STEP 7 / TIA Portal | V13 SP1 Update 9 (or later V13 SP1 cumulative update) | Engineering license |
| WinCC Advanced (TIA Portal option) | V13 SP1 | Engineering license (Floating or Named User) |
| TP900 Comfort HMI | 6AV2 124-1GC01-0AX0 (9" widescreen) | WinCC Comfort/Advanced RT image |
| Audit Trail option | Option for WinCC Advanced Runtime | Per-panel runtime license |
| PLC tag resource | Bit-mapped Dword area in S7-1200/S7-1500 DB or %MW area | — |
| Storage medium | SD card ≥ 4 GB or USB stick; Audit Trail requires non-volatile storage | — |
3. Alarm Architecture in WinCC Advanced V13 SP1
WinCC Advanced groups alarms into three classes: Discrete, Analog, and User-defined. Discrete alarms are driven by a single PLC bit transition; analog alarms are derived from an HMI tag that crosses a configured high/low threshold; user-defined alarms are constructed in scripts or function blocks. For an application that mirrors a PLC Dword bit (your existing approach), you will use the Discrete class. For a high/low analog limit that needs the actual process value, the Analog class is the correct target because it natively supports the limit text and a bound value tag.
The runtime state machine of an alarm, valid since WinCC Comfort/Advanced V11 and unchanged in V13 SP1, is conceptually identical to the WinCC Unified alarm states model: an alarm is Active when the trigger condition is fulfilled, Cleared when the trigger condition is released, and Acknowledged when an operator presses ACK. Each transition generates a record in the alarm archive.
4. Configuring Discrete Alarms with PLC Bit Triggers
- In the TIA Portal project tree, expand your_HMI > HMI alarms > Discrete alarms.
- Right-click Discrete alarms → Add new. A row appears in the alarm editor.
- In the ID column enter a unique integer (WinCC Advanced auto-numbers if you leave the cell; do not rely on auto-numbering for FDA audit trails).
- In the Trigger tag column, browse to the HMI tag wired to one bit of your PLC Dword. A 32-bit Dword from the PLC must be split into 32 separate HMI tags of data type
Bool(one per bit) to drive 32 discrete alarms; this split is performed in the HMI tag table with the Bit access checkbox on the offset/length property. - In the Trigger bit dropdown, choose Trigger on rising edge (1 → 0) for an active-high alarm, or falling edge for an active-low alarm.
- Populate the Alarm text column. Right-click inside the cell → Insert tag field (see Section 6 for details).
- Set the Class to Warning, Error, or a custom class.
- Set the Group for filtering in the alarm view control.
%DB20.DBD0 is mapped to the HMI as a 32-element Dword array. Create 32 Bool tags whose Bit address points to bit 0..31 of the array. Each Bool tag becomes the trigger of one discrete alarm. This is the standard pattern for transporting 32 limit flags from an S7-1200/S7-1500 to a Comfort panel using a single Dword handshake.
5. Understanding the StateAfter Column
When an alarm is enabled for archiving, each transition writes one row to the alarm log. The most important diagnostic column is StateAfter. The values are:
| StateAfter | Manual definition | Engineering meaning | Typical operator wording |
|---|---|---|---|
| 0 | Incoming / outgoing | Alarm has cleared (the trigger condition is no longer fulfilled). | "Limit HH cleared" |
| 1 | Incoming | Alarm has become active (the trigger condition is now fulfilled). | "Limit HH exceeded" |
| 2 | Acknowledged | Operator has acknowledged an active alarm. | "ACK by operator" |
| 3 | Acknowledgement cleared | Active alarm is acknowledged and the trigger is gone. | "ACK + clear" |
For a regulator the two crucial rows are StateAfter = 1 (the violation started) and StateAfter = 0 (the violation ended). The duration of any given alarm event is therefore:
T_duration = Timestamp(StateAfter=0) - Timestamp(StateAfter=1)
Note that this duration is not stored as a column; it must be computed downstream (Excel pivot, SQL view, Python pandas) from the paired rows.
6. Embedding Process Values in Alarm Messages
For an analog alarm (a high/low limit driven by a process tag), the value that triggered and the value that cleared the alarm are part of the same tag that triggers the alarm. The cleanest way to capture the value is to insert a tag field in the alarm text. The procedure is:
- Select the discrete or analog alarm in the editor.
- Click inside the Alarm text cell of the Properties pane (or in the alarm text column of the table view).
- Right-click → Insert tag field > [your process tag].
- WinCC inserts a placeholder of the form
{Tag name}or, in the script view, a reference such as'Process_Tag'. The runtime substitutes the current value at the moment the alarm transition occurs.
The text now reads, for example:
Reactor PT-102 high level: 87.4% (limit 85.0%)
Both the incoming row and the outgoing row carry the value of the trigger tag at the moment the transition was logged. The value at the outgoing moment is in general different from the value at the incoming moment (the analog signal has moved back through the threshold), and that is the additional information your client needs. The placeholder is not a static label; it is a runtime reference, and the value is embedded in the archive row.
999.9 for level in %, 0.00 for pressure in bar). Without an explicit format the runtime shows the tag's raw data type, which can be misleading when the underlying tag is a Real with no unit scaling.
If you are using discrete alarms driven by a PLC bit (your Dword approach), the trigger tag itself is a Bool and embedding it is unhelpful. In that case create a parallel process value HMI tag wired to the same engineering variable that the PLC uses to evaluate the limit. Insert that value tag in the alarm text. The result is functionally identical to a native analog alarm but allows you to keep the bit-mapped Dword pattern that you already deploy.
7. Archive Configuration for Audit Trail
- Open HMI alarms > Properties > Archive.
- Tick Archive alarms.
- Choose a Storage location: Storage card (SD/USB) for audit-grade persistence; internal flash only for short-term diagnostic logs.
- Set Path. The default for Comfort panels is
/media/simatic/<volume>/Logs. - Enable Sequential numbering and Time stamp format = ISO 8601 (yyyy-MM-dd HH:mm:ss.fff). The millisecond field is essential when reconstructing events in fast loops.
- Under Audit Trail, tick Record operator actions, Record system events, and Record value changes.
- Set the Number of records conservatively. A TP900 with a 4 GB SD card can hold > 1 million alarm rows in CSV, but the runtime builds an in-memory index; the recommended upper bound for an Audit Trail project is 500,000 records before the index is rolled.
The alarm log columns written to disk are:
| Column | Description | Used for audit |
|---|---|---|
| Nr | Sequential record number | Yes (gaps indicate rolled segments) |
| TimeAndDate (UTC or local) | Time of state transition | Yes (primary key) |
| StateAfter | 0, 1, 2, 3 (see Section 5) | Yes (primary key) |
| AlarmNumber | Configured alarm ID | Yes |
| AlarmText | Substituted text including tag field values | Yes |
| AlarmClass | Warning / Error / custom | Optional |
| TriggerTag | Tag that caused the transition | Yes |
| TriggerValue | Value at the moment of transition | Yes |
| AckTime | Time of acknowledgement | Yes (if ACK required) |
| User | Logged-in operator (if user administration enabled) | Yes |
8. Reading and Exporting the Alarm Archive
The runtime writes two files per segment:
/media/simatic/<volume>/Logs/Alarms_<YYYYMMDD>.csv
/media/simatic/<volume>/Logs/Alarms_<YYYYMMDD>.ldf (signature)
The CSV is plain text, comma-separated, with a header row. The .ldf companion is the cryptographic hash file used by the Audit Trail viewer; it is not a human-readable file but must be preserved untouched to keep the chain of custody valid.
To retrieve the file:
- Stop the runtime (Settings → Stop Runtime) or pull the SD card while the panel is powered down. Hot-swapping is permitted on the SD slot of the TP900 Comfort.
- Mount the card on a Windows PC. The CSV opens directly in Excel or in any text editor.
- To compute event duration, use an SQL view such as:
SELECT a.AlarmNumber,
a.TimeAndDate AS Incoming,
b.TimeAndDate AS Outgoing,
DATEDIFF(SECOND, a.TimeAndDate, b.TimeAndDate) AS Duration_s,
a.AlarmText AS Value_at_incoming,
b.AlarmText AS Value_at_outgoing
FROM AlarmLog a
JOIN AlarmLog b
ON a.AlarmNumber = b.AlarmNumber
AND a.StateAfter = 1
AND b.StateAfter = 0
AND b.TimeAndDate > a.TimeAndDate
AND NOT EXISTS (SELECT 1 FROM AlarmLog c
WHERE c.AlarmNumber = a.AlarmNumber
AND c.StateAfter = 1
AND c.TimeAndDate BETWEEN a.TimeAndDate AND b.TimeAndDate);
This pattern matches the open/close pair of a single alarm event and is the standard query in regulated environments.
9. Verification Procedure
- Compile the HMI project, download to the TP900 Comfort, and start the runtime.
- Force one of the trigger bits on the PLC to
1using the watch table or the PLC's force table. Confirm the alarm appears in the alarm view control on the panel with the substituted process value. - Clear the bit. Confirm a second row appears in the archive with
StateAfter = 0and the (now lower) process value in the text. - Stop the runtime, extract the SD card, open the CSV, and verify the two rows are present and that the timestamps differ by the expected duration.
- If your client requires user attribution, log in as Operator_A, trigger the alarm, log out, log in as Operator_B, and acknowledge it. Confirm two additional rows appear (one with the user at acknowledgement time).
10. Troubleshooting Matrix
| Symptom | Likely cause | Remedy |
|---|---|---|
| No alarm rows in the CSV | Archive not enabled; storage path invalid; SD card missing | Re-check Section 7. Audit Trail grays out if the storage medium is not detected. |
Only StateAfter = 1 rows; no cleared rows |
Discrete alarm set to Trigger on rising edge only; the falling edge is not configured as a second event | Add the same alarm twice: once for the rising edge (StateAfter=1) and once for the falling edge (StateAfter=0). Or use the Analog class which auto-generates both edges. |
Process value in alarm text shows raw Real digits (e.g. 0.8739999 instead of 87.4) |
No display format set on the inserted tag field | Right-click the tag field in the alarm text → Properties → set the format string. |
| Value at outgoing moment equals the limit value exactly | The trigger uses a tolerance band, the process value has not yet moved out of the band when the transition is logged | Increase the trigger's Deadband (Analog class) or insert the value tag explicitly so the live value, not the band, is recorded. |
Alarm text shows {TagName} literally |
Tag field was typed manually, not inserted via the editor context menu | Delete the text and re-insert with Insert tag field in the editor. |
| CSV is on internal flash and disappears after power cycle | Internal flash of TP900 is volatile during a hard reset; SD/USB is required for persistent audit | Configure storage to SD/USB and re-archive. |
| Time stamp is off by one hour | Daylight-saving transition not handled, or the panel is set to UTC and the viewer expects local | Set Time base in the panel's Regional settings and document it in the audit SOP. |
| CSV rows are out of order | Multiple transitions in the same millisecond; runtime writes them with identical timestamps | Sort downstream by Nr (sequential record number) instead of timestamp. |
11. Best Practices for Regulated Environments
- Disable Allow operator to delete alarms. Operators must never alter the log; only engineers with a password may clear the on-screen buffer.
- Synchronize the panel time to an SNTP/NTP source at least every 24 h. The audit timestamp is only as trustworthy as the panel's RTC.
- Use the Analog class for any limit that can be expressed as a numeric range. The runtime will automatically log both the incoming and the outgoing transition with the substituted value, and the engineering effort is lower than mirroring the same logic in PLC code.
- Keep the Dword bit-mapped pattern only for non-analog or non-numeric alarms (valve open, motor running, interlock active). The bit pattern is efficient but blind to the value that caused the bit to flip.
- Document the alarm ID numbering scheme in the project Functional Specification. Auditors will ask why alarm 1024 follows alarm 1023 and not 1025.
- Reserve one alarm class named Audit (custom) for batch/lot boundary events; do not mix it with operational warnings.
- Schedule a daily export of the CSV to a network share via the panel's Service Tool or via an external WinCC Audit Trail Viewer license. The CSV on the SD card is the source of truth but a redundant off-panel copy protects against card failure.
- Do not enable Allow modification of alarms in the alarm view. Once an alarm is in the archive it must be immutable.
12. Frequently Asked Questions
What does StateAfter = 0 mean in the WinCC Advanced alarm archive?
StateAfter = 0 indicates that the alarm has cleared (the trigger condition is no longer fulfilled). StateAfter = 1 is the incoming/active transition, StateAfter = 2 is the acknowledgement, and StateAfter = 3 is the acknowledgement-with-cleared combination. The pair (StateAfter = 1) followed by (StateAfter = 0) defines one full alarm event.
How do I record the analog process value that triggered an alarm?
Open the alarm's Properties → Alarm text, right-click and choose Insert tag field, then pick the process tag. WinCC substitutes the live value at the moment of the state transition; the value is stored in the AlarmText column of the CSV and can be retrieved downstream without any extra PLC code.
Why does my CSV contain only one row per alarm?
Either Archive alarms is enabled but the discrete alarm is configured for a single edge, or the panel is running without an SD card and the runtime is silently dropping the outgoing transition. Configure the alarm for both edges (or use the Analog class) and verify the storage medium is the SD card, not the internal flash.
Do I need the Audit Trail license to log alarm timestamps?
Basic alarm logging works without Audit Trail. The license is required only if you also need tamper-evident signing (the .ldf file), operator-action logging, and a viewer that re-verifies the signature chain. For FDA 21 CFR Part 11 or EU GMP Annex 11 compliance, the Audit Trail license is effectively mandatory.
Can I keep using my Dword bit-mapped alarm word from the PLC?
Yes. Split the Dword into 32 HMI Bool tags (one per bit) and create 32 discrete alarms, one per Bool. To also capture the process value that set the bit, insert a separate process-value HMI tag into the alarm text using Insert tag field. The bit pattern is preserved; the value that caused the bit to flip travels with the alarm record.
Where are the alarm archive files stored on the TP900 Comfort?
By default they are written to /media/simatic/<volume>/Logs/Alarms_<YYYYMMDD>.csv with a companion .ldf signature file. The path is configurable in HMI alarms > Properties > Archive > Storage location. The SD card must remain inserted; on internal flash the audit signature cannot be guaranteed across a power cycle.
How is the duration of an alarm computed from the archive?
Pair the StateAfter = 1 row with the next StateAfter = 0 row of the same AlarmNumber and compute Outgoing_Timestamp - Incoming_Timestamp. The SQL example in Section 8 shows the canonical query that also handles overlapping events and unclosed alarms.