Troubleshooting MP270B WinCC Flexible Network File Write Failures
Field-engineer reference for diagnosing intermittent, unrecoverable file-write drops in a Siemens MP270B Multi Panel running WinCC Flexible 2008, where scheduled and tag-change triggered VB scripts fail to deposit log files on a Windows XP engineering station over Ethernet. Covers root-cause matrix, on-panel diagnostics, hardening steps, and the path to migrating the data-logging role to a PC-based WinCC Flexible Runtime.
1. System Architecture and Reported Symptom
The reported topology comprises a Siemens MP270B Multi Panel connected to an S7-300 CPU 313C-2DP, with two OP77B operator panels hanging off the same Profibus segment. The MP270B and a Windows XP SP3 engineering station share an Ethernet segment. The S7-300 is connected to that segment through a CP 343-1 IT communications processor. The MP270B is a monitoring and data-logging peer; it is not in the S7-300 I/O path.
Two classes of VB script on the MP270B perform data logging:
- Scheduled scripts triggered by the WinCC Flexible Scheduler (typically hourly flow totals, shift reports, batch end-of-step dumps).
- Tag-driven scripts triggered by the OnChange event of one or more HMI tags, recording the value transition plus a timestamp.
Two failure modes are reported:
- The targeted .txt or .csv files on the XP box appear as expected, but the most recent interval or transition is missing.
- None of the scheduled or tag-driven log files are written for an extended period. The MP270B continues to display values and respond to touch; only the script-driven file output stalls. Rebooting the panel restores logging for between two hours and four days before the symptom returns.
The PC, MP270B and Ethernet switch are all on a common UPS, which rules out transient mains loss as the trigger. Because the failure survives panel reboot, the root cause is not transiently held in volatile state; the panel repeatedly enters a bad state and must be restarted to clear it.
2. Why the MP270B Is the Most Likely Culprit
The MP270B runs Windows CE 5.0. WinCC Flexible 2008 executes VB script in the CE 5.0 script engine, a 16-bit Unicode, single-process, single-threaded environment with hard limits that are easy to brush up against in long-running logging applications:
| Resource | MP270B Windows CE 5.0 limit (typical default) | Observed failure mode when exceeded |
|---|---|---|
| Concurrent open file handles per process | ~64 by default; tunable via ProcessHandleQuota registry |
OpenTextFile returns 0x800A0035 (Path/File access error) or 0x80070005; GetLastError logs E_OUTOFMEMORY-style codes |
| Path length |
MAX_PATH = 260 wide characters; UNC paths must remain below 260 |
Long share paths are silently truncated, writing to a phantom local path under \Storage Card2\
|
| Stack per script invocation | Default 64 KB per VBScript invocation in CE 5.0 | Recursion or large string concatenation raises "Out of stack space" (0x800A001C) |
| Network session cache | Up to 8 simultaneous authenticated UNC sessions per process | "Multiple connections to a server or shared resource by the same user" (0x800704C3) or 0x80070035 "Network path not found" |
| CompactFlash write cache | CE 5.0 file system cache ~512 KB | Forced flush on TextStream.Close can stall the script thread for 100-400 ms; a burst of closes can back up the scheduler |
Every file the script opens via FileSystemObject in WinCC Flexible remains open for the duration of the script or until explicitly closed with .Close. A scheduled script that opens a daily log file and never closes it will accumulate handles until the per-process table fills. A tag-driven script that fires rapidly on a noisy process tag can do the same in minutes. When the table fills, the next script returns an error that the default On Error Resume Next pattern silently absorbs, so the operator sees no error message and the log simply stops growing.
Rebooting the panel releases every handle and clears every UNC session, which is why the cure is always a restart. The same mechanism explains the wide variance in time-to-failure: the handle count grows linearly with script activity, so a panel that runs only an hourly job fails in days, while one that runs a per-second tag-change job fails in hours.
3. Root Cause Matrix
| ID | Hypothesis | Evidence that supports it | Evidence that refutes it | Verification step |
|---|---|---|---|---|
| R1 | File-handle leak in scheduled and tag-change scripts | Symptoms recover on reboot; affected file count grows over time before stalling | Does not by itself explain multi-day hang if the leak rate is low | Add handle-counter logging via CreateObject("Scripting.FileSystemObject") inventory at script start; check win32k handle table via CE remote display |
| R2 | UNC session cache exhaustion against XP | XP allows only 10 simultaneous CIFS connections from one user by default; the panel may use the default user for every script | A clean error (0x800704C3) would normally surface in On Error Goto trap |
Run net session on the XP box during a stall; run net use from a peer to enumerate the share's open handles |
| R3 | XP password expiry, screen lock, or auto-logout of the share user | Failure appears correlated with work hours; HMI and PC on UPS means screen lock is a candidate | Not reported as time-aligned in the original observation | Disable screen lock on the share user account; set Reset on disconnect = No on the share; set a non-expiring password |
| R4 | Ethernet switch port or cabling flapping (less likely on UPS) | None of the other Profibus devices are affected | HMI continues to read live values from the S7-300 via the same switch | Read CP 343-1 IT diagnostic buffer; use the switch's GetPortStats / RMON counters for CRC and link-flap events |
| R5 | MP270B internal Flash file system corruption | Onboard Flash has a limited write-cycle budget; partial writes under any prior UPS loss can corrupt the FAT | Symptoms are network-side, not local | Export \Storage Card2\Logs via FTP or ActiveSync; inspect with the chkdsk equivalent for the FAT partition |
| R6 | WinCC Flexible Runtime internal buffer overflow or script-engine hang | CP 343-1 IT, OP77Bs, and S7-300 continue to operate normally; only the script thread stalls | Re-arming after a stall works for hours, suggesting it is not a deadlock | Enable PDLRT /log; export the Runtime diagnostic file from \Storage Card2\Logs
|
| R7 | Antivirus or Windows XP background maintenance (Defragmenter, AutoUpdate) locking the share | Symptom does not align with a fixed pattern | Would not explain rapid onset of failure after a few hours of operation | Exclude the share path from real-time AV scanning; reschedule defrag and autoupdate to off-shift |
In practice, R1 is the most common cause on MP270B and similar Multi Panel hardware, with R2 and R3 acting as amplifiers. The remaining hypotheses are useful in the field checklist but rarely the sole driver.
4. On-Panel Diagnostics
Before changing the application, instrument the panel so the next occurrence can be captured. The instrumented build is left in place for at least one full shift or one full multi-day incident, whichever comes first.
- Enable the WinCC Flexible diagnostic trace. In the Engineering project, navigate to Project > Runtime Settings > Services and activate the diagnostic files. On the panel, the resulting trace is written to
\Storage Card2\Logs\PDLRT_<timestamp>.log. - Replace
On Error Resume Nextwith an explicit error trap that writes to a rolling error log on Flash, where the panel always has local access:
Sub WriteBatchLog(sPath, sLine)
Dim oFSO, oTS, iErr, sErr
On Error Resume Next
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile(sPath, 8, True) ' 8 = ForAppending
If Err.Number <> 0 Then
iErr = Err.Number
sErr = Err.Description
Err.Clear
Set oTS = oFSO.OpenTextFile("\Storage Card2\diag_err.csv", 8, True)
oTS.WriteLine Now & ";" & sPath & ";0x" & Hex(iErr) & ";" & sErr
Else
oTS.WriteLine sLine
oTS.Close
End If
Set oTS = Nothing
Set oFSO = Nothing
End Sub
- Add a one-second periodic script that records
FreeFileavailability, free RAM (viaMemoryStatusequivalent inSystemInfo), and the count of open UNC sessions to a ring buffer on Flash. When the buffer fills, the next event overwrites the oldest entry so the file size is bounded. - Enable the CE 5.0 FTP server on the panel (Start > Programs > FTP Server) with anonymous read-only access to
\Storage Card2\Logsso the logs can be pulled remotely without an ActiveSync cradle. The FTP server uses a separate socket pool from the WinCC Flexible Runtime and is not affected by handle-table pressure in the Runtime process. - Mirror the script to write to a local Flash path as well as the UNC path. If the local copy keeps arriving and the UNC copy does not, the panel and Runtime are healthy and the failure is in the network path or share.
5. Hardening the Existing Configuration
If the project must stay on the panel in the short term, apply the following changes without altering the project logic. Each change is independent; applying all of them is acceptable and additive.
5.1 Use a dedicated share user with persistent credentials
Create a Windows XP local account such as mp270svc with a non-expiring password. On the share, set Maximum allowed = 10, Allow caching = No, and Offline files = Disabled. On the panel, configure the connection once via CE Remote Display or by using net use \\<xp>\<share> /user:mp270svc <pwd> /persistent:yes executed from a startup script. The persistent connection consumes one of the ten share slots and avoids reconnect latency on every script trigger.
5.2 Force-close every file handle
Every OpenTextFile in any script must be paired with an explicit .Close and a Set ... = Nothing. The Format parameter in WinCC Flexible's OpenTextFile call accepts 0 (ASCII, the default) or -1 (Unicode). Use -1 only when the consuming app on the XP side expects UTF-16; otherwise use 0 to keep the files text-grep friendly and to avoid doubling the on-Flash file size.
5.3 Bound the file size and roll
CE 5.0 supports very large files in theory, but a Runtime script that appends without rotation will eventually trip the path-length and handle-count failures described in Section 2. Adopt a fixed-size rolling scheme, e.g. 1 MB per file, and delete the oldest beyond a count of ten. Pseudocode:
Function Rotate(sBase, iMaxBytes, iKeep)
Dim oFSO, oFile, i
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(sBase) Then
Set oFile = oFSO.GetFile(sBase)
If oFile.Size >= iMaxBytes Then
oFSO.MoveFile sBase, sBase & "." & Format(Now,"yyyymmddhhnnss")
End If
End If
For i = iKeep To 1 Step -1
If oFSO.FileExists(sBase & "." & i) Then
If oFSO.FileExists(sBase & "." & (i + 1)) Then
oFSO.DeleteFile sBase & "." & (i + 1)
End If
oFSO.MoveFile sBase & "." & i, sBase & "." & (i + 1)
End If
Next
Set oFile = Nothing
Set oFSO = Nothing
End Function
5.4 Move the file target from the XP share to the CP 343-1 IT file system
The CP 343-1 IT provides an integrated file system accessible via FTP. The panel can FTP the log file directly to the CP, removing the Windows XP box from the data path and eliminating the share-session, password, and antivirus interactions. Configure the CP using STEP 7 CP 343-1 IT > File System and the FTP server settings. The CP file system is small (typically 8 to 16 MB of user space) but is sufficient for an hourly or shift-rate text log. This converts the data path from CIFS/UNC to FTP, which is connectionless from the panel's perspective and survives most share-side failures. See the WinCC flexible archiving PDF on the Siemens support portal for the equivalent mechanism on the engineering side: How are tags and messages archived in WinCC flexible?.
5.5 Replace tag-change with rate-limited scheduler
If a tag is changing more than once per second, replace OnChange with a 1-second or 5-second scheduled script that captures the latest value and the time of the last change. This reduces the script invocations from thousands per minute to 12 or 60 per minute, eliminates the per-invocation handle churn, and gives a consistent data rate for downstream processing. It also makes the resulting log files easier to align with batch and shift boundaries on the XP side.
6. Migrating the Data-Logging Role to a PC Runtime
If the panel-based data path cannot be made reliable within the available maintenance windows, the more robust architecture is to move the logging role to a PC that already participates in the same Ethernet segment. The panel keeps its operator-interface role; the PC adds the historian/file-writer role. This decouples display responsiveness from data integrity and lets the PC use a desktop file system, scheduled tasks, and the WinCC Flexible PC Runtime simultaneously. Yes, a copy of WinCC Flex Runtime on the PC is the better architecture, and no, you do not need a separate option module to do it: the base PC Runtime includes the same scheduler, tag system, and VB-script engine as the panel Runtime, and the existing scripts run unchanged.
6.1 What WinCC Flexible Runtime on PC delivers
WinCC Flexible Runtime is the PC equivalent of the panel Runtime. It is a Windows service plus a visualization surface that:
- Connects to the S7-300 over TCP/IP through the CP 343-1 IT using S7-Comm (PUT/GET), or via MPI/Profibus with a CP 5611 or CP 5613 installed in the PC.
- Runs the same WinCC Flexible project that runs on the panel, with any device-specific differences enforced by device-specific settings in the project.
- Hosts the same scheduler, the same tag system, and the same VB-script environment as the panel, with the desktop Windows Script Host underneath. No script rewrite is needed.
- Writes files to the local NTFS file system, where handles, file size, path length, and concurrent connections are limited only by the operating-system defaults rather than by the CE 5.0 handle-table budget.
6.2 Licensing
WinCC Flexible 2008 PC Runtime is licensed in PowerTag tiers. The smallest tier is 128 PowerTags, with subsequent tiers at 512, 2048, and 4096 PowerTags. Additional options such as Recipes and Audit are licensed separately and stack on top of any Runtime tier. Verify the current catalog numbers and prices with Siemens or your distributor, as licensing was reorganized during the 2008-to-2010 update cycle. For the data-logging use case described in this article, no option is required beyond the base Runtime: the VB script engine, the scheduler, and the tag system are all part of the base license. The user's distributor should be able to quote a 128-PowerTag Runtime without options, and that is sufficient for this project.
6.3 Architecture after migration
7. Migration Procedure
- Install WinCC Flexible 2008 SP5 on the PC. Use the same major service-pack level as the panel Runtime to avoid project-version round-tripping issues. SP5 is the last released update for WinCC Flexible 2008 in the 2008 product line.
- Copy the existing project
.hmifile to the PC. Open it in the Engineering Station. The project will open in Target: PC Runtime mode and the panel-specific compilation options will be ignored. - Adjust the connection from S7-300/400 MPI/Profibus to S7-300/400 TCP/IP and enter the CP 343-1 IT IP address. Enable PUT/GET access on the CP in STEP 7 under CP 343-1 IT > Properties > Options > Connections if it is not already.
- Re-target the VB scripts that use
FileSystemObjectto a local path, e.g.C:\PlantLogs\Batch\<date>.csv. NTFS supports 32K path components and file sizes up to the partition size, removing both of the CE-side failure modes. - Compile and download to the PC Runtime. The Runtime starts as a Windows service and the visualization surface appears on the monitor. Configure it to start automatically with the workstation, with auto-login if the PC is dedicated to this role.
- Decide whether the panel remains as a display or is decommissioned. The minimum-cost option is to leave the panel on the network as a secondary viewer; remove its script triggers to avoid double-logging and to keep the panel CPU free for display.
- Configure the PC for unattended operation: disable screen lock, set the power profile to Never sleep, exclude the log path from real-time AV scanning, and configure Windows to write a small status file every minute so that an external monitor (or the existing MP270B, repurposed as a status display) can confirm the Runtime is alive.
8. Verification and Acceptance Test
After either hardening or migration, run an acceptance test that exercises both the happy path and the failure scenarios observed in the field.
| Test | Method | Pass criterion |
|---|---|---|
| Hourly scheduled log | Run for 24 hours; verify 24 files present on the target share | All 24 files present, none truncated, sizes within the rolling envelope |
| Tag-change log under burst | Force the triggering tag to oscillate at 5 Hz for 5 minutes | No dropped transitions, no file-handle errors in the diagnostic log |
| Network share outage | Disconnect the XP box for 10 minutes, reconnect | Scripts queue or fail soft; no panel hang; logging resumes automatically once the share is back |
| CP 343-1 IT reboot | Power-cycle the CP | PC Runtime reconnects within 30 seconds; logging resumes |
| Panel reboot (if panel retained) | Cold restart the MP270B | PC Runtime is unaffected; no missing log entries |
| 48-hour soak | Leave the system running for 48 hours | Log file count matches the scheduled count, no diagnostic errors, RAM and handle counters stable |
9. Long-Term Recommendations
The MP270B and WinCC Flexible 2008 are end-of-life products. The recommended replacement paths for new installations are:
- Same generation replacement: MP 277 Multi Panel, which increases memory, USB host support, and the script-engine stability on a newer Windows CE build.
- Current generation replacement: Comfort Panel (TP 177 / KTP 700 / TP 900) on TIA Portal and WinCC Comfort/Advanced. These panels use a newer Windows CE / Windows Embedded Compact, with a much larger file-handle table and built-in script-debug trace.
- PC Runtime replacement: WinCC Runtime Advanced (TIA Portal) on a SIMATIC IPC, which gives a 64-bit script environment and direct access to SQL Server for proper historian storage. The new WinCC Unified data logging path in TIA Portal is described in the official documentation: Basics of data logging (RT Unified).
For the data-logging role specifically, the historical move from per-tag CSV files to a real historian is the right direction. WinCC Flexible supports direct SQL output via an ODBC script, and TIA Portal's Data Logging capability provides a database-backed tag log that removes the need for hand-rolled VB scripts. For existing WinCC Flexible projects, the How are tags and messages archived in WinCC flexible? PDF on the Siemens support portal describes the integrated tag-log and alarm-log mechanisms that can replace ad-hoc scripts entirely. A useful third-party tool for inspecting the resulting log files is the open-source WinCCflexLogViewer by yuriqdev on GitHub, which reads WinCC Flexible and TIA Portal archive files directly.
10. FAQ
Can I run a WinCC Flexible project on a PC and on the MP270B at the same time?
Yes. The PC Runtime is licensed as a separate seat and the panel Runtime continues to operate against the same S7-300 connection. Avoid configuring both runtimes to write to the same log path or trigger on the same tag events, otherwise the file will be written twice and the network load will be doubled.
Do I need any add-on option to use VB scripts on the PC Runtime?
No. The base WinCC Flexible Runtime licenses include the same VB-script engine as the panel Runtime. No additional option is required for the standard FileSystemObject and database access that the existing panel scripts use. Recipes and Audit are the two options that are licensed separately, and neither is required for logging.
How many log files can a single MP270B write per day without exhausting handles?
In practice, an MP270B starts to show handle pressure when more than 100 to 150 OpenTextFile calls are outstanding at any one moment. With hourly files and a daily rotation, the per-day count is fine; with minute-resolution tag-change logs, a single day's run can reach 1,440 files and a single per-tag open handle per log entry. Migrate to a per-minute rolling file rather than one file per minute to keep the open-handle count bounded.
Is the CP 343-1 IT file system a reliable drop-in replacement for the Windows XP share?
For low-to-medium data rates (a few MB per hour), yes. The CP 343-1 IT has a small file system (typically 8 to 16 MB user space), 32-bit file handles, and an FTP server that is connectionless from the panel's perspective. For higher rates or for redundancy, use the PC Runtime as the historian and the CP 343-1 IT only as a buffer.
What is the smallest license that covers my project?
Count the external S7 tags that participate in the project, including those used by scripts and alarms. The smallest license whose PowerTag count exceeds that number is the minimum. The 128-PowerTag tier is the entry point; the 512, 2048, and 4096 tiers add capacity without adding features other than the separately licensed Recipes and Audit options.