Troubleshooting
Why MTP1500 CSV log export needs a script in TIA V20
Short answer
On an MTP1500 engineered in TIA Portal V20 there is no ExportTagLog system function and no Comfort-style CloseAllLogs/ArchiveLogFile/OpenAllLogs sequence, because Unified logs are SQLite segments, not TXT or CSV files. The documented route is the supplied snippet under Snippets > HMI Runtime > Tag Logging > Export Tag Log as CSV, sequenced with status tags so logging stays open and no samples are lost.

On this page
The operator wants to press one button, get a complete CSV archive on a USB stick, and lose nothing. On an MTP1500 engineered in TIA Portal V20 that button cannot call a ready-made export function, because V20 has no ExportTagLog system function, and the Comfort Panel sequence CloseAllLogs, ArchiveLogFile, OpenAllLogs does not exist on WinCC Unified. The documented route is the JavaScript snippet supplied with the engineering tool, sequenced with status tags, with tag logging left open throughout. This article gives that sequence, the boundary model that guarantees completeness, and the decision for each case.
Why the Comfort sequence does not transfer #
The three Comfort functions fail on a Unified panel for two separate reasons:
- They are not provided. WinCC Unified replaces the Comfort system-function set with a JavaScript scripting engine and its own function set, so
CloseAllLogs,ArchiveLogFileandOpenAllLogssimply cannot be configured. - The file model is different. Comfort Panels wrote TXT or CSV log files that a PC could open directly, which is also why a TP700 Comfort CSV log needs a computer to print. A Unified panel such as the MTP1500 logs into SQLite segment files, so copying a log file to USB produces something the recipient's spreadsheet will not read.
There is also a design reason to drop the close-copy-reopen pattern even where it exists: closing every log before copying interrupts acquisition. When the requirement is that no sample is lost, logging must stay open during the transfer and the exporter must read a bounded historical range instead of touching the live segment files.
The V20 route: the supplied snippet #
In V20 the starting point is the snippet the engineering tool ships. Open the script editor, and take the code under Snippets > HMI Runtime > Tag Logging > Export Tag Log as CSV. Then adapt it to the project:
- Bind the snippet to the tag log that holds the analog transmitter values.
- Set the output path to the location the USB stick occupies at runtime; the path must resolve in the panel's runtime environment, and a temporary stick must be verified present and writable before the export starts.
- Feed the export range from a captured boundary rather than a project constant, so every request covers all retained records through the moment the operator pressed the button.
- Wire the snippet's progress and result into project status tags, and drive the operator indication from those tags.
Treat the snippet as a working implementation to be completed, not as a drop-in. The connection to the log, the destination, the range and the error handling are project work.
What V21 changes #
From TIA Portal V21 the function set includes ExportTagLog as a system function for Unified runtime, so the export call itself no longer requires the snippet. The matching JavaScript method SysFct.ExportTagLog() is documented as an asynchronous operation that does not block, which confirms the sequencing rule below applies to both versions: an started export is not a finished export. Do not design a V20 project around ExportTagLog; either keep the V20 script route or plan the upgrade to V21 as a separate engineering and runtime change.
Backup location is retention, not a CSV archive #
Unified also offers a configured backup location that receives copies of the log segments. Two documented conditions decide when it is the right tool:
- The backup path must be specified completely, not just as a storage device. A network destination, for example, takes the form
/net/mount/myShare/Archive/. - The backup contains the log segments but not the main database, so a PC holding only those files cannot resolve the internal IDs.
That makes the choice binary:
| Requirement | Route | Result |
|---|---|---|
| Unified-side retention or restoration | Configured backup location | SQLite segments, database context missing |
| Values readable on a PC | Tag log export as CSV | Portable file for analysis software |
Your operator inserts a stick to analyze values on a local PC, so the route is the CSV export, and the backup location is not a substitute for it.
Sequence with status tags, not delays #
Because the export runs asynchronously, dependent steps must wait for their predecessor's reported completion. A fixed delay only shrinks the odds of a race; a slow USB write can outlast any delay you pick. Use project-defined status tags to hold the phase and result, and run this state flow:
- Accept the request only from the idle state; refuse a second press while one export is active.
- Verify the USB destination is mounted at the configured path and writable; on failure, report media unavailable and stay idle.
- Capture the export boundary — the timestamp of the accepted request.
- Start the CSV export for all retained records through that boundary, with tag logging still open.
- Wait for the export operation to report completion or failure.
- Validate the output and publish the final indication: export complete, export failed, or media unavailable.
Keep the previous success state separate from the current request, so an old export-complete indication cannot be mistaken for the transfer just requested. A button press should only submit the request; the controlled sequence does and monitors the work.
Worked example: the export boundary #
Illustrative numbers. Suppose four analog tags are logged on a 1 s cycle and the panel retains 7 days of history. The operator presses the button at 14:30:00; the boundary is captured as that timestamp.
- Records per tag in the file: 7 days × 86,400 s/day at one record per second = 604,800 records.
- Total values in the CSV: 4 tags × 604,800 records = 2,419,200 values.
Every sample with a timestamp at or before 14:30:00 belongs to this file; samples logged at 14:30:01 and later stay in the active log and appear in the next export. Logging ran continuously, so nothing was lost — completeness means the file ends exactly at the boundary, which you verify by comparing the last CSV record's timestamp against the captured boundary.
Symptoms and their causes #
- Export fails immediately: the USB device is absent, the path does not resolve, or the destination is not writable. Keep logging active, report a destination fault, and return to the media check.
- File exists but no spreadsheet opens it: raw SQLite segments were copied instead of exported. Return to the snippet route.
- Export works only after an arbitrary delay: asynchronous operations are started without completion feedback. Replace delay-only sequencing with status-driven transitions.
- File holds old data but not the newest records: the export range was fixed instead of captured at request time. Pass the boundary through and compare it with the last CSV record.
- Logging shows a gap around the transfer: logs were closed and reopened for copying. Leave logging open and export a bounded historical range.
The decision #
- Staying on TIA Portal V20 with an MTP1500: use the supplied snippet under Snippets > HMI Runtime > Tag Logging > Export Tag Log as CSV, driven by the six-step status-tag sequence above, with logging open and the boundary captured at request time. This delivers the complete, no-loss CSV archive the operator asked for.
- Free to upgrade: V21's
ExportTagLogsystem function replaces the export call, but keep the destination check, boundary capture and completion handling unchanged, since the operation is asynchronous in both versions. - Recipient needs Unified recovery rather than readable values: configure the complete backup path such as
/net/mount/myShare/Archive/and accept that the segments need the panel's database context; do not hand a PC-only recipient that backup as if it were a CSV archive.
Questions asked
Does moving to TIA Portal V21 remove the need for the script?
V21 documents an ExportTagLog system function, so the export call itself no longer needs the snippet. The JavaScript method SysFct.ExportTagLog() is documented as asynchronous and non-blocking, so the completion handling, the destination check and the boundary capture stay exactly as they are.
Where does an MTP1500 actually store its datalogs?
WinCC Unified logs tag values into SQLite segment files in the configured log storage location, not into TXT or CSV files like a Comfort Panel. That is why a plain file copy to a USB stick does not give the PC a readable archive.
Why not configure the Unified backup location instead of exporting?
The backup location copies log segments for retention, but the main database is not included, so the segments alone are not self-describing on a PC. Use the backup route for Unified-side recovery and CSV export when engineers must open the values in analysis software.
The export button fails the moment the operator presses it. What do I check first?
Check that the USB device is mounted at the path the project writes to and that the path is writable. A temporarily inserted stick is not a permanently available destination; the request should be refused with a media-unavailable indication while logging continues untouched.
How do I prove the newest records reached the CSV file?
Compare the timestamp of the last CSV record with the boundary captured when the request was accepted. If the last record is older than the boundary, the export range was fixed in the project instead of captured at request time, and the script must pass the boundary through.

