S7-300 CPU 315-2 PN/DP Open TCP Communication via PN Port

David Krause13 min read
S7-300SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

1. Overview and Problem Statement

Two Siemens SIMATIC S7-300 CPU 315-2 PN/DP stations must exchange user data over their integrated PROFINET (PN) interfaces. Engineers familiar with the classic S7-300/400 approach (NetPro configured S7 connection, PUT/GET, BSEND/BRCV) attempt the same workflow on the PN port and find that the connection editor behaves differently: the PN interface of an S7-300 CPU does not expose the same configured-connection resources as a CP343-1 or a CP443-1 module.

The correct approach is the Open Communication via Industrial Ethernet family of function blocks. Instead of configuring a static S7 connection, the programmer builds a connection description DB that is handed to FB65 TCON at runtime, then transfers payload with FB67 TUSEND / FB68 TURCV and tears the link down with FB66 TDISCON. The connection DB replaces the NetPro dialog and is the only valid configuration entry point for open TCP, ISO-on-TCP and UDP over the integrated PN port of the CPU 315-2 PN/DP.

Typical symptoms that drive engineers to this article:

  • Local/remote port fields are missing in HW Config because the PN interface is not a CP module.
  • PUT / GET blocks time out (SF LED on, diagnostic buffer entry "connection resource not configured").
  • Only one direction works (A → B) while the reverse path stays idle.
  • NetPro shows the two stations online but no S7 connection object exists between them.
Key engineering fact: The PROFINET interface of a CPU 315-2 PN/DP supports open TCP/IP communication only. Configured S7 connections, S7 routing, and the classic PUT/GET pair cannot be bound to the PN port of an S7-300 CPU; they require a CP (e.g. CP 343-1) or a CPU with CP-integrated PROFINET that exposes the configured-connection resource set (e.g. CPU 319-3 PN/DP in some firmware levels, or S7-400 CPUs).

2. Hardware and Software Prerequisites

Item Required value / catalog number Notes
CPU A 6ES7 315-2EH14-0AB0 (or -2EH13) CPU 315-2 PN/DP, firmware ≥ V3.2 recommended
CPU B 6ES7 315-2EH14-0AB0 Same family for symmetric setup
PROFINET cable 6XV1840-2AH10 (Cat 5e) or 6XV1870-2B RJ45, crossover not required (Auto-MDI/MDIX)
Switch (optional) SCALANCE XC-108 or XB-008 Direct patch cable also works in lab
STEP 7 SIMATIC Manager V5.5 + SP2 / HF7 or higher TIA Portal V13+ also supported but block names identical
Open Comm blocks FB65 TCON, FB66 TDISCON, FB67 TUSEND, FB68 TURCV Shipped with STEP 7 standard library under "Communication Blocks"
Open Communication Wizard Siemens Support entry ID 8773153 (legacy) / 24239907 (newer) Generates the connection DB and TCON call

Firmware matters: CPU 315-2 PN/DP ships with two main firmware generations (V2.x and V3.x). V3.x increased the number of open communication resources to 16, whereas V2.x is limited to 8. If you plan bidirectional data plus reserved HMI connections, prefer V3.2 or V3.3.

3. Why NetPro Does Not Configure the PN Port

On an S7-400 or an S7-300 with a CP343-1, NetPro shows a "PN-IO" or "Ethernet" interface object that accepts a configured S7 connection. For the integrated PROFINET interface of a CPU 315-2 PN/DP, NetPro displays the port properties (IP address, subnet mask, router) but the right-click "New Connection" option is grayed out for S7 connections. The reason is architectural: the PN stack of the S7-300 CPU does not contain the configured-connection resource class; it only contains the open-communication resource class.

Consequences:

  1. IP, subnet, and PROFINET device name are still configured in HW Config or in the device properties of the PN interface.
  2. Transport ports (TCP/UDP port numbers, e.g. 2000) are not an HW Config field. They live in the connection DB that you hand to TCON.
  3. The connection itself is established at runtime, not at project download time.

4. Project Setup and IP Configuration

  1. Open SIMATIC Manager and create a new S7-300 station for each CPU.
  2. Insert the CPU 315-2 PN/DP from the hardware catalog (SIMATIC 300 → CPU 300 → CPU 315-2 PN/DP → 6ES7 315-2EH14-0AB0).
  3. Double-click the PN port row (X2) in the station view. In the Properties dialog, assign a fixed IP address (avoid DHCP for deterministic control traffic):
    • CPU A: IP 192.168.0.10, Subnet 255.255.255.0, no router.
    • CPU B: IP 192.168.0.11, Subnet 255.255.255.0, no router.
  4. If the two CPUs are directly patched, set the PROFINET device name to match the station name (e.g. cpu_a, cpu_b) and disable the PROFINET IO controller role. Open communication does not require PROFINET IO, only the IP layer.
  5. Compile and download HW Config to both CPUs.
Verification step 1: From a PG/PC on the same subnet, ping both addresses. If the ping fails, fix the physical layer or the IP address before touching application code.

5. The Open Communication Wizard

Manually building the connection DB is error-prone (the TCON_PAR UDT has dozens of fields). Siemens provides the Open Communication Wizard that generates a ready-to-use DB plus a starter instance of FB65 TCON.

  1. Launch the wizard from the Windows Start menu (installed with STEP 7) or download the current version from Siemens Support entry 24239907.
  2. Select the S7 project, the CPU station, and the protocol: TCP (not ISO-on-TCP and not UDP for this use case).
  3. Specify the partner:
    • Partner type: specified partner (active or passive) or unspecified for broadcast-free server mode.
    • Partner IP: 192.168.0.11 (CPU B).
    • Partner port: 2000 (decimal).
    • Local port: 2000 (decimal).
  4. Connection name: e.g. TCP_A_to_B. The wizard creates DB100 (configurable) containing the TCON_PAR structure.
  5. Tick "Generate instance DB for TCON" – the wizard inserts FB65 with its instance DB into OB1.
  6. Repeat on CPU B, mirroring local/remote IP and ports.

6. Connection Parameter DB Layout

The generated DB contains a structure of type TCON_PAR. The fields relevant to TCP are:

Offset Field Type Meaning Example value
0.0 block_length WORD Length of the structure (always 64) W#16#0040
2.0 id WORD Connection identifier (1..16, unique per CPU) W#16#0001
4.0 connection_type BYTE 11 = TCP, 12 = ISO-on-TCP, 13 = UDP B#16#0B
5.0 active_est BOOL TRUE = active open (client), FALSE = passive (server) TRUE for CPU A, FALSE for CPU B
6.0 local_device_id BYTE 1 = PN interface, 2..14 = CP modules B#16#01
7.0 local_tsap_id_len BYTE Length of local port field in bytes (0 for TCP) B#16#00
8.0 rem_subnet_id_len BYTE Always 0 for TCP/IP B#16#00
9.0 rem_staddr_len BYTE 4 for IPv4 B#16#04
10.0 rem_tsap_id_len BYTE 0 for TCP B#16#00
11.0 next_staddr_len BYTE 0 B#16#00
12.0 local_tsap_id ARRAY[1..16] Local port (big-endian word) for TCP local_tsap_id[1]=B#16#07, [2]=B#16#D0 (= 2000)
28.0 rem_subnet_id ARRAY[1..6] Unused for TCP 0
34.0 rem_staddr ARRAY[1..4] Remote IP, e.g. {192,168,0,11} B#16#C0, A8, 00, 0B
38.0 rem_tsap_id ARRAY[1..16] Remote port (big-endian word) for TCP rem_tsap_id[1]=B#16#07, [2]=B#16#D0
54.0 spare WORD Reserved, 0 W#16#0000
Byte order trap: Port numbers are stored as two bytes with the high byte first. Port 2000 = 0x07D0 → local_tsap_id[1] = B#16#07, local_tsap_id[2] = B#16#D0. Reversing them gives 0xD007, which the stack silently treats as port 53255.

7. Calling the Open Communication Blocks

The four FBs sit in the standard library Communication Blocks under CP 300 / CPU 300. Copy them into your program so the calls become part of the project, not the library reference.

7.1 FB65 TCON – Establish connection

CALL "TCON" , DB_TCON   // instance DB auto-generated by wizard
REQ    := M10.0          // rising edge starts the connect attempt
ID     := W#16#0001      // matches the id field in the connection DB
DONE   := M20.0          // one cycle TRUE on success
BUSY   := M20.1          // TRUE while the connect attempt runs
ERROR  := M20.2          // TRUE on protocol error
STATUS := MW22           // detailed error code (see section 10)
CONNECT:= "TCP_A_to_B".TCP_PAR  // pointer to TCON_PAR in DB100

7.2 FB66 TDISCON – Tear down

CALL "TDISCON" , DB_TDIS
REQ    := M11.0
ID     := W#16#0001
DONE   := M21.0
BUSY   := M21.1
ERROR  := M21.2
STATUS := MW24

7.3 FB67 TUSEND – Send user data over TCP

CALL "TUSEND" , DB_SEND
REQ    := M12.0          // trigger with rising edge
ID     := W#16#0001
LEN    := 20             // bytes to send, <= 8192
DONE   := M22.0
BUSY   := M22.1
ERROR  := M22.2
STATUS := MW26
DATA   := P#DB20.DBX0.0 BYTE 20   // source data area

7.4 FB68 TURCV – Receive user data over TCP

CALL "TURCV" , DB_RCV
EN_R   := M13.0          // enable reception
ID     := W#16#0001
RCVD_LEN := MW28         // actually received length
NDR    := M23.0          // new data received
ERROR  := M23.2
STATUS := MW30
DATA   := P#DB21.DBX0.0 BYTE 800   // receive buffer
Block parameter names vary slightly between STEP 7 V5.5 and TIA Portal V13+. In TIA the TUSEND block exposes LEN as SEND_LEN and TURCV's RCVD_LEN becomes RCV_LEN. Always cross-check against the F1 help of the block version in your project.

8. Bidirectional Data Flow on One Connection

A common engineering question after the first successful transfer is: "A sends to B and it works, but how does B send to A on the same connection?"

TCP is full-duplex. A single established connection carries traffic in both directions simultaneously. The send and receive FBs use the same connection ID and operate independently:

  • CPU A calls TUSEND with ID=1 → bytes leave A, arrive at B's receive buffer managed by TURCV with ID=1.
  • CPU B calls TUSEND with ID=1 → bytes leave B, arrive at A's receive buffer managed by TURCV with ID=1.

No second connection is required. The asymmetry in the early-stage report comes from a typical mistake: the receive FB is never called on the receiving CPU, or its instance DB is not loaded, so RCVD_LEN stays at 0 and the user thinks the path is dead. Cyclically call TURCV in OB1 (with EN_R := TRUE) so the stack can dispatch incoming frames into the receive buffer at any time.

9. Active vs Passive Connection Establishment

Role active_est in connection DB Behaviour Typical use
Active (client) TRUE Issues the SYN, retries until partner accepts CPU that polls the other on power-up
Passive (server) FALSE Listens on the configured port, accepts incoming SYNs CPU waiting for an HMI / second PLC to connect

For two CPU 315-2 PN/DP units, configure one side active and the other passive. If both are active, the SYN packets race and at least one side may report error 0x80C4 (connection already established, second attempt rejected). If both are passive, neither initiates, and the link never opens.

10. Status and Error Code Reference

STATUS (hex) Meaning Remediation
0000 Job completed without error —
7000 Block not active (FB idle / not called this cycle) Normal for first call before REQ
7001 First call, job started, BUSY = TRUE Wait for DONE / ERROR
7002 Job still running after second call Continue polling BUSY
8085 LEN = 0 or > 8192 on TUSEND Clamp LEN to payload size
8086 ID parameter outside the range 1..16 Match ID with the connection DB id field
80A1 Local or remote port = 0 or 65535 in connection DB Re-check byte order, port must be 1..65534
80A3 Attempt to establish a connection that is already active Set active_est differently on each side or call TDISCON first
80A4 IP address of partner is local IP or 0.0.0.0 Re-enter the partner address in rem_staddr
80C3 All connection resources used Reduce concurrent open connections or upgrade CPU firmware
80C4 Temporary resource conflict (re-entered too fast) Add a small delay, then re-trigger REQ

11. Verification Procedure

  1. On CPU A, force M10.0 to TRUE once. Observe M20.1 go TRUE, then M20.0 TRUE → connection established.
  2. On CPU B, the stack should report the incoming connection on its TURCV background path. Check the diagnostic buffer of CPU B for entry "Connection established (active: yes, ID=1)".
  3. Set a recognizable pattern in DB20 (e.g. 20 bytes of 16#AA), trigger TUSEND on CPU A, and watch DB21 on CPU B fill with the same pattern after a few OB1 cycles.
  4. Reverse the direction: write to DB30 on CPU B, trigger its TUSEND, verify DB31 on CPU A updates.
  5. Use the STEP 7 online dialog PLC → Information → Connection Overview to view the live state of connection ID 1. It should show status Established with bytes-sent and bytes-received counters increasing in both directions.
Verification step 2: If counters increment in only one direction, the most likely cause is that the receive FB on the silent side is not called in OB1. Add CALL "TURCV" , DB_RCV unconditionally in OB1 with EN_R := TRUE and re-test.

12. Troubleshooting Matrix

Symptom Likely root cause Fix
STATUS = 80A1 at TCON Wrong byte order in port field of connection DB High byte first: 2000 → 07 D0
STATUS = 80A4 at TCON Partner IP equals own IP Cross-check IP settings in HW Config
TCON never sets DONE, BUSY stays TRUE Partner not reachable Ping partner, check switch, PROFINET cable
TURCV never sets NDR TURCV not cyclically called Place CALL in OB1 with EN_R = TRUE
One-way communication only Receive FB instance DB not downloaded to the receiver Download all instance DBs, not just the program blocks
SF LED on, diagnostic buffer "connection resource not configured" Trying to use PUT/GET over the PN port Switch to TCON/TUSEND/TURCV as documented
STATUS = 80C3 after a few minutes Connection leaks (TCON called repeatedly without TDISCON) Call TDISCON on shutdown, reuse same ID
Reset of CPU breaks the connection TCON not re-triggered after restart Use OB100 to issue REQ on cold restart

13. Field-Proven Caveats

  • Watchdog during long blocking calls. TUSEND and TURCV complete in one OB1 cycle for short payloads, but a 4 KB transfer may span two or three cycles. Increase OB1 cycle budget accordingly or partition the data into ≤ 1 KB chunks.
  • Port 2000 is the historical Siemens default but is not reserved; any free port 1024..65534 is acceptable. Some plant firewalls block high ports, so 2000 often works in production networks already permitted for S7 communication.
  • CPU 315-2 PN/DP firmware V2.x ships with a smaller open-communication stack. If you hit STATUS = 80C3 even with a single connection, upgrade to V3.2 or later.
  • PROFINET device name and IP are independent. Open TCP needs only the IP. You can disable the PROFINET IO controller role entirely to free CPU resources if the controller functionality is not used.
  • Connection DBs are downloaded as part of the S7 program. A common field failure is the programmer updates the DB online and forgets to save it offline. After a CPU stop/start, the wizard-generated value is lost.

14. Summary Workflow

  1. Assign fixed IP addresses to both PN ports in HW Config.
  2. Run the Open Communication Wizard on each CPU, generate connection DB and TCON instance.
  3. Download HW Config + program blocks (FB65..FB68 + instance DBs + connection DB) to both CPUs.
  4. Wire the send/receive FBs in OB1 (and OB100 for restart handling).
  5. Trigger TCON once on power-up, then call TUSEND / TURCV cyclically.
  6. Verify both directions via the connection overview and the receive DB contents.

Following this procedure turns the PROFINET port of the CPU 315-2 PN/DP into a deterministic TCP transport, supporting both unidirectional and bidirectional user-data exchange between two S7-300 stations without requiring a CP module or a configured S7 connection.

Can I use NetPro to configure a TCP connection on the CPU 315-2 PN/DP integrated PN port?

No. The integrated PROFINET interface of the CPU 315-2 PN/DP only supports open communication (TCP, ISO-on-TCP, UDP). NetPro will not allow you to create a configured S7 connection on the PN port; instead, you must build a TCON_PAR connection DB and call FB65 TCON at runtime.

Where do I set the local and remote port number (e.g. 2000)?

Port numbers are not set in HW Config. They are stored in the connection DB generated by the Open Communication Wizard, inside the TCON_PAR structure at the local_tsap_id and rem_tsap_id fields. Remember the high byte must come first, so 2000 decimal is stored as B#16#07 then B#16#D0.

Why does only one direction work even though the connection is established?

TCP is full-duplex, so the single connection carries traffic both ways. The reason one direction appears dead is almost always that FB68 TURCV is not called cyclically on the receiving CPU, or its instance DB was not downloaded. Add a CALL "TURCV" with EN_R := TRUE in OB1 on both sides.

Which FB do I call to send, FB8 USEND or FB67 TUSEND?

For TCP use FB67 TUSEND paired with FB68 TURCV. FB8 USEND / FB9 URCV are for UDP only. For ISO-on-TCP use FB65 TCON with connection_type B#16#0C plus the BSEND/BRCV pair (FB12/FB13) or TSEND/TRCV (FB63/FB64).

How many open TCP connections can a CPU 315-2 PN/DP handle?

Firmware V3.2 supports up to 16 open communication resources; firmware V2.x is limited to 8. Each open TCP connection consumes one resource for the lifetime of the link, so plan HMI PG connections, OPC UA wrappers and PLC-PLC links against this budget.

Back to blog