Overview: Trend Architecture in WinCC TIA Portal
WinCC TIA Portal – whether in the Comfort, Advanced, or Professional flavor – does not render trend curves from arbitrary external databases. The Trend view, the Online Trend Control, and the f(t) trend view all read from a single data source: HMI data logs configured inside the project tree under the HMI device's Historical data node. Each data log persists its samples to a file on the panel's storage media (internal flash on compact panels, SD card on Comfort Panels, local disk or network share on a PC Runtime). Once a data log exists, any trend control on any screen can be bound to it and will render both the live tail and any stored historical segments within the trend's visible window.
This single-source architecture has three practical consequences that drive every configuration decision in this guide:
- Direct ODBC, OLE-DB, or SQL queries against an external relational database (SQL Server, MySQL, Oracle, PostgreSQL, SQLite) are not supported from inside the runtime trend view. The trend control reads only the panel's own
.csvor.rdblog files. For SQL/SAP/ERP archiving, deploy the SIMATIC WinCC Archive Connector as a separate Windows service. - If process values are written from a VBScript to a free-form
.csvfile, the trend view cannot natively re-open that file. The values must first be inside a configured data log (or imported by the Archive Connector before the trend renders). - Date-wise or batch-wise "report" trends are achievable by either (a) splitting logs by shift or batch using separate data log files or segmented storage, or (b) post-processing the trend's exported
.csvvia Excel or the Archive Connector. There is no direct SQL-style query language exposed at runtime.
Prerequisites
Verify the engineering environment, panel firmware, and storage capacity before configuring historical trends. The matrix below is the recommended baseline; values reflect Siemens documentation for TIA Portal V16/V17/V18.
| Component | Requirement |
|---|---|
| TIA Portal | V15.1 minimum for modern Comfort Panel images; V16 / V17 / V18 supported. Project binary format must match the panel image version. |
| HMI Runtime | WinCC Runtime Advanced (PC-based) or WinCC Comfort/Advanced firmware on a SIMATIC Comfort Panel: TP700 / TP900 / TP1200 / TP1500 / TP1900 / TP2200, or KP400 through KP1500 key panels, or a Unified Comfort Panel. |
| Storage | Comfort Panels: SD card ≥ 2 GB (Siemens 6AV2 181-8XP00 or larger recommended). PC Runtime: local drive or UNC network share with write permission for the runtime service account. |
| Tags | Process tags must be HMI tags with a defined acquisition cycle. Cycle choices depend on panel class: Comfort Panels support 100 ms minimum, panels with reduced performance 250 ms. |
| Licensing | No separate option for local data logs on Comfort Panels. PC Runtime requires a WinCC Runtime Advanced license (16, 128, 2048, 8192, 65536 power tags). SQL export requires WinCC Archive Connector with its own per-tag or per-server license. |
| User rights | Operator class must allow Logging and Export operations, otherwise the runtime hides the relevant buttons. |
Configuring HMI Data Logs
Data logs are the storage layer. Create them before configuring the trend view, otherwise the trend's source dropdown will be empty.
- In the TIA Portal project tree, expand the HMI device, then expand
Historical data. Right-click and choose Add new data log. - Name the log semantically (e.g.
BatchReport_ProcessValues,Reactor_TempTrend). Avoid spaces, umlauts, and special characters – the file on the panel becomes<Name>.csv. - Add logging tags. Click Add in the tag list and choose HMI tags. Each tag occupies one column in the log file. The first column is always the timestamp.
- Select the Logging mode:
- Cyclic – log every N seconds. Choose for fixed-rate sampling or process signature trends.
- On change – log when the tag value changes (with optional hysteresis). Choose for event-driven data and minimal file size.
-
On demand via script – the recommended mode for variable-time logging driven by the PLC. Use the
AddRecordmethod from a VBScript.
- Set the Logging cycle (1 s default). For data reduction, set the cycle higher than the acquisition cycle of the underlying HMI tag – values are averaged or decimated internally.
- Set Storage method:
- Circular buffer – oldest entries are overwritten.
- Segmented – a new file is opened on a daily / shift / trigger basis. Best for batch reports.
- Do not overwrite – logging stops when full. Use for compliance / FDA-style records.
- Configure Storage location under Runtime settings → Historical data:
- Comfort Panel default:
\Storage Card SD\Logs\ - PC Runtime default:
C:\ProgramData\Siemens\Automation\Logs\ - Network share (PC Runtime only):
\\server\share\hmi_logs\with the runtime service account granted write access.
- Comfort Panel default:
Data Log Property Matrix
| Property | Recommended value | Notes |
|---|---|---|
| Logging mode | Cyclic 1 s for trend replay; On demand for batch scripts | Cycle ≤ acquisition cycle causes aliasing; cycle ≥ 10x acquisition causes data loss |
| Hysteresis (on change) | 0.5 % of engineering range for analog tags | Default 0 logs every analog noise tick |
| Storage method | Segmented with daily segments | Allows archiving old segments without breaking the live trend |
| Field separator | Semicolon (;) for German locale, comma (,) for English |
Must match Excel regional settings or use Import Wizard |
| Decimal separator | Locale-matched (avoid mixing , decimal with , separator) |
Common source of mis-parsed exports |
| Maximum entries / segment | 500,000 for Comfort, 1,000,000 for RT Advanced | See panel manual |
Configuring the Trend View
Trend views are placed on a screen and bound to one or more data logs. There are three trend controls in TIA Portal; pick by use case:
| Control | Available on | Use case |
|---|---|---|
| Trend view (f(t)) | All Comfort Panels, RT Advanced | Standard time-axis trend. Sufficient for 90 % of applications. |
| Online Trend Control | RT Advanced / RT Professional only | Multiple trends in one control, operator-side zoom, ruler, export. |
| f(x) Trend view | RT Advanced / RT Professional | One tag plotted against another (e.g. flow vs. pressure characteristic). |
Step-by-step for the standard Trend view:
- Open the desired HMI screen in the editor. Drag Trend view from the toolbox onto the screen.
- In the properties pane, navigate to Trend → Trend areas and click Add to create one trend line per process tag you want to plot.
- For each trend area, configure Source settings:
- Data source: Data log (the only historical source).
- Data log: select the log created above.
-
Tag / column: select the column to plot. For HMI tags named
ReactorTemp, the column is logged under that exact name. - Trend type: choose Real-time trend, Historical trend, or Real-time/historical trend with common X-axis. The combined mode is the default for shift-report screens.
- Configure the Time axis:
- Mode: Point of time (timestamps absolute) or Time interval (relative window).
- Range: e.g. 60 minutes, 8 hours, 24 hours, 7 days.
- Zoom: enable operator zoom in the Toolbar configuration.
- Configure the Value axis: scaling, line color, line weight, trigger tag for dynamic limits.
- Under Online → Export, enable Export data record and assign a target path. The export writes the visible window to a
.csvat the operator's request.
For a historical-only trend (date or batch report), choose Historical trend and bind the Start time tag and End time tag as HMI Date_Time tags. The operator – or a script – sets the window and the trend re-renders the stored segment.
Variable-Interval Logging with VBScript
If the sampling interval must vary based on a value or trigger written by the PLC (the situation in the original scenario: a VB script reads variable-time-interval data from the PLC), the cleanest pattern is to write a small VBScript that the runtime calls on a tag change. There are two practical approaches; choose by data volume.
Approach 1 – Toggle logging on/off and let the data log use its configured cycle. Best when the PLC tells the HMI when to start and stop, and the HMI uses a fixed internal cycle:
' HMI script – triggered by the OnChange event of tag "LoggingEnable" (Bool)
Sub StartStopLogging(ByVal Item)
If SmartTags("LoggingEnable").Value = True Then
SmartTags("BatchReport_ProcessValues").StartLogging
Else
SmartTags("BatchReport_ProcessValues").StopLogging
End If
End Sub
Approach 2 – Write a single row to the data log on each PLC trigger (variable timestamps, single row per trigger). Best when the PLC dictates both the trigger time and what to capture:
Sub WriteLogRow(ByVal Item)
Dim oLog
Set oLog = SmartTags("BatchReport_ProcessValues")
oLog.AddRecord Array( _
Now, _
SmartTags("Temperature_PV").Value, _
SmartTags("Pressure_PV").Value, _
SmartTags("Flow_PV").Value _
)
End Sub
Wire the script to the OnChange event of a trigger tag (e.g. LogTrigger rising edge) or schedule it on a 100 ms cycle if the PLC pulse rate is faster than the smallest reliable HMI tick. On Comfort Panels, do not schedule faster than 100 ms – the script engine cannot guarantee sub-100 ms execution.
For per-batch file separation, rename the data log path or trigger a new segment via LogClose / LogOpen at batch boundary:
Sub CloseAndReopenLog(ByVal Item)
SmartTags("BatchReport_ProcessValues").StopLogging
' Optional: archive the .csv via filesystem object
Dim fso, src, dst
Set fso = CreateObject("Scripting.FileSystemObject")
src = "\Storage Card SD\Logs\BatchReport_ProcessValues.csv"
dst = "\Storage Card SD\Archive\Batch_" & Format(Now, "yyyymmdd_hhnnss") & ".csv"
If fso.FileExists(src) Then fso.MoveFile src, dst
SmartTags("BatchReport_ProcessValues").StartLogging
End Sub
AddRecord requires that the data log was configured with a sufficient number of tags and that the array's element count matches the data log tag count. Mismatches raise WinCC system event 13001 ("Data log: number of columns does not match") at runtime. Confirm event ID against the panel's online diagnostics under Diagnostics → System events. See the Siemens Industry Online Support for the full event ID catalog.Date-wise and Batch-wise Historical Trend Reports
To produce a "report" view that mimics an Excel export of one shift or one batch:
- Use separate data logs per batch, or rely on TIA's automatic timestamped segment naming (with Storage method = Segmented, each new segment becomes
<DataLogName>_<YYYYMMDD>_<HHMMSS>.csv). - From runtime, navigate the operator to a Trend view configured as Historical. Provide an input field bound to StartTime and EndTime HMI tags. The operator enters the shift window and confirms – the trend re-renders the stored segment.
- Use the trend's built-in Export function (Online → Export data record) to write the visible window to USB or a network share. The exported file is
.csvand opens directly in Excel. - For SQL/SAP/ERP archiving, deploy the SIMATIC WinCC Archive Connector (separate installation). Configure an ODBC data source pointing at the database. The Connector polls the panel's log directory and inserts rows into the configured SQL tables.
Sample Operator Screen Composition
| Element | Type | Purpose |
|---|---|---|
| Batch number | I/O field (string) | Selects which batch segment to load |
| Start time | Date/time picker | Earliest timestamp for the trend |
| End time | Date/time picker | Latest timestamp for the trend |
| Trend view | Historical trend | Renders the selected window |
| Load button | Button with script | Triggers refresh of the trend view |
| Export button | Button with script | Writes the visible window to USB |
Storage, File Format, and Limits
| Aspect | Value |
|---|---|
| File extension |
.csv for cyclic / segmented logs; .rdb for compressed binary logs (selected in the data log's Storage method property) |
| Field separator | Configured per log; ; is the default for German locale, , for English locale |
| Decimal separator | Locale dependent; ensure Excel regional settings match or use the Import Wizard |
| Timestamp format | ISO 8601 with timezone, e.g. 2024-05-12 08:14:33.250
|
| Default path (Comfort Panel) | /storage card sd/Logs/<DataLogName>.csv |
| Default path (PC Runtime) | C:\ProgramData\Siemens\Automation\Logs\<DataLogName>.csv |
| Max data logs / panel | 100 (Comfort); 1,000 (RT Advanced) |
| Max entries / segment | 500,000 (Comfort); 1,000,000 (RT Advanced) |
| Compressed log size | ~ 30 % of the equivalent .csv; not directly importable to Excel without the Archive Connector |
SQL / SAP Integration via WinCC Archive Connector
The WinCC Archive Connector is a Windows service that reads the panel's .csv / .rdb files and inserts the rows into a relational database through ODBC. It is the supported bridge between WinCC TIA logs and any SQL-based MES / ERP / historian system. Configuration steps:
- Install the Archive Connector on a Windows server with network access to both the panel (or its storage share) and the target SQL server.
- Create a 32-bit ODBC data source (
odbcad32.exe) pointing at the target database. Use the SQL Server Native Client or the provider supplied with your RDBMS. - In the Archive Connector configuration tool, map each data log to a target table. The Connector creates the table on first run if the database user has DDL rights.
- Set the polling interval (default 10 s) and the file-source path. UNC paths to a PC Runtime's log directory are preferred over FTP.
- Monitor the Connector log under
%ProgramData%\Siemens\ArchiveConnector\Logs\.
Performance and Optimization
| Bottleneck | Symptom | Mitigation |
|---|---|---|
| Acquisition cycle too fast | High CPU load on the panel; trend view lag | Raise acquisition cycle to 250 ms or 500 ms where the process allows |
| Too many data logs | SD card wear; boot time increase | Consolidate tags into fewer logs; use On change where appropriate |
| Hysteresis 0 | Logging fires on analog noise | Set hysteresis to 0.5 %–1 % of engineering range |
| Trend update rate too high | Trend redraws faster than the eye can follow | Set the trend's update cycle to 500 ms or 1 s |
| SD card fill-up | Logging stops after a few days | Switch to segmented logging; archive old segments via FTP / Archive Connector |
| Concurrent script writes | Torn rows, system event 13001 | Centralize all writes in one scheduled task; avoid overlapping OnChange scripts on related tags |
Troubleshooting Matrix
| Symptom | Likely Cause | Resolution |
|---|---|---|
| Trend view is blank after starting runtime | Data log not started; tag not listed in log; logging cycle longer than visible window | Confirm StartLogging was called; verify the tag is listed in the data log's tag table; reduce the logging cycle to 1 s for initial verification |
| System event 13001 logged at runtime | Mismatch between the number of columns in AddRecord and the data log definition |
Re-check the array dimensions and the data log tag list; both must match exactly |
| Historical trend shows "no data" for a past date | Data log used circular overwrite; segment was deleted by housekeeping | Set the log method to Segmented or Do not overwrite; archive .csv files externally before they roll over |
| Trend flickers / values out of order | Multiple scripts writing to the same data log concurrently; PC clock skew | Centralize all writes in a single scheduled task; enable NTP on the panel and on PCs |
| Operator cannot export trend to USB | USB storage not whitelisted in Runtime settings; insufficient user rights | Enable USB storage under Runtime settings → General → Removable media; verify the operator user class has export rights |
| SD card fills up after a few days | Too many logs; cycles too short; logging not segmented | Switch to segmented logging; archive old segments via FTP or Archive Connector |
Exported .csv opens in Excel as a single column |
Field separator mismatch with locale | Change the data log's field separator or change Excel's regional settings to match |
| Runtime reports "Log full" but SD card is half-empty | Segment size limit hit, not disk size | Raise entries per segment, or close and re-open the segment at midnight |
| Date/time picker shows "invalid time" on the panel | Panel locale set to a region without DST handling, or battery low | Check panel battery; set locale to English (USA) for reproducible timestamps |
| Trend renders smoothly in simulator but stutters on panel | RT simulator has more CPU than the target panel | Reduce the number of trends per view, or split into multiple trend controls on separate screens |
Field-Proven Caveats
- WinCC Trend view will not directly query SQL Server, MySQL, or Oracle. The WinCC Archive Connector is the supported bridge for that pattern.
- Writing values to a free-form
.csvfrom a VBScript bypasses the data log; the trend view will not see those rows. Either funnel the writes throughAddRecordon a configured data log, or import the.csvinto Excel for the report. - On Comfort Panels, the data log file is closed and re-opened each cycle to limit data loss on power-cut. This is why timestamps may appear off by one cycle if the panel is power-cycled while a write is in flight.
- On change logging only fires when the value changes by more than the configured hysteresis (default 0). Set the hysteresis deliberately for floating-point tags to avoid logging every analog noise tick.
- Multiple HMI connections to the same PLC tag should not log to the same data log file – race conditions on file flush may cause torn rows.
- Compressed
.rdblogs cannot be opened in Excel directly. Export them via the Archive Connector or convert with the runtime's Export function. - If the SD card is removed while runtime is active, the next write fails silently and the panel raises system event 13002. The trend view will show a flatline gap.
- Do not name data logs starting with a digit or containing umlauts; some Comfort Panel firmwares reject these at boot.
- On PC Runtime, the runtime service account must have write permission to the configured log path. Network shares should use a service account with a non-expiring password.
- When migrating from WinCC flexible 2008 to TIA Portal, legacy Archive tags map to Data logs. The on-disk format changes; archive the legacy files before the migration.
Migration to Unified Comfort Panels
If the project is being migrated to a SIMATIC HMI Unified Comfort Panel (e.g. MTP700 / MTP1000 / MTP1500 / MTP1900 / MTP2200), the data log concept is preserved, but the API surface differs:
- Data logs are configured under Historical data with the same property set.
- Trend controls are Trend view (Unified) and Online Trend Control (Unified).
- The script model is JavaScript instead of VBScript. The
AddRecordmethod is replaced by theDataLog.writeJavaScript method on the runtime API. - Storage defaults to
/media/simatic/Logs/on the Unified panel.
Plan a re-test of the entire logging path after any TIA Portal upgrade; behavior changes between major TIA Portal releases have historically affected the data log flush timing on Comfort Panels.
Can WinCC TIA Trend view read directly from an external SQL database?
No. The Trend control reads only the panel's own data log files (.csv or .rdb). For SQL or SAP archiving, deploy the SIMATIC WinCC Archive Connector to forward logged rows to an ODBC target such as SQL Server, MySQL, or Oracle.
How do I retrieve date-wise historical trends in WinCC TIA?
Configure the Trend view as Historical trend, bind it to the data log, and expose StartTime and EndTime HMI Date_Time tags so the operator – or a script – can select the date window to render. Confirm the data log uses Segmented storage so the date window actually exists on disk.
Can I write logged values to a .csv from a VBScript and render them in the trend?
You can write the .csv, but the Trend view will not read it directly. Use the AddRecord method on a configured data log instead, then render the trend from that log. This guarantees the trend view sees the rows and that the runtime's housekeeping applies.
What is the difference between cyclic and on-change logging?
Cyclic logging writes one row every N seconds regardless of value change – useful for fixed-rate process signatures. On-change logging writes only when the tag value changes (optionally with a hysteresis) – useful for event-driven data with minimal file size on slow-moving tags such as valve states or setpoint changes.
How do I control the data log start time from the PLC?
Define an HMI tag (Bool) driven by the PLC, attach a VBScript to its OnChange event, and call SmartTags("DataLogName").StartLogging or .StopLogging based on the tag value. For variable-interval sampling, attach the script to a trigger tag rising edge and use AddRecord to write one row per trigger.
Why does my exported .csv open in Excel as a single column?
The field separator in the data log (default semicolon for German locale, comma for English) does not match the regional settings on the Excel machine. Either change the separator in the data log properties, or change Excel's List separator under File → Options → Advanced. An alternative is to import via the Data → From Text/CSV wizard and specify the delimiter manually.