Troubleshooting
Why MB_MASTER on an S7-1200 returns an error status but no data
Short answer
If the slave answers your PC master but MB_MASTER returns an error STATUS with no data, the PLC never handed the port over or mis-sized the buffer. Run MB_COMM_LOAD once on a first-scan edge, wire its instance DB into every MB_MASTER call through MB_DB, tie both EN inputs to the rail, and size DATA_PTR in bytes while DATA_LEN counts registers.
On this page
- What the working PC test proves
- Run MB_COMM_LOAD once and pass its DB to MB_MASTER
- Tie both EN inputs to the rail and trigger with REQ
- Size DATA_PTR in bytes against DATA_LEN in registers
- Example: sizing DATA_PTR for 10 holding registers at 40001
- Enter the address in the five-digit convention
- Work the fault in this order
- Decode STATUS and prove the wire
- Poll several slaves on one port without breaking the sequence
- Questions asked
When a Modbus RTU slave answers every poll from a PC master tool but MB_MASTER on the S7-1200 returns an error STATUS and no data, the slave is innocent: the port on the PLC was never handed over, or the receive buffer is mis-sized. Four faults cover nearly every case. MB_COMM_LOAD never completed a successful execution, its instance DB is not wired into the MB_MASTER call through MB_DB, the EN inputs of the two blocks are gated by logic instead of tied to the power rail, or DATA_PTR is sized in bytes wrongly against DATA_LEN, which counts registers. Work them in that order and the transaction completes.
What the working PC test proves #
A ModScan32 poll that returns good registers, and a ModSim32 session that answers the PC, prove five things before you open the PLC project: the slave's station number, the baud and parity, the register map, the two-wire pair, and the drive's readiness to answer a master. Stop retesting them. The fault sits on the PLC side, in one of four places: the port handover from MB_COMM_LOAD, the EN gating of the two blocks, the DATA_PTR buffer, and the address convention in DATA_ADDR. Everything below attacks those four. If your master link is Ethernet rather than serial, this handover does not exist, and the configuration that matters instead is what you must configure on the PLC side for Modbus TCP.
Run MB_COMM_LOAD once and pass its DB to MB_MASTER #
MB_COMM_LOAD configures the PtP port for Modbus RTU. Until it has completed successfully once, the port is unconfigured and every MB_MASTER call finishes with an error STATUS before any frame leaves the CPU.
Call MB_COMM_LOAD with REQ from the first-scan system memory contact, plus a manual one-shot for later parameter changes, and latch its DONE, ERROR and STATUS into tags so a failed load is visible at a glance. PORT takes the hardware identifier that the device configuration assigns to the CB 1241 port — drag it from the PLC tags table rather than typing a number. Set BAUD and PARITY to exactly what the PC master used against the same device. Then wire that instance DB into every MB_MASTER call on the port through the MB_DB input; an unwired MB_DB is the most common parameter error here. If all master calls share one instance DB, a single MB_COMM_LOAD execution serves them all.
Tie both EN inputs to the rail and trigger with REQ #
Connect the EN input of MB_COMM_LOAD and of MB_MASTER directly to the power rail, with no variable and no contacts in series, and control activity only through REQ. An EN that drops false part-way through a transaction abandons the state machine inside the instance DB: the port stays owned but idle, and the next request finishes with an error. Drive REQ with a rising edge, hold it until DONE or ERROR returns, drop it for at least one scan, then start the next transaction. Keep exactly one request outstanding per port — two instances pulsing REQ on one pair collide on the wire.
Size DATA_PTR in bytes against DATA_LEN in registers #
DATA_PTR counts bytes and DATA_LEN counts registers, so the two numbers never match for a register read: 50 registers need P#M1000.0 BYTE 100. An undersized pointer produces a persistent error STATUS with no transfer — the instruction runs, the sizing parameter is wrong, and nothing moves, the same failure shape as a TSEND_C that completes with zero bytes when LEN carries zero. Because an absolute P# pointer addresses fixed byte locations, the target DB must use standard, non-optimized block access; an optimized DB has no fixed addresses for the pointer to aim at.
Example: sizing DATA_PTR for 10 holding registers at 40001 #
The VFD manual lists its first holding register at protocol address 0x0000 and you want ten of them into DB100. Enter DATA_ADDR = 40001 and DATA_LEN = 10 registers, with MODE = 0 for a read. Each Modbus register is two bytes, so the buffer is 10 × 2 = 20 bytes. Create DB100 with standard, non-optimized block access and enter DATA_PTR = P#DB100.DBX0.0 BYTE 20: the pointer spans DBB0 through DBB19, and the next free byte in that DB is DBB20. Had DB100 been left optimized, the absolute pointer would have no fixed byte address to aim at, MB_MASTER would end with a parameter-class STATUS, and no register would ever arrive.
Enter the address in the five-digit convention #
The value in DATA_ADDR selects the Modbus function code as well as the location, using the classic five-digit ranges:
- 1–9999 — coils, read and write, DATA_LEN in bits
- 10001–19999 — discrete inputs, read-only, DATA_LEN in bits
- 30001–39999 — input registers, read-only, DATA_LEN in registers
- 40001–49999 — holding registers, read and write, DATA_LEN in registers
Many drive manuals list raw protocol addresses from zero. Protocol address 0x0000 is DATA_ADDR 40001; an illegal-data-address exception means the manual and the entry sit one register apart, so shift by one and poll again. MB_ADDR carries the slave's station number; a request that leaves with station 0 is a separate fault with its own fix, covered in why Modbus RTU sends to slave address 0 instead of your device.
Work the fault in this order #
- Confirm the load: MB_COMM_LOAD called on a first-scan contact, DONE latched true, STATUS clean. If it never ran, nothing else matters.
- Check the handover: the MB_COMM_LOAD instance DB wired into every MB_MASTER call at MB_DB.
- Tie both EN inputs to the power rail and move every interlock onto REQ.
- Verify PORT holds the CB 1241 port's hardware identifier from the device configuration, not a typed guess.
- Recount DATA_PTR in bytes against DATA_LEN in registers, and confirm the target DB is non-optimized.
- Re-check DATA_ADDR against the manual's convention: protocol zero is 40001, not 40000.
- Only now look at the wire: swap A and B at the CB 1241 terminals if STATUS shows timeouts while the PC master still works.
Decode STATUS and prove the wire #
Capture STATUS into a word tag on DONE and ERROR so the last fault survives the scan. The TIA Portal instruction help sorts the values into a parameter class and a communication class; read the class first. Parameter-class STATUS with no telegram on the pair points at the handover, the pointer or the address — work the list above. A timeout with MB_MASTER apparently idle usually means EN gating starved the state machine or REQ never pulsed. If a frame reaches the drive and nothing decodes, suspect polarity: A and B naming is not standardized between devices, so a pair that worked for the PC adapter can be reversed at the CB 1241, and the adapter's bias and termination do not travel with two screws. Make any terminal swap with the drive stopped.
Poll several slaves on one port without breaking the sequence #
Keep one MB_MASTER instance per port and let transactions follow one another. To change the buffer per slave, either allocate one contiguous standard DB sized for the largest transfer, keep the pointer fixed at its start and copy each reply out after DONE, or wrap the call in an FB that passes a different DB per call while the master instance stays single. Either way, change MB_ADDR, DATA_ADDR, DATA_LEN and DATA_PTR only while BUSY is FALSE: new values taken mid-transaction corrupt the reply handling.
Questions asked
How do I size the buffer for coils or discrete inputs?
For bit accesses, DATA_LEN counts bits: 32 coils need a 4-byte buffer, 40 coils need 5. The pointer still counts bytes and still needs a standard-access target, and an undersized bit buffer fails exactly like an undersized register buffer — an error STATUS with no data delivered.
Does each serial port need its own MB_COMM_LOAD call?
Yes — each physical port is configured by its own MB_COMM_LOAD execution. The instance DB that execution produces feeds the MB_DB input of the master calls on that port. A second CB or CM port on the CPU needs its own execution, its own PORT identifier and its own instance DB; one port's configuration cannot be shared with another.
What does a baud or parity mismatch look like on MB_MASTER?
Not as a parity error. Frames that fail the checksum or never decode leave MB_MASTER with a timeout-class STATUS even though the slave is healthy. Take BAUD and PARITY from the PC master session that already worked against the same device; if the PC tool talked to it, those exact settings talk to it from the PLC too.
How many slaves can one MB_MASTER instance serve?
All of them, one at a time. Modbus RTU station numbers run from 1 to 247, and a single MB_MASTER instance reaches any of them by changing MB_ADDR between transactions. The practical limit is timing: each transaction consumes request time, the slave's response time and the turn-around delay, and only one request may be outstanding on the pair.