IMDHMIControls LibraryShop main store

Troubleshooting

Why S7-1200 V4.1 MB_SERVER rejects single-register writes with 8383

Industrial networks Published 6 min read By IMDHMI controls team

Short answer

With firmware V4.1, MB_SERVER accepts a client write only when the request covers the whole MB_HOLD_REG block, so a one-register write returns Modbus exception 02 and STATUS 16#8383 while reads keep working. Declare MB_HOLD_REG as an Array of Word instead of a STRUCT, set MB_DATA_LEN to the register count, and single-register writes pass; firmware V4.2 or later also corrects the behavior.

On this page
  1. The fault signature
  2. The cause in firmware V4.1
  3. Convert the block to an array
  4. Size the array and set MB_DATA_LEN
  5. REAL values still need both registers
  6. Prove the fix with one register
  7. When the block cannot change
  8. Questions asked

On an S7-1200 with firmware V4.1, MB_SERVER accepts a client write only when the request covers the entire MB_HOLD_REG block, so a one-register FC 06 write into a five-register block fails with Modbus exception 02, illegal data address, and STATUS 16#8383 while reads keep working. The culprit is the STRUCT declaration of the holding-register block, not the client, the cable or the gateway. Declare MB_HOLD_REG as an array of Word and set MB_DATA_LEN to the register count, or update the CPU to firmware V4.2 or later. Below is the fault signature, the conversion, and the one-register test that proves it.

The fault signature #

  • Reads with function code 03 return correct data; only writes fail.
  • Any write whose quantity is smaller than the block is answered with exception code 02, which the Modbus application protocol defines as an address or quantity the server does not serve. On the wire the reply carries the function code with its high bit set, 0x86 for a rejected FC 06, followed by the exception code.
  • MB_SERVER reports it as STATUS 16#8383, decimal 33667, on its STATUS output.
  • An S7 partner running MB_CLIENT shows 16#7005 while it processes the request, 16#7006 once the connection stands and it waits for the response, then ends on the server's exception, forwarded unchanged.
  • One request that writes every register in the block succeeds. That last point is the fingerprint: it separates this fault from wiring and addressing problems.
  • If your S7-1200 is the client and only large quantities fail on reads, you are looking at a different limit: why MB_CLIENT returns Modbus TCP error 8383 on multi-register reads.

The cause in firmware V4.1 #

The S7-1200 Modbus TCP library runs from firmware V4.1 onward, and the first release carries this write behavior. When MB_HOLD_REG points at a STRUCT, the V4.1 server compares the quantity field of the write request with the total length of the structure and serves the request only on an exact match. Any shorter write is treated as out of range even when its address is valid, so writing 1 register out of 5 fails while writing all 5 passes. With the same parameter pointed at an ARRAY, writes to a single register or any sub-range inside the block are accepted.

MB_DATA_LEN is identical in both cases, so the client sees the same register map either way. The difference lies in how the server maps request offsets onto the block, which is why changing the master, the timing or the gateway never fixes it. A frame capture shows a valid request going in, with a correct MBAP header, address 0 and quantity 1, and a clean exception coming back.

What you change is how MB_HOLD_REG points at the holding-register block, under the rule that those registers must live in a non-optimized global DB or in M memory; how MB_HOLD_REG struct pointing works in TIA Portal covers the pointing itself. Siemens documents the behavior in its application note on Modbus/TCP with the MB_CLIENT and MB_SERVER instructions, and the corrected write handling ships in firmware V4.2 and later.

Convert the block to an array #

  1. Open the global DB wired to the MB_HOLD_REG input.
  2. Confirm that optimized block access is disabled for that DB: MB_SERVER reads its holding registers from a non-optimized global DB or from M memory.
  3. Replace the STRUCT with a single tag of type Array[0..n] of Word, where n + 1 equals the number of 16-bit registers your clients need. Keep the old element order so existing Modbus addresses keep their meaning.
  4. Point MB_HOLD_REG at the new array tag itself, not at a parent structure that contains it. This is the conversion shown in S7-1200 Modbus TCP MB_HOLD_REG configuration error fix.
  5. Set MB_DATA_LEN to the register count: for a zero-based array, the upper bound plus one.
  6. Compile and download. The DB keeps its number because you changed its content rather than deleting it, so the Modbus map stays where it was; only program code that referenced STRUCT element names must move to array indexes.
  7. If the CPU refuses the download because the block interface changed, cycle power and download again.

Size the array and set MB_DATA_LEN #

Take an application that needs 4 REAL setpoints and 6 WORD counters. One REAL occupies two consecutive registers and one WORD occupies one, so the block must hold:

4 × 2 registers + 6 × 1 register = 8 + 6 = 14 registers

Declare Array[0..13] of Word and set MB_DATA_LEN = 13 − 0 + 1 = 14. Addresses 0 through 13 now accept single-register writes, while a request at address 14 sits outside the map and earns its exception 02 honestly. That is the decision line: inside the range, the V4.1 server with an array writes any register alone; outside it, every firmware rejects.

REAL values still need both registers #

The conversion removes the server's accidental protection of REAL pairs: a client can now write one half of a value and leave the other half stale. Keep REAL writes as two-register FC 16 requests, or accept torn values between two single writes. Standard Modbus sends the high word first, so to use a pair in the program, combine the words and convert:

// Example names chosen for this article, not required identifiers.
// "ModbusRegs": global DB, optimized block access disabled
// Reg: Array[0..13] of Word (holding registers 0 to 13)
// "PlantData": global DB
// Setpoint1: Real
// Temp of the calling block:
// rawValue: DWord, initial value DW#16#0000_0000

#rawValue := DW#16#0000_0000; // defined start value
#rawValue.%W1 := "ModbusRegs".Reg[0]; // high word: first register on the wire
#rawValue.%W0 := "ModbusRegs".Reg[1]; // low word: second register
"PlantData".Setpoint1 := DWORD_TO_REAL(#rawValue);

Prove the pair with one write: send REAL 100.0 as a two-register FC 16 to addresses 0 and 1. IEEE 754 encodes 100.0 as 0100 0010 1100 1000 0000 0000 0000 0000, so the first register must read 16#42C8 and the second 16#0000; with the snippet above, Setpoint1 then monitors as 100.0.

Prove the fix with one register #

  1. Go online, open the MB_SERVER instance and watch STATUS.
  2. From the master, send FC 06 to address 0. STATUS must return to 16#0000.
  3. Send FC 06 to the last address in your range. Also 16#0000.
  4. Send FC 06 one address past MB_DATA_LEN. Exception 02 again, correctly this time.
  5. Read the whole block with FC 03 and confirm every written value landed.
  6. If 8383 persists on in-range single writes, MB_DATA_LEN and the array length disagree, so recount as upper bound minus lower bound plus one, or MB_HOLD_REG still points at a structure instead of the array tag.
  7. When the test master is another S7-1200 running MB_CLIENT, mind its addressing quirk before blaming the server: why Modbus error 8189 needs 400001 added to the register address.

When the block cannot change #

On a validated line with a frozen DB, two paths remain. The clean one is firmware: update the CPU to V4.2 or later from the TIA Portal online view, then repeat the one-register test before releasing the machine. The interim one is client-side: make every writer send the full block in one FC 16 request, which passes on V4.1. That stopgap turns each write into a read-modify-write of the whole block, so two writers race and a stale copy of any register overwrites fresh data; use it only until the firmware or the block changes.

Questions asked

Can I keep the STRUCT if my client writes every register in one request?

Yes, and on firmware V4.1 that full-block write is the only one that passes. The cost is operational: every writer must send the whole block each time, so each write becomes a read-modify-write cycle, two writers can overwrite each other's fresh values with stale copies, and any client that ever sends a partial block fails again. Treat it as a stopgap until the firmware or the block changes.

Will my HMI's Modbus register numbers change after the conversion?

No, provided the array keeps the old element order and MB_DATA_LEN keeps the same count. A value's Modbus address is its position in the block, so an HMI polling addresses 0 to 4 sees the same data in the same places after the conversion. Only PLC code that referenced the STRUCT by element names has to move to array indexes; the clients never notice.

Does the same type fault appear with Modbus RTU on this CPU?

The RTU library applies the same rule to the holding-register block, but the symptom differs: an MB_HOLD_REG type mismatch shows up there as status 16#8187 rather than the TCP write error. The cure is the same conversion to an Array of Word with the length set to the register count, so fix both interfaces in one pass if the CPU serves RTU and TCP masters.

Does a multi-register write fail too, or only single-register writes?

Any write whose quantity differs from the full STRUCT length fails on firmware V4.1. With a five-register block, a three-register FC 16 request is rejected exactly like a one-register FC 06, and only the full five-register request passes. After the array conversion, an FC 16 for any sub-range inside the block is accepted, which is what makes partial block updates usable again.

Keep reading

  • How-to

    Set up a CLICK Plus as Modbus TCP client to an S7-1200

    Yes: make the S7-1200 the Modbus TCP server with MB_SERVER mapped to a data block of INTs, and make the CLICK Plus the client with Send and Receive instructions aimed at the CPU's IP address and port 502. Write the shared register map first; the S7 logic copies physical inputs into it and applies its output words to the real outputs.

    Industrial networks

  • How-to

    What an S7-1500 needs as Modbus TCP server for a PC master

    When the central PC is the Modbus TCP master, the S7-1500 runs as server with one MB_SERVER call per connection; MB_CLIENT instances belong to the side that initiates requests. Map the holding registers with an absolute pointer into a standard-access DB, sized in words to the register range the PC will touch, and give any additional server connection its own instance DB, connection ID and port.

    Industrial networks

  • Troubleshooting

    Why an HMI Modbus TCP write leaves the S7-1200 DB unchanged

    The write most likely never reached the register you think it did: the HMI's 400001 is a one-based display number, while the Modbus request carries a zero-based offset that the server block maps onto DB102.DBW0. Confirm the server block status and data area, confirm station 3 points at the S7-1200 rather than the motion controller, match the driver's register convention, and prove the path with one known value written to a single word.

    Industrial networks

Why MB_CLIENT error 8383 blocks DIRIS A40 register 50512 reads