What is exactly the difference between registers in the Modbus protocol data model?
The protocol defines the following data model:
| Discretes Input | Single bit | Read-only |
| Coils | Single bit | Read-write |
| Input Registers | 16-bit | Read-only |
| Holding Registers | 16-bit | Read-write |
Who exactly is allowed to read and write? Is it applies to the master (client) or the slave (server). If the access restrictions apply to the master, then the word “input” in the read-only registers does not make much sense to me. If it is other way around, then why would a slave have registers that it can not modify?
The official protocol specification document is not clear on that issue, so please help.
Thanks
The slave device typically has a number of input interfaces to some external unit that it is monitoring. You want to know what the state of these inputs are so that you can take some decision based on their state. These inputs cannot be modified by you and so are read-only. The slave takes the input states and passes them to you as a read only value in a register. The slave creates a report based on the physical state of the inputs.
The read-write elements are registers that allow you to send state information to the slave that will appear on the controller outputs. They are writable so that you can control their state and readable so that you can check that what you wrote actually got there.
Example traffic light controller with traffic sensors under the road. The sensors would be read only and the light control (red, amber, green) would be read/write so you can set and check the lighting state.