Overview
The SIMATIC S7-300 CPU 315-2 PN/DP is a compact PLC with an integrated PROFINET interface that supports both PROFINET IO and open TCP/UDP communication. Unlike the older CP 343-1 communications processor path, the on-board PROFINET port of the CPU 315-2 PN/DP can be programmed directly with the T-block family (TCON, TSEND, TRCV, TDISCON) without inserting a CP in the hardware catalog. This avoids the recurring confusion of mixing AG_SEND/AG_RECV (CP-only) with the T-functions (CPU PN port) inside the same project.
For Modbus/TCP interoperability with non-Siemens controllers, Siemens provides a free library (OpenModbusTCP PN CPU - Entry ID 25209116) that runs entirely on the CPU and uses the same T-block primitives underneath. A configuration wizard (the "OC Wizard" for Open Communication) generates the connection DB, MODBUS application DB, and instance DBs automatically, dramatically cutting engineering time.
This reference covers the on-board PN port, the T-block interface, the connection description UDT, TIA Portal / STEP 7 V5.x configuration, the OpenModbusTCP library, the OC wizard workflow, and field-proven verification and troubleshooting steps.
Hardware Identification: CPU 315-2 PN/DP Variants
Before programming, identify the exact order number (MLFB) because firmware (FW) behavior changes the supported connection counts and OpenModbusTCP library compatibility.
| Order Number (MLFB) | Firmware | PN Ports | Open Conn. (TCP/UDP) | Status |
|---|---|---|---|---|
| 6ES7315-2EH14-0AB0 | V3.3 | 2 (integrated switch) | 16 | Current production |
| 6ES7315-2EH13-0AB0 | V3.2 | 2 (integrated switch) | 16 | Phase-out |
| 6ES7315-2EH10-0AB0 | V2.x | 1 | 8 | Discontinued |
| 6ES7315-2EG10-0AB0 | V1.x | 1 | 4 | Discontinued |
For T-block communication with third-party devices, FW V2.5 or higher is recommended because the TCON "active connection establishment" became fully stable across all integrated PN interface revisions. The OpenModbusTCP PN CPU library requires FW V2.6 or higher on the CPU 315-2 PN/DP. Always confirm the exact number of supported open connections in the device manual for your MLFB; the table above is a guideline, not a guarantee.
Communication Options on the Integrated PN Port
The CPU 315-2 PN/DP integrated PROFINET interface supports the following open communication services in parallel with PROFINET IO:
| Service | ConnectionType (TCON) | Block Family | Typical Use |
|---|---|---|---|
| TCP (RFC 793) | 16#0B | TCON / TSEND / TRCV / TDISCON | Generic raw socket to third-party controller |
| ISO-on-TCP (RFC 1006) | 16#12 or 16#11 | TCON / TSEND_C / TRCV_C | Siemens-to-Siemens or RFC 1006-capable devices |
| UDP | 16#13 | TCON / TUSEND / TURCV | Datagram exchange, broadcast, diagnostics |
| S7 Communication | BSEND/BRCV/GET/PUT | Built-in (no TCON) | Siemens S7 peer, HMI panel |
| Modbus/TCP | 16#0B (TCP) + library | OpenModbusTCP PN CPU | Modbus-only third-party device |
For a true third-party (non-Siemens, non-PROFINET) device, the two most common paths are raw TCP via TCON/TSEND/TRCV or Modbus/TCP via the OpenModbusTCP library. ISO-on-TCP is technically open (RFC 1006) but the framing is rarely implemented outside Siemens and a handful of vendors; use it only when the partner explicitly supports RFC 1006.
Native TCP Communication with TCON / TSEND / TRCV / TDISCON
The T-block library is part of the SIMATIC system library and ships with STEP 7 V5.5 SPx and TIA Portal V13+. The blocks are reusable, multi-instance capable, and can run from any priority class (OB1, OB35) provided that the user program does not exceed the cyclic OB1 budget. Refer to the Siemens Entry ID 34677186 for the canonical T-block manual.
Block Roles
- TCON - establishes or aborts the connection on the rising edge of REQ. After the call the connection is held in a CONNECT data block.
- TSEND - sends a user-defined number of bytes from a source data area on the rising edge of REQ. It returns DONE when the partner ACKs the bytes.
- TRCV - receives bytes into a destination data area. LEN, ADHOC, and DATA determine the receive length and behavior.
- TDISCON - cleanly terminates the connection on the rising edge of REQ.
Unlike the legacy AG_SEND/AG_RECV pair used with CP 343-1, the T-block family uses a single call per request, supports partial-length reception with LEN, and uses a single connection ID per partner. The ID is part of the connection description, not a separate call parameter.
Connection Description Structure (UDT / DB)
The T-block interface requires a structure (typically a DB) describing the connection. In TIA Portal V18+ the system UDT TCON_Param is auto-instanced when you drop TCON. In STEP 7 V5.5 SPx the engineer must build the structure manually. Below is a working example for raw TCP to 192.168.0.50:2000 with the CPU as active client.
DATA_BLOCK DB100
TITLE = TCON_Param_ThirdParty
VERSION : 0.0
STRUCT
BlockLength : WORD := 64; // total length of this structure
Id : WORD := 1; // Connection ID (must be unique project-wide)
ConnectionType : BYTE := 16#0B; // 0x0B = TCP
ActiveEstablished : BOOL := TRUE; // TRUE = active (client), FALSE = passive (server)
LocalDeviceId : BYTE := 16#00; // 0x00 = PN interface of the CPU
LocalTsapIdLen : BYTE := 0; // 0 for TCP (TSAP only for ISO-on-TCP)
LocalTsapId : ARRAY[1..16] OF BYTE;
RemoteTsapIdLen : BYTE := 0; // 0 for TCP
RemoteTsapId : ARRAY[1..16] OF BYTE;
RemoteAddressLen : BYTE := 4; // 4 for IPv4
RemoteAddress : ARRAY[1..4] OF BYTE := 192,168,0,50;
RemotePort : UINT := 2000; // destination port
LocalPort : UINT := 0; // 0 = any free local port
Spare : WORD := 16#0000;
END_STRUCT;
END_DATA_BLOCK
Field guidance:
- Id must be unique across the whole S7-300 station - the same ID cannot be reused for the HMI panel and the third-party TCP partner.
- LocalDeviceId 0x00 selects the on-board PN port. 0x01 / 0x02 select the first/second CP if installed. Do not use these values for the integrated port.
- ActiveEstablished = TRUE means the CPU opens the connection. Set FALSE only when the CPU must accept an incoming connection from a foreign server (for example when the partner is port-forwarded through a router).
- RemoteAddress uses 4 bytes (one per IPv4 octet). For DNS names the structure must be expanded with the UDT "TCON_Param_v4" or the TIA Portal UDT65.
- LocalPort = 0 lets the OS pick a free ephemeral port. Set a fixed value only when the partner's firewall requires a specific source port.
TIA Portal Configuration Procedure
This procedure assumes a CPU 315-2 PN/DP with FW V3.3 and TIA Portal V17/V18. The third-party partner is a generic TCP server on 192.168.0.50:2000.
- In the project tree, open Devices > [CPU 315-2 PN/DP] > Properties > PROFINET interface [X2]. Assign IP address (for example 192.168.0.10) and subnet mask. Activate "Use router" only if the partner is across a router.
- Confirm the PN port is NOT configured as a PROFINET IO controller with strict IRT real-time settings; mixing IRT and T-block communication on the same port is permitted, but T-blocks use standard priority and may be delayed by IRT cycles.
- Add a new Global DB (for example
DB_ConnModbus) and two Data Blocks for send and receive buffers (for exampleDB_TxData,DB_RxData). Mark the DBs as non-optimized (S7-300-compatible access) - the T-block system library does not work with optimized DBs on the S7-300 CPU. - Insert the T-blocks from Instructions > Communication > Open Communication:
- TCON in OB100 (cold start) or in OB1 (first cycle flag).
- TSEND in OB1, triggered by a handshake bit.
- TRCV in OB1, set to ADHOC = FALSE, LEN = expected payload length.
- TDISCON in OB100 (warm restart) or in the user stop sequence.
- Wire the
CONNECTpin of TCON to the TCON_Param DB. Wire theIDpin of TSEND/TRCV to the same ID word from the CONNECT DB (Word 0 in the structure). - Compile and download to the CPU. Go online and force TCON to establish the connection.
STEP 7 V5.x Configuration Procedure
The traditional engineering tool is still widely deployed in brownfield S7-300 sites. The PN port is configured in HW Config by opening the CPU's Properties > PROFINET IO > IP Address tab. There is no "connection" object in NetPro for the integrated port; NetPro is only used to configure the CP 343-1 route.
- Open SIMATIC Manager > S7 Program > Blocks. Right-click and add a new DB (DB100 from the previous example).
- From Libraries > Standard Library > Communication Blocks, copy
TCON,TSEND,TRCV, andTDISCONfrom the Open Communication subfolder. Do NOT useFC5/FC6(AG_SEND/AG_RECV) - those are CP 343-1 only. - Call TCON in OB1 with:
CALL "TCON" , DB_TCON REQ := TRUE ID := W#16#1 CONNECT := DB100.DBX0.0 BYTE 64 DONE := M100.0 BUSY := M100.1 ERROR := M100.2 STATUS := MW102 - Add a multi-instance or a standalone instance DB for TSEND and TRCV with the matching
ID := W#16#1. Build the S7 program and download the blocks, then go online and monitor STATUS.
Cycle-Time and Performance Considerations
Raw TCP is a stream protocol with no message framing. The CPU 315-2 PN/DP does not buffer beyond the receive window of the IP stack, so the user program must drain incoming bytes on a deterministic schedule. The recommended pattern:
- Call TRCV every OB1 cycle with a fixed LEN. If no data is present, the block returns NDR = FALSE, RC = 16#7000 (BUSY).
- Maintain a circular buffer in the user DB; TRCV writes into the head, the user program consumes the tail.
- For payload > 8 KB, do not use a single TSEND with a 32 KB buffer. Fragment at the application layer into 1 KB packets and TSEND them back-to-back.
The CPU 315-2 PN/DP FW V3.3 sustains roughly 200 TPS of TSEND/TRCV calls of 240 bytes each when OB1 runs at 10 ms and the program is otherwise idle. Real numbers depend on OB1 cycle and PROFINET IRT share. Always validate with a long-duration Wireshark capture before signing off.
Open Modbus/TCP PN CPU Library
When the third-party device speaks Modbus/TCP (Schneider M340, ABB AC500, Wago 750, Red Lion, many SCADA servers), the OpenModbusTCP PN CPU library provides ready-made function blocks and saves weeks of manual frame building. Download it from the Siemens Industry Online Support entry 25209116.
| FB / FC | Modbus Function Code | Description | Direction |
|---|---|---|---|
| MB_CYCLIC | n/a (driver) | Cyclic driver; runs once per call, manages the TCP connection | Master |
| MB_READ | FC 01, 02, 03, 04, 07 | Read Coils, Discrete Inputs, Holding Reg, Input Reg | Master |
| MB_WRITE | FC 05, 06, 15, 16 | Write Single Coil, Single Reg, Multiple Coils, Multiple Reg | Master |
| MB_SLAVE | FC 01..16 | Slave / server role when the S7-300 acts as Modbus device | Slave |
The zip contains the OC Wizard, the library, and an example STEP 7 project. The current release targets FW V3.2 and V3.3 of the CPU 315-2 PN/DP. The library is not formally maintained; always test it with the target firmware combination before commissioning.
OpenModbusTCP Wizard Workflow
The OC Wizard is a standalone executable that ships with the library zip. It generates a complete STEP 7 project sub-tree, including connection DB, MODBUS DB, instance DBs, and a sample OB1 call structure. This avoids hand-typing 64 bytes of TCON_Param and the symbolic MODBUS request table.
- Unzip
25209116_OC_Wizard.zipto a writable directory on the engineering station. RunSetup.exeand choose Open Communication Wizard. - Select CPU 315-2 PN/DP from the device dropdown. The wizard then offers only the libraries compatible with the CPU FW.
- Add a Modbus connection: assign ID (1..255), Connection Type "TCP", partner IP, partner port (default 502), local TSAP / port. The wizard fills the connection DB fields automatically.
- Add jobs (MODBUS requests). For each job specify a name, function code, unit ID (Modbus slave address 0..255), data type, start address, length, and a target data block. The wizard allocates the offsets in the MODBUS DB.
- Click Generate. The wizard produces the library FBs (typically MB_CYCLIC, MB_READ, MB_WRITE, optionally MB_SLAVE), DBs for connection / Modbus / instance, and a sample OB1. Merge or copy these into the STEP 7 / TIA Portal project.
- Recompile the S7 program. Download all new blocks to the CPU. The first OB1 call will establish the TCP connection and the Modbus layer.
Comparison: CPU PN Port vs. CP 343-1
| Feature | CPU 315-2 PN/DP Integrated Port | CP 343-1 (e.g., 6GK7343-1EX30-0XE0) |
|---|---|---|
| Block family | TCON / TSEND / TRCV / TDISCON | AG_SEND / AG_RECV or T-blocks (depending on FW) |
| Connection count | 8-16 (FW dependent) | 16-32 (model dependent) |
| Configuration site | HW Config PN port, TIA Portal device view | HW Config + NetPro connection objects |
| PG/OP routing through port | Yes (limited) | Yes (more flexible) |
| OpenModbusTCP support | Library 25209116 | Library 21267474 (CP variant) |
| PROFINET IRT support | Yes (only as IO controller) | Yes (model dependent) |
| Add-on cost | None (integrated) | Adds ~EUR 400-900 per slot |
Choose the integrated PN port when the third-party device count is ≤ 16 and no second physical network is required. Choose CP 343-1 when you must exceed 16 open connections, isolate the third-party traffic on a separate switch, or need additional diagnostics interfaces.
Security and Hardening
Open TCP on the integrated PN port is a plain Ethernet service. The CPU 315-2 PN/DP does not provide encryption, authentication, or rate limiting at the application layer. The following hardening steps are field-proven:
- Place the CPU behind a managed switch with port security (MAC lockdown) so the partner cannot be MAC-spoofed.
- Use a dedicated VLAN for the third-party traffic; do not mix with the HMIs and engineering stations.
- Disable the integrated Web server on the CPU if not strictly required - it shares the same TCP stack.
- Enable Access Protection (CPU Properties > Protection) with a password so an attacker with physical access cannot stop TCON and start a rogue server.
- For Modbus/TCP, configure the partner to accept only explicit unit IDs in the 1..247 range; reject 0 (broadcast) and 248..255 (reserved).
Verification and Diagnostics
Once the program is loaded, verify the connection is open and traffic is flowing before declaring success.
- Open Online & Diagnostics > PROFINET interface > Statistics in TIA Portal, or PLC > Diagnostics/Settings > PN Statistics in STEP 7. Verify the port shows non-zero counters on TPA Frames Sent / Received.
- Monitor the TCON STATUS word (MW102 in the example). For TCP, the standard positive return values are
16#0000for DONE and16#7000for BUSY. A common fault is16#80A1(connection aborted by remote) or16#80A3(connection aborted by local IP stack). - On the third-party device side, capture Wireshark on the partner port. Look for the TCP 3-way handshake to port 2000 (or 502 for Modbus), then payload PDUs at the expected cadence.
- Trigger a TSEND with a known pattern. The third-party partner should see the same byte sequence. Trigger a TRCV; verify LEN returned equals bytes received.
- For Modbus/TCP, the wizard's example OB1 has a watch table with
MB_DB.state. State values:-
0- Init, not connected -
1- TCP open, Modbus idle -
2- Request issued, waiting for response -
3- Response received, valid -
4- Error (seeMB_DB.error)
-
Common Faults and Troubleshooting Matrix
| Symptom | STATUS / Code | Root Cause | Remediation |
|---|---|---|---|
| TCON DONE never true, BUSY stays on | 16#7000 (BUSY persistent) | Remote partner not listening on the port | Verify partner firewall, IP, and port; check cable/link |
| TCON ERROR = TRUE | 16#8086 | ID is in use by another connection | Change Id in CONNECT structure, recompile |
| TCON ERROR = TRUE | 16#80A1 | Remote partner actively closed | Check partner application logs, ensure keepalive |
| TSEND returns DONE but no bytes arrive | 16#0000 | TSEND LEN = 0 or source DB is optimized | Set LEN > 0, switch DB to "standard" attribute |
| TRCV DATA never updated | 16#80B1 | ADHOC = FALSE and LEN mismatch with remote | Match LEN to the actual payload, or set ADHOC = TRUE |
| Modbus state 4 immediately | 16#0006 (no response) | Wrong unit ID, wrong function code, or wrong base address | Verify with the Modbus map of the third-party device |
| Connection opens, then drops after 1-2 s | 16#80A3 | TCP keepalive or partner timeout too short | Increase partner timeout, or use periodic TSEND to keep socket warm |
| PROFINET IO is online but T-block fails | 16#8087 | Port already bound by an IRT cycle | Move T-block to a slower OB (OB1) and check IRT phase |
| No traffic, LED on partner port is dark | n/a | Wrong cable or wrong port of the integrated switch | Verify Port 1 / Port 2 of the CPU X2 connector |
| Compile error: "Invalid TCON_Param length" | n/a | DB was generated as optimized / symbolic-only | Set DB to "non-optimized / standard" access |
Migrating an Existing CP 343-1 Project to the Integrated PN Port
When modernizing a brownfield S7-300 site, the integrated PN port can replace a CP 343-1 with code changes only:
- Re-route the Ethernet cable from the CP 343-1 front connector to the CPU X2 PN port (Port 1 or Port 2 of the integrated switch).
- Update HW Config: remove the CP 343-1 from the rack; keep the existing IP address on the CPU PN port. Save and recompile.
- Replace
AG_SEND/AG_RECVcalls with the equivalentTSEND/TRCVcalls. The CONNECT DB (DB100 in the example) replaces the LADDR / ID pair of the CP variant. - Re-test the partner with a Wireshark capture. The on-the-wire payload is identical; the only change is the local TCP source port range.
USEND/URCV (UDP) on the CP 343-1, the same T-block substitution applies - only the ConnectionType changes from 16#0B to 16#13.Frequently Asked Questions
Do I need a CP 343-1 to talk to a third-party Ethernet device on the CPU 315-2 PN/DP?
No. The integrated PROFINET port of the CPU 315-2 PN/DP supports the T-block family (TCON, TSEND, TRCV, TDISCON) directly. A CP 343-1 is only required if the number of open connections exceeds the CPU's limit (up to 16 for FW V3.x, exact value depends on the MLFB) or if a second physical network is needed.
What is the difference between AG_SEND/AG_RECV and TSEND/TRCV?
AG_SEND/AG_RECV are CP-only blocks (FC5/FC6) used with CP 343-1 or older CP 343 Lean. TSEND/TRCV work on the CPU's integrated PN port and use a single call per request, support partial-length reception with LEN, and have a unified STATUS model that maps directly to the T-block family used on S7-1500.
Can I use ISO-on-TCP (RFC 1006) instead of plain TCP?
Yes. Set ConnectionType := 16#12 in the TCON_Param structure and populate the LocalTsapId and RemoteTsapId. Many third-party devices that support Siemens PN also speak ISO-on-TCP because RFC 1006 is open. For fully foreign devices without the Siemens stack, plain TCP (16#0B) is the safer choice.
How many third-party TCP partners can the CPU 315-2 PN/DP talk to at once?
Firmware V3.3 supports up to 16 open communication connections in total (S7 + TCP + ISO + UDP combined). Each third-party partner consumes one connection ID. The OpenModbusTCP PN CPU library internally multiplexes a single TCP connection across multiple Modbus jobs, so 32 Modbus jobs can share one ID.
What firmware do I need for the OpenModbusTCP PN CPU library?
Library Entry ID 25209116 requires CPU 315-2 PN/DP firmware V2.6 or higher. The current release of the library targets FW V3.2 and V3.3. Older FW (V1.x, V2.0) does not contain the TCON block, and the library will not load on these revisions.