IMDHMIControls LibraryShop main store

Troubleshooting

Why a Modbus TCP coil write lands one address off the map

Industrial networks Published 6 min read By IMDHMI controls team

Short answer

Enter the printed coil number plus one as the Modbus TCP client offset: a 32-solenoid bank whose map lists the first coil as 320 took entry 321, because the printed map number and the instruction's address field count on different bases. Prove it with a single-coil write at a 10-second repeat interval and latched result bits, then shorten the interval to 1 second.

On this page
  1. Translate the printed coil number to the wire offset
  2. Prove one coil before you trust the whole block
  3. Read the decision from the latched bits
  4. Check the coil-versus-word map before a second offset guess
  5. Keep the server setting out of the write path
  6. Verify the bank and record both numbers
  7. Questions asked

A Modbus TCP coil write that communicates cleanly but moves no solenoid has one first suspect: the address base. Enter the printed coil number plus one. On this fault's pairing, a Do-more H2-DM1E writing to a 32-solenoid valve bank, the device map printed the first commanded coil as 320 and the address entry that reached it in the MWX network write instruction was 321. The printed number and the entry field count on different bases, so the transaction completes either way and the write simply lands one coil early. Prove it before moving anything: one known coil, a 10-second repeat interval, and the success and error result bits latched in PLC logic, because in time-based mode those bits last one scan. When the intended solenoid follows the commanded bit, shorten the repeat interval to the 1 second the production logic needs.

Translate the printed coil number to the wire offset #

On the wire, a Modbus TCP coil write — function 5, write single coil — carries the element address as a 16-bit unsigned offset counted from zero: the first coil in a device's map is offset 0 and legal offsets run 0 to 65535. Printed maps and client entry fields do not share a base. Some maps follow the classic convention and print element numbers counted from one, others print the raw zero-based offset, and an entry field can expect either form. When the two sides differ, the mismatch is one-based numbering against zero-based offsets: every transaction completes normally and every write lands exactly one element away from the coil you chose. Counting from zero is the same convention behind why Modbus RTU sends to slave address 0 instead of your device — there the trap is slave identity, here it is the coil offset.

Worked example, from the commissioning test that pinned this fault:

  • The valve-bank map printed the first commanded coil as 320.
  • The single-coil proof showed the map prints the wire offset, counted from zero, while the MWX address entry counts coils from one.
  • Entry = printed number + 1: 320 + 1 = 321.
  • Check: entry 321 sends wire offset 321 - 1 = 320, which is the coil the map prints as 320. The original entry of 320 sent offset 319, one coil early, and the bank never moved.

Treat entry = printed + 1 as the proven rule for this map and write it into the program comments. A different map, module revision, or replacement interface can flip the direction: a map printed in classic element numbers needs the printed number minus 1. The single-coil proof in the next section settles the direction in one transaction, so run it on any new pairing before releasing a whole block.

Prove one coil before you trust the whole block #

Run the proof in this order:

  1. Put the machine in a safe test state, and isolate stored energy such as the air supply if an unexpected solenoid could move a mechanism.
  2. Ping the valve-bank interface or open its built-in web page. That proves IP reachability, not mapping: a reachable device still receives writes on the wrong element.
  3. Configure the MWX transaction for time-based mode with a 10-second repeat interval, long enough to separate transactions and record each result.
  4. Command one known output: a write length of one coil and the other 31 commands off, so a one-element shift is unmistakable.
  5. Add the capture logic from the next section, a latch on the success bit and a counter on the error bit.
  6. Run the transaction and read the latched pair. If the write completes and the solenoid stays still, apply the plus-one correction to the address entry and repeat this exact test.
  7. When the intended solenoid follows the commanded bit, shorten the repeat interval to the 1 second the production logic needs, widen the write to the full command block, and confirm the error counter stays flat at that rate.

Read the decision from the latched bits #

In time-based mode the MWX result bits are on for one scan at the end of each transaction, so an online status display never shows them; the latch and the counter are the only witnesses. They split the fault in two:

  • Success latched, output still: the transaction completed and the bits landed somewhere other than the intended coil. That is addressing — apply the plus-one correction and repeat the single-coil test.
  • Error counter climbing: the endpoint refused or dropped the request. Work the path instead of the offset: IP address, port, and whether the device accepts a coil write to that area at all.

A completed write with no output movement has one more branch before you re-enter the address entry: the map may not be coils at all. And if a transaction completes while the target genuinely accepts nothing, that is the cousin fault described in why an HMI Modbus TCP write leaves the S7-1200 DB unchanged, which has its own PLC-side causes.

Check the coil-versus-word map before a second offset guess #

The valve bank's documentation carried two views: one listed discrete coils in the block this fault began with, and another placed outputs and status as words in the 40000 range. Decide which view the active configuration actually exposes before a second guess. If the interface presents packed output words, no entry rescues a coil write — it is the wrong transaction for that map. The fallback check during this investigation was a word write to 40020, a test target that proves the module answers a word transaction without settling the coil question. A word write may need the command bits packed into the word, and byte order only matters after the correct word is selected, so keep byte-swap settings out of the first entry test. Keep the two data types separate: one transaction per type, proven one element at a time.

Keep the server setting out of the write path #

The Modbus TCP server entry in the controller's CPU configuration answers requests made to the controller: an external client reading or writing its mapped memory. The valve-bank writes are outbound transactions from the client side, and on this installation they ran with the server enabled and with it disabled, so the setting plays no part in this fault and enabling it cannot repair an entry. Leave the server off unless another device must read the controller's data; the controller can act as client and server at the same time. The inbound side has its own checklist in what you must configure on the PLC side for Modbus TCP, and it stays separate from this write path.

Verify the bank and record both numbers #

With the correction proven, close the loop in this order:

  1. Toggle the first commanded bit and confirm the intended solenoid follows, then toggle it back.
  2. Exercise the next output on its own; this catches a map that is shifted, reversed, or packed differently from the command buffer.
  3. Step through all 32 outputs under safe conditions and record each PLC bit-to-valve assignment.
  4. Watch the latched success counter across cycles at the production interval; a flat success count or a rising error count sends you back to the interval or the endpoint.
  5. Remove temporary forces and diagnostic latches so the normal program owns the output data again.
  6. Record the printed number and the working address entry side by side in the program comment or drawing, so a later edit or a replacement interface does not silently restore the dead value. If the replacement carries a different map, repeat the single-coil test before releasing the whole block.

Questions asked

What offsets cover the last coil of a 32-coil block whose map lists the first coil as 320?

Apply the same translation to the end of the block. Printed numbers run 320 through 351, because 351 - 320 + 1 = 32 coils, so the address entries run 321 through 352 and the wire offsets run 320 through 351. Release the full block only after the single-coil test has proven the first entry.

A Modbus TCP coil write completes normally but the output never moves — what does that prove?

It proves the device received the request and answered it; it says nothing about which element took the bits. A normal response to a write-single-coil request echoes the function code and the coil offset, so compare the echoed offset against the offset you intended. If the echo matches and the output still does not move, look at what owns that output: an inhibit state, machine interlock logic, or missing field power can hold a correctly addressed coil off.

Can the printed-to-entry rule run the other way on a different device?

Yes. Maps that follow the classic convention print element numbers counted from one, and those need the printed number minus 1: printed coil 1 is wire offset 0. The valve-bank map in this fault needed the printed number plus 1 instead. The single-coil proof settles the direction for any new map, module revision, or replacement in one transaction.

Does the one-scan result behavior apply to reads as well as writes?

Yes. The MRX read instruction in time-based mode raises its result bits for one scan at the end of each transaction, exactly like the MWX write, so a read result watched in the online display is gone before you see it. Commissioning logic that checks read results needs the same latch or counter as the write path.

Keep reading

  • Explainer

    Why a Modbus TCP client cannot write M340 input bits

    Yes, it is normal. In Mixed topological and State RAM mode a Modicon M340 exposes %I and %IW as read only to a Modbus TCP client, and Modbus defines no function that writes discrete inputs on any server. Keep client writes on %M coils and %MW holding registers, and publish server-to-client bits in a separate, non-overlapping %M block the client reads as coils.

    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

  • Explainer

    Why an S7-400H PN interface carries only one IP address

    The integrated PN interface of an S7-400H CPU carries one IPv4 address, so Modbus TCP to the DCS and S7 communication share that address and are separated by TCP port and connection resources. A VLAN or routed subnet separates the traffic logically; a physically separate DCS network needs a second interface, a communication processor with its own address on its own subnet.

    Industrial networks