Configuring CPU315-2 DP Profibus: AG_SEND vs DP_SEND Blocks

David Krause16 min read
S7-300SiemensTechnical Reference
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. Problem Identification: Misapplication of DP_SEND on the Integrated PROFIBUS-DP Port

The Siemens SIMATIC S7-300 CPU 315-2 DP module integrates a single PROFIBUS-DP interface directly on the base board. Engineers attempting to push ASCII control characters, free-form data, or S7 payloads from this port to a PC frequently reach for DP_SEND and DP_RECV because the block names follow the DP-family naming convention. Both blocks are members of the SIMATIC_NET_CP library and operate exclusively against the Siemens CP 342-5 and CP 343-5 PROFIBUS communications processors. They cannot be bound to the integrated PROFIBUS-DP port of a CPU 31x-2.

1.1 Why the Assumption Fails

The two blocks are only resolved in the context of an instance database (IDB) that belongs to the CP-hosted DP master. The internal hardware object they manipulate is the CP-hosted DP interface. The CPU 315-2 DP integrated port has neither an IDB for those blocks nor any FC 1 / FC 2 instance. When the user code calls DP_SEND against the integrated interface, the runtime raises an SF condition, OB 121 executes, and the call returns with no useful status.

1.2 Failure Signature

When DP_SEND is wired against the wrong interface, engineers observe:

  • CPU diagnostic buffer entry "OB not loaded" / "background OB missing", referencing the FC 1 instance request.
  • STOP / RUN cycling when OB 121 is not loaded.
  • ERROR = 1 and STATUS = W#16#8081 / W#16#8183 if a CP is mistakenly installed in the rack without the matching CP firmware or DB shell.
  • Successful online compile but complete absence of bus traffic on PROFIBUS-DP X2.

2. CPU315-2 DP Hardware Reference

The 315-2 family history matters because some blocks behave differently based on firmware and master/slave capability. Representative order numbers and integrated interface specifications appear in the table below. Always confirm against the engraved MLFB on the front module and the firmware release under Module Information > Firmware.

CPU 315-2 variants and integrated interface detail
MLFB Interface X2 (PROFIBUS-DP) Interface X1 Firmware Lifecycle
6ES7315-2AG10-0AB0 DP master (DP-V0) MPI V2.0 Discontinued
6ES7315-2AH14-0AB0 DP master / slave (DP-V0 / V1) MPI / DP V3.3 Active standard selection
6ES7315-2EH14-0AB0 DP master / slave (DP-V0 / V1) on X2 PROFINET 2-port switch V3.3 Replacement part for new machines

The X2 connector is a 9-pin D-sub female PROFIBUS interface. The recommended baud rate depends on segment length: 12 Mbps up to 100 m, 1.5 Mbps up to 200 m, 187.5 kbps up to 1000 m per IEC 61158 / IEC 61784-1. Termination power must be supplied or the terminating resistors activated only at the two segment end nodes.

3. Function Block Selection Matrix

Use the decision table below to pick the right user block by counter-party role and physical interface. Library names appear as referenced in STEP 7 V5.5 and the TIA Portal library reference table for S7-300 / ET 200.

Block selection by interface and counter-party
Interface Used Counter-Party Service User Block (STEP 7) User Block (TIA Portal library) Connection Type
Integrated DP port X2 S7 station (CPU / IM) S7 communication AG_SEND / AG_RECV (FC 5 / 6), PUT / GET (SFB 14 / 15) AG_SEND / AG_RECV or PUT / GET family S7 connection over PROFIBUS
Integrated DP port X2 S7 station S7 coordinated bulk transfer USEND / URCV (SFB 8 / 9), BSEND / BRCV (SFB 12 / 13) USEND / URCV / BSEND / BRCV S7 connection over PROFIBUS
Integrated DP port X2 Any DP-V0/V1 slave Cyclic I/O I/O directly in process image (PI / PQ) I/O mapped directly DP master–slave configuration
Integrated DP port X2 FDL-capable peer SDN / SDA / SRD AG_SEND / AG_RECV (FC 5 / 6) AG_SEND / AG_RECV family FDL connection
CP 342-5 in rack S7 station or DP slave S7 or DP via CP AG_SEND / AG_RECV (FC 5 / 6) AG_SEND / AG_RECV S7 connection via CP
CP 342-5 in rack DP-V0 slave DP data record exchange DP_SEND / DP_RECV (FC 1 / 2), DPWR_DAT / DPRD_DAT DP_SEND / DP_RECV, DPWR_DAT / DPRD_DAT CP-hosted DP master
Critical: DP_SEND and DP_RECV are reserved for the CP 342-5 / CP 343-5 hosted PROFIBUS-DP interface and must never be wired against the CPU's onboard X2 port.

4. NetPro: Configuring an S7 Connection on the Integrated DP Port

To use AG_SEND, AG_RECV, PUT, GET, BSEND, BRCV, USEND, or URCV over the integrated DP port, the application must first establish a connection through NetPro (STEP 7 V5.5) or "Connections" (TIA Portal). The connection binds a local TSAP, a remote PROFIBUS address, and a transport selector for S7 communication.

4.1 Prerequisites

  • CPU 31x-2 DP with at least V2.0 firmware. V3.x is recommended because it supports BRCV interrupt routing without extra configuration.
  • STEP 7 V5.5 SP4 or later; TIA Portal V14 SP1 or later for newer part numbers.
  • Counter-party node must support S7 communication; verify with the partner's product documentation.
  • Configured PROFIBUS addresses for both stations; the integrated port X2 is typically set to a unique address on the segment.

4.2 Step-by-Step NetPro Configuration

  1. Open the S7 project in SIMATIC Manager and select the CPU icon.
  2. Launch NetPro (select the project node and click Open NetPro).
  3. Click the CPU; double-click the PROFIBUS subnet entry to verify the network exists and the integrated DP port is bound to it.
  4. Right-click the CPU > Insert New Connection. Pick S7 connection as the type. S7 connection (unspecified) can be used when the partner is not in the same STEP 7 project.
  5. Pick the partner CPU. If the partner is not visible, choose Unspecified and enter the partner PROFIBUS address manually.
  6. Under Properties > General, the Connection ID is assigned by NetPro. Note this value; it becomes the ID parameter for AG_SEND / AG_RECV.
  7. Set the maximum message length (typically up to 240 bytes for S7-SEND/RECV; up to 960 bytes for BSEND with V3.x firmware under extended S7).
  8. Compile and download the project. Verify the connection appears with status Established in Accessible Nodes.

5. AG_SEND / AG_RECV Programming for an S7 Connection

After the connection exists, the user calls AG_SEND (FC 5) and AG_RECV (FC 6) to push and pull data on it. These blocks are universal across integrated MPI / DP / PN interfaces and external CPs.

5.1 Block Interface (STEP 7)

AG_SEND (FC 5) input/output interface
I/O Name Type Meaning
INPUT ACT BOOL Rising edge triggers send
INPUT ID WORD Connection ID from NetPro
INPUT LADDR WORD Logical base address of the interface (Hardware ID in TIA Portal) — integrated DP X2 accepts 0 / W#16#0; an external CP uses its rack address
INPUT SEND ANY Pointer to source data area
INPUT LEN WORD Byte length to send (only if SEND ANY is fully sized)
OUTPUT DONE BOOL 1 = send completed without error
OUTPUT ERROR BOOL 1 = error occurred
OUTPUT STATUS WORD Detailed status (refer to F1 online help)

5.2 STL Snippet — Coordinated Send of 8 Bytes

// Trigger positive edge in "sTrig"
A   sTrig;
AN  ag_done;
=   act_edge;

CALL FC 5 "AG_SEND"
     ACT    := act_edge
     ID     := W#16#1
     LADDR  := W#16#0
     SEND   := P#DB11.DBX0.0 BYTE 8
     LEN    := W#16#8
     DONE   := ag_done
     ERROR  := ag_err
     STATUS := ag_sts;

5.3 Ladder Equivalent

---| sTrig |---| ag_done |-----( ACT )------( CALL FC 5 )

5.4 Receive Pattern

Call AG_RECV (FC 6) with a cyclic launch (OB 1 typically) and a non-zero length. When the remote sends data, AG_RECV writes to the receive ANY pointer. The job continues through multiple OB 1 cycles; poll DONE and ERROR for completion. STATUS may show W#16#0000 while no data is pending.

5.5 Common AG_SEND / AG_RECV STATUS Codes

Selected AG_SEND / AG_RECV STATUS values
STATUS (hex) Meaning Remediation
0000 No job active / no data pending Allow OB 1 cycle to continue
7000 Job active Wait for DONE / ERROR transition
8081 Connection ID not found in IDB Verify NetPro connection; download again
8082 No local resources / OB not loaded Increase OB stack or reduce concurrent AG calls
8183 Partner not reachable Check PROFIBUS cable, termination, partner address
8185 Length mismatch with configured maximum Re-split payload or change partner max length

6. PUT / GET Programming for an S7 Connection

For remote read / write where the partner acts as a server (S7-1500 client, S7-300 / 400 / WinCC / OPC server partner), the integrated port supports PUT (SFB 15) and GET (SFB 14) over S7 connections on PROFIBUS up to 160 bytes per call (firmware V2.0+). This is the cleanest pattern for variable read/write and requires no coordinated handshake.

CALL SFB 15 "PUT"
     REQ     := put_req
     ID      := W#16#1
     LADDR   := W#16#0
     DONE    := put_done
     ERROR   := put_err
     STATUS  := put_sts
     ADDR_1  := P#DB20.DBX0.0 BYTE 16
     ADDR_2  :=
     ADDR_3  :=
     ADDR_4  :=
     SD_1    := P#DB10.DBX0.0 BYTE 16
     SD_2    :=
     SD_3    :=
     SD_4    :=;

Access protection must permit PUT/GET access on the partner CPU (default on S7-300; on S7-1500 the "Permit Access with PUT/GET" option must be explicitly enabled in the CPU protection dialog). If the partner is locked, GET returns W#16#8383 with ERROR = 1.

7. PROFIBUS-DP Master–Slave I/O Exchange

If the partner is a passive DP-V0/V1 slave (ET 200S, ET 200M, third-party DP head), the integrated DP master handles cyclic I/O directly. The S7 user program reads inputs (PIW) and writes outputs (PQW) without any additional block. There is no SEND/RECV step; data flow is deterministic by the GSD file and slot configuration.

  1. Install the slave GSD in HW Config.
  2. Assign the slave to a PROFIBUS master X2.
  3. Slot the slave's I/O channels; the configuration assembles a process image slice in the CPU.
  4. Download HW Config and verify SF on the slave is clear and BF on the master is clear.

This mode is not suitable for transferring free-form characters to a PC.

8. PROFIBUS-FDL for Free-Form Payloads

For sending limited binary or character payloads to non-S7 partners (drives, gateways, third-party DP/FDL peers), the integrated port supports PROFIBUS-FDL (Fieldbus Data Link layer 2). NetPro connection type is set to FDL connection. AG_SEND / AG_RECV then act on the FDL LSDB (link services).

8.1 FDL Service Selection

  • SDN — Send Data with No Acknowledge. One-way broadcast-like send. Use when the recipient does not return a frame.
  • SDA — Send Data with Acknowledge. Each recipient must respond.
  • SRD — Send and Receive Data. Token-ring handshake; used for FETCH/WRITE active jobs on a peer.

8.2 NetPro FDL Connection Setup

  1. In NetPro right-click the CPU > Insert New Connection > pick FDL connection.
  2. Enter the remote PROFIBUS address, the LSAP and SSAP selectors (typically 0 / 0 for naive slaves; refer to the partner manual).
  3. Set max message length (≤240 bytes; up to 480 bytes subject to firmware support).
  4. Compile and download.

The block call pattern is identical to Section 5. Only the connection type differs. FDL on a CPU 315-2 DP running V3.3 firmware supports the full SDN/SDA/SRD set; firmware V2.0 supports a subset and must be verified per CPU.

9. CP 342-5 / CP 343-5: When DP_SEND / DP_RECV Apply

If the application already hosts a CP 342-5 in the rack (slots 4–11 in the S7-300) and uses that CP as the DP master, the project legitimately needs DP_SEND (FC 1) and DP_RECV (FC 2). Both blocks belong to the SIMATIC_NET_CP library. FC 1 / FC 2 share an IDB with the CP-hosted I/O area; calling them against the CPU X2 port returns the SF / OB 121 condition described in Section 1.2.

Block selection rules by interface hosting the DP master
DP Master Host Block Used Library
CPU 31x-2 DP integrated X2 None — direct PI / PQ access via HW Config n/a
CP 342-5 DP_SEND (FC 1) / DP_RECV (FC 2) SIMATIC_NET_CP
CP 343-5 (with S7 routing) AG_SEND (FC 5) / AG_RECV (FC 6) for S7 over PROFIBUS SIMATIC_NET_CP
Critical: Mixing FC 1 / FC 2 with the integrated X2 port damages nothing, but produces OB 121 / 122 load errors and runtime status W#16#8083. Always pick the block that matches the host interface.

10. ASCII Control Characters to a PC: Converter and CP 340/CP 341 Paths

The original requirement—sending two or three ASCII control characters from the CPU 315-2 DP PROFIBUS port to a PC via a PROFIBUS-to-RS232 converter—is a clean application of the DP slave role, not the DP master role.

10.1 Architecture: PROFIBUS-to-RS232 Converter

  1. CPU 315-2 DP acting as DP master on X2.
  2. A PROFIBUS-to-RS232 converter (third-party DP-V0 slave with UART pass-through firmware) configured as a DP slave with defined I/O. Some converter modules present RS232 TX bytes as output bytes (CPU → converter), and RX bytes as input bytes (converter → CPU).
  3. Standard RS232 line to the PC, with a terminal application reading the bytes.

10.2 Implementation

  1. Import the converter's GSD into HW Config.
  2. Add the slave to the subnet.
  3. Configure 1 output byte to the converter's "TX" slot.
  4. Apply ASCII bytes directly with a load-and-transfer: L 0x02; T PQB 268 (addresses vary with the HW Config layout).
  5. Configure COM port on the PC; the converter firmware typically presents a 9600 / 19200 / 38400 8-N-1 transparent stream.

This approach is fully cyclic and avoids the SEND/RECV stack. It also allows the CPU side to encode framing bytes such as STX / ETX.

10.3 Asynchronous Serial Alternative: CP 340 / CP 341

If the project has spare slots in the S7-300 rack, a CP 340 (RS-232-C, 3964R, or ASCII driver) or CP 341 provides direct RS232/RS422/RS485 to a PC or modem. These CPs do not use the PROFIBUS-DP port, but they cleanly solve the original requirement without a PROFIBUS-to-RS232 converter.

  • CP 340 family RS-232-C variants and CP 341 family RS-232-C variants are typically ordered from the 6ES7340-1 / 6ES7341-1 ranges (confirm the exact MLFB at the time of procurement).
  • Loader blocks: FB 7 / FB 8 (P_SEND / P_RCV) or FB 2 / FB 3 for the ASCII driver.
  • For "a couple of control characters", the ASCII driver is the lowest-overhead pattern; choose the CP variant that matches the protocol required by the PC (ASCII, 3964R, Modbus RTU master, RK 512).

11. Migration to CPU 315-2 PN/DP

For new machines, Siemens recommends the CPU 315-2 PN/DP (6ES7315-2EH14-0AB0) which keeps the same PROFIBUS-DP interface on X2 while adding a two-port PROFINET switch on X1 (PROFINET IO controller and IO device plus S7 communication).

  • The same STEP 7 V5.5 SP4 or TIA Portal V14 SP1 source can be re-targeted to the PN/DP variant without changing user blocks.
  • The integrated DP port block interface remains identical: AG_SEND / AG_RECV (FC 5 / 6), PUT / GET (SFB 14 / 15).
  • The PROFINET port opens paths to PROFINET IO and to OPC UA via CP 443-1 or SCALANCE.
  • Firmware V3.3 supports both integrated interfaces simultaneously and can act as PROFINET controller while keeping the DP master role active.

12. Troubleshooting Matrix and Field Commissioning Procedure

12.1 Common Block / Port Mismatches

Troubleshooting matrix
Symptom Likely Cause Verification Remediation
SF on CPU; OB 121 missing DP_SEND wired against integrated X2 Check which FC instance uses LADDR; cross-check HW Config / CP presence Replace with AG_SEND / AG_RECV; ensure NetPro S7 connection exists
STATUS W#16#8081 on SEND block No valid connection configured Open NetPro and check connection state Insert S7 connection in NetPro and download
STATUS W#16#8183 Partner station not yet reachable Check PROFIBUS cable and termination; verify partner address Swap terminators; check bus topology; fix duplicate addresses
BF on DP master, slaves all flashing Baud rate mismatch or duplicate address Use PROFIBUS diagnostics (e.g., BT 200 / soft diagnostics on the master) Set consistent baud rate and unique addresses
Converting ASCII via DP-to-RS232 gateway; garbled output Converter configured for 8-N-1 but PC set to 7-E-1 Cross-check converter config with PC terminal Align both sides; consider parity turn-around for legacy devices
PUT/GET returns STATUS W#16#8383; partner rejects Access protection on S7-1500 partner CPU Check partner CPU properties > Connection mechanisms > Permit PUT/GET Enable PUT/GET on partner CPU or switch to AG_SEND with FETCH/WRITE
CPU STOP after OB 122 load error I/O fault during hardware config mismatch Diagnostic buffer via STEP 7 online Compile and download HW Config; ensure PI / PQ alignment

12.2 Field Commissioning Procedure

  1. Read the engraved MLFB and the firmware version with PLC > Module Information in STEP 7. Record both values for the bill of materials.
  2. Open the project and confirm the integrated DP port X2 is on the correct subnet (HW Config > Properties of CPU > Interface). For non-symmetric firmware versions, force the X2 driver parameter set (12 Mbps, high, retry count 3) under Properties > Interface > Interface Parameters.
  3. Insert an S7 or FDL connection in NetPro and pin down the partner PROFIBUS address, TSAP / LSDB selectors, and maximum message length.
  4. Generate or hand-code the user block calls in OB 1 (cyclic) or OB 35 (time-driven). For OB 35, schedule the call every 50–100 ms; this avoids hot loops on the integrated port.
  5. Download hardware, then software, then connections. Watch Connections in NetPro for green state.
  6. Run a smoke test: write a 16-byte payload via AG_SEND to a partner and verify it returns; repeat the call at 100 ms intervals for 5 minutes to validate stability.
  7. If a DP-to-RS232 converter is involved, poll the converter inputs for its "TX activity" flag (often mapped via the slave's diagnostic area) and watch the PC terminal in lockstep.
  8. Capture diagnostic buffer entries with timestamps. Compare against the table in Section 12.1. None should remain at the end of the smoke test.

Can DP_SEND be used on the integrated PROFIBUS-DP port of a CPU 315-2 DP?

No. DP_SEND (FC 1) and DP_RECV (FC 2) are bound to the CP 342-5 / CP 343-5 communications processor. On the integrated X2 port of the CPU 315-2 DP, use AG_SEND / AG_RECV (FC 5 / 6) or PUT / GET (SFB 14 / 15) over a configured S7 connection.

What is the difference between DP_SEND and AG_SEND on a Siemens CPU?

DP_SEND works only against a CP 342-5 hosted DP master. AG_SEND works against any configured S7 or FDL connection on an integrated interface or external CP. They are not interchangeable: the block's instance data assumes a CP-hosted DP interface.

How do I configure an S7 connection for PROFIBUS communication in NetPro?

Open the project in SIMATIC Manager and launch NetPro. Right-click the CPU and choose Insert New Connection. Pick S7 connection, specify the partner PROFIBUS address, and note the assigned Connection ID. Compile and download, then verify that the connection state shows green.

Do I need a CP 342-5 to communicate via PROFIBUS-DP from a CPU 315-2 DP?

No. The integrated X2 port on the CPU 315-2 DP already serves as a PROFIBUS-DP master for up to 32 slaves and supports S7 / FDL communication. A CP 342-5 only becomes necessary when the project needs a second DP master, an additional PROFIBUS segment, or routing through PROFIBUS as a backbone.

Which Siemens CPU replaces the CPU 315-2 DP for new projects?

The CPU 315-2 PN/DP (6ES7315-2EH14-0AB0) extends the 315-2 DP with an integrated PROFINET two-port switch while retaining the same DP master on X2. It runs the same STEP 7 V5.5 SP4 / TIA Portal block families, making migration seamless.

Back to blog