1. Problem Description
An S7-1200 CPU (firmware V4.x or V5.x, programmed in TIA Portal V15.1 or later) is configured as a Modbus RTU master through a CM 1241 RS-485 / RS-232 communication module or through the onboard PtP interface of the CPU. The remote station is an Allen-Bradley (Rockwell) MicroLogix, SLC 500, CompactLogix, or ControlLogix controller exposing the following data over Modbus RTU slave mode:
| Tag group | Modbus data address (decimal) | Length | Modbus function code | Modbus memory type |
|---|---|---|---|---|
| Inputs (status bits) | 10400 | 32 bool (≈ 2 words) | 02 – Read Discrete Inputs | 1xxxx |
| Outputs (status bits) | 10440 | 32 bool (≈ 2 words) | 01 – Read Coils | 0xxxx |
| Alarms | 10101 | 48 bool (3 words) | 02 – Read Discrete Inputs | 1xxxx |
| Analog values | 41002 | 8 real (16 words) | 03 – Read Holding Registers | 4xxxx |
The user's program calls one MB_Comm_Load block followed by four MB_Master blocks, each linked to a different data area of the remote controller. After some operating time the link begins to drop with:
- Status word = 16#80C8 – "Slave device timeout".
- Polling then halts for the rest of the cycle or, depending on the call sequence, all four master requests fail.
The remote Allen-Bradley controller and the physical RS-485 layer are otherwise healthy. The error appears intermittently and is reproducible only after a few hours of runtime, which is the classic signature of a request-handling or buffering problem in the master rather than a wiring issue.
2. System Architecture
The logical topology is point-to-point RS-485 between a single S7-1200 master and a single AB slave, although the principle applies to a multi-drop bus as well.
Key electrical parameters that must match on both ends of the bus:
- Baud rate: 9600 / 19200 / 38400 / 57600 / 115200 bit/s.
- Parity: 8E1 (even) is the default for Allen-Bradley Modbus. Avoid "none" unless the slave explicitly supports 8N1.
- Slave address: 1..247 (AB commonly uses 1).
- Inter-character and inter-frame silence: 3.5 character times at the chosen baud rate.
3. Allen-Bradley Modbus Address Map
Modbus defines a fixed memory layout. Allen-Bradley controllers expose their internal tag and I/O databases through the addresses below. The address the master sends in the protocol frame is the last four or five digits of the address family; the leading digit identifies the area.
| Modbus address family | Function code | Direction | Typical AB source | Word / bit semantics |
|---|---|---|---|---|
| 0xxxx (1..65536) | 01 / 05 / 15 | Read/Write | Output image, B file | Coil = 1 bit; 16 coils per word |
| 1xxxx (10001..165536) | 02 | Read-only | Input image, I file | Discrete input = 1 bit |
| 3xxxx (30001..365536) | 04 | Read-only | Input register, N file | 16-bit word, big-endian |
| 4xxxx (40001..465536) | 03 / 06 / 16 | Read/Write | Holding register, F/N file | 16-bit word, big-endian; pair for 32-bit float |
For the 8 real (32-bit IEEE-754 float) values starting at address 41002 the master must read 16 holding registers (8 × 2 = 16). The S7-1200 MB_Master instruction stores the response in a byte buffer; the application program re-assembles each float from two words using WORD_TO_REAL or by direct pointer dereference, because Modbus RTU is always big-endian on the wire while the S7-1200 is little-endian in memory.
4. MB_Comm_Load and MB_Master – Block Behavior
Two instructions from the SIMATIC Modbus RTU library are involved:
-
MB_Comm_Load (FB / block class 3, instance DB required). Configures the CM 1241 or onboard PtP port: baud rate, parity, flow control, and the response timeout. The instruction is edge-triggered on
REQand only needs to be executed once after a restart of the CPU, after a STOP/RUN transition, or after a port re-parameterization. -
MB_Master (FB / block class 3, instance DB required). Sends one Modbus request and waits for the slave response. Each instance carries
MB_ADDR,MODE,DATA_ADDR,DATA_LEN, and aDATA_PTRthat points to the data buffer in the S7-1200 memory.
The crucial rule – taken verbatim from the TIA Portal online help – is:
If multiple calls of the Modbus_Master instruction with different settings for MB_ADDR, MODE, DATA_ADDR or DATA_LEN are placed in your program, you must ensure that only one of these call is active at any given time. Otherwise, the error message 0x8200 is output (interface is busy with an ongoing request). If a call cannot be processed in full, the watchdog is activated by the Blocked_Proc_Timeout parameter and terminates the ongoing command.
In other words, the hardware interface (CM 1241 channel) is single-threaded. Although a single MB_Comm_Load can in principle serve several MB_Master instances, the master blocks must be sequenced by the application; they cannot all be called in the same OB1 cycle without arbitration. The TIA help explicitly permits the "one Comm_Load – many Master" pattern; it does not permit parallel Master calls.
5. Root Cause Analysis of the 80C8 Error
Status word 16#80C8 is generated by the Modbus master when the round-trip time of a request exceeds the configured response timeout. The 80C8 code, by itself, does not distinguish between the following physical/logical causes:
| # | Possible cause | Diagnostic check | Typical fix |
|---|---|---|---|
| 1 | Two MB_Master calls active simultaneously (race condition) | Watch DONE / ERROR / STATUS of each instance; check for 0x8200 immediately before 80C8 | Sequence the calls through a state machine |
| 2 | Response timeout (Tio / Timeout) too short for the chosen baud rate | Compute 3.5 char × (bits per char) and add slave processing margin | Increase MB_Comm_Load timeout or lower baud |
| 3 | RS-485 bias / termination missing, signal integrity on long cable | Oscilloscope on A/B lines; check 120 Ω terminator at both ends | Add termination and bias resistors, shield, ground |
| 4 | Parity mismatch (8E1 vs 8N1) | Compare port configuration with AB DF1/Modbus setting | Match parity and stop bits on both sides |
| 5 | Address range crosses Modbus area boundary or unsupported by AB | Check that 10400, 10440, 10101 map to valid input/coil tables in the AB project | Map the tags to the corresponding I/B/N/F file of the AB controller |
| 6 | Slave CPU scan time + Modbus gateway scan too slow for the master's poll period | Measure round-trip with a Modbus scanner utility | Increase the polling interval on the S7-1200 side |
| 7 | Block instance DB overwritten by HMI / Web API or by a re-download | Online compare of the instance DB | Re-initialize the instance DB after download |
| 8 | Blocked_Proc_Timeout too aggressive | Set it ≥ 5 s; monitor DONE rising edge | Raise Blocked_Proc_Timeout to 5–10 s |
In the scenario described, cause #1 is the dominant one. The TIA Portal online help snippet quoted in the field report confirms that the 0x8200 busy error precedes a slave timeout, because a request that the master cannot dispatch within its watchdog window is aborted by Blocked_Proc_Timeout and the slave reply that eventually arrives is then treated as orphan traffic. The orphan reply is not associated with a pending master call, the watchdog expires, and the next scheduled request is reported as 80C8.
6. State Machine for Multiple MB_Master Calls
The recommended, vendor-supported pattern is a cyclic state machine in OB1 or in a cyclic OB (e.g. OB35 at 100 ms) that advances through the four masters one at a time. A typical implementation in SCL follows.
// State machine in OB1 (or OB35)
CASE iState OF
0: // idle – start first request
MB_Master_1(REQ := TRUE, ...);
IF MB_Master_1.DONE OR MB_Master_1.ERROR THEN
MB_Master_1(REQ := FALSE, ...);
iState := 10;
END_IF;
10: // settle 50 ms before next request
IF tDelay.Q THEN iState := 20; END_IF;
20: MB_Master_2(REQ := TRUE, ...);
IF MB_Master_2.DONE OR MB_Master_2.ERROR THEN
MB_Master_2(REQ := FALSE, ...);
iState := 30;
END_IF;
30: IF tDelay.Q THEN iState := 40; END_IF;
40: MB_Master_3(REQ := TRUE, ...);
IF MB_Master_3.DONE OR MB_Master_3.ERROR THEN
MB_Master_3(REQ := FALSE, ...);
iState := 50;
END_IF;
50: IF tDelay.Q THEN iState := 60; END_IF;
60: MB_Master_4(REQ := TRUE, ...);
IF MB_Master_4.DONE OR MB_Master_4.ERROR THEN
MB_Master_4(REQ := FALSE, ...);
iState := 0; // wrap around
END_IF;
END_CASE;
Rules to obey:
- Only one
REQinput may be TRUE at any instant. - Do not set
REQon the same call thatDONEorERRORjust became TRUE; resetREQfirst so the next scan does not re-trigger the request. - Insert a small delay (50–100 ms) between requests to let the slave turn-around its RS-485 transceiver.
- Use a different instance DB for each
MB_Mastercall; the instance DB holds the working counters, status and the diagnostic word. - Read
DONEon the falling edge ofREQto avoid missing a one-cycle pulse.
7. Step-by-Step Fix Procedure
- Keep one MB_Comm_Load, four MB_Master. The original architecture (one Comm_Load, four Master) is correct and is supported by Siemens. The bug is in how the four Master blocks are scheduled, not in the number of Comm_Load blocks.
-
Replace parallel calls with the state machine in §6. Remove any logic that sets
REQon more than one Master per scan. A common cause of parallel calls is the use of fourTP(pulse) timers driven by the same clock – do not use that pattern. -
Set Blocked_Proc_Timeout to 5 s (default is 1 s). In the MB_Comm_Load instance DB raise
Static.ActiveBits.Blocked_Proc_Timeoutfrom 1000 ms to 5000 ms. This gives the application time to schedule the next request without aborting the previous one. -
Set the response timeout in MB_Comm_Load. For 9600 8E1, start with 1500 ms; for 19200 8E1, 1000 ms. Formula:
Timeout_ms >= (4 × N_chars × 10 / Baud) × 1000 + ScanTime_slave. For 8 real values (16 registers) the response payload is 37 bytes, so the frame is 8 + 37 = 45 characters; at 9600 8E1 each character is ~1.04 ms, hence ~47 ms of pure air time – well inside any reasonable timeout. - Add 120 Ω termination at both ends of the bus and verify the shield is grounded at one end only.
- Confirm parity and stop bits match the AB controller. Use 8E1 unless the AB project is configured for 8N1.
- Verify the AB Modbus map is published correctly. On MicroLogix 1100/1400, open the Modbus mapping table in RSLogix 500 and confirm that the addresses 10400..10431, 10440..10471, 10101..10148 and 41002..41017 are bound to real tags.
-
Download the modified program to the S7-1200 and watch the four instance DBs online. Expect
STATUS = 0,DONErising once per poll period,ERROR = FALSEindefinitely.
8. Buffer Sizing and Data Type Mapping
The size of the data buffer that DATA_PTR points to must equal or exceed the byte length of the Modbus PDU. Sizing rules:
| Function code | Length declared in MB_Master (DATA_LEN) | Minimum DATA_PTR size | Re-interpretation on S7-1200 |
|---|---|---|---|
| 01 / 02 | N bits (1..2000) | ceil(N/8) bytes, but DB must have at least 1 WORD | Packed bits; use P#Bit addressing |
| 03 / 04 | N words (1..125) | 2 × N bytes | WORD array; swap bytes for big-endian |
| 05 | 1 bit | 1 WORD | Bit 0 of low byte |
| 06 | 1 word | 1 WORD | Single holding register |
| 15 | N bits | ceil(N/8) bytes | Coil array |
| 16 | N words | 2 × N bytes | Register array |
For the analog area (8 real values), the buffer is a 16-element WORD array in a global DB. Conversion to REAL requires byte-swap, because Modbus is big-endian and the S7-1200 is little-endian. The SCL snippet below shows the safe conversion path:
// Read 16 WORDs from data area starting at 41002
// MB_Master_4.DATA_PTR := P#DB20.DBX 0.0 BYTE 32
// DB20 is a global DB with 16 WORDs at offset 0
FOR i := 0 TO 7 DO
// High word first on the wire (big-endian):
wHi := DB20.DW[i*2];
wLo := DB20.DW[i*2 + 1];
rAnalog[i] := DWORD_TO_REAL( (wHi << 16) OR wLo );
END_FOR;
9. Cabling, Termination, and Physical Layer
The 80C8 timeout is frequently attributed to the master logic but in a brownfield installation it is most often the cable. Apply the following physical-layer checklist before changing program code:
- Cable type: Belden 3106A, 9841, 9842 or equivalent twisted pair, 120 Ω characteristic impedance, ≤ 1200 m at 9600, ≤ 200 m at 115200.
- Termination: 120 Ω across A/B at both physical ends of the bus, never in the middle of a stub.
- Bias: Fail-safe bias resistors (typically 680 Ω pull-up to 5 V on B and 680 Ω pull-down to GND on A) are required when the master and slave do not provide internal bias. The CM 1241 does not provide bias; the AB port typically does not either – bias must be added externally.
- Shield: Connect shield to protective earth at one end only. Avoid routing RS-485 parallel to VFD power cables (≥ 200 mm separation).
- Common-mode voltage: Stay within -7 V to +12 V on the AB / CM 1241 common.
- Connector pinout on CM 1241 (RS-485): Pin 8 = T/R+ (D1 / A), Pin 9 = T/R- (D0 / B), Pin 5 = GND. Verify against the AB port; some AB devices label A as "−" and B as "+".
10. Commissioning Verification
Use the following procedure to confirm the fix is stable over at least 24 hours of continuous operation.
- Open the S7-1200 online view and place the four MB_Master instance DBs in a watch table. Poll
DONE,ERRORandSTATUSevery scan. - Set a rising-edge trigger on
ERROR= TRUE; if 80C8 reappears, capture the timestamps of the last 20 scans and the values ofMB_ADDR,MODE,DATA_ADDR,DATA_LENof the failing instance. - Run a free Modbus scanner (e.g. Modbus Poll, QModMaster, or the in-built Modbus master test in TIA Portal's "Modbus RTU Master" support package) on a laptop with a USB-to-RS485 adapter connected to the same A/B lines. Verify that the four addresses return the expected data with a sub-200 ms round-trip at the chosen baud rate.
- Force a STOP/RUN transition on the S7-1200 and confirm that all four master blocks re-acquire the data within the first second of the OB1 cycle.
- Disconnect the AB controller. The four
MB_Mastercalls should all returnSTATUS = 16#80C8(or 16#80C0, 16#80C1, 16#80C2) – no 0x8200 must be observed. The 0x8200 busy code proves that the application is still calling more than one master in parallel. - Reconnect and log
STATUScontinuously for 24 h. The expected value is 0x0000 the whole time.
11. Modbus Error Code Reference
The STATUS output of MB_Master uses the following canonical values. Knowing them short-circuits troubleshooting.
| STATUS (hex) | Meaning | Field action |
|---|---|---|
| 0x0000 | No error | None |
| 0x80C0 | Wrong parity / framing / overrun on receive | Check cable, baud, parity |
| 0x80C1 | Reserved / parity mismatch | Check 8E1 vs 8N1 |
| 0x80C2 | Receive buffer overflow | Increase CM 1241 receive buffer or slow down poll |
| 0x80C3 | CRC error in the response | Noise on the line; check termination/bias |
| 0x80C4 | Invalid function code in response | MB_Master was configured with a code the slave does not support |
| 0x80C5 | Address acknowledgement error | DATA_ADDR + DATA_LEN exceed slave's published area |
| 0x80C6 | Slave is busy / acknowledges without being ready | Reduce polling rate on the master |
| 0x80C7 | Negative acknowledgement (NAK) | Slave rejected the request |
| 0x80C8 | Slave timeout – no response within Timeout | See §5; check scan time, cable, timeout value |
| 0x80C9 | Reserved | Update firmware |
| 0x80CA..0x80CF | Parameter / configuration errors | MB_Comm_Load parameters inconsistent with hardware |
| 0x8200 | Interface is busy with another request | Sequence the MB_Master calls (§6) |
| 0x8380 | Modbus_Comm_Load returned a parameter error | Inspect MB_Comm_Load STATUS |
12. Frequently Asked Questions
Can I really use one MB_Comm_Load with several MB_Master blocks on a single CM 1241?
Yes. A single MB_Comm_Load (multi-instance or single-instance) configures the CM 1241 port once at startup. Any number of MB_Master instance DBs can then target the same port, provided that their REQ inputs are sequenced so that only one is active at a time. The TIA Portal online help describes this pattern explicitly.
Why does my MB_Master return 80C8 even though the AB controller is online and answering a laptop scanner?
80C8 means the S7-1200 sent a request and did not get a response within its configured timeout. If a scanner reads the same address successfully, the slave is healthy. The cause is therefore on the master side: either the timeout is too short, the CM 1241 is not actually transmitting because a second MB_Master is still active, or the line has noise that the scanner tolerated but the master does not. Capture the MB_Master.STATUS over time and look for 0x8200 immediately preceding the 80C8.
What value of Blocked_Proc_Timeout should I use?
For a four-master scan with 50 ms inter-request delay and a worst-case slave scan of 200 ms, start with 5 s (5000 ms). Lower it to 2 s only after observing a stable scan time over 24 h. The parameter is found at Static.ActiveBits.Blocked_Proc_Timeout inside the MB_Comm_Load instance DB.
How do I read 32-bit REAL values (8 floats) starting at Modbus address 41002?
Configure the MB_Master call with MODE = 4 (Read Holding Registers, FC03), DATA_ADDR = 41002, DATA_LEN = 16. The DATA_PTR must point to a buffer of at least 32 bytes. In your application program, swap the two 16-bit words of each pair (Modbus is big-endian, S7-1200 is little-endian) and convert the resulting DWORD to REAL. See the SCL snippet in §8.
Do I need pull-up / pull-down (bias) resistors on the RS-485 bus between CM 1241 and the AB controller?
In practice, yes. The CM 1241 RS-485 port and most AB communication ports do not include internal fail-safe bias. Without bias, an idle bus floats and the first character of a request is often corrupted, producing intermittent 0x80C0 framing errors and, when the corruption lands in the address byte, 80C8 timeouts. Add 680 Ω pull-up on B to +5 V and 680 Ω pull-down on A to GND at the master end, plus 120 Ω termination at both physical ends of the cable.