Overview
The SIMATIC S7-300 CPU 317-2 PN/DP integrates a 2-port PROFINET switch, PROFINET IO controller, and a PROFIBUS-DP master into a single backplane module. Process data exchange between this CPU and a laptop or PC therefore requires only a standard Cat 5e or better patch cable and a TCP/IP stack on the PC side. The Ethernet services exposed by the CPU fall into four families: passive server services (Fetch/Write), S7 communication blocks (PUT/GET, BSEND/BRCV, USEND/URCV), Open IE communication over ISO-on-TCP/TCP/UDP (TCON/TSEND/TRCV), and the PG/OP routing channel used by STEP 7. On the laptop, those services can be consumed through SIMATIC NET (OPC DA/UA), a proprietary Siemens toolset (Prodave), an open-source library (Libnodave/Snap7), or a custom C#/VB/.NET application. Choosing between them is largely a trade-off between engineering effort, license cost, long-term maintainability, and whether the application runs once or as a permanent HMI/SCADA bridge.
For the most current CPU variant (MLFB 6ES7317-2EK14-0AB0, firmware V3.3.x), Siemens ships the same functional surface as the earlier 6ES7317-2EK13-0AB0, 6ES7317-2AK14-0AB0, and 6ES7317-2AJ10-0AB0. Only the security defaults changed in firmware V3.3, where PUT/GET must now be explicitly enabled in the CPU properties.
Hardware Prerequisites
| Item | Specification | Notes |
|---|---|---|
| CPU | 6ES7317-2EK14-0AB0 (current) or -2EK13 / -2AJ10 / -2AK14 | Integrated 2-port PROFINET switch on front X1 (P1/P2) |
| Memory card | SIMATIC Micro Memory Card (MMC) | Optional for Ethernet comms; required only for firmware update |
| Ethernet cable | Cat 5e / Cat 6 UTP, RJ45, patch or crossover | Patch through a switch; crossover only required for direct connection to a non-Auto-MDI/MDIX laptop NIC |
| Laptop | RJ45 10/100 Ethernet (Auto-MDI/MDIX recommended) | USB-to-Ethernet adapters with Intel/RTL8153/AX88179 chipsets are acceptable |
| Switch (optional) | SCALANCE XB-005 (unmanaged), XC-208 (managed) | Not mandatory for a single PC link; required for multi-station networks or PROFINET diagnostics |
| STEP 7 | STEP 7 V5.5 SP4+ (classic) or TIA Portal V14 SP1+ to V18 | TIA Portal V18 supports the latest 6ES7317-2EK14-0AB0 firmware |
| SIMATIC NET (optional) | SIMATIC NET V18 PC software | Includes OPC DA server and station configuration editor; required only for OPC method |
Network Topology and Cabling
For a single PC talking to one CPU, the SCALANCE switch is not required. The PC connects directly to one of the two PROFINET ports (P1 or P2) on the CPU front. Modern laptop NICs (built-in or USB-Ethernet adapters from Intel, Realtek 8153, ASIX AX88179) implement Auto-MDI/MDIX, so a regular straight-through patch cable works in every direction. If Auto-MDI/MDIX is disabled in the laptop NIC driver, use an Ethernet crossover cable (T568A on one end, T568B on the other) for the direct connection.
Add a managed switch when:
- Multiple PCs/PGs need concurrent access to the same CPU.
- The PROFINET network will later host distributed I/O (ET 200S, ET 200MP) on the same switch.
- You need PROFINET diagnostics, port statistics, or LLDP topology.
Recommended IP plan for an isolated engineering link:
| Device | IP Address | Subnet Mask | PROFINET Device Name |
|---|---|---|---|
| CPU 317-2 PN/DP X1 (PN-IO) | 192.168.0.1 | 255.255.255.0 | cpu317-2pn |
| Engineering laptop | 192.168.0.10 | 255.255.255.0 | pg-laptop (optional) |
Configure the CPU IP in STEP 7 via HW Config > CPU 317-2 PN/DP > Properties > Ethernet Interface > IP Address, or directly from the PG through PLC > Ethernet Node > Edit Ethernet Node after selecting the accessible node.
Communication Methods Compared
| Method | Direction | CPU FBs | PC Side | License Cost | Effort | Throughput | Best For |
|---|---|---|---|---|---|---|---|
| Fetch/Write (passive server) | PC ↔ PLC | None in user program; enabled in CPU config | SIMATIC NET OPC, custom SAPI/S7 app | SIMATIC NET license | Low (config only) | Medium | Legacy OPC DA, simple polling |
| S7 Communication PUT/GET | Bidirectional | FB14 GET, FB15 PUT | SIMATIC NET OPC, Libnodave, Snap7 | Free (open libs) or licensed | Low to medium | High | Bidirectional data blocks, batch transfer |
| S7 Communication BSEND/BRCV | Bidirectional, block oriented | FB12 BSEND, FB13 BRCV | SIMATIC NET, Snap7, Libnodave (limited) | Free or licensed | Medium | High | Variable-size packets up to 32 KB |
| Open IE (TCP) | Bidirectional | FB65 TCON, FB66 TDISCON, FB63 TSEND, FB64 TRCV | Custom socket (.NET, Python, C) | Free (PC side is sockets) | Medium to high | Highest | Custom protocols, vendor-neutral apps |
| Open IE (ISO-on-TCP / RFC 1006) | Bidirectional | FB65/66/63/64 with connection type 12 | Snap7, Libnodave, custom | Free | Medium | High | Port 102 partner; S7-compatible stream |
| Prodave | Bidirectional | None | Prodave DLL + C/C++ app | Paid (legacy) | Low to medium | High | Existing Prodave installations |
| Libnodave / Snap7 | Bidirectional | None (consumes S7 service) | C, C#, Java, Python wrappers | Free / open source | Low | High | Cost-sensitive PC apps, custom dashboards |
Method 1: Fetch/Write Service
Fetch/Write is the oldest of the S7 passive services and the one that the original Siemens "Fetch/Write" application example targets. The CPU acts as a server; the PC (or OPC server) is the client. No FBs are downloaded into the PLC user program; the service is enabled in the CPU configuration.
Step-by-step: Enable Fetch/Write on CPU 317-2 PN/DP
- Open the S7 project in STEP 7 (V5.5) or TIA Portal.
- In the device configuration, open Properties > CPU 317-2 PN/DP > Communication.
- Select the check box "Permit access with PUT/GET communication from remote partner (PLC, HMI, OPC, ...)".
- For the Fetch/Write service specifically, also enable "Allow Fetch/Write" in the connection configuration.
- Save and download the hardware configuration to the CPU.
6ES7317-2EK14-0AB0, the security setting "PUT/GET" must also be enabled for any non-S7 partner to read/write data blocks. The PUT/GET setting is found under CPU Properties > Protection & Security > Connection mechanisms.
Step-by-step: PC Side with SIMATIC NET OPC Scout
- Install SIMATIC NET 2008 or later (matches the STEP 7 version). The OPC server component is included with the PC software install.
- Open Station Configuration Editor and add a PC station with one OPC server and one IE General (ISO-on-TCP) interface.
- Configure the IE interface to the same IP subnet as the CPU (192.168.0.10 in the example).
- Open OPC Scout V10 and add a new S7 connection: partner IP 192.168.0.1, connection type ISO-on-TCP, slot/rack 0/2 (CPU 317-2 PN/DP), Fetch/Write attributes enabled.
- Create items pointing to the data blocks you want to read/write, e.g.
DB1.DBD0,DB1.DBD4,MB10,QB0. - Write a value to the CPU by toggling the item to "active" with a typed value, then read it back to confirm.
Data Addressing in OPC Scout
| S7 Tag | OPC Item Access Path | Length |
|---|---|---|
| DB1.DBD0 (REAL) | S7:[CPU317]DB1,REAL0 |
4 bytes |
| DB1.DBD4 (DWORD) | S7:[CPU317]DB1,DWORD4 |
4 bytes |
| MW10 (WORD) | S7:[CPU317]M,W10 |
2 bytes |
| I0.0 (BOOL) | S7:[CPU317]I,B0,X0 |
1 bit |
| Q4.0 (BOOL) | S7:[CPU317]Q,B4,X0 |
1 bit |
Method 2: S7 Communication with PUT/GET (FB14/FB15)
PUT/GET is the simplest bidirectional S7 communication pair. The S7-300 side calls FB14 to read a data block from a remote partner and FB15 to write to one. The laptop side typically initiates via SIMATIC NET or a library like Snap7; for a one-CPU-only network, the laptop becomes the partner and the CPU is the server.
FB15 PUT Call Interface
CALL "PUT" , %DB20
REQ := TRUE // rising edge triggers the job
ID := 1 // connection ID from NetPro / connection table
DONE := M30.0 // TRUE on success, single cycle
ERROR := M30.1 // TRUE on error
STATUS := MW32 // 16-bit status word
ADDR_1 := P#DB1.DBX0.0 BYTE 10 // remote area 1: pointer to send buffer
ADDR_2 := P#DB1.DBX20.0 BYTE 10 // remote area 2 (optional)
ADDR_3 := P#DB1.DBX40.0 BYTE 10 // remote area 3 (optional)
ADDR_4 := P#DB1.DBX60.0 BYTE 10 // remote area 4 (optional)
SD_1 := P#DB100.DBX0.0 BYTE 10 // local source area 1
SD_2 := P#DB100.DBX10.0 BYTE 10
SD_3 := P#DB100.DBX20.0 BYTE 10
SD_4 := P#DB100.DBX30.0 BYTE 10
Up to four data areas can be packaged in a single PUT, with a combined maximum of 160 bytes for S7-300 PUT. FB14 GET has identical parameters but with RD_1..RD_4 as the receive areas on the local side.
Status Word Interpretation
| STATUS (hex) | Meaning |
|---|---|
| 0000 | Job completed without error |
| 7000 | No job in progress |
| 7001 | First call, job in progress |
| 7002 | Subsequent call, job in progress |
| 80A1 | Connection error or partner not reachable |
| 80A2 | Point-to-point error, partner denied |
| 80B0 | Pointer error (ADDR_/SD_ out of range) |
| 80C0 | Object access error (DB does not exist) |
| 80C1 | Object access error (DB too short) |
| 80D0 | Write access error (target cannot be written) |
Method 3: S7 Communication with BSEND/BRCV (FB12/FB13)
Use BSEND/BRCV when the data payload is variable and may exceed the 160-byte PUT/GET limit, up to 32 KB (S7-300) or 64 KB (S7-400). The handshake is two-phase: BSEND hands a pointer to a data buffer to the operating system, the OS fragments and transmits the data with acknowledgements, then sets DONE.
CALL "BSEND" , %DB21
REQ := M50.0
R := FALSE
ID := 2
DONE := M50.1
ERROR := M50.2
STATUS := MW52
SD_1 := P#DB200.DBX0.0 BYTE 5000 // up to 32 KB per call
LEN := #SendLen // actual length this call
The remote side uses FB13 BRCV to accept the incoming buffer. Pair BSEND/BRCV with the Snap7 BSEND/BRCV on the PC for the cleanest bidirectional tunnel.
Method 4: Open IE Communication with TCP/ISO-on-TCP
Open IE is the lowest-level family. The CPU program owns the full TCP state machine, while the PC uses ordinary Berkeley sockets or a wrapper library. This is the only path that lets you bypass SIMATIC NET entirely.
Connection DB UDT65 Layout
Fill a connection DB (instance of UDT 65 "TCON_PAR") with the parameters for ISO-on-TCP (connection type 12) or TCP (connection type 11):
| Byte | Field | ISO-on-TCP value (RFC 1006) | TCP value |
|---|---|---|---|
| 0..1 | Block ID | Always 0 | Always 0 |
| 2..3 | Connection ID | 1..16 (must match TCON ID) | 1..16 |
| 4..5 | Connection type | W#16#000C (12) | W#16#000B (11) |
| 6..7 | Active/passive | W#16#0000 = passive, W#16#0001 = active | same |
| 8..11 | Local IP | 0.0.0.0 = any | 0.0.0.0 = any |
| 12..13 | Local port | e.g. W#16#0100 (256) | any unused port |
| 14..17 | Remote IP | e.g. 192.168.0.10 | 192.168.0.10 |
| 18..19 | Remote port | e.g. W#16#0100 | e.g. W#16#0BB8 = 3000 |
| 20..21 | TSAP length (ISO-on-TCP only) | 2 or 4 | 0 |
| 22..25 | Local TSAP | e.g. 0xC0 0x01 | n/a |
| 26..29 | Remote TSAP | e.g. 0xC0 0x01 | n/a |
TSEND Call
CALL "TSEND" , %DB30
REQ := M60.0
ID := 3
LEN := 32
DATA := P#DB300.DBX0.0 BYTE 32
DONE := M60.1
ERROR := M60.2
STATUS := MW62
C# .NET TCP Client Skeleton
using System.Net.Sockets;
TcpClient cli = new TcpClient("192.168.0.1", 2000);
NetworkStream ns = cli.GetStream();
byte[] payload = BitConverter.GetBytes(1234.567f); // example REAL
ns.Write(payload, 0, payload.Length);
byte[] rx = new byte[32];
int n = ns.Read(rx, 0, rx.Length);
For ISO-on-TCP from .NET, use the Snap7.NET package or implement RFC 1006 framing manually (length prefix is one 16-bit big-endian integer; data follows immediately).
Method 5: Libnodave and Snap7 (Open Source PC Clients)
Libnodave (pre-2015) and Snap7 are BSD-style libraries that speak the S7 protocol directly over ISO-on-TCP/TCP without requiring SIMATIC NET. Snap7 is the modern, actively maintained successor and exposes C, C++, .NET, Java, Python, Node.js, and LabVIEW bindings.
Snap7 C# Client (Process Data Read/Write)
using Snap7;
// ...
S7Client plc = new S7Client();
plc.ConnectTo("192.168.0.1", 0, 1, 0); // IP, rack, slot, rack again for slot 0
byte[] buf = new byte[32];
int res = plc.DBRead(1, 0, buf.Length, buf); // read DB1 from offset 0
float value = BitConverter.ToSingle(buf, 0);
BitConverter.GetBytes((float)42.0f).CopyTo(buf, 4);
plc.DBWrite(1, 0, buf.Length, buf);
plc.Disconnect();
Throughput
Snap7 over ISO-on-TCP achieves roughly 800-1500 requests per second for short reads on a 100 Mbit link, which is more than sufficient for SCADA polling and well above OPC DA's typical 100-200 tag updates per second.
Method 6: Prodave
Prodave (current release Prodave S7 Windows V7.2) is a Siemens-licensed C DLL that exposes S7 functions similar to the FBs but on the PC side. It is appropriate when you have an existing Prodave installation and want to add a TCP path without rewriting the application. New projects should prefer Snap7 because Prodave requires a paid runtime license tied to a USB dongle or activation key.
Method 7: WinCC Flexible with OPC Client Add-in
WinCC flexible 2008 SP5 / TIA Portal WinCC Comfort/Advanced includes an OPC DA server that can be enabled on the runtime PC. Excel can then read tags as an OPC client via the Siemens OPC DA Automation Wrapper or the free OPC Scout V10. This is the lowest-effort path when the goal is data into a spreadsheet for trending.
Excel OPC Automation Example (VBA)
Dim opc As New OPCAutomation.OPCServer
Dim grp As OPCAutomation.OPCGroup
Dim items() As OPCAutomation.OPCItem
opc.Connect("OPC.SimaticNET.1")
Set grp = opc.OPCGroups.Add("S7Group")
grp.OPCItems.AddItem "S7:[CPU317]DB1,REAL0", 1
items(1).Read 1, value, quality, timestamp
Range("A1").Value = value
Connection Limits on CPU 317-2 PN/DP
| Resource | Maximum |
|---|---|
| Total S7/PG/OP/HMI connections | 16 (firmware dependent; later revisions allow 32) |
| Reserved for PG (STEP 7) | 1 |
| Reserved for OP/HMI | 1..12 (configurable) |
| Open IE connections (TCP, ISO-on-TCP, UDP) | 16 |
| PROFINET IO real-time connections | Depends on firmware; typically up to 256 |
If "no more connections available" is reported, raise the OP/HMI reservation count in CPU Properties > Communication > Connection Resources and recompile the hardware configuration.
Verification and Diagnostics
- From the laptop, ping the CPU:
ping 192.168.0.1. TTL should be 64 and round-trip <1 ms on a direct cable. - In STEP 7 / TIA Portal, choose Online > Accessible Nodes. The CPU should appear with its IP and PROFINET device name.
- Read the CPU diagnostic buffer via Online > CPU Diagnostics and confirm "Communication established with [PC IP]".
- For S7 communication, monitor FB14/FB15 STATUS after a job. 0x0000 confirms data round-trip.
- For OPC, monitor the OPC Scout watch window. Quality code should be Good (0xC0, 192).
- For Snap7, log the return value of
ConnectTo. 0 = success; -1 = TCP error; -2 = ISO-on-TCP PDU mismatch.
Troubleshooting Matrix
| Symptom | Likely Cause | Action |
|---|---|---|
| PLC not visible in "Accessible Nodes" | Wrong subnet, firewall on laptop, Windows network profile is Public | Set network to Private; disable Windows firewall temporarily; verify IP/subnet; use static IPv4, no DHCP |
| OPC DA quality = Bad (0) | OPC server cannot establish connection | Confirm SIMATIC NET Station Configuration Editor is loaded with the IE General component active; restart the "SIMATIC NET OPC" service |
| FB14/FB15 STATUS = 80A1 | Connection ID does not match the configured connection, or partner has PUT/GET disabled | Open NetPro/Connection table; ensure ID matches; on the partner CPU enable "Permit access with PUT/GET" |
| FB65 TCON STATUS = 80C4 | TSAP port already in use, or connection type mismatch | Verify remote TSAP (e.g. 0x01 0x01 for S7 default); set local port to 0 for auto-assign |
| Snap7 error -1 | TCP connect refused | Check PC firewall for inbound TCP 102; verify the CPU's IP with a ping first |
| Data values are swapped (endianness) | S7 stores REAL/DWORD big-endian, x86 is little-endian | Swap bytes manually: Array.Reverse(buf, 0, 4) in C#, or use a library helper such as Snap7.S7.GetRealAt
|
| "DB does not exist" on read | DB not loaded in CPU, or wrong DB number | Download the DB to the CPU and confirm online; verify the configured DB number matches the request |
| Fetch/Write connection fails in OPC Scout | Fetch/Write service disabled in CPU security settings | Enable "Allow access via Fetch/Write" in CPU properties > Protection & Security |
| Libnodave keeps losing connection | Old library does not support PDU negotiation | Switch to Snap7 which negotiates PDU size up to 960 bytes |
Best Practice Recommendations
- For long-term PC applications, prefer Snap7 (open source, royalty free) over Libnodave, which has not been actively maintained since 2015.
- For one-off data inspection and quick commissioning, use SIMATIC NET OPC Scout - it is already installed with STEP 7 and does not require code.
- Always enable PUT/GET in the CPU security properties unless your environment strictly forbids remote writes.
- Reserve at least two OP connections and two free S7 connections in NetPro / TIA connection table when commissioning new programs.
- Wrap any user program in OB100 startup with a "set first connection to active" once at startup, then leave the OS to maintain it. Do not call TCON repeatedly.
- Use BSEND/BRCV (FB12/FB13) for any payload above 100 bytes; PUT/GET silently truncates or returns 0x80B0 above the 160-byte limit.
- Do not enable PG/OP routing through the CPU for production panels - it is a debugging convenience that bypasses firewall isolation.
FAQ
Can I connect the laptop directly to the CPU 317-2 PN/DP without a SCALANCE switch?
Yes. Use a Cat 5e/6 patch cable. Most modern laptop NICs support Auto-MDI/MDIX, so a straight-through cable works. If the NIC does not auto-detect, swap to a crossover cable (T568A on one end, T568B on the other). Add a SCALANCE switch only when more than one device is on the link or you want PROFINET diagnostics.
Do I need SIMATIC NET if I use Snap7 or Libnodave?
No. Snap7 and Libnodave speak the S7 protocol directly over ISO-on-TCP or TCP and only require the .NET runtime (Snap7) or C/C++ headers (Libnodave). SIMATIC NET is only needed when you want the OPC DA/UA server interface.
Why does FB14 GET return STATUS 80A1 even though the network is up?
STATUS 80A1 means the partner rejected the connection. The most common cause is the partner CPU's PUT/GET security setting being disabled, or the connection ID used by FB14 not matching the ID configured in NetPro / TIA Portal connection table. Re-check both and recompile.
What is the difference between Fetch/Write and PUT/GET?
Fetch/Write is a passive S7 service: the PC client always initiates, the PLC never has to call any FB. PUT/GET is an active S7 communication pair: both sides can trigger reads/writes through FB14/FB15. Fetch/Write is older and limited in payload; PUT/GET is the modern replacement.
How do I read a REAL (float) value from a Siemens DB on a Windows PC?
Siemens stores REAL in big-endian byte order (byte 0 = MSB, byte 3 = LSB). After Snap7 DBRead returns the four bytes, reverse them with Array.Reverse(buf, 0, 4) in C# before calling BitConverter.ToSingle. Snap7 also provides helpers like S7.GetRealAt that handle the swap automatically.