Exporting Data from a Siemens CPU 313C-2DP (S7-300) to a PC: A Field Reference
Exporting measurement values and alarm records from a SIMATIC S7-300 CPU 313C-2DP to a host PC is a recurring requirement in retrofit and small-machine projects. Unlike the S7-1200 and S7-1500 families, which have integrated Data Logging instructions (see the TIA Portal V20 data-logging overview), the S7-300 family requires the user to choose between a driver library (PRODAVE), a SCADA package (WinCC flexible, ProTool/Pro, WinCC), a third-party OPC server, or a custom user program running against the SAPI-S7 or Snap7 interface. Each path has distinct cost, complexity, and licensing implications.
This reference defines the realistic options for a 313C-2DP paired with a TP170A panel and ranks them by hardware prerequisites, software cost, and recurring engineering effort.
1. CPU 313C-2DP Hardware Inventory and Communication Interfaces
Before choosing a logging method, identify the physical interfaces available on the CPU. The 313C-2DP order number 6ES7313-6CF03-0AB0 (and similar variants) provides exactly two physical ports:
| Port | Type | Default Protocol | Use for PC Connection? |
|---|---|---|---|
| X1 (top) | RS485 MPI/PROFIBUS-DP master | MPI (187.5 kbit/s default) | Yes, via PC adapter or CP |
| X2 (bottom) | RS485 PROFIBUS-DP slave | DP slave | Indirect via DP master |
The 313C-2DP has no integrated Ethernet port. To use TCP/IP-based logging, the project must include either a CP 343-1 Lean (6GK7343-1CX10-0XE0), CP 343-1 (6GK7343-1EX30-0XE0), or an external Ethernet module on the PROFIBUS backbone. The TP170A panel itself connects via MPI or PROFIBUS and does not provide Ethernet pass-through.
2. Option Matrix: PC-Side Logging Paths
| Method | PC Connection | Relative Cost (USD, list) | Engineering Effort | Bidirectional | Best For |
|---|---|---|---|---|---|
| PRODAVE S7 / MPI/IE | MPI (PC Adapter USB) or Ethernet (CP 343-1) | Library only, no runtime royalty; ~$1,500 list | Medium — C/C++/.NET calls | Yes | Custom Windows logging app |
| ProTool/Pro RT | MPI / PROFIBUS | Discontinued; ~$2,500 legacy | Low — configuration only | Limited | Existing TP170A projects |
| WinCC flexible 2008 | MPI / PROFIBUS / Ethernet | ~$1,800 (RT 128 tags) to $4,500 (RT 2048) | Low — tag-based | Yes | HMI upgrade path; small SCADA |
| WinCC V7.x / TIA WinCC | MPI / PROFIBUS / Ethernet | ~$5,000–$15,000 | Medium-High | Yes | Larger plant SCADA with archive |
| OPC Server (Simatic NET / Softing / Kepware) | MPI / PROFIBUS / Ethernet | ~$2,500–$6,000 | Low — OPC DA/UA client handles rest | Yes | Any third-party historian |
| Custom libnodave / Snap7 | MPI (PC Adapter) / Ethernet | Free (open-source) | Medium-High | Yes | Linux/embedded integrators |
| STEP 7 Archive (Recipe/Data Log on MMC) | None (on-CPU) | Free with STEP 7 | Medium | One-way | Periodic CSV on MMC, retrieved via PC adapter |
For the original question — simplest and cheapest — the candidates narrow to PRODAVE (custom app), WinCC flexible Advanced (SCADA), or a free Snap7/libnodave client reading tags directly through MPI.
3. Method A — PRODAVE Library (Cheapest Commercial Path)
PRODAVE is Siemens' proprietary PC-side communication library for S7 PLCs. The current commercial release is PRODAVE S7 V6.2 / PRODAVE MPI/IE V7.x (sometimes shipped as part of PC Internal Interface bundles). It exposes a Windows DLL (w95_s7.dll for MPI/IE or w95_s7.dll for Ethernet-only) callable from C, C++, VB6, or .NET via P/Invoke.
3.1 Hardware Prerequisites
- Siemens PC Adapter USB A2 (6GK1571-1AA00) or a CP 5611/CP 5621 PROFIBUS card for MPI.
- For Ethernet: CP 343-1 Lean (or higher) installed in the S7-300 rack; PRODAVE MPI/IE V7.x or higher.
- STEP 7 V5.5 SPx (or TIA Portal) configured project for the 313C-2DP and CP 343-1.
3.2 Function Set (Relevant Calls)
-
LoadConnection_ex()/SetActiveOnlineConnection()— establish PC↔PLC connection, returns a connection handle. -
db_read()/db_write()— read/write full DBs (binary image). -
mb_read_bit(),mb_read_byte(),mb_read_word()— operand-level access (M, I, Q, DB). -
field_read_float()/field_write_float()— typed REAL conversions matching IEEE 754. -
unload_connection()— graceful close.
The official entry point and print reference is the PRODAVE MPI/IE V7.0 Programming Manual, also referenced through the ST70 catalog and Siemens support entry ID 21973664 under Siemens Support 21973664. The PDF lists every function call signature and the error codes returned by GetErrorMessage():
| Hex Return | Meaning | Typical Cause |
|---|---|---|
| 0x00000000 | OK | — |
| 0x80000001 | Connection not loaded | Call sequence error |
| 0x80000002 | Invalid handle | Connection closed before call |
| 0x80000100 | MPI/DP driver error | CP 5611 driver not installed or license missing |
| 0x80000200 | Ethernet connection error | CP 343-1 IP unreachable; check ISO-on-TCP port 102 |
| 0x80000300 | PLC error during read | Wrong DB number; access-protection on optimized DB (irrelevant for S7-300 classic) |
| 0x80000400 | Timeout | MPI baud rate mismatch (default 187.5 kbit/s vs. PC Adapter USB auto) |
3.3 Sample C++ Logging Loop
// Pseudo-code for logging 4 REAL values from DB100 every 1000 ms
#include "Prodave.h"
int main() {
HANDLE hConn = 0;
CON_TABLE con;
memset(&con, 0, sizeof(con));
strcpy(con.adr, "192.168.0.10"); // CP 343-1 IP
con.rack = 0;
con.slot = 2; // CP 343-1 slot, not CPU slot
con.type = CON_TCP; // ISO-on-TCP (RFC1006)
if (LoadConnection_ex(&hConn, &con) != 0) {
printf("Connect failed: 0x%08X\n", GetLastError());
return 1;
}
FILE* fp = fopen("log.csv", "w");
fprintf(fp, "Timestamp,PV1,PV2,PV3,PV4\n");
while (running) {
float pv[4];
for (int i = 0; i < 4; ++i) {
if (field_read_float(hConn, 100, 0, i * 4, &pv[i]) != 0) {
// read offset DB100.DBD0, DBD4, DBD8, DBD12
}
}
time_t t = time(NULL);
fprintf(fp, "%ld,%.3f,%.3f,%.3f,%.3f\n", t, pv[0], pv[1], pv[2], pv[3]);
fflush(fp);
Sleep(1000);
}
UnloadConnection(hConn);
fclose(fp);
return 0;
}
3.4 Verification Checklist for PRODAVE
- Use
Ping(PRODAVE diagnostic tool shipped with the CD) to confirm CP 343-1 visibility before any code runs. - Confirm STEP 7 PG-PC Interface setting on the development PC matches the physical adapter (ISO Ind. Ethernet or MPI/DP).
- Monitor PRODAVE version against STEP 7: PRODAVE V6.x is for STEP 7 V5.4 and earlier; V7.x is for V5.5 / TIA V13+.
- License: the PRODAVE CD requires the Authorisation key to be transferred to the local license server. Without it, the DLL returns
0x80000100.
4. Method B — WinCC flexible 2008 / WinCC RT (Simplest Commercial Path)
WinCC flexible is the SCADA package designed for the TP170A/B and the S7-300 family. The Runtime component runs as a Windows service, polls the PLC via MPI/PROFIBUS or Ethernet, and natively archives tags. No programming is required to log data; configuration happens in the WinCC flexible Engineering tool.
4.1 Configuration Steps
-
Create a connection: WinCC flexible → Connections → New. Driver
S7 MPI/DPfor PC Adapter orS7 Ethernetfor CP 343-1. Rack/Slot must match the CPU (313C-2DP is rack 0, slot 2). - Define tags: each PV becomes one tag with a specific DB address. Use a polling cycle of 1000 ms; WinCC flexible downsamples internally to the archive cycle.
- Create a Tag Log: Logs → Tag Logging → Add. Set acquisition cycle (e.g., 1 s) and archive cycle (e.g., 60 s for averaging, 1 s for raw).
-
Add a CSV export action: configure an Output that writes the Tag Log to
C:\Logs\Process.csvevery 60 minutes. WinCC flexible uses its internal Channel Diagnosis event scheduler for this. - Compile and start RT: download the WinCC flexible Runtime to the PC; the panel project remains separate.
4.2 Constraints
- Tag count is the primary price driver. WinCC flexible 2008 RT 128 PowerTags ≈ $1,800; RT 2048 PowerTags ≈ $4,500 (single list-price band).
- The TP170A runs its own firmware (ProTool/Pro RT or WinCC flexible Micro); the PC WinCC flexible RT does not interfere with the panel.
- CSV files are appended in WinCC flexible's internal format with an RDB header; converting to plain CSV requires the WinCC flexible ES Export tool or a custom ODBC query against the underlying
.rdbSQLite-style file.
5. Method C — OPC Server Approach (Most Vendor-Neutral)
OPC DA or OPC UA provides a standard interface. The most common Siemens-branded option is SIMATIC NET PC Software with the S7-OPC Server. Third-party options include Softing OPC Server for S7 MPI/PROFIBUS and Kepware Siemens TCP/IP Ethernet Driver.
5.1 Architecture
5.2 Setup Steps (Simatic NET)
- Install SIMATIC NET PC Software V18 or later; license the S7-OPC Server component.
- Run Station Configuration Editor; add an OPC Server slot and an IE General or MPI module corresponding to the PC Adapter.
- In SIMATIC NET OPC Scout, browse the PLC tags (DB100.DBD0, etc.) and add them to the group.
- From any OPC DA client (Excel with OPC DA connector, Python with OpenOPC, C# with OPCAutomation) subscribe to the items at the desired update rate (typically 1000 ms).
6. Method D — Free/Open-Source: libnodave or Snap7
For projects where licensing cost dominates, the open-source drivers libnodave and Snap7 expose the S7 ISO-on-TCP (port 102) protocol directly. Snap7 supports 64-bit Windows and Linux, communicates with the CP 343-1 over TCP/IP, and provides C, C++, C#, Python, and Java wrappers. The downside is no commercial support and the user must implement error-recovery, reconnection logic, and tag-to-symbol mapping themselves.
6.1 Typical Python Sketch with Snap7
import snap7, time
client = snap7.client.Client()
client.connect("192.168.0.10", 0, 2, 102) # IP, rack, slot, port
DB = 100
START = 0
SIZE = 16 # 4 REALs
with open("log.csv", "a") as fp:
fp.write("t,PV1,PV2,PV3,PV4\n")
while True:
raw = client.db_read(DB, START, SIZE)
vals = snap7.util.get_real(raw, 0), snap7.util.get_real(raw, 4), \
snap7.util.get_real(raw, 8), snap7.util.get_real(raw, 12)
fp.write(f"{time.time()},{vals[0]:.3f},{vals[1]:.3f},{vals[2]:.3f},{vals[3]:.3f}\n")
fp.flush()
time.sleep(1.0)
7. Method E — STEP 7 Data Archiving on the MMC
The S7-300 CPUs do not have integrated "data logging" instructions in the same sense as S7-1200/1500. However, two indirect mechanisms are commonly used:
- SFC 82 / SFC 83 / SFC 84 (READ_DBL, WRIT_DBL, READ_SZL): cannot write CSV but can move blocks to the SIMATIC MMC, which is then read from the PC via STEP 7's PLC → Card Reader/USB menu with a PC Adapter.
-
FTP via CP 343-1 IT: if the rack contains a CP 343-1 IT (6GK7343-1GX31-0XE0), the CPU can be configured to expose an FTP server. CSV files placed on the MMC can be retrieved with
GET db.csvfrom a script — but this requires the more expensive IT variant.
For a 313C-2DP paired with a plain CP 343-1 Lean, the recommended "no extra software" route is to log directly into a DB in a ring-buffer fashion and have PRODAVE/Snap7 read it on the PC side.
8. Wiring & Topology Notes
8.1 MPI Wiring (PC Adapter USB)
- CPU X1 → PC Adapter USB → PC USB-A.
- PG-PC Interface must be set to
S7ONLINE (STEP7) → PC Adapter USB (MPI). - Terminating resistors on the MPI connector: ON only at the two physical ends. With only the CPU and the PC Adapter, both must be ON (default on the PC Adapter).
8.2 Ethernet Wiring (CP 343-1)
- CP 343-1 → standard Cat 5/6 → managed switch → PC NIC. Siemens recommends no direct crossover but modern NICs handle MDI/MDIX.
- CPU must know the CP's MAC address — this is automatic in STEP 7 V5.5 if both stations are in the same S7 project.
- Routing: for ISO-on-TCP, no special routing configuration is needed if the PC is on the same subnet.
9. Sampling, Timing, and Buffer Sizing
For a 1 Hz log of 4 REALs, the file size after 24 h is: 4 × 4 bytes × 86400 + headers ≈ 1.4 MB. Always use a ring buffer DB on the PLC side to prevent the PC missing samples during a network outage:
| Element | Recommendation |
|---|---|
| DB ring size | ≥ 3,600 REALs (1 h buffer at 1 Hz) |
| Read granularity | Read the entire DB block in one call — never single-byte reads |
| Time sync | Use PLC local time via SFC 1 (READ_CLK); PC time is unreliable across reboots |
| Connection watchdog | Enable PRODAVE/Snap7 keep-alive every 10 s; S7 idle timeout default = 30 s |
10. Choosing the Right Method for the 313C-2DP / TP170A Combination
| Scenario | Recommended Method | Why |
|---|---|---|
| Already running ProTool/Pro on TP170A | ProTool RT + WinCC flexible RT on PC | Reuses tags and project |
| Greenfield with IT infrastructure | CP 343-1 + Snap7 (free) or PRODAVE (paid) | Lowest recurring cost, no SCADA |
| Need alarms and historian with visualization | WinCC V7.x or TIA WinCC Professional | Native alarm logging, WebNavigator |
| Cannot add CP 343-1 hardware | PRODAVE MPI via PC Adapter USB | No hardware change to PLC |
| Third-party software (Python/MATLAB) | Snap7 over Ethernet OR OPC DA | Clean API, no proprietary DLL |
| Periodic dumps only (daily/hourly), no live view | MMC + CP 343-1 IT FTP OR PRODAVE pull-on-trigger | Cheap, no PC needed online 24/7 |
11. Verification Steps After Implementation
- Confirm the connection survives a PC reboot — test that the application reconnects automatically without manual intervention.
- Verify timestamp consistency: compare three consecutive samples against PLC clock (SFC 1) and ensure
Δt = 1.000 ± 0.05 s. - Stop the network (disconnect cable) and confirm the PC application logs an explicit error rather than hanging.
- Restore the network and verify the ring buffer on the PLC has not been overwritten (no gaps in CSV).
- Perform a cold start of the CPU (MRES) and ensure the connection recovers within the documented S7 timeout (30 s by default).
12. Field-Proven Caveats
-
MPI baud mismatch: PRODAVE/MP1 default is 187.5 kbit/s; if the CPU has been re-parameterized (e.g., to 19.2 kbit/s), PRODAVE calls return
0x80000400timeouts. Always check the MPI properties in STEP 7 Hardware Configuration. -
CP 343-1 Lean slot: CP 343-1 occupies a slot different from the CPU; PRODAVE and Snap7 both ask for
rackandslotseparately. Wrong slot =0x80000200(TCP) or0x80000300(MPI). - TP170A compatibility: the TP170A panel only understands ProTool/Pro or WinCC flexible Micro project files; if a TIA WinCC project is downloaded to it, it bricks visually but does not damage the unit. Always verify the panel's firmware version in the WinCC flexible ES before compiling.
- License timing: PRODAVE licenses are tied to the host PC's hard disk serial at install. Re-imaging the PC will void the license until the Authorisation disk is re-installed or the license server (Softbus) is restored.
- S7-300 ≠ S7-1500 data logging: do not attempt to call TIA Portal V20 DataLogCreate, DataLogWrite, or DataLogClose instructions on a 313C-2DP — they do not exist in the instruction set. The 313C-2DP CPU firmware supports only the classic S7 instruction set (BIT, BY, W, DW, BCD, FP, etc.); if S7-1200/1500-style logging is required, the CPU itself must be replaced.
13. Summary Recommendation
For the original combination of CPU 313C-2DP + TP170A with the goal of simplest and cheapest:
- If a CP 343-1 is already installed: use Snap7 (free) over ISO-on-TCP. 4–8 h of Python work, no licensing, easy to extend.
- If only the MPI port is available: buy the PC Adapter USB A2 (~$450) and use either PRODAVE (commercial) or libnodave (free). libnodave is older but stable; PRODAVE has cleaner .NET interop.
- If the project will grow into a multi-station plant: invest in SIMATIC NET OPC Server and an OPC client — this isolates the PLC layer from the historian layer.
- Avoid building a logging solution on the TP170A alone: the panel's internal log is limited and the only retrieval path is the same MPI link the PC would use anyway.
FAQ
What is the simplest way to log data from a CPU 313C-2DP to a PC?
Use WinCC flexible 2008 Runtime on the PC, connect via the PC Adapter USB over MPI, and configure a Tag Log with an automatic CSV export cycle. No custom code is required; the engineering effort is configuration only.
Does PRODAVE work with the 313C-2DP's MPI port?
Yes. PRODAVE MPI V6.x supports all S7-300 CPUs via the PC Adapter USB at 187.5 kbit/s default. The 313C-2DP uses rack 0, slot 2 for the CPU; the connection slot in PRODAVE must be set accordingly. The official reference is the PRODAVE MPI/IE V7.x programming manual (Siemens Support entry 21973664).
Can I use the S7-1500 data-logging instructions on an S7-300?
No. DataLogCreate, DataLogWrite, and DataLogClose are S7-1200/S7-1500-only instructions. The 313C-2DP CPU firmware does not include them. To achieve equivalent CSV-on-CPU behavior on an S7-300 you must either implement a ring-buffer DB and read it externally, or use the FTP function on a CP 343-1 IT.
Do I need a CP 343-1 to connect the 313C-2DP to Ethernet?
Yes. The 313C-2DP has only MPI and PROFIBUS-DP interfaces. Adding a CP 343-1 Lean (6GK7343-1CX10-0XE0) is the minimum-cost way to expose ISO-on-TCP (port 102) for PC-side logging via Snap7, libnodave, PRODAVE MPI/IE, or SIMATIC NET OPC.
What baud rate does the 313C-2DP use for MPI by default?
187.5 kbit/s, but it can be reconfigured in STEP 7 Hardware Configuration to anything from 19.2 kbit/s to 12 Mbit/s. If the PC Adapter or PRODAVE client is set to a different rate, the connection will silently time out with PRODAVE error 0x80000400. Always verify with the PG-PC Interface test in STEP 7.