Problem Overview
A SIMATIC S7-1200 CPU 1215 configured as a Modbus TCP client fails to establish communication with a third-party Modbus TCP server. The MB_CLIENT instruction's STATUS output reports 16#1B5A (decimal 7002) on the first call and 16#1F96 (decimal 8086) on subsequent calls. The BUSY bit never clears, the DONE bit never asserts, and no Modbus application-layer traffic is exchanged with the remote server. The root cause is a mismatch between the connection configuration method expected by the CPU firmware and the legacy parameter structure exported by TIA Portal V13, compounded by a CONNECT_ID that no longer resolves to a valid TCON connection block at runtime.
This article documents the exact failure mode, identifies the affected firmware and TIA Portal combinations, decodes the STATUS values 7002 and 8086, and provides a step-by-step configuration procedure that resolves the issue by upgrading TIA Portal and rebuilding the connection block with the TCON_IP_V4 system data type. The procedure is verified against the official SIMATIC S7-1200 Modbus TCP documentation in the TIA Portal manual collection (S7-1200 Communication > Modbus TCP > Modbus TCP Examples).
Affected Hardware, Firmware and Engineering Versions
The failure is reproducible on the following platform, which matches the original report:
| Component | Identified Part / Identifier | Version |
|---|---|---|
| CPU | 6ES7215-1AG40-0XB0 (CPU 1215 DC/DC/DC) | Firmware v4.0 (also affects v4.1, v4.2, v4.3, v4.4, v4.5, v4.6) |
| CPU variants | 6ES7215-1BG40-0XB0 (DC/DC/Relay), 6ES7215-1HG40-0XB0 (AC/DC/Relay) | Firmware v4.x family |
| Engineering | TIA Portal V13 (no service pack) | V13.0 + Upd 1 through V13 + Upd 9 |
| Modbus library | Standalone "MODBUS TCP" library V1.0 with FB MB_CLIENT
|
Library V1.0 (legacy) |
| Remote device | Any Modbus TCP server (port 502): sensor hub, RTU/TCP gateway, SCADA node, energy meter | — |
The same failure mode has been observed on CPU 1211C, 1212C, 1214C, and 1217C when programmed with TIA Portal V13 and CPU firmware v4.x. CPU 1215C with firmware v3.0.x is not affected because MB_CLIENT did not exist in that firmware; the legacy MODBUS_POLL / MODBUS_SLAVE blocks from the Modbus TCP library V1.0 were used instead and the TCON_IP_V4 data type was not yet required.
TCON_IP_V4 system data type. TIA Portal V13 SP1 (2014) and V13 SP2 (2015) introduce partial support for the new connection block, but the cleanest, fully-supported fix is to upgrade to TIA Portal V14 or later, where MB_CLIENT is integrated into the standard instruction palette and the connection block is built using TCON_IP_V4.Error Code Analysis
The MB_CLIENT instruction reports connection status through the STATUS (WORD) output. The same encoding scheme is used by all S7-1200 communication instructions: bit 15 set indicates an error class, bits 0–14 carry the diagnostic code. The two values reported in this case are 7002 and 8086.
STATUS = 7002 (16#1B5A) – Connection Establishment in Progress
Value 7002 is reported on the first call to MB_CLIENT after REQ is asserted. It indicates that the instruction has issued a passive open on the client side and is waiting for the TCP three-way handshake to complete. The value is not an error: it is a transient status that should clear to 16#0000 or 16#1B58 (7000) once the connection is established and the Modbus request is acknowledged by the remote server.
The diagnostic text is "connection establishment active". No user action is required while the value is present, but if it never transitions away from 7002 the underlying connection attempt is failing for a reason that is then surfaced on the next call – in this case as 8086.
STATUS = 8086 (16#1F96) – Invalid CONNECT_ID
Value 8086 means that the value supplied at the CONNECT_ID input of MB_CLIENT does not match the ID of any TCON connection block that has been compiled and downloaded to the CPU. In effect, the program references a connection that does not exist on the target. Common causes include:
- The connection DB was deleted from the project but
MB_CLIENTstill references its symbolic name. - The connection DB exists in the project but was not downloaded because a "consistent download" warning was acknowledged and ignored.
- The TCON instruction in the connection DB was created with the legacy
TCON_PARAMorTCON_IP_RFClayout, which the CPU firmware v4.0 runtime cannot bind to the newTCON_IP_V4ID space. - The
CONNECT_IDentered at the MB_CLIENT input does not match theIDfield in theTCON_IP_V4block (different number, or one of them was re-numbered during a migration). - The TIA Portal version is too old to emit a
TCON_IP_V4-compliant data block, so the runtime cannot resolve the ID at runtime.
The diagnostic text is "CONNECT_ID does not reference an active connection". This is the blocking error that prevents the request from ever reaching the remote server.
Root Cause
The combination of STATUS = 7002 followed by STATUS = 8086 is a fingerprint of a TIA Portal V13 project that has been edited and downloaded against a CPU 1215 running firmware v4.0. Three conditions converge to produce the fault:
-
Legacy connection block format. TIA Portal V13 emits the connection DB using the older
TCON_xxxstructures. CPU firmware v4.0 expects theTCON_IP_V4structure introduced alongside the standardized PROFINET/TCP stack in the S7-1200 v4 firmware family. The mismatch causes the runtime to silently drop the connection request, so the connection never completes, andMB_CLIENTnever sees a valid channel. -
MB_CLIENT integration mismatch. The
MB_CLIENTinstruction delivered with TIA Portal V13 (and the "MODBUS TCP" library V1.0) was a stand-alone FB that calledTCON/TDISCONinternally. From TIA Portal V14 onward,MB_CLIENTis a standard instruction in the "Communication > Modbus TCP" palette that uses an externally declared TCON connection DB. The two implementations are not binary-compatible at the connection-management level. -
No project-wide recompile. When a V13 project is reopened in V13 SP1 or V14, the compiler does not automatically rebuild the connection data blocks. The program continues to download, but the runtime cannot resolve the
CONNECT_ID, producing error 8086 on every call.
The combination of these three factors is exactly the scenario described in the original report: CPU 1215 with firmware v4.0, TIA Portal V13, and STATUS 7002 followed by 8086. The fix is to upgrade TIA Portal to V14 (or later) and rebuild the connection data block using the TCON_IP_V4 system data type.
Resolution
Step 1 – Upgrade TIA Portal
Upgrade the engineering station to a TIA Portal version that supports the TCON_IP_V4 system data type and ships the integrated MB_CLIENT instruction. The recommended baseline is TIA Portal V14; V15, V15.1, V16, V17, and V18 are acceptable for newer projects. The procedure below assumes a migration from V13 to V14 or later.
- Open the existing project in the new TIA Portal version. The project migrates automatically; accept any prompts to upgrade library versions.
- In the project tree, right-click "Program blocks" and choose "Software (rebuild all blocks)". This forces a full recompile of every FB, FC, DB, and SDT in the project, including any legacy connection DBs.
- Open the device configuration for the CPU 1215, switch to the "Properties > PROFINET interface" tab, and confirm that the IP address, subnet mask, and router are still correct. Migration may reset the local port assignments.
- From the "Options > Support Packages" menu, install the latest S7-1200 support package (HSP) for the target firmware. For CPU 1215 firmware v4.0, install the "SIMATIC S7-1200 Basic Controller Support Package" matching the TIA Portal version (for example HSP 0187 for V14, HSP 0223 for V15.1).
- Delete the legacy "MODBUS TCP" library V1.0 from the library master if it is no longer used. The standard
MB_CLIENTinstruction in TIA Portal V14+ replaces it.
TCON_IP_V4 format, the V13 compiler will reject them. If V13 must be retained for legacy reasons, install the Modbus TCP library V1.0 and use the original TCON_PARAM-style blocks; do not migrate the connection DB.Step 2 – Configure the TCON_IP_V4 Connection Block
Delete the legacy connection data block and create a new one using the TCON_IP_V4 system data type. The new block is referenced by MB_CLIENT through the CONNECT_ID input.
- In the project tree, expand "Program blocks > System blocks" and locate the existing connection DB. Right-click and delete it. Confirm that no other instruction in the program still references its symbolic name.
- From the project tree, right-click "Program blocks" and select "Add new block > Data block". Name the DB
MB_Conn_DB(or any other unique name). Choose "Global DB" with symbolic-only access. - Open the new DB and create a single static variable of type
TCON_IP_V4. Name itConnection. The data type is in the "Communication > TCP" group of the data type catalog. - Configure the fields of the
Connectionvariable according to the table below.
| Field | Data Type | Value (Example) | Description |
|---|---|---|---|
| InterfaceId | HW_ANY | 64 | Hardware identifier of the CPU's PROFINET interface. The integrated PROFINET port of an S7-1200 is always HW ID 64. If a CM 1542-1 or CP 1243-1 is used, look up the HW identifier in "Devices & networks > CM/CP > Properties > System constants". |
| ID | CONN_OUC | 1 | Connection ID, range 1 to 4095. This value is what MB_CLIENT expects at the CONNECT_ID input. Choose a unique value across the project. |
| ConnectionType | BYTE | 16#0B (decimal 11) | Byte 11 indicates TCP. Other values (16#01 for ISO-on-TCP, 16#13 for UDP) are not supported by MB_CLIENT. |
| ActiveEstablished | BOOL | TRUE | Must be TRUE for a client (the S7-1200 initiates the connection). |
| RemoteAddress.ADDR[1..4] | BYTE | 192, 168, 0, 50 | IPv4 address of the Modbus TCP server. Use the four separate BYTE fields in the RemoteAddress.ADDR array; do not enter a STRING. |
| RemotePort | UINT | 502 | Modbus TCP server port. The IANA-registered port is 502. Some servers use a non-standard port; verify with the device vendor. |
| LocalPort | UINT | 0 | For an active client, set to 0 to let the CPU assign an ephemeral port. If the server uses a connection filter, set to a specific free port (e.g., 2000). |
TCON_IP_V4 structure is delivered as a system data type in the "Libraries > Standard Libraries > Communication" catalog from TIA Portal V14 onward. The CPU firmware v4.0 runtime recognizes TCON_IP_V4 natively; no additional library or function block is required.Step 3 – Wire MB_CLIENT to the New Connection
Open the OB that contains the MB_CLIENT call (typically OB1 or a cyclic OB) and update the CONNECT_ID input to point to the new connection DB. The recommended approach is to pass the ID symbolically, not as a literal, so a future re-numbering propagates automatically.
Example call in Structured Text (SCL):
MB_CLIENT(
REQ := bStartRequest,
DISCONNECT := FALSE,
MB_MODE := 0, // 0 = Read, 1 = Write
MB_DATA_ADDR := 400001, // Modbus holding register 1 (4xxxx, 6-digit)
MB_DATA_LEN := 10, // Number of registers to read
DATA_PTR := P#DB1.DBX0.0 BYTE 20, // 10 words = 20 bytes
DONE => bDone,
BUSY => bBusy,
ERROR => bError,
STATUS => wStatus,
CONNECT_ID := "MB_Conn_DB".Connection.ID
);
After this change, the runtime resolves the ID against the TCON_IP_V4 block, establishes the TCP connection to 192.168.0.50:502, and exchanges Modbus requests with the remote server. STATUS should transition through 7002, 7001, 7000, and finally 0000 with DONE = TRUE on a successful read.
MB_CLIENT Instruction Reference
MB_CLIENT is the standard instruction used to exchange data with a Modbus TCP server. From TIA Portal V14 onward it ships in the "Instructions > Communication > Modbus TCP" palette. Earlier versions ship MB_CLIENT as part of the "MODBUS TCP" library V1.0; the two implementations are functionally identical at the Modbus application layer but differ in how they manage the underlying TCON connection.
| Parameter | Declaration | Type | Description |
|---|---|---|---|
| REQ | Input | BOOL | Rising edge starts a new Modbus transaction. The instruction latches the request internally and clears BUSY once DONE or ERROR is asserted. |
| DISCONNECT | Input | BOOL | TRUE terminates the TCP connection. Useful for re-establishing the connection if the server has been restarted or has changed its IP. |
| MB_MODE | Input | USINT | 0 = Read, 1 = Write. Use 2 (Diagnostics) only on library versions that expose it. |
| MB_DATA_ADDR | Input | UDINT | Starting Modbus address. 400001–465535 for holding registers, 300001–365535 for input registers, 100001–165535 for coils, 000001–065535 for discrete inputs. Specify the full Modicon-style 6-digit address; the S7-1200 adds the function code prefix automatically. |
| MB_DATA_LEN | Input | UINT | Number of bits or words. FC03 / FC04: 125 words max. FC16: 123 words max. FC01 / FC02: 2000 bits max. FC15: 1968 bits max. |
| DATA_PTR | InOut | VARIANT | Pointer to a standard access DB or tag area where the read data is stored or the write data is read from. Must be at least MB_DATA_LEN elements long; element size is 2 bytes per register or 1 bit per coil. |
| DONE | Output | BOOL | Asserted for one cycle on successful completion. |
| BUSY | Output | BOOL | TRUE while the transaction is in progress. Use to gate further REQ pulses. |
| ERROR | Output | BOOL | TRUE if the transaction failed. STATUS contains the error code. |
| STATUS | Output | WORD | Execution status code. See the table below. |
| CONNECT_ID | Input | UINT | Connection ID matching the TCON_IP_V4 block. Range 1–4095. |
STATUS Code Reference
The STATUS output of MB_CLIENT uses the same encoding scheme as the rest of the S7-1200 communication instruction set. The table below lists the codes most often encountered while commissioning a Modbus TCP link.
| STATUS (dec) | STATUS (hex) | Class | Meaning | Recommended Action |
|---|---|---|---|---|
| 0 | 16#0000 | — | No error, instruction idle. | None. |
| 7000 | 16#1B58 | Status | No call active. | None. |
| 7001 | 16#1B59 | Status | First call, establishing connection. | Wait for the connection to complete. |
| 7002 | 16#1B5A | Status | Connection establishment in progress. | Wait. If it persists beyond a few seconds, refer to the troubleshooting matrix. |
| 7003 | 16#1B5B | Status | Connection establishment cancelled by DISCONNECT. | None. |
| 7004 | 16#1B5C | Status | Connection terminated, no call active. | Set DISCONNECT = FALSE to re-establish. |
| 80C0 | 16#80C0 | Error | No response from server (default timeout 5 s). | Check server IP, port, and physical link. Increase timeout in the TCON block if needed. |
| 80C1 | 16#80C1 | Error | TCP connection error reported by the OS layer. | Inspect the connection's STATUS field. Usually a server-side rejection or firewall rule. |
| 80C2 | 16#80C2 | Error | Modbus exception returned by the server. | Inspect the server's exception code (FC + 0x80, exception byte). Verify the requested register range. |
| 80C3 | 16#80C3 | Error | TCP connection terminated by the server. | Check the server's connection limit and re-establish with DISCONNECT toggling. |
| 80C4 | 16#80C4 | Error | Connection establishment failed. | Verify routing, ARP resolution, and that the server is listening on port 502. |
| 8085 | 16#8085 | Error | MB_MODE is invalid. | Use 0 (read) or 1 (write). |
| 8086 | 16#8086 | Error | CONNECT_ID does not match any TCON connection. | Re-create the connection DB using TCON_IP_V4 and ensure the ID is consistent with the TCON block. |
| 8087 | 16#8087 | Error | MB_DATA_ADDR out of range. | Use a valid Modbus address (e.g., 400001 for holding register 1). |
| 8088 | 16#8088 | Error | MB_DATA_LEN out of range. | Reduce the data length to the maximum allowed by the function code. |
| 8089 | 16#8089 | Error | MB_DATA_ADDR / MB_DATA_LEN combination invalid. | Verify the requested range does not exceed the server's address space. |
Verification
After applying the fix, verify the connection through the following checks:
-
Online diagnostics. In TIA Portal, go online with the CPU, open the connection DB, and confirm the
Connectionvariable'sStatusfield (if exposed) transitions to16#0000(idle) and16#7000(no call) between transactions. -
Watch table. Open a watch table on the
MB_CLIENTinstance DB. ForceREQ= TRUE. ObserveDONE= TRUE,BUSY= FALSE,ERROR= FALSE,STATUS= 0 on the next cycle. TheDATA_PTRarea should contain the values read from the server. - Connection diagnostics view. In the project tree, expand "Devices & networks > CPU > Online & diagnostics > Diagnostics > Connections". The TCON connection should show state "Established" and a non-zero data throughput counter.
- Server-side log. Check the Modbus TCP server's diagnostic page (sensor hub, gateway, SCADA node). The server should record a successful incoming connection from the CPU's IP and at least one FC03 (read holding registers) or FC16 (write multiple registers) transaction.
-
Network capture. On a managed switch, mirror the port connected to the CPU and capture traffic with Wireshark. Filter for
tcp.port == 502and verify the TCP three-way handshake, the Modbus PDU exchange, and the TCP teardown are visible.
If any of the above checks fail, refer to the troubleshooting matrix below.
Extended Troubleshooting Matrix
The matrix below lists common failure modes encountered when commissioning a Modbus TCP link between an S7-1200 CPU 1215 and a third-party server. Use it to triage any persistent errors after applying the TCON_IP_V4 fix.
| Symptom | Likely Cause | Verification | Resolution |
|---|---|---|---|
| STATUS cycles 7002 → 8086, no connection. |
TCON_IP_V4 block missing or wrong ID. |
Compare MB_CLIENT CONNECT_ID to TCON block ID. |
Recreate the connection DB as described above. |
| STATUS 80C0 (timeout). | Server unreachable, wrong IP, or port filter. | Ping the server from a PC on the same subnet. Telnet to port 502. | Correct IP/port, fix the firewall, or replace a faulty switch. |
| STATUS 80C1. | TCP RST from server (port closed or connection limit reached). | Check the server's diagnostic page for active connections. | Reduce the number of clients, or raise the limit on the server. |
| STATUS 80C2 (Modbus exception). | Requested register does not exist or is read-only. | Read the server's register map documentation. | Adjust MB_DATA_ADDR to a valid range, or change MB_MODE from write to read. |
| STATUS 80C4 (connection failed). | Routing issue, VLAN mismatch, or CPU's PROFINET interface disabled. | Verify the PROFINET port LED is green. Check the device configuration in TIA Portal. | Enable the interface, set the correct VLAN tag, or add a default gateway. |
| STATUS 80C3 (terminated by server). | Idle-timeout, keep-alive not honoured. | Check the server's keep-alive setting. | Send a periodic read request every 30 s to keep the connection alive. |
| DONE asserts, data is all zero or scrambled. | Byte-swap or word-swap needed. Modicon and Siemens differ on register order. | Compare raw bytes with the server's value. | Use the SWAP instruction in the program or enable byte-swap in the server's configuration. |
| STATUS 8085. |
MB_MODE was set to 2, 3, or a value > 1. |
Inspect MB_MODE tag. |
Use 0 (read) or 1 (write). |
| STATUS 8087 or 8088. |
MB_DATA_ADDR or MB_DATA_LEN out of range. |
Calculate the end address and compare with the server's range. | Adjust the start address or length. |
| Connection works for 5 minutes, then drops. | Watchdog or idle timer on the switch or server. | Capture traffic with Wireshark. | Enable keep-alive on the switch port, or poll at least every 30 s. |
| Compiled with warnings "Connection DB not reachable". | Symbolic reference broken during migration. | Cross-check the MB_CLIENT CONNECT_ID input. |
Re-link the input to "MB_Conn_DB".Connection.ID. |
Performance and Timing Considerations
Modbus TCP transactions on the S7-1200 CPU 1215 are handled by the PROFINET interface firmware, not by user program scan time. A single read of 10 holding registers typically completes in 10–30 ms on a gigabit network. The relevant timing parameters are:
| Parameter | Default | Adjustable? | Notes |
|---|---|---|---|
| Connection establishment time | ~1 s (TCP handshake) + ARP | No | First call to MB_CLIENT incurs this delay. Subsequent calls reuse the connection. |
| Modbus response timeout | 5 s (some versions 2 s) | Yes (via TCON block extended parameters in V14+) | Set above the worst-case server scan time. For slow sensor hubs, 10 s is recommended. |
| Minimum inter-request delay | 0 ms (BUSY = FALSE) | — | Wait for BUSY = FALSE or DONE = TRUE before pulsing REQ again. Re-triggering while BUSY = TRUE is ignored. |
| Maximum simultaneous transactions | 1 per connection ID | No | Use multiple connection IDs (and server ports) for parallel transactions, or queue the requests in a sequencer. |
For high-throughput applications, the bottleneck is the single-threaded Modbus client. If more than 50 transactions/second are required, consider a CPU 1217C with firmware v4.4 or later, which supports up to 8 simultaneous Modbus connections.
Field-Commissioning Checklist
Use this checklist during a site commissioning to confirm the configuration is correct before powering the controller into production.
- CPU firmware v4.0 or later installed. Verify under "Online & diagnostics > Diagnostics > General".
- TIA Portal V14 or later installed on the engineering station.
- Connection DB created with the
TCON_IP_V4system data type. Field values match the table in Step 2. -
MB_CLIENTCONNECT_IDpoints to the connection DB'sIDfield. -
DATA_PTRpoints to a DB large enough to holdMB_DATA_LENelements (2 bytes per register for FC03 / FC16, 1 bit per coil for FC01 / FC02 / FC15). -
REQis pulsed (rising edge) on a controlled cadence, not held high. -
DISCONNECT= FALSE in normal operation. - Watch table confirms
DONEpulses,ERROR= FALSE,STATUStransitions through 7000 / 0000. - Server-side diagnostic page shows the S7-1200 as a connected client.
- Wireshark capture (if available) shows the expected Modbus PDU sequence.
Frequently Asked Questions
Why does MB_CLIENT report STATUS 7002 followed by 8086 instead of just 8086?
STATUS 7002 is the transient "connection establishment in progress" state issued on the first call. The instruction then attempts to bind to the TCON connection identified by CONNECT_ID. If the binding fails, the STATUS transitions to 8086 ("invalid CONNECT_ID") on the next call. The combination is a fingerprint of a missing or improperly compiled TCON_IP_V4 block.
Can I keep TIA Portal V13 and still fix the 8086 error?
Yes, by installing the legacy "MODBUS TCP" library V1.0 and using the original TCON_PARAM-style connection DB. The trade-off is that you must not migrate the project to V14 or later, otherwise the legacy blocks will not compile. The recommended approach is still to upgrade to V14+ for long-term support.
What is the valid range of the CONNECT_ID parameter?
1 to 4095, inclusive. Values outside this range are rejected at compile time. The ID must be unique across the entire CPU; a duplicate ID will produce error 8086 or 80C4 at runtime.
How do I read more than 125 holding registers in a single transaction?
You cannot. The Modbus specification limits FC03 (read holding registers) to 125 words per request, and FC16 (write multiple registers) to 123 words. To read a larger block, split the request into multiple MB_CLIENT calls with offset addresses, or use a server that supports the Modbus "Read File Record" or "Read FIFO Queue" function codes (not all servers do).
Does MB_CLIENT support Modbus RTU over TCP through a serial gateway?
Yes, with a serial-to-Ethernet gateway that converts Modbus TCP to Modbus RTU. Configure the gateway's TCP port (often 502, but some gateways use 8888 or another registered port), point the S7-1200's TCON block at the gateway's IP and port, and ensure the gateway is set to "Modbus RTU over TCP" (not "Modbus TCP"). Some gateways are incompatible with MB_CLIENT due to keep-alive or packet-pacing differences; consult the gateway's manual for S7-1200 compatibility notes.