Overview: Logging Architecture Shift from Comfort to Unified
The legacy SIMATIC Comfort Panels (TP/KTP Comfort) stored tag data and alarm logs as plain .csv or .txt files on removable media. Those files opened directly in Excel without any conversion. The second-generation SIMATIC Unified Comfort Panels (MTP700 Unified, MTP1000 Unified, MTP1200 Unified, MTP1500 Unified, MTP1900 Unified, MTP2200 Unified) replaced that flat-file model with an embedded SQLite database stored under the /home/industrial/Runtime partition on the panel. The change is intentional: it permits high-speed, filtered queries from runtime and reporting, but it means the file no longer opens in Excel by double-click.
This article documents the three sanctioned paths to push that SQLite log data into a CSV or XLSX file usable by an operator or engineer:
- Trend Control export button – operator-driven, runtime-only.
-
JavaScript
FireCommandonUI.Enums.HmiFunctionTrendControlID.Export– script-driven, customizable target. - WinCC Unified Reporting – server-side XLSX templates generated on a schedule or on demand.
None of the three methods requires an additional "Logging" license for Unified Comfort Panels; logging is included in the base runtime image. Optional licenses only apply when the panel is upgraded to a WinCC Unified PC Station or when the Reporting add-on is loaded on a separate server.
Prerequisites
| Item | Specification |
|---|---|
| Engineering tool | SIMATIC WinCC Unified in TIA Portal V17 Update 4 or later (V18, V19, V20 supported) |
| Runtime target | SIMATIC Unified Comfort Panel, firmware V17.0.0.4 or later |
| Panel image | Configured with Logging → SQLite database (default) |
| Storage targets | USB stick (FAT32, exFAT) on the panel's X61/X62 USB port, or SMB/CIFS network share, or internal /home/industrial/Runtime
|
| Reporting (optional) | WinCC Unified Reporting installed on a separate Windows host (TIA Portal add-in) |
| External viewer | Microsoft Excel 2016 SP1 or later (for .xlsx), any text editor (for .csv) |
/home/industrial/Runtime/Logging/<LoggingTagName>.sqdb. It cannot be opened directly with the public SQLite CLI because Siemens adds a 512-byte header. Treat the file as opaque and always export it through one of the official methods.SQLite Database Layout and Storage Path
Each configured logging tag creates a single .sqdb file in the runtime partition. A standard MTP1500 with two logging tags (for example Motor_Speed and Tank_Level) yields the following structure after a few hours of runtime:
/home/industrial/Runtime/
└── Logging/
├── Motor_Speed.sqdb
└── Tank_Level.sqdb
The database is written every cycle defined in the tag's Acquisition cycle (minimum 100 ms, recommended 1 s for trend data) and rotated when the file reaches the configured Maximum file size (default 4 MB, configurable up to 1 GB). The retention policy is governed by Segment count (default 10 segments per tag) – older segments are dropped automatically.
Method 1: Export Button in the Trend Control
This is the operator-facing path and is the simplest to deploy. The button is built into the Unified Trend Control and is enabled in TIA Portal under Properties > Toolbar > Export.
Configuration Steps
- Open the project in TIA Portal and navigate to the HMI screen containing the Trend Control.
- Select the Trend Control, open Properties > Toolbar, and enable "Export". Add it to the visible toolbar if it is not already there.
- In Properties > General > Export settings, configure the destination:
| Parameter | Default | Recommended |
|---|---|---|
| File format | CSV | CSV (UTF-8 with BOM for Excel compatibility) |
| Separator | Semicolon | Semicolon for EU locale, comma for US locale |
| Decimal separator | Comma | Match Excel locale |
| Time stamp format | ISO 8601 | yyyy-MM-dd HH:mm:ss.fff |
| Target path | Local runtime |
/home/industrial/usb/<USB0>/Logs or SMB share |
- Compile and download the project to the Unified Comfort Panel.
- At runtime, zoom the trend to the time range of interest, then press the export button on the Trend Control toolbar. The operator is prompted for a destination path.
Method 2: JavaScript Export Using FireCommand
The JavaScript runtime API provides programmatic control of the export, allowing the operator to trigger a full-fidelity export without the pixel-downsample penalty. Siemens ships a ready-to-use code snippet that handles USB stick and network share targets.
Insert the Siemens Snippet
- In TIA Portal, open the screen in which you want to add the export trigger.
- Open the Scripts editor and create a new JavaScript file (or open an existing one).
- Right-click in the editor and choose "Snippets > HMI Runtime > Tag Logging > Export tag log as CSV".
- The snippet is inserted with the boilerplate shown below. Adjust the logging tag name, target path, and time range:
// Export tag log as CSV (Siemens Unified Comfort Panel)
// Snippet: HMI Runtime > Tag Logging > Export tag log as CSV
export async function ExportTagLogToCsv() {
// 1. Configure export parameters
const logTagName = "Motor_Speed"; // Logging tag from the project tree
const startTime = new Date(2024, 0, 1); // January 1, 2024 00:00:00
const endTime = new Date(); // Now
const targetPath = "/home/industrial/usb/USB0/Logs";
// 2. Build the export job descriptor
const exportJob = {
LogTagName: logTagName,
StartTime: startTime,
EndTime: endTime,
FileFormat: "CSV",
Separator: ";", // use "," for US locale
DecimalSeparator: ",", // use "." for US locale
Encoding: "UTF-8",
FileName: logTagName + "_" +
startTime.toISOString().slice(0,10) + ".csv"
};
// 3. Submit the export via the unified logging API
try {
const result = await HMIRuntime.Logging.ExportLog(exportJob, targetPath);
HMIRuntime.Trace("Export OK: " + result.FilePath);
} catch (err) {
HMIRuntime.Trace("Export failed: " + err.message);
}
}
Trigger the Export from a Button
Wire the function to a button's Click event:
- Drop a Button control on the screen.
- In Properties > Events > Click, add a new JavaScript action and call
ExportTagLogToCsv(); - Compile, download, and test on the panel.
Alternative Trigger via UI Function on the Trend Control
If you prefer to use the trend area's UI rather than a separate button, the runtime exposes UI.Enums.HmiFunctionTrendControlID.Export. The pattern is:
// Trigger Trend Control export programmatically
const trendControl = Screen.FindItem("TrendControl1"); // Trend Control name
const cmd = UI.Enums.HmiFunctionTrendControlID.Export;
// FireCommand is the unified runtime equivalent of the legacy
// VBScript .FireCommand on classic panels.
trendControl.FireCommand(cmd);
This call invokes the same dialog that the toolbar button shows, but it can be initiated from any screen or scheduled task.
ExportLog throws error 0x8004F4E1 (path not in whitelist).Method 3: WinCC Unified Reporting to XLSX
WinCC Unified Reporting is a TIA Portal add-in that runs on a separate Windows host and creates Excel templates (XLSX) bound to one or more logging tags. The template is rendered on demand or on a schedule, producing a file that opens in Excel without further conversion.
Architecture
Reporting does not run on the Unified Comfort Panel itself – it requires a connection from the Reporting server to the panel's runtime (or to the Unified PC runtime). On a panel-only installation, configure the reporting server to query the panel via the built-in OPC UA server.
- Install the WinCC Unified Reporting plug-in on the engineering PC (TIA Portal V18 or later).
- Open the project in TIA Portal and switch to the Reports editor.
- Create a new report and drag the logging tags (e.g.
Motor_Speed,Tank_Level) onto the worksheet. The runtime automatically generates a table with columnsTimestamp,Value,Quality. - Configure the report schedule under Report properties > Trigger – options include Time-based (cron), Event-based (bit trigger), or Manual.
- Set the output destination: local folder, FTP/SFTP, or email attachment.
Sample Template Layout
| A: Timestamp | B: Motor_Speed [rpm] | C: Tank_Level [%] | D: Quality |
|---|---|---|---|
| 2024-05-12 08:00:00.123 | 1480 | 62.4 | Good |
| 2024-05-12 08:00:01.124 | 1481 | 62.5 | Good |
| 2024-05-12 08:00:02.121 | 1481 | 62.5 | Good |
The Quality column reflects the OPC UA status code from the runtime; mapping is documented in the WinCC Unified manual, section "Logging diagnostics".
File System Targets and Path Mapping
| Logical name | Physical path | Use case |
|---|---|---|
| Local runtime | /home/industrial/Runtime/<subfolder> |
Local archive, transferred later via TIA Portal or SFTP |
| USB front | /home/industrial/usb/<USB0> |
Operator-removable media, FAT32/exFAT, max 32 GB recommended |
| USB rear | /home/industrial/usb/<USB1> |
Same as above on rear port (MTP1500/1900/2200 only) |
| Network share | \\server\share\<subfolder> |
CIFS/SMB v2 or v3; configured under Runtime settings > Network drive |
| SFTP | sftp://user@host/path |
Reporting-only; requires key-based auth |
All paths used by JavaScript or the Trend Control export must be allowlisted in Runtime settings > File system > Allowed paths. If a path is denied, the export fails with a runtime entry in the diagnostic viewer (Event ID 13001 for path-not-allowed).
CSV to Excel: Encoding and Locale Pitfalls
A CSV exported with the wrong encoding or separator will appear garbled or merged into a single column when opened by Excel. The two most common pitfalls:
- UTF-8 without BOM: Excel does not auto-detect encoding. If the CSV is exported as UTF-8 without a BOM and opened by double-click on a German/French locale Excel, umlauts and accents break. Always export with UTF-8 with BOM when targeting Excel.
- Semicolon vs. comma separator: EU locales default to semicolon, US locales default to comma. Configure the export to match the operator's Excel locale or use Data > Get Data > From Text/CSV in Excel 365 to set the delimiter manually.
Safe Excel-Compatible Export Settings
// Safe Excel-compatible CSV export
const exportJob = {
FileFormat: "CSV",
Separator: ";", // semicolon for EU Excel
DecimalSeparator: ",", // comma for EU Excel
Encoding: "UTF-8BOM", // critical for Excel
TimeStampFormat: "yyyy-MM-dd HH:mm:ss.fff"
};
Verification Checklist
After configuring one of the three methods, run through the following checks on the panel:
- Trigger the export (button, script, or schedule).
- Confirm the file appears at the target path with the expected extension.
- Copy the file to a PC and open it in Excel – values must land in separate columns.
- Spot-check the first and last timestamp against the runtime clock to confirm the time range filter worked.
- Open the WinCC Unified diagnostic viewer on the panel (Control Panel > Diagnostics) and verify there are no
Event ID 1300xerrors related to logging or file system.
Troubleshooting Matrix
| Symptom | Likely cause | Remediation |
|---|---|---|
| Export button greyed out | Toolbar button not enabled in TIA Portal | Enable Toolbar > Export on the Trend Control |
| Trend Control export shows fewer rows than expected | Pixel downsampling | Use Method 2 (JavaScript) or Method 3 (Reporting) |
HMIRuntime.Logging.ExportLog throws 0x8004F4E1
|
Path not allowlisted | Add path under Runtime settings > File system > Allowed paths |
| CSV opens in Excel with all data in column A | Wrong separator | Change Separator to semicolon (EU) or use Excel Get Data wizard |
| Umlauts/accents broken in Excel | UTF-8 without BOM | Export with Encoding = UTF-8BOM
|
| JavaScript snippet missing from menu | TIA Portal < V17 Update 4 | Upgrade TIA Portal to V17 Update 4 or later |
| Reporting server cannot connect to panel | OPC UA server disabled | Enable Runtime settings > OPC UA > Server and open port 4840 in firewall |
| Database fills disk within hours | Default 4 MB segments are too small | Increase Maximum file size to 64 MB and Segment count to 20 |
| USB stick not detected | NTFS or exFAT with journaling | Reformat to FAT32 or non-journaled exFAT |
| Network share export fails intermittently | SMB v1 disabled on server | Force SMB v2/v3 in Runtime settings > Network drive |
Performance and Capacity Notes
On a mid-range MTP1500 Unified, the JavaScript export of one logging tag spanning 24 h at 1 s cycle produces a CSV in ~1.5 s and consumes ~6 MB of RAM peak. Exporting multiple tags in a single job is serial – allow ~0.8 s per additional tag. Reporting is heavier: a 24 h, 10-tag XLSX template takes ~8 s on the server and ~30 MB RAM. Schedule large reports for off-peak hours to avoid runtime impact.
References (Inline)
- Siemens WinCC Unified – Export Logs doc: Export Logs - WinCC Unified
- Siemens Support – Configuring Logging for SIMATIC WinCC Unified Systems PDF: WinCC Unified Logging V1.0
FAQ
Can the Unified Comfort Panel log directly to a CSV file instead of SQLite?
No. Unified Comfort Panels V17 and later store logging data exclusively in SQLite (.sqdb) format on the runtime partition. CSV output must be generated via the Trend Control export, the JavaScript ExportLog API, or WinCC Unified Reporting.
Do I need an extra license for logging on a Unified Comfort Panel?
No. Logging is included in the base Unified Comfort Panel runtime image. Only WinCC Unified Reporting on a separate server host requires its own license; on-panel export is license-free.
Why does the Trend Control export contain fewer rows than the database?
The Trend Control export is downsampled to the pixel width of the trend area – one point per pixel per series. To retrieve the full-resolution dataset, use the JavaScript HMIRuntime.Logging.ExportLog API or WinCC Unified Reporting.
How do I trigger a CSV export from an operator button?
Insert the Siemens snippet Snippets > HMI Runtime > Tag Logging > Export tag log as CSV into the HMI script, configure the logging tag name and target path, then call the function from the button's Click event.
How do I export logs to a USB stick directly from the HMI?
Configure the export target path as /home/industrial/usb/<USB0>/Logs, make sure the path is allowlisted under Runtime settings > File system > Allowed paths, and use a FAT32-formatted USB stick. The panel will write the CSV directly to the removable media without operator intervention.