Overview
Continuous data logging on a Siemens SIMATIC S7-1200 PLC combined with a TP1200 Comfort HMI is a routine requirement for test stands, environmental chambers, and process validation runs where 10 or more RTD inputs must be captured without gaps. The engineering question is not whether the system can log, but where to log: inside the PLC's load memory and loadable file system, inside the HMI's archive store on SD/USB/network, or in parallel on both with a synchronization strategy.
This reference covers both options end-to-end: the DataLog instruction set in the S7-1200 firmware (DataLogCreate, DataLogOpen, DataLogWrite, DataLogClose, DataLogNewFile, DataLogDelete), and the WinCC Comfort/Advanced data log and tag logging configuration on the TP1200 Comfort Panel. File formats (CSV ANSI, RDB, TXT), storage media limits, web-server-based retrieval, and verification procedures are documented with concrete parameters.
Prerequisites
Before configuring continuous logging, confirm the following hardware and software baseline.
| Item | Specification |
|---|---|
| CPU | S7-1200 firmware V4.2 or later (DataLog full instruction set); V4.0 acceptable for DataLogCreate/Write/Close subset |
| CPU model | CPU 1211C, 1212C, 1214C, 1215C, 1217C (any DC/DC/DC or AC/DC/RLY variant) |
| RTD module | SM 1231 RTD (6ES7 231-5PD32-0XB0 for 4-channel, 6ES7 231-5PF32-0XB0 for 8-channel); supports Pt100, Pt200, Pt500, Pt1000, Ni100, Ni120, Cu10 in 2-wire/3-wire/4-wire |
| HMI | TP1200 Comfort (6AV2 124-1MC01-0AX0) |
| HMI storage | SD card >= 4 GB Class 10 (Siemens 6AV2 181-2AA10-0AA0 or industrial-grade equivalent), or USB stick, or network share |
| Engineering | TIA Portal V16 or V17 with STEP 7 Basic + WinCC Comfort/Advanced; ES license 6ES7 822-0AA04-0YA5 (Comfort/Advanced) |
| Web access | S7-1200 CPU with activated Web Server (firmware V4.0+) for browser-based CSV download |
System Topology and Data Flow
The following diagram shows the physical and logical path for logged data. The PLC periodically samples RTDs via SM 1231 modules, then writes rows either to its own internal CSV files (DataLog) or to the HMI's archive over Ethernet. The HMI can additionally hold its own logs independent of the PLC.
PLC Data Logging Architecture (S7-1200)
The S7-1200 CPU maintains a file system on its load memory (internal flash, optionally SIMATIC Memory Card). Data logging is implemented with the following IEC instructions, all from the "Data log" group in STEP 7:
| Instruction | Purpose | Typical Trigger |
|---|---|---|
DataLogCreate |
Creates a new CSV file with header row and assigns a handle (DWORD ID) | Once at startup or new test |
DataLogOpen |
Opens an existing log for appending; returns handle | After CPU restart or log rollover |
DataLogWrite |
Appends one row of values (timestamp + N columns) | Cyclic OB or timed interrupt |
DataLogClose |
Flushes buffers and closes the file | Test end, before power-down |
DataLogNewFile |
Closes current file and opens a new one (sequential naming) | Size or time threshold reached |
DataLogDelete |
Removes a log file from the file system | Maintenance, archive rotation |
Files are stored under /DataLogs/ in the CPU's user file system. Maximum concurrent open logs is limited by RAM; on CPU 1214C this is typically 8 open logs at any time, with each file bounded by available load memory (internal flash size: 1 MB on CPU 1211C, 2 MB on 1214C, 4 MB on 1215C).
Configuring DataLog on S7-1200 — Step-by-Step
-
Create a global data block. Add DB "RTD_Logger" with the following structure:
DataLogName : STRING[20];→ e.g. 'RTD_2025_01_Test42'
LogID : DWORD;→ handle returned by DataLogCreate
LogStatus : INT;→ 0 = closed, 1 = open, negative = error
Columns : ARRAY[1..10] OF REAL;→ RTD scaled values - Define a data block for one logging row. DB "RTD_LogRow" with one timestamp REAL (or DTL) plus 10 REAL columns matching physical RTDs.
-
Initialize the log in OB100 (startup). Call DataLogCreate with RECORD = DB RTD_LogRow, NAME = 'RTD_
', then DataLogOpen to obtain the handle into LogID. - Trigger sampling. In a cyclic OB (OB1) or a time-of-day interrupt OB (OB10, configured to 1 s), copy the SM 1231 RTD process image words into DB RTD_LogRow.Columns[1..10], then call DataLogWrite with ID = LogID.
- Close on test end. Triggered by an HMI tag or end-of-test boolean: call DataLogClose, then optionally DataLogNewFile to sequence the next test.
- Activate the Web Server (CPU properties → Web server → Activate; add user "anonymous" with read-only data log permission) to retrieve files via browser without TIA Portal.
ST Code Examples
The following SCL (Structured Control Language) snippet implements the create / write / close sequence for a 10-RTD test. Drop this into a function block FB_RTD_Logger and call it from OB1.
// FB_RTD_Logger — DB instance background
// Input: iStart (BOOL), iStop (BOOL), iSample (BOOL, 1 Hz from OB10)
// Output: qStatus (INT), qFileSize (DWORD), qFileName (STRING)
// InOut: ioRTD : ARRAY[1..10] OF REAL
IF iStart AND (qStatus = 0) THEN
"RTD_Logger".DataLogName := 'RTD_';
DataLogCreate(
RECORD := "RTD_LogRow",
NAME := "RTD_Logger".DataLogName,
ID := "RTD_Logger".LogID,
HEADER := 't;RTD1;RTD2;RTD3;RTD4;RTD5;RTD6;RTD7;RTD8;RTD9;RTD10',
FORMAT := 0, // 0 = CSV ANSI comma
TIMECOL := TRUE // auto-insert timestamp column
);
IF "RTD_Logger".LogID <> 0 THEN
qStatus := 1;
END_IF;
END_IF;
IF iSample AND (qStatus = 1) THEN
// copy live RTDs into row buffer
FOR i := 1 TO 10 DO
"RTD_LogRow".Column[i] := ioRTD[i];
END_FOR;
DataLogWrite(
ID := "RTD_Logger".LogID,
RECORD := "RTD_LogRow"
);
END_IF;
IF iStop AND (qStatus = 1) THEN
DataLogClose(ID := "RTD_Logger".LogID);
qStatus := 2; // 2 = closed & archived
END_IF;
HMI Data Logging on TP1200 Comfort
The TP1200 Comfort Panel hosts its own log engine, fully independent of any PLC DataLog. Configuration is done in TIA Portal under HMIs → TP1200 → Historical data → Data logs. The Comfort family supports the following capacities:
| Parameter | Limit |
|---|---|
| Number of logs | 50 (independent of PLC logs) |
| Maximum entries per log (theoretical) | 20,000 |
| Recommended entries per log (field practice) | 5,000 |
| Log file formats | CSV (ANSI), RDB (proprietary), TXT (tab-separated) |
| Storage locations | SD card, USB stick, network share (SMB) |
| Logging modes | Cyclic (overwrite oldest), segmented (multiple files), upon request (event-driven) |
| Trigger | Time cyclic, tag change (any tag in the log), event-triggered via PLC bit |
To configure a 10-RTD data log on the TP1200:
- In the project tree, expand the TP1200 device → Historical data → add a new Data log named "RTD_Test_Log".
- Add 10 log tags, each pointing to a PLC DB word address (e.g.
DB_RTD_Buffer.Column[1..10]) via the configured HMI connection. - Set Acquisition cycle = 1000 ms (1 s). For sub-second acquisition, enable Trigger = tag change for a heartbeat bit on the PLC; this allows acquisition down to 100 ms without flooding the connection.
- Define Storage location =
\Storage Card SD\Logs\and select CSV (ANSI) format. - Enable Segmentation and set file size limit to 4 MB or daily rollover — this prevents single-file bloat on long-duration tests.
- Add an f(t) trend view on the same screen, bind all 10 tags, and enable "Save trend data" so the on-screen trend corresponds to the historical log.
PLC vs HMI Data Logging — Comparison
| Criterion | PLC DataLog (S7-1200) | HMI Data Log (TP1200 Comfort) |
|---|---|---|
| Capacity | Limited by internal load memory (1–4 MB); not SD-card | SD card / USB / SMB; multi-GB available |
| Maximum logs | ~8 concurrent open (CPU-dependent) | 50 independent logs |
| Recommended rows per file | Up to ~250,000 (memory-bound) | 5,000 (Siemens-recommended for performance) |
| Min sample rate | ~10 ms (depends on row width) | 100 ms (cyclic) or tag-change |
| File format | CSV only (header-configurable) | CSV ANSI / RDB / TXT |
| Retrieval without TIA | Web server URL → standard browser | Export via Control Panel → USB, or network share browsing |
| Survives HMI swap | Yes — lives on PLC | No — files lost if SD not transferred (unless archived to SMB) |
| Engineering effort | Medium — SCL, OB configuration | Low — mouse-driven configuration |
| Best for | Long-duration unattended logging; redundant storage | Operator-facing trends; quick deployment |
Recommendation: For a 10-RTD validation test where the operator wants both live trending on the TP1200 and recoverable historical CSV files that survive HMI replacement or SD card failure, configure both paths. Use the HMI log for operator visualization (f(t) trend) and the PLC DataLog for archival retrieval via web server. The PLC DataLog becomes the authoritative record.
File Formats and Storage Paths
| Format | Extension | Internal Structure | Open With |
|---|---|---|---|
| CSV ANSI | .csv | Comma-separated, ISO-8859-1, decimal point = '.' | Excel, Notepad++, any text editor |
| CSV UTF-8 | .csv | UTF-8, with optional BOM (PLC V4.2.3+) | Excel 2016+, Notepad++, R/Python |
| TXT | .txt | Tab-separated; first row = column names | Excel import wizard, Notepad++ |
| RDB | .rdb | Siemens proprietary relational database format (compressed) | WinCC Viewer, ProSave tool, MS Access via ODBC (advanced) |
Storage paths:
-
PLC DataLog: internal flash, accessible via
https://<CPU_IP>/DataLogs/<filename>.csvwhen Web Server is activated and "Allow data log access" is enabled. -
TP1200 Comfort:
\Storage Card SD\Logs\<logname>\on the SD card, or\USB\Storage USB\Logs\<logname>\, or\<SMB_share>\Logs\<logname>\for network archive.
Memory and Performance Sizing
For 10 RTDs at 1 s acquisition: each row consumes roughly 50 bytes (timestamp + 10 × REAL + separators). Calculate duration before memory exhaustion:
Duration (hours) = Memory (bytes) / [50 × 3600 / SamplePeriod(s)]
| CPU | Internal Load Memory | 1 s sample, 10 RTDs | 10 s sample, 10 RTDs |
|---|---|---|---|
| CPU 1211C | 1 MB (after program) | ~5.5 h | ~55 h |
| CPU 1214C | 2 MB (after program) | ~11 h | ~110 h |
| CPU 1215C | 4 MB (after program) | ~22 h | ~220 h |
For tests longer than the table indicates, implement DataLogNewFile to roll over, then move files off via web server to a PC. Alternatively, use the TP1200 Comfort with a 32 GB SD card, where 32 GB / (50 B × 3600 / 1) = ~178 h of continuous 1 s logging is feasible.
Retrieving Data — Web Server (PLC) and Export (HMI)
From the PLC (DataLog CSV)
- Open a browser at
http://<CPU_IP>. - Log in if a user/password is configured.
- Navigate to Data Logs → click the file → browser download dialog → save
.csv.
For scripted retrieval, use a Python or PowerShell snippet with HTTP basic auth; the CPU responds with standard text/csv MIME. The download URL is http://<IP>/DataLogs/<filename>.csv.
From the TP1200 Comfort (HMI log)
- Insert USB stick in TP1200.
- Open the panel's Control Panel → Backup/Restore → Export logs.
- Select log, choose format, copy to USB.
Alternative: configure the log's storage path as \\NAS\share\ via SMB, so each rollover writes a new file directly to the network share. The TP1200 supports SMBv1/v2 with username/password; v3 requires TIA V17+ panel image.
Verification Procedures
-
Confirm DataLog creation: in TIA Portal online view, watch
"RTD_Logger".LogIDafter iStart; expect non-zero DWORD. -
Confirm row writes: read
qFileSize; expect monotonic growth matching sample period. - Pull the file via web server within 30 s of writing 10 rows; open in Excel; confirm 1 header line + 10 data lines and timestamp monotonically increasing.
- Confirm TP1200 trend shows the same numeric values as the PLC DB within ±0.1 °C.
-
Stress test: run for 1 h at production sample rate; verify no DataLog error code returned (codes 0001–001A in
qStatus; see matrix below).
Troubleshooting Matrix
| Symptom | Likely Cause | Corrective Action |
|---|---|---|
| DataLogCreate returns LogID = 0 | Log name already exists in file system | Call DataLogDelete first or append unique timestamp to NAME |
| DataLogWrite error 0x0001 | ID invalid (log closed or never opened) | Re-issue DataLogOpen; check qStatus before write |
| DataLogWrite error 0x0006 | Internal memory exhausted | Call DataLogNewFile to roll, or reduce sample rate |
| TP1200 trend shows flat line | HMI connection area pointer missing, or wrong DB number | Re-check connection under Devices & Networks; ping PLC from HMI Control Panel |
| CSV file empty after download | DataLogClose not called; data in buffer only | Always call DataLogClose before file retrieval, or force a flush via 100-row threshold |
| Garbled characters in CSV | Non-ANSI characters in tag names with UTF-8 format on legacy Excel | Use FORMAT = 0 (CSV ANSI) or open with Notepad++ encoding set to UTF-8 |
| Web server returns 404 on /DataLogs/ | Web server not activated, or "Allow data log access" unchecked | CPU properties → Web server → activate, then tick data log permission |
| TP1200 SMB archive fails | Auth mismatch, SMBv3 required but not supported on older panel image | Set NAS to SMBv2 or update panel image to TIA V17 |
Field-Proven Caveats
- Power-loss resilience: PLC DataLog files are committed only on DataLogClose or every 100 rows internally buffered; mid-test power loss may lose up to ~100 rows. The HMI RDB format is more transactional but still not ACID-grade — for regulatory 21 CFR Part 11 compliance, add a UPS and a verification hash on close.
- Clock drift: Use the PLC's DTL (DATE_AND_TIME) for row timestamps, not the HMI's internal clock, to maintain a single time authority across PLC and HMI logs.
- RTD scaling: SM 1231 RTD returns values already in °C when configured for Pt100/Pt1000. For raw resistance logging (Ω), scale by 0.1 in the AI config — useful when the test is sensor-characterization rather than temperature validation.
- Segmentation naming: TP1200 segmented logs append a six-digit sequence (_000001). Include the test ID in the log name to avoid confusion across re-runs.
What is the maximum number of rows per CSV file when logging 10 RTDs on an S7-1200?
With internal load memory of 1–4 MB and a row width of ~50 bytes, the S7-1200 supports roughly 20,000–80,000 rows per file before DataLogWrite returns error 0x0006 (memory exhausted). For long tests, use DataLogNewFile to roll over to a new file at a chosen threshold.
Should I log on the PLC or on the TP1200 Comfort?
Use the PLC DataLog for the authoritative record (survives HMI swap, retrievable via web server, lives in non-volatile CPU flash). Use the TP1200 data log for operator-facing f(t) trend visualization and quick on-screen historical review. For a 10-RTD validation test, configure both and accept the small overhead — the redundancy is worth the engineering cost.
Can I retrieve PLC DataLog CSV files without TIA Portal installed?
Yes. Activate the Web Server on the S7-1200 CPU (firmware V4.0+) and browse to http://<CPU_IP>/DataLogs/. Files download as standard CSV. Enable "Allow data log access" under Web server user permissions and configure a read-only user account. No TIA installation is required on the retrieval PC.
What is the minimum reliable sample period for 10 RTDs?
On a CPU 1214C, the minimum stable sample period for DataLogWrite with 10 REAL columns plus a timestamp is approximately 100 ms when called from OB1, or 10 ms when called from a time-of-day interrupt OB10 with a dedicated logging priority. Below 100 ms, expect CPU scan-time violations on the cyclic program; below 10 ms, expect buffer overruns.
Which file format should I choose — CSV, RDB, or TXT?
Use CSV (ANSI) for the broadest compatibility with Excel, MATLAB, and Python pandas. Use TXT (tab-separated) when you need to avoid locale-specific decimal separators (e.g., European PLCs). Use RDB only when consuming the data in WinCC Runtime/Viewer on another engineering station; the format is compressed and not human-readable.