S7-1200 Modbus Master: Addressing Slave ID 248 Workaround
The SIMATIC S7-1200 Modbus master instruction (MODBUS_MASTER) declares its MB_Unit_ID input as a BYTE in default installations of TIA Portal, which restricts the addressable range to 1–247. Field engineers regularly encounter third-party devices that ship from the factory with slave ID 248 pre-configured, and they cannot talk to the device until that ID is changed. Because changing the ID usually requires the vendor's PC tool, and the vendor tool itself needs a working Modbus link, the PLC programmer is stuck in a chicken-and-egg situation. This reference documents the three engineered paths out of that loop: the TIA Portal V15+ extended-range workaround, an external Modbus gateway/repeater, and a one-time peer-to-peer reconfiguration using the S7-1200 as a temporary Modbus slave.
1. Problem Summary
| Item | Value |
|---|---|
| Controller family | SIMATIC S7-1200 (CPU 1211C/1212C/1214C/1215C/1217C) |
| Communication module | CM 1241 RS-232, CM 1241 RS-422/485, or CB 1241 RS-485 |
| Instruction | MODBUS_MASTER (legacy PtP Modbus RTU) / Modbus_Master (S7-1500 style) |
| Default MB_Unit_ID data type | BYTE (0–255) |
| Effective range with BYTE | 1–247 (Modbus spec), 0 = broadcast |
| Target slave | Third-party device preconfigured at Unit ID 248 |
| Symptom | MB_MASTER returns error 16#80C8 (timeout) or 16#80C9 (no response / illegal Unit ID) |
2. Why 1–247? The Modbus Addressing Rule
The Modbus Organization's MODBUS Application Protocol Specification V1.1b3, section 4.1 Protocol Description, defines the addressing field on the serial link as one byte (8 bits). The specification reserves:
- 0 – Broadcast address (master writes, slaves do not respond)
- 1–247 – Individual slave addresses
- 248–255 – Reserved (legacy use, not part of the public Modbus standard)
Siemens implements the Modbus RTU master in the S7-1200 to be a strict consumer of the Modbus specification. The MB_Unit_ID input is therefore a one-byte unsigned value, and Siemens validates the range to 1–247 in instruction run-time. Slave ID 248 is rejected because it falls outside the public protocol address space. Refer to the MODBUS Application Protocol V1.1b3 specification for the authoritative definition.
3. Siemens S7-1200 Modbus Implementation Details
3.1 Default Data Type Mapping (TIA Portal ≤ V14 SP1)
The legacy MODBUS_MASTER instruction installed from the S7-1200 program block library exposes the following parameter signature:
| Input | Data type | Range | Purpose |
|---|---|---|---|
| REQ | BOOL | 0/1 | Rising edge triggers one transaction |
| MB_ADDR | BYTE | 1–247 | Modbus Unit ID / slave address |
| MODE | USINT | 0/1 | Read / Write mode selector |
| DATA_ADDR | WORD | 0–65535 | Modbus register/coil address |
| DATA_LEN | UINT | 1–125 | Element count for the request |
| DATA_PTR | VARIANT | — | Data buffer (P#, M%, DB) |
| DONE | BOOL | — | Success flag (one-shot) |
| BUSY | BOOL | — | Transaction in progress |
| ERROR | BOOL | — | Error present (one-shot) |
| STATUS | WORD | — | Error code (16#80C8, 16#80C9, etc.) |
Because MB_ADDR is a BYTE, the maximum storable value is 255, but the instruction's run-time guard refuses any value outside 1–247. Slave ID 248 cannot be written into MB_ADDR without triggering a syntax warning at compile time, and the request never reaches the wire.
3.2 Error Codes You Will See at ID 248
| STATUS hex | Meaning | Typical cause |
|---|---|---|
| 16#80C8 | Slave timeout (3.5 char time exceeded) | No device answered on the bus |
| 16#80C9 | Illegal Unit ID or function code | Master sent ID the slave ignored |
| 16#80D1 | Parameter error in MB_ADDR | Pre-check rejected value > 247 |
| 16#80E0 | Message truncated | CRC error or wire fault |
4. Workaround 1 — TIA Portal V15+ Extended MB_Unit_ID Range
Starting with TIA Portal V15.0, Siemens widened the MB_Unit_ID input in the S7-1200 Modbus_Master instruction to a WORD / UINT data type, which lifts the engineering-time limit from 1–247 to 1–65535. The instruction still rejects 0 (broadcast is read-only in client mode) and the run-time error codes remain, but a value of 248 can now be passed legally through the FB parameter. This is the cleanest fix when you are licensed for V15 or later.
4.1 Prerequisites
- TIA Portal V15.0, V15.1, V16, V17, V18, V19 or later (Engineering in TIA Portal)
- S7-1200 CPU firmware V4.2 or higher (the older V4.0/V4.1 images still lock the type to BYTE)
- CM 1241 or CB 1241 with a fully wired RS-485 two-wire or RS-422 four-wire segment
- Termination resistor 120 Ω enabled at both physical ends of the trunk (DIP switch on CM 1241)
- Shielded twisted-pair cable, shield grounded at the cabinet entry only
4.2 Procedure
- Upgrade the project. Open the project in TIA Portal V15+ and accept the CPU firmware upgrade prompt. Verify the CPU is at firmware V4.2+ via Online → Accessible Devices → Online & Diagnostics.
-
Insert the Modbus_Master instruction. From Instructions → Communication → Modbus (PtP), drag
Modbus_Master(the post-V15 instance) into a new FB or OB1. Right-click the instance DB and confirm the FBG version is >= V6.0. -
Inspect MB_Unit_ID. Open the block interface. Confirm the
MB_Unit_IDinput is now declared asWORDorUINT. Older instances keepBYTE; recompile to regenerate. -
Wire the new parameter. Create a tag of type
WORDin the global symbol table, e.g."Slave_Unit_ID"= 16#00F8 (decimal 248). Connect it directly to theMB_Unit_IDinput. - Configure the port. Open the CM/CB 1241 properties → Port Configuration and set the protocol to Modbus Master (RTU), baud, parity and stop bits to match the slave vendor spec (commonly 19200 / 8N1 or 9600 / 8E1).
- Compile and download the hardware configuration and software to the CPU. The download re-initializes the PtP port.
-
Trigger a single Read Holding Registers (FC=03) request at address 0x0000, length 1. Monitor
STATUS: it should return 16#0000 onDONE.
4.3 STL / SCL Reference Snippet
// SCL example, S7-1200 / TIA V17, MB_ADDR widened to WORD
"Modbus_Master_DB".REQ := Start_Trigger; // BOOL pulse
"Modbus_Master_DB".MB_Unit_ID := 248; // WORD, now legal
"Modbus_Master_DB".MODE := 0; // 0 = read
"Modbus_Master_DB".DataAddr := 16#0000; // Holding register 0
"Modbus_Master_DB".DataLen := 1; // One register
"Modbus_Master_DB".DataPtr := P#DB1.DBX0.0 BYTE 2; // Target in DB1
If the project must remain on TIA V14 or earlier, the FB instance is locked to the BYTE type and the workaround above is unavailable. In that case, deploy Workaround 2 or 3.
5. Workaround 2 — External Modbus Gateway or Address Translator
Insert a third-party Modbus RTU-to-RTU address-translating gateway (also called a slave-multiplexer or ID-rewriting bridge) between the S7-1200 CM 1241 and the third-party device. The gateway acts as the slave at a compliant ID (for example, 10) on the S7-1200 side, and forwards traffic to the physical device at ID 248 on the field side, transparently rewriting the Unit ID byte. Popular families include the Anybus X-gateway Modbus RTU (HMS Industrial Networks), ProSoft Modbus Multiplexer, and the Wieland Electric Wienet RTU router.
5.1 Configuration Steps
- Power the gateway and connect the upstream port to the CM 1241 (RS-485 A, B, GND).
- Connect the downstream port to the third-party device's RS-485 terminals.
- In the gateway's web/HMI configuration, set the upstream Unit ID (e.g. 10) and the downstream Unit ID (248).
- Match baud rate, parity, character format, and inter-frame timeout on both sides. The inter-frame timeout must be ≤ 3.5 character times per the Modbus RTU spec.
- From TIA Portal, set the S7-1200
MB_ADDR = 10and proceed with normal MODBUS_MASTER calls. The gateway handles the ID rewrite silently.
6. Workaround 3 — One-Time Reconfiguration as Modbus Slave
Use the S7-1200 temporarily as a Modbus slave to write the desired address change directly to the third-party device. The instruction set in question is MB_SLAVE – Communicate using the PtP port as Modbus RTU slave. The MB_SLAVE instruction supports broadcast write requests from any Modbus master, so once the S7-1200 holds a generic master (also the same CPU using the MODBUS_MASTER block) it can reach the device at its factory address and rewrite the slave-ID holding register, after which the third-party device reboots at the new address and normal master polling resumes.
6.1 Step-by-Step Reconfiguration Procedure
- Wire the CM 1241 RS-485 to the third-party device with bias and termination as per the Modbus standard.
- Insert a
Modbus_Master(V15+ type, see §4) into the S7-1200 program. SetMB_Unit_ID = 248. - Read the device's address-change holding register (vendor documentation, commonly register 0x07D0 with two-byte value). Verify the response:
DONE = 1,STATUS = 16#0000. - Write the new address (e.g. 7) to that same register using
MODE = 1(write single register, FC=06) andDataPtrpointing at a data word = 7. - Cycle power on the third-party device. The new Unit ID takes effect on cold start per vendor firmware behavior.
- Change the S7-1200
MB_Unit_IDtag to 7 (or whatever address the device was set to). Resume normal polling. The extended-range workaround from §4 is no longer required.
6.2 PLC Code Skeleton
// Step 1 - Read current slave ID register from device at Unit ID 248
IF First_Scan THEN
Read_Req := TRUE;
Slave_ID := 248; // WORD, requires TIA V15+
Mode_Read := 0; // Read
Reg_Addr := 16#07D0; // Vendor-defined address register
Reg_Len := 1;
END_IF;
// Step 2 - When Read_Req_Done and the read value is, e.g., 248, write 7
IF Read_Req_Done AND Read_Data.Word = 248 THEN
Write_Req := TRUE;
Mode_Write := 1; // Write single register
Write_Data.Word := 7;
END_IF;
// Step 3 - After Write_Req_Done cycle power to the slave (digital output).
IF Write_Req_Done THEN
Slave_Power := FALSE; // De-energize via DO
END_IF;
7. Choosing the Right Workaround
| Criterion | TIA V15+ Extended Range | External Gateway | One-Time Reconfigure |
|---|---|---|---|
| Project TIA version | V15 or newer | Any | Any (V15+ preferred) |
| CPU firmware | V4.2+ | Any | Any |
| Extra hardware | None | Gateway module | None |
| Long-term maintenance | Cleanest | Most flexible | Requires repeat on slave replacement |
| Added latency | 0 ms | 4–20 ms | 0 ms (after ID change) |
| Standards compliance | Improved (still non-standard ID) | Compliant (PLC side) | Compliant (after ID change) |
| Cost | $0 | $300–$1,200 | $0 |
| Skill required | PLC programmer | Network engineer | PLC programmer |
8. Verification Procedure
-
Watch table: Open Online → Watch & Force Tables in TIA Portal. Force
MB_Unit_ID = 248and trigger a read. ConfirmSTATUS = 16#0000,DONE = 1within the configuredTimeout(default 1000 ms). -
Bus monitor: Use a Modbus protocol analyzer (e.g. Simply Modbus on a tap, or the in-built trace of HMS Anybus) to capture the byte stream. Verify the on-wire Slave Address byte is
0xF8(decimal 248) and the CRC-16 matches. - Electrical check: With a scope on A and B, verify the differential voltage swing is > 1.5 V at the receiver under load. Half-duplex RS-485 must idle HIGH on A (–) and LOW on B (+) per TIA-485-A. Bias resistors 620 Ω pull-up on +5 V and pull-down on GND are required when the master is not actively driving.
- End-to-end register test: Read a known holding register (for example 0x0000) and confirm the value matches the vendor documentation. Document the result in the SAT (Site Acceptance Test) report.
-
Failure mode test: Disconnect the slave. The
STATUSmust transition to 16#80C8 (timeout) within the configuredTimeoutvalue. Reconnect and verify auto-recovery to 16#0000 on the nextREQpulse.
9. Troubleshooting Matrix
| Symptom | Likely root cause | Corrective action |
|---|---|---|
| Compiler error: Value '248' outside type BYTE | Old MODBUS_MASTER instance, TIA ≤ V14 SP1 | Upgrade TIA to V15+ and reinsert the block; confirm MB_Unit_ID data type |
| STATUS = 16#80D1, parameter error | MB_ADDR still BYTE in online CPU image | Recompile and download the entire software; do not download single block |
| STATUS = 16#80C8 timeout | Wiring, baud, or termination | Check A/B polarity, swap if needed; enable 120 Ω termination; verify common ground |
| STATUS = 16#80C9 illegal Unit ID | Vendor device rejects non-248 traffic | Confirm device firmware version; some units hard-code ID 248 and reject all others |
| Garbled bytes in bus monitor | Termination or bias missing, cable too long | RS-485 max 1200 m at ≤ 100 kbps; reduce baud or add repeater |
| Intermittent OK / timeout | Reflected wave, no bias resistors | Add 620 Ω bias on master end only |
| DONE never sets after ID change | Vendor device requires power cycle to apply new ID | Cycle DO powering the device; wait 5 s; retry |
10. Field-Proven Best Practices
- Always keep the vendor configuration tool in the cabinet. The day you have to swap the third-party device under failure conditions, the new unit will ship with the same default 248.
- Document non-standard Unit IDs in the project's P&ID and the PLC tag database. A simple comment field in the data block, e.g.
// Unit ID 248 - vendor default, see SAT-2024-08, prevents the next engineer from wasting hours on the same issue. - Escalate the deviation to the vendor. Cite the Modbus Application Protocol Specification V1.1b3 §4.1 and request a firmware update that defaults to a compliant ID (1–247). A polite non-conformance report often produces a fix in the next release.
- For multi-vendor RS-485 networks, always insert a gateway in front of legacy or non-compliant devices. It isolates the S7-1200 from bus faults and allows you to swap slaves without reprogramming the controller.
- Validate the entire bus with a Modbus scanner (Modbus Poll, QModMaster, or a portable Witte Analog RTU tool) before connecting the PLC. This confirms the slave is alive on its claimed address and saves the PLC's debug STATUS from being used as a general-purpose bus tester.
11. Glossary
| Term | Definition |
|---|---|
| Unit ID | Modbus identifier of a slave on a serial link, range 1–247 per spec |
| MB_Unit_ID | Siemens naming for the Modbus Unit ID input parameter on Modbus_Master |
| PtP | Point-to-Point communication, the family of S7-1200 CM/CB 1241 protocols |
| RS-485 | Multi-drop differential serial standard (TIA-485-A), basis of Modbus RTU |
| RTU | Remote Terminal Unit – the binary Modbus frame format with CRC-16 |
| FC | Modbus Function Code, e.g. FC=03 read holding registers, FC=06 write single register |
| CRC-16 | 16-bit cyclic redundancy check, last two bytes of every Modbus RTU frame |
| Broadcast | Modbus Unit ID 0, write-only, no slave may respond |
Why does the S7-1200 Modbus_Master block refuse slave ID 248?
Because the Modbus Application Protocol Specification V1.1b3 reserves Unit IDs 1–247 for individual slaves and 248–255 for legacy use. Siemens implements the S7-1200 Modbus_Master instruction strictly to the spec, so values above 247 are rejected at compile time when the parameter is BYTE, and at run time when it is WORD/UInt.
Which TIA Portal version is required to pass slave ID 248 directly to MB_Unit_ID?
TIA Portal V15.0 or later combined with S7-1200 CPU firmware V4.2 or later. The instruction block is regenerated and the MB_Unit_ID input is widened from BYTE to WORD/UINT, accepting 1–65535.
Can I keep TIA V14 and still talk to a slave at ID 248?
Yes, but not directly. Insert a Modbus address-translating gateway (such as the HMS Anybus X-gateway Modbus RTU or a ProSoft Modbus Multiplexer) that exposes ID 10 to the PLC and forwards to ID 248 on the field side, or perform a one-time write of the slave's address-change register using the S7-1200 as a temporary Modbus master via MB_SLAVE support and a broadcast write.
What is the difference between MB_SLAVE and Modbus_Slave on the S7-1200?
MB_SLAVE is the legacy PtP Modbus RTU slave instruction that runs on a CM 1241 or CB 1241 port. It accepts function codes 01, 02, 03, 04, 05, 06, 15 and 16 from any master and supports broadcast write requests. Modbus_Slave is the newer symbolic block added in TIA V15+ for the same role. Both are slaves, neither acts as a master to address a third-party slave at ID 248.
What happens if I write a new address to the third-party slave and then cycle power?
Most vendor devices commit the new address to non-volatile memory on the next cold start, and the S7-1200 can thereafter poll them at the standard ID. Always re-validate with a bus monitor and update the PLC tag comments. Keep the vendor tool available because a factory-reset or a firmware update typically reverts the device to its shipping default of 248.