Overview
WinCC Flexible (and the TIA Portal WinCC Comfort/Advanced successor) ships with a built-in data-logging engine that writes process tags from S7 PLC data blocks into comma-separated values (CSV) files on the panel's internal flash, an external CF/MMC/SD card, or a network share. The TP270 10-inch and TP277 7-inch HMI panels fully support this functionality, giving field engineers two operational recording strategies:
- Operator-triggered logging – records a snapshot of up to 16 tags when an operator presses a button. Useful for batch records, hand-off logs, and alarm-event capture.
- Scheduled logging – appends a row to the CSV once per day at a configurable wall-clock time, typically used for shift-end reports or 24-hour production summaries.
This reference walks through configuring both modes against an S7-300/400 data block, addresses the well-known TP270 limitation that on-demand logging appears to fail when even a single tag is left in cyclic mode, and documents the verification steps that confirm the file actually contains the expected rows on the storage card.
Prerequisites
Confirm the following before opening the project in WinCC Flexible:
- Engineering station running WinCC Flexible 2008 SP5 or TIA Portal V13 SP1+ with the WinCC Comfort/Advanced option installed.
- Target panel: TP270 10", TP277 6"/10", MP277, OP277, or PC Runtime 2008. Each panel ships with 4–32 MB of internal flash, but the storage card slot is required for sustained logging above 64 KB.
- S7-300, S7-400, S7-200, ET200S, or LOGO! connected via MPI/PROFIBUS or PROFINET and reachable from the panel's Connections editor.
- Source data block structured as a flat array of elementary types (BOOL, INT, REAL, BYTE) or as accessible structured tags. Optimized access (S7-1500 symbolic-only) is not supported by WinCC Flexible; switch to non-optimized block access or use a separate access DB.
- Storage media formatted FAT16 (≤ 2 GB) or FAT32 (≤ 32 GB). The TP270 accepts Type I/II CF cards; TP277 and MP277 accept SD/MMC.
- Operator authorization level configured if the log trigger is to be protected against inadvertent use.
Verify the panel firmware is at least V10.01.00 for TP270 or V11.02.00 for TP277, which fixed earlier CSV-header encoding bugs in Spanish and Asian locales. The firmware revision is visible in Panel Information under System > About.
Logging Mode Reference
WinCC Flexible exposes three logging modes in the Data Logs editor. The correct choice determines whether the operator or the scheduler is in control of when a row is written.
| Mode | Trigger Source | Typical Use | CSV Output Behavior |
|---|---|---|---|
| Cyclic, continuous | Configured acquisition cycle (1 s, 5 s, 1 min, 1 h, user-defined) | Trending, historian, post-event analysis | One row per cycle; file grows continuously; segmentation at configurable size or interval |
| Cyclic, segmented | Acquisition cycle, written in 24-h or size-bounded chunks | Daily production logs | New file at midnight or at the size limit; old file rolled over |
| On demand | Operator pushbutton, PLC bit, scheduler, or VBScript call to LogTag
|
Snapshot of state, batch record, alarm capture | One row only when the function is invoked; nothing recorded in between |
Important: A single data log can only operate in one mode. To obtain both cyclic trend data and on-demand snapshots, configure two separate data logs that point to the same storage path but use different file-name patterns (for example, Trend_%date%.csv and Snap_%date%_%time%.csv).
Step 1 – Configure External Tags from the PLC Data Block
- In the project tree, right-click Tags > Add New Tag.
- Set the connection to the S7 PLC created in the Connections editor.
- Enter the DB number, byte offset, and bit offset. For a 16-bit INT starting at DB20.DBX0 use address
DB 20, DBW 0; for a 32-bit REAL at offset 2 useDB 20, DBD 2; for a BOOL at byte 6 bit 0 useDB 20, DBX 6.0. - Match the data type exactly. Mismatches (e.g. INT read as WORD) will produce silently corrupt values when WinCC writes them to the CSV.
- Repeat for every variable to be logged. The TP270 supports up to 16 tags per single
LogTagcall; for larger snapshots use multipleLogTagcalls in sequence on the same pushbutton event.
Group the tags in a dedicated folder (e.g. BatchRecord_Inputs) so the data log's tag list remains readable.
Step 2 – Create the Data Log
- Open Data Logs in the project tree and select Add New Data Log.
- Name the log descriptively, e.g.
BatchRecord_Log. - Set the storage location: Storage Card for portable exchange, or Internal Flash for tamper-resistant retention.
- Define the path. Use forward slashes; WinCC Flexible converts them for the panel OS. Example:
/Logs/Batch/. - Configure the file-name pattern. The substitution fields supported are
%date%(yyyy-mm-dd),%time%(hh:mm:ss),%year%,%month%,%day%,%hour%,%minute%,%second%, and%name%(log name). A common pattern isSnap_%date%_%time%.csvfor time-stamped snapshots. - Set Logging mode to On demand.
- Click Select Tags and pick the previously created external tags. The list order in the editor becomes the column order in the CSV.
- Set the decimal separator to a period and the field separator to a comma to maximize Excel/CSV-tool compatibility.
Step 3 – Trigger On-Demand Logging with a Pushbutton
- Insert a button on the desired screen. Configure the Event as On Click.
- In the event function list, choose Logging > LogTag (not LogDataRecord – that function is for trend views).
- Select the data log created in Step 2.
- By default, the function logs all tags assigned to the log. If you need a subset, select the individual tags here.
- Compile and download the project to the panel. The first download after creating a new data log requires a full rebuild, not a delta transfer.
To verify on the panel, press the button and inspect the storage card with ProSave or by removing it and reading the CSV on a PC. A correctly configured log will append one row with the current tag values, even if the button is pressed repeatedly within the same second.
LogTag function will appear to do nothing, while that single tag continues to log at its old cycle. The remediation in the field is: delete every data log, remove the offending tag entirely from the tag list (not merely change its mode), recompile, and rebuild the data log from scratch. The behavior is documented as a stale internal pointer in the WinCC Flexible runtime that is not refreshed by an online change.Step 4 – Schedule a Daily CSV Dump
WinCC Flexible provides two scheduling mechanisms. Pick the one that matches the operator workflow.
Option A – Scheduler with "When Time Changes"
- Create a tag, e.g. HMI_Tag_1, of type DateTime.
- In Schedules, add a new task named
DailySnapshot. - Trigger: When time changes.
- Enter the time of day, e.g.
23:59:55to capture a clean last row of the day. - Function list: Logging > LogTag on the same data log as in Step 3.
Option B – PLC-controlled scheduler bit
- On the PLC, generate a one-second pulse at the desired wall-clock time and write it to a BOOL tag, e.g.
DB50.DBX0.0 "DailyLog_Trigger". - Expose the tag to the panel as an external tag.
- Add a scheduler with trigger When tag changes value, debounced to fire only on a 0→1 transition.
- Function: LogTag on the same data log.
Both options create a new row at the configured time. Combine with a file-name pattern of Daily_%date%.csv to obtain a single file per day, segmented automatically by the %date% substitution.
Step 5 – Storage Paths and File Naming
On the TP270 the storage card mounts as /Storage Card/; on TP277 it is /Storage Card MMC/ or /Storage Card SD/ depending on the slot used. Always use forward slashes. The runtime concatenates the configured path with the file-name pattern as follows:
/Storage Card/Logs/Batch/Snap_2024-03-18_14-22-07.csv
For long-term retention, segment files at 1 MB or 10 000 rows to avoid the FAT32 file-size limit of 4 GB and to keep CSV import times short in Excel.
| Path | Use Case | Capacity | Field Note |
|---|---|---|---|
/Storage Card/... |
Operator-removable archive | Card-dependent | Safe to swap; card must be reinserted before next log cycle |
/Flash/... |
Tamper-resistant retention | 4–32 MB | Not replaceable in field; will fill quickly with cyclic logging |
\<server>\share\ |
Centralized historian | Server-dependent | Requires panel network share credentials; slow over MPI-bridged Ethernet |
Troubleshooting Matrix
| Symptom | Likely Cause | Diagnostic | Remediation |
|---|---|---|---|
| Pushbutton produces no CSV row | Data log still in cyclic mode; stale runtime pointer | Check the log's Mode in the panel's System > Data Logs menu | Delete the log, remove and re-add the tag, recompile full project |
| One tag records every second despite on-demand setting | Residual cyclic acquisition cycle on that tag | Open the tag in the editor and inspect the Acquisition column | Set acquisition to "On demand" or remove the tag entirely; full rebuild required |
| CSV header row missing | Tool used to open the file strips leading rows; or BOM not present | Inspect with a hex viewer; the first three bytes should be EF BB BF for UTF-8 |
Enable Write column headers in the data log properties |
| File size = 0 after a log event | Storage card full or write-protected | Check the card lock switch; check free space under System > Storage | Replace or unlock card; verify card reader compatibility |
| Decimal values appear with European comma (1,23 instead of 1.23) | Regional settings on the panel | Control Panel > Regional Settings > Decimal Symbol | Set to "." for CSV, "," for operator display only |
| Scheduled log fires at the wrong time | Panel time zone or DST setting incorrect | Check Control Panel > Date/Time | Set time zone manually or sync with PLC via the Time Synchronization area connection |
| File locked / cannot be opened on PC | Panel still has the CSV open for writing | Stop the log via the panel menu or use ProSave "Stop Logging" command | Configure Close file after write in the data log properties |
Verification and Commissioning
Use this checklist on the panel after every change to the data-log configuration:
- Insert a blank storage card and perform a full project download, not a delta.
- From the panel's System > Data Logs menu, verify the log appears with the correct mode and tag count.
- Press the pushbutton three times at one-second intervals; expect three identical rows in the CSV.
- Wait for the scheduled trigger; verify the wall-clock time on the panel matches the configured scheduler time to within ±1 s.
- Remove the storage card and open the CSV in a text editor (Notepad++ or VS Code) – do not use Excel first, as it can re-encode the BOM and lose the time stamp format.
- Confirm the header row is present, all expected columns are populated, and the row count matches the number of trigger events.
- Cycle panel power; the on-demand log should still register a new row on the next button press, and the cyclic log (if any) should resume from its last good cycle.
Best-Practice Notes
- Keep the data-log tag count below 16 per
LogTagcall. Larger lists exceed the runtime stack on TP270 and produce silent truncation at the end of the row. - Use a separate, dedicated data block for logged tags. Sharing the production DB exposes logged data to be overwritten by application code.
- Pre-allocate the storage card to at least 2× the expected daily log volume. Frequent FAT reindexing on nearly full cards is a primary cause of "file size = 0" errors.
- Configure the panel's Time area pointer to the PLC so the wall-clock time used in the scheduler and in
%date%/%time%substitutions matches the actual shift schedule. - For TIA Portal migrations: WinCC Comfort/Advanced is binary-compatible with WinCC Flexible data-log files. Old
*.csvfiles are read directly, but the panel firmware must be ≥ V14 for the migration project to load.
FAQ
Why does my on-demand pushbutton not write a row even though the data log is configured?
The most common cause is a residual cyclic acquisition cycle on one of the tags in the log. Delete the data log, remove and re-add every tag in the tag list, recompile, and perform a full project download. The WinCC Flexible runtime does not refresh stale mode pointers with an online change; only a full rebuild clears them.
What is the maximum number of tags I can log with a single LogTag call on a TP270?
The TP270 limits each LogTag invocation to 16 tags. For larger snapshots, chain multiple LogTag calls on the same On Click event in the order the columns should appear in the CSV. Exceeding 16 tags causes silent truncation of the trailing columns without an error message.
How do I schedule a CSV write once per day at a specific time?
Use the Schedules editor with the trigger set to When time changes and enter the wall-clock time, for example 23:59:55. The function list should call Logging > LogTag on the desired data log. Combine with the file-name pattern Daily_%date%.csv so a new file is created automatically each day.
Where does WinCC Flexible store the CSV on a TP270?
By default, on the storage card at the path you configure in the data-log properties (e.g. /Storage Card/Logs/Batch/Snap_*.csv). The internal flash path is /Flash/... and is used for tamper-resistant retention. Network shares (e.g. \\server\share\) are also supported but require the panel to be a member of a Windows domain or have explicit credentials configured.
Why does the CSV show European decimal commas (1,23) instead of periods?
The panel's regional setting under Control Panel > Regional Settings > Decimal Symbol controls how REAL tags are written. Set the decimal symbol to "." for CSV compatibility, and configure the operator display to use the desired symbol independently. The change requires a project download, not just an online change.