IMDHMIControls LibraryShop main store

Explainer

Modbus holding register vs input register: which one to use

Industrial networks Published 5 min read By IMDHMI controls team

Short answer

Use a holding register (40001+) when the client must read and write a 16-bit value: variables, timer and counter values, setpoints, output commands. Use an input register (30001+) when the device supplies a read-only 16-bit value such as an analog or counter reading. Coils and discrete inputs are the 1-bit equivalents.

On this page
  1. The four Modbus data areas
  2. Function codes follow the area
  3. Reference ranges versus protocol addresses
  4. Worked example: a level signal and a setpoint on one slave
  5. File records are outside the four areas
  6. Questions asked

Pick a holding register when the client has to write the value; pick an input register when only the device writes it. A holding register, referenced from 40001, is a read/write 16-bit word for variables, timer and counter values, and commands to outputs. An input register, referenced from 30001, is a read-only 16-bit word the device itself supplies, such as an analog-input or high-speed-counter reading. Coils (00001+) and discrete inputs (10001+) are the 1-bit equivalents, and the read function code you use follows from the area, not from the data's meaning.

The four Modbus data areas #

The Modbus application protocol specification defines four data areas, each either one bit or one 16-bit register wide, with a fixed access right:

  • Coils, 1-bit, read/write: internal Boolean state and real-world outputs such as a lamp or contactor.
  • Discrete inputs, 1-bit, read-only: real-world binary inputs such as a pushbutton.
  • Input registers, 16 bits, read-only: values the device supplies, written by analog-input or counter hardware, sometimes BCD.
  • Holding registers, 16 bits, read/write: general variables, math operands and results, timer and counter values, and values destined for an analog-output card.

The Modbus specification states the access rights one way: an input register is read-only because no write function exists for it, while a holding register is the area a client may both read and write. Two independent memory blocks sit behind the two areas on the slave side, so input register 1 and holding register 1 are different storage, not two views of one word.

One reference identifies one 16-bit register. 30001 is a single word, not one bit spread over 30001 through 30016; the same holds for 40001. A register's interpretation as decimal, hexadecimal, BCD, or a two-register float belongs to the application, not to the protocol, and the specification does not fix a word order for multi-register floats, so both ends must agree on that convention separately.

Function codes follow the area #

Each area has its own read function, and the write functions exist only where access is read/write. Function code 03 reads holding registers, and function code 04 reads input registers; function codes 05 and 06 write a single coil and a single holding register, and the multi-write codes extend those areas. A read can fetch up to 125 contiguous 16-bit registers in one request, so scanning a whole block at once is normal practice.

This is why the choice is an ownership decision, not a style choice. If your electronics own the value, expose it as an input register and the client reads it with function 04. If the client owns it, expose a holding register: the client reads it with function 03 and writes it with 06, and the slave applies the value. A value you place in an input register cannot be changed by the client; a value that must change from the client side has to live in a holding register from the start. Before you let a supervisory client write to a controller's output registers, read safe Modbus writes to PLC output registers from SCADA, because an unvalidated write on a live machine is a real hazard.

Reference ranges versus protocol addresses #

The 00001/10001/30001/40001 style is a documentation convention for the four blocks. The Modbus specification numbers data elements from 1 but carries them on the wire from 0, so registers numbered 1 to 16 are addressed as 0 to 15. Tools differ in whether they want the documented reference or the protocol address, and mixing the two is the classic off-by-one fault; the same trap exists for discrete inputs, as in why Modbus discrete inputs are off by one at the PLC.

Worked example: a level signal and a setpoint on one slave #

Suppose your electronics act as a Modbus slave for a touchscreen: it reports a tank level from your A/D front end and receives a pump speed setpoint.

Inputs, each from the Modbus data model above:

  • Level: a 16-bit value your hardware supplies. It is read-only to the client, so it belongs in input register 30001, read with function 04.
  • Setpoint: a 16-bit value the client writes and your logic reads. It belongs in holding register 40011, written with function 06 and read with function 03.
  • The screen's numeric conversions: level element 1, protocol address 0; setpoint element 11, protocol address 10.

Rule: protocol address equals the reference minus the block base, so address = 40011 − 40001 = 10 for the setpoint, and address = 30001 − 30001 = 0 for the level.

The client's exchanges are then: read input registers, function 04, address 0, quantity 1, and it gets the level; write single holding register, function 06, address 10, and it sets the pump speed. Your slave firmware serves both blocks independently, and a write attempt against address 0 returns an exception because the input area has no write function.

Decision: any value the client must change goes in the 40001 block with a 06 write; any value only your device produces goes in the 30001 block with a 04 read. Map every point in your device this way before writing firmware, and publish the map with each address, its access right, and its engineering meaning.

File records are outside the four areas #

A file record is a separate access mechanism the specification leaves largely to the application: it does not define a record layout, contents, or purpose for your data. Treat it as unavailable for text or mixed data until the peer device's own documentation defines the record structure and the operations both ends implement. For ordinary points, the four areas cover Boolean, binary-input, device-supplied, and read/write word data; anything else is a design agreement, not a Modbus feature.

Questions asked

Are holding registers writable in every slave?

The Modbus specification makes holding registers a read/write area, but a device designer may restrict individual addresses. The area you implement defines what the client may do; check the device's register map for any address it documents as read-only within its holding-register block.

Why does my client request register address 10 when I want holding register 40011?

The Modbus specification numbers data elements from 1 and addresses them from 0, so protocol address equals the reference minus the block base. Holding register 40011 is element 11, protocol address 10. Most configuration tools accept either convention; entering the wrong one is the classic off-by-one fault.

Can I read a holding register with function code 04?

No. Function code 04 is defined for input registers only, and function code 03 for holding registers. A slave that receives a request against the wrong area returns an exception rather than the data, so match the function code to the block the value actually lives in.

Keep reading

  • 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

  • Troubleshooting

    Why Modbus error 8189 needs 400001 added to the register address

    Status 16#8189 from MB_MASTER on an S7-1200 is an invalid data address, not a wiring fault. When the slave's manual documents a zero-based holding-register offset, add the holding-register base to it: offset 20200 is entered as DATA_ADDR 420201, and the block transmits function code 3 to the intended register. The accepted address ranges, the arithmetic and the checks for a stubborn 8189 follow.

    Industrial networks

  • Explainer

    Why S7-1500 Modbus RTU input registers come from the IW area

    On an S7-1500 Modbus RTU slave, input registers read with FC 04 are served from the CPU's process image of inputs, the IW area; the DB pointer on the slave call routes only holding registers. An analog module mapped at IW0 therefore answers input-register requests with live process values that belong to nothing in your register map. Correct the master's function code or move the module's I addresses out of the requested range.

    Industrial networks