Overview: CP 341 as a Modbus RTU Node
The SIMATIC CP 341 (6ES7 341-1xx02-0AE0 hardware family) is a serial point-to-point communication processor for the S7-300 and S7-400 PLC families. It is most commonly deployed in retrofit and brownfield environments where RS-485 or RS-232C infrastructure already exists and Modbus RTU is the de-facto fieldbus. Unlike the S7-1200/1500 onboard serial ports, the CP 341 does not execute Modbus in the base firmware. The Modbus RTU frame engine, the Modbus function code interpreter, the CRC16 verifier, and the messaging FBs are delivered as a loadable driver package that must be installed in TIA Portal (or STEP 7 V5.5) and licensed on the physical CP 341 hardware.
This article is the practical reference for configuring the CP 341 as a Modbus RTU master or slave inside TIA Portal V13, identifying the correct FBs (MOD_MASTER, MODB_341), determining the licensing requirement, and resolving the most common commissioning faults. It is written for engineers who have already attempted to use the S7-1200/1500 Modbus blocks (MB_COMM_LOAD, MB_MASTER, MB_SLAVE) and discovered — correctly — that they are not compatible with the CP 341.
Hardware Identification and Interface Submodules
The CP 341 is sold as a base unit plus a pluggable interface submodule. The base unit and the interface module must be matched against the physical wiring. The following table covers the most common configurations in service as of TIA Portal V13 (2014) and still supported in V20 documentation.
| CP 341 Order Number | Interface Submodule | Physical Standard | Typical Use |
|---|---|---|---|
| 6ES7 341-1AH02-0AE0 | 6ES7 341-1AH00-0AA0 (RS-232C) | RS-232C, full duplex, point-to-point | Single Modbus RTU slave on a short cable (< 15 m) |
| 6ES7 341-1CH02-0AE0 | 6ES7 341-1CH00-0AA0 (RS-422/485) | RS-422 (4-wire full duplex) / RS-485 (2-wire half duplex) | Multi-drop Modbus RTU bus, up to 32 nodes |
| 6ES7 341-1BH02-0AE0 | 6ES7 341-1BH00-0AA0 (RS-485 only) | RS-485, 2-wire half duplex | Cost-optimized multi-drop Modbus RTU |
The 6AG1 (SIPLUS) and 6ES7 341-1NF00-0AE0 (RS-485 with PG/OP socket) variants exist for harsh environments and should be substituted into the same driver/license framework without code change. TIA Portal V13 Service Pack 1 and later support the -1xH02 hardware revision. Older -1xH01 modules (pre-2007) require the legacy Modbus driver version and will not appear in the TIA Portal device catalog on a clean install.
For Modbus RTU the RS-485 variants are by far the most common. Confirm 2-wire vs 4-wire termination, fail-safe bias, and the line termination resistor (typically 120 Ω at each bus end) before commissioning. The CP 341 does not supply line bias internally on the RS-485 models; bias must be applied externally or via a terminating connector with built-in failsafe.
Why Modbus_Comm_Load and Modbus_Master Cannot Be Used
The S7-1200/1500 Modbus library is bound to the CPU's serial port or the dedicated CM PtP modules (CM 1241, CM PtP for S7-1500). The relevant instruction names are MB_COMM_LOAD, MB_MASTER, MB_SLAVE in TIA Portal, or the older MODBUS_Comm_Load / Modbus_Master / Modbus_Slave variants in the S7-1200 program editor. These FBs call the CPU's integrated serial driver directly and carry an MB_DB background data block whose MODE, DATA_ADDR, and DATA_LEN parameter signatures are specific to the S7-1200/1500 data type semantics.
The CP 341 is an external module and exposes its own application interface through the standard P_SND_RK / P_RCV_RK primitives (FBs from the Standard Library > Communication > Point-to-Point). The Modbus RTU state machine for the CP 341 is implemented on top of these primitives in a separately shipped driver DLL and matching FBs (MOD_MASTER and MODB_341). The MB_* instructions do not link to the CP 341 P_SND_RK layer and will not compile against the CP 341 instance DBs.
Loadable Driver Packages
Two Modbus RTU loadable drivers are supplied by Siemens for the CP 341 family. They are distributed on the "CP PtP Param / Modbus Master / Modbus Slave" CD and are also available through the Siemens SiePortal / Industry Online Support entry MODB_341 — Modbus slave instruction for CP 341 (S7-300, S7-400).
| Driver | Role | Order Number (legacy) | Order Number (TIA Portal V13+) | Companion FB |
|---|---|---|---|---|
| Modbus Master | CP 341 initiates requests, reads/writes remote coils, registers | 6ES7 870-1AA01-0YA0 | 6AV6 671-1AE01-0AX0 | MOD_MASTER (FB 81 in some versions) |
| Modbus Slave | CP 341 responds to a master, exposes data via a configured DB | 6ES7 870-1AB01-0YA0 | 6AV6 671-1AF01-0AX0 | MODB_341 (FB 82 in some versions) |
The driver package contains the parameterization tool (PTP Param), the Modbus master and slave wizards, the compiled .APO / .PAR files for the CP 341, and the FBs that are placed into the project library. After installation, restart TIA Portal so that the new device versions and instruction folders are recognized. In TIA Portal V13 the CP 341 Modbus slave instruction is documented in the function manual as MODB_341; the master is MOD_MASTER. In STEP 7 V5.5 the same functions exist as FB 81 / FB 82 (or FB 80 depending on the version of the driver CD).
Licensing the Modbus Driver
Yes, a license is required. The Modbus master and Modbus slave drivers are licensed, not free, and the license is bound to the serial number of the physical CP 341 module. Licensing is per CP 341, not per project, not per S7 CPU, and not per TIA Portal installation.
- Install the Modbus driver from the CD. The installation copies the parameterization data and the FBs to the engineering system and registers them with the Automation License Manager.
- Open the Automation License Manager. Locate the slot for "CP 341 Modbus Master" and/or "CP 341 Modbus Slave".
- Transfer the license to the USB license stick or to the PG/PC that is online with the target CP 341.
- In TIA Portal, go online to the target CP 341. Right-click the CP 341 > "License > Transfer License to Module". This writes the right-to-use into the CP 341's CF/SD or internal non-volatile memory (depending on the -H02 hardware revision).
- Power cycle the CP 341 once after license transfer. The license is then persistent across power-downs and CPU restarts.
If the license is missing, the CP 341 will accept the configuration but every Modbus transaction returns STATUS = W#16#0801 (No license found). The CP 341 will not enter the run state for Modbus application tasks without a valid license. A trial / demo license of 14 days is available from the Automation License Manager for testing; it is converted to a full license by purchasing the appropriate order number and re-activating.
Configuring the CP 341 in TIA Portal V13
Prerequisites
- TIA Portal V13 (Service Pack 1 minimum recommended) installed with the Modbus driver CD for CP 341.
- S7-300 or S7-400 project created with the matching CPU firmware version.
- CP 341 inserted into the rack (slots 4-11 on S7-300) and a valid interface submodule selected in the device configuration.
- Automation License Manager with the correct license present on the PG/PC.
Step 1 — Device Configuration
- Open the project and the device view of the S7-300 / S7-400 station.
- Drag the CP 341 from the catalog into the rack. Use the order number that matches the physical hardware you have on the shelf (RS-485 variant for typical Modbus RTU bus).
- Open the CP 341 properties. In the "Interface" tab select the correct submodule and set the protocol to "Modbus Master" or "Modbus Slave".
- Set the physical parameters: baud rate (1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 are supported — verify with the slave device), parity (None / Even / Odd), data bits (8 for Modbus RTU), stop bits (1 or 2), and the inter-character / inter-frame timeouts.
- In the "Modbus" tab configure the addressing model: for a master, set the polling table, the response timeout (typical 1000 ms), and the inter-request pause. For a slave, set the slave address (1-247) and the data block used to expose Modbus registers.
Step 2 — Hardware Identifier (HWID)
Every CP 341 is addressed in the user program by its hardware identifier (HWID), assigned automatically by TIA Portal. Note the HWID — it is used as the LADDR input on the MOD_MASTER / MODB_341 call and is the same identifier that the diagnostic FB PNI_DIAG uses. The default value in a single-CP 341 project is usually 264 (decimal), but do not assume; check the CP 341 properties > "System constants".
Step 3 — Insert the Modbus FB
- In the project library, expand the "CP 341 Modbus Master" or "CP 341 Modbus Slave" folder.
- Drag the MOD_MASTER or MODB_341 FB into OB1 (or a dedicated OB for Modbus handling such as OB35, the cyclic interrupt OB).
- TIA Portal will ask for an instance DB; accept the default name. The instance DB is created automatically and must remain a singleton — never reuse the same instance DB across multiple calls.
- Open the instance DB and verify that the static section matches the CP 341's parameterization. The Modbus driver writes the protocol configuration into the instance DB at startup.
Programming the Master (CP 341 as Modbus Master)
The MOD_MASTER FB has the following parameter signature. Some parameters are renamed across TIA Portal V13 service packs, but the contract is the same.
| Parameter | Direction | Type | Description |
|---|---|---|---|
| REQ | INPUT | BOOL | Rising edge starts a new Modbus transaction. |
| CONT | INPUT | BOOL | Continue communication after a fault without operator intervention. |
| LADDR | INPUT | INT / HW_IO | Hardware identifier of the CP 341. |
| UNIT | INPUT | BYTE | Logical port (usually B#16#01). |
| MODE | INPUT | BYTE | Selects the Modbus function code set (e.g. 0 = FC 03/04 read holding/input, 1 = FC 06/16 write single/multiple, etc.). |
| DATA_ADDR | INPUT | DWORD | Modbus address of the first register/coil on the slave. |
| DATA_LEN | INPUT | INT | Number of registers/coils to read or write. |
| DATA_PTR | INOUT | VARIANT / ANY | Pointer to the S7 data block (e.g. P#DB100.DBX0.0 BYTE 100) used as the source/destination for the data. |
| DONE | OUTPUT | BOOL | Set for one cycle on a successful transaction. |
| ERROR | OUTPUT | BOOL | Set when the transaction ended in error. |
| STATUS | OUTPUT | WORD | Detailed status / error code (see status table below). |
Sample SCL Code — Master Reading 16 Holding Registers from Slave 1
FUNCTION_BLOCK "ModbusMasterPoll"
{ S7_Optimized_Access := 'FALSE' }
VERSION : 0.1
VAR
TriggerCycle : BOOL; // one-second tick from OB35
Busy : BOOL;
ErrorLatch : BOOL;
StatusWord : WORD;
END_VAR
BEGIN
// Edge-triggered call
IF "IO_Cycle_1Hz" AND NOT Busy THEN
"ModbusMaster_DB".REQ := TRUE;
ELSE
"ModbusMaster_DB".REQ := FALSE;
END_IF;
"ModbusMaster_DB"(REQ := "ModbusMaster_DB".REQ,
CONT := TRUE,
LADDR := 264, // CP 341 HWID
UNIT := B#16#01,
MODE := B#16#00, // FC 03 holding register read
DATA_ADDR := DW#16#0000, // Modbus address 40001
DATA_LEN := 16, // 16 registers
DATA_PTR := P#DB100.DBX0.0 BYTE 32,
DONE => Busy,
ERROR => ErrorLatch,
STATUS => StatusWord);
END_FUNCTION_BLOCK
This is the most common pattern: a slow cyclic interrupt (e.g. OB35 at 1000 ms) sets REQ for one cycle, the FB executes the request, and the next OB35 call does not raise REQ again until Busy drops. The Modbus master FB then orchestrates the P_SND_RK / P_RCV_RK primitives internally and the user code does not call them directly.
Programming the Slave (CP 341 as Modbus Slave)
The MODB_341 FB is the slave counterpart. It has a smaller signature because the slave does not poll — it only receives requests and dispatches them to a configured data block.
| Parameter | Direction | Type | Description |
|---|---|---|---|
| REQ | INPUT | BOOL | Initial start request to begin Modbus slave processing. |
| CONT | INPUT | BOOL | TRUE = automatic restart after a fault. |
| LADDR | INPUT | INT / HW_IO | Hardware identifier of the CP 341. |
| DATA_PTR | INOUT | VARIANT / ANY | Pointer to the S7 data block that exposes holding registers, input registers, coils, and discrete inputs to the Modbus master. |
| DONE | OUTPUT | BOOL | Set for one cycle on a successful Modbus exchange. |
| ERROR | OUTPUT | BOOL | Set when the slave rejects a request or the line fails. |
| STATUS | OUTPUT | WORD | Detailed status / error code. |
Sample SCL Code — Slave exposing 100 Holding Registers
BEGIN
// One-shot start, then continuous operation
IF "FirstPass" THEN
"ModbusSlave_DB".REQ := TRUE;
"FirstPass" := FALSE;
ELSE
"ModbusSlave_DB".REQ := FALSE;
END_IF;
"ModbusSlave_DB"(REQ := "ModbusSlave_DB".REQ,
CONT := TRUE,
LADDR := 264,
DATA_PTR := P#DB200.DBX0.0 BYTE 200,
DONE => "ModbusDone",
ERROR => "ModbusError",
STATUS => "ModbusStatus");
END_FUNCTION_BLOCK
The 200-byte area in DB200 is mapped to the Modbus address space as 100 16-bit holding registers (Modbus address 40001-40100). Coils, discrete inputs, and input registers can be exposed in additional non-overlapping regions of the same data block by configuring the slave mapping in the CP 341 properties.
Status and Error Code Reference
Both MOD_MASTER and MODB_341 return a 16-bit STATUS word. The most common values engineers will see in commissioning are listed below. These are documented in the CP 341 Modbus master/slave function manuals in the TIA Portal online help system.
| STATUS (hex) | Meaning | Typical Cause | Action |
|---|---|---|---|
| 0000 | No error (idle) | — | Normal — DONE will toggle on each successful transaction. |
| 0001 | No error, request in progress | — | Wait for DONE or ERROR. |
| 0801 | License missing | Modbus driver license not transferred to CP 341 | Use Automation License Manager; transfer license to the CP 341; power-cycle. |
| 0802 | Configuration error in instance DB | Data block pointers inconsistent with the CP 341 parameterization | Recompile the CP 341 configuration; download again; check DATA_PTR length is even and within the DB boundary. |
| 0803 | Protocol parameter error | Baud rate / parity / stop bits mismatch with slave | Match parameters on both ends. Re-parameterize the CP 341 from the PTP Param wizard. |
| 0E01 | Response timeout | Slave did not reply within configured timeout | Check wiring, slave address, slave power, line termination. Increase timeout if line is slow. |
| 0E02 | Parity / framing error | Noise, baud rate mismatch, broken cable | Inspect cable shield and ground; reduce baud rate; swap to a tested cable. |
| 0E03 | Overrun error | CP 341 buffer overflow from incoming data | Reduce polling rate; check that the slave is not transmitting continuously. |
| 0F01 | CRC16 error | Bit corruption on the bus | Same as 0E02; also confirm 2-wire A/B are not swapped. |
| 0F02 | Function code not supported | Master issued a Modbus function the slave does not implement | Check the slave's documentation; configure MOD_MASTER MODE to a supported FC set. |
| 0F03 | Address error / illegal data address | DATA_ADDR + DATA_LEN exceeds the slave's register map | Reduce DATA_LEN or start at a valid address. |
| 0F04 | Illegal data value | Out-of-range write value or unsupported function variant | Inspect what was written; check FC 16/06 payload. |
| 7001 | Slave device failure | Generic slave error response | Inspect slave diagnostics; check its power and CPU load. |
| 7002 | Slave resource unavailable | Slave buffer overflow, slave CPU at limit | Reduce request rate; check slave CPU's task load. |
| 7003 | Acknowledge (slave busy) | Slave is processing a previous request | Add a small inter-request delay in MOD_MASTER. |
| 7004 | Gateway path unavailable | Modbus gateway in front of the slave cannot be reached | Verify gateway routing if the network has one. |
Diagnostics and Online Behavior
Three online checks belong in every CP 341 Modbus commissioning:
- CP 341 LEDs: Green "DC24V" indicates power, green "TXD" flashes on transmit, green "RXD" on receive. A steady red "SF" (System Fault) indicates either a configuration download error or a missing license. A flashing red "SF" indicates a runtime fault (timeout, CRC). A steady red "BF" (Bus Fault) on the front of the CP 341 indicates the line interface is not connected or shorted.
- TIA Portal online > CP 341 > Diagnostics: Right-click the CP 341 in the device view, go online, and open "Diagnostics". The "Modbus status" tab shows the current MODE, the last STATUS word, the number of valid transactions, the number of errored transactions, and the inter-character timing histogram. This is the single best tool for confirming that messages are physically leaving the RS-485 driver.
- PNI_DIAG (FB 11): Place the standard PNI_DIAG FB in OB82 (diagnostic interrupt) or call it cyclically in OB1. It surfaces hardware-level diagnostics (module removed, submodule mismatch, channel fault). On a CP 341, the channel fault is the most useful indicator that the RS-485 interface submodule is not seated properly.
Wiring Notes for RS-485 Modbus RTU
Modbus RTU over RS-485 is a 2-wire, half-duplex, multi-drop bus. The CP 341's RS-485 interface module exposes a 15-pin SUB-D connector. Pin assignments and practical wiring rules:
- Pin 11 = T(R)DA / T(R)DB (the differential A/B pair). On the CP 341 these are the same pair in both directions — half duplex — so a single twisted pair is sufficient.
- Pin 6 + 13 = +5 V supply for fail-safe bias resistors. Many termination connectors (e.g. Phoenix Contact PSI-MODEM-CONF) take 5 V from this pin and apply failsafe bias; do not connect to external supplies.
- Shield = pin 5 / connector housing. Bond the shield to ground at one end only to avoid ground loops; Siemens recommends bonding at the cabinet entry, not at the device.
- 120 Ω termination at both bus ends, not in the middle. Most slaves and the CP 341 do not include internal termination — external resistor across A/B at each end is required.
- Maximum cable length: 1200 m at 9600 baud, less at higher baud rates. For 115200 keep total cable length well below 100 m.
- Maximum nodes: 32 standard RS-485 unit loads. Modbus RTU slaves often present 1/8 or 1/32 unit loads, allowing 256 nodes in theory, but the CP 341 can typically drive up to 32 slaves cleanly at 9600 baud.
Verification: How to Confirm the Link Is Live
- Watch the CP 341 RXD LED while the master is running. It must flash on every Modbus response. If it never flashes, the slave is not transmitting — check the slave's serial port enable and the A/B polarity.
- In TIA Portal online monitoring, force
REQ := TRUEfor one cycle and watch the STATUS output. A clean loop returns STATUS = 0x0001 then 0x0000 with DONE = TRUE. - Use a Modbus master simulator on a PC (e.g. "Modbus Poll" or "QModMaster") on a virtual COM port via a USB-RS485 converter, and read the same registers the CP 341 is configured to read. If the simulator sees traffic but the CP 341 does not, the issue is on the CP 341 side. If the simulator does not see traffic either, the issue is on the physical bus.
- Run a 24-hour soak test in OB35 with the STATUS word latched into a watch table. Verify the error counter does not increment. A healthy bus shows 0x0000 in STATUS and DONE toggling on every cycle.
Troubleshooting Matrix
| Symptom | Likely Root Cause | Diagnostic Step | Resolution |
|---|---|---|---|
| STATUS = 0x0801 on first call | Modbus license not transferred to CP 341 | Automation License Manager > Modbus Master slot | Transfer license to CP 341, power-cycle |
| STATUS = 0x0802 after parameter change | Instance DB out of sync with CP 341 config | Compare DB layout to CP 341 properties | Recompile and download the project; do not edit instance DB manually |
| STATUS = 0x0E01 with all slaves | Physical layer fault (no termination, swapped A/B, no bias) | Inspect wiring, oscilloscope the bus | Add 120 Ω termination at both ends, add bias, verify A/B polarity |
| STATUS = 0x0E01 with one slave only | That slave's address or baud rate is wrong | Read the slave's configuration | Match slave address (1-247) and baud rate to the CP 341 |
| STATUS = 0x0F01 intermittently | EMC noise on the cable | CRC error counter increasing in CP 341 diagnostics | Use shielded twisted pair, ground shield at one end, separate from VFD cables |
| SF LED steady red | License missing or submodule missing | Check submodule seating, license status | Reseat the RS-485 submodule, transfer license |
| SF LED flashing red | Runtime fault | Read STATUS from the FB | Refer to status code table above |
| MB_Master block compiles but does not appear in CP 341 catalog | Wrong library dragged into project | Check the source library version | Use the Modbus driver CD library, not the S7-1200/1500 instructions |
| Master reads but writes fail | Slave is read-only, or FC 06/16 not supported | Check the slave's function code set | Switch MODE on the master to a supported FC, or use a different slave register |
| Communications work in STEP 7 V5.5, fail in TIA Portal V13 | Driver not installed in TIA Portal | Check TIA Portal installation > CP 341 catalog | Install the CP 341 Modbus driver CD into the TIA Portal installation |
| Communication at 9600 works, fails at 115200 | Cable too long, no termination | Reduce baud rate, check wiring | Shorten cable, add termination, or stay at 19200 / 38400 |
Migration Notes: From STEP 7 V5.5 to TIA Portal V13+
Projects originally written in STEP 7 V5.5 with FB 80 / FB 81 / FB 82 (legacy Modbus driver) can be migrated to TIA Portal V13, but the FBs must be replaced. The V5.5 FBs are not compatible at the interface level with the TIA Portal V13 Modbus driver, and the instance DB structure is different. The migration path is:
- Migrate the S7-300 / S7-400 station to TIA Portal. The CP 341 device version migrates automatically.
- Install the TIA Portal Modbus driver CD for CP 341.
- Delete the old FB 80 / FB 81 / FB 82 calls and the corresponding instance DBs.
- Drag the new MOD_MASTER or MODB_341 FB from the project library.
- Rewire the parameter list to match the new signature (in particular, the LADDR / HWID may change because TIA Portal assigns hardware identifiers differently from STEP 7 V5).
- Re-test on hardware with a Modbus simulator on a free COM port.
FAQ
Can I use Modbus_Comm_Load and Modbus_Master with a CP 341?
No. Modbus_Comm_Load and Modbus_Master (also spelled MB_COMM_LOAD / MB_MASTER) are part of the S7-1200/1500 Modbus instruction set and are bound to the CPU's serial port or CM PtP module. The CP 341 requires the loadable Modbus driver (MOD_MASTER for master, MODB_341 for slave) installed from the CP 341 Modbus driver CD.
Do I need to buy a license for the Modbus driver on CP 341?
Yes. The Modbus master and Modbus slave drivers are licensed separately and the license is bound to the serial number of the CP 341 module. Order numbers are 6ES7 870-1AA01-0YA0 (Master, legacy) / 6AV6 671-1AE01-0AX0 (TIA Portal) and 6ES7 870-1AB01-0YA0 (Slave, legacy) / 6AV6 671-1AF01-0AX0 (TIA Portal). A 14-day trial license is available from the Automation License Manager for testing. Without a license the FB returns STATUS = W#16#0801.
Which FB should I call for a CP 341 acting as a Modbus master?
Call MOD_MASTER from the project library that the CP 341 Modbus driver CD installs. Place it in OB1 or a cyclic interrupt OB (OB35). Supply the CP 341 hardware identifier in the LADDR input (typically 264, verify in CP 341 system constants) and a VARIANT pointer to the data block used as the Modbus register source/sink.
Why is STATUS returning 0x0801 even though the FB is being called?
STATUS 0x0801 means the Modbus driver license is missing from the CP 341. Open the Automation License Manager, find the "CP 341 Modbus Master" or "CP 341 Modbus Slave" license slot, transfer the license to the CP 341, then power-cycle the module. The license is stored in the CP 341's non-volatile memory and survives a power-down once written.
Why does my CP 341 read Modbus traffic on the simulator but not from the real slave?
Almost always a physical layer issue. Check the RS-485 A/B polarity (pin 11 on the CP 341 is the differential pair, do not swap), confirm 120 Ω termination at both bus ends, and add failsafe bias (pull-up on B to 5 V, pull-down on A to GND) at one point on the bus. Verify the slave's baud rate and parity match the CP 341 parameterization exactly. Inspect the CP 341 RXD LED while polling — if it never flashes, the bus is electrically silent.