开发者

Access restrictions in Modbus protocol data model

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 o开发者_开发问答n 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.


The authoritative explanation of the Modbus data model is found in section 4.3 of the Modbus Application Protocol Specification available from modbus.org via this link: http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf

It is important to note that the specification shows two examples of Modbus Data Model implementation. One where each of the register types is located in a different memory location and the other where they are all located in the same memory. In the latter case Input Register #1 (16 bit) would contain the status of Discrete Inputs #1 to #16


  1. Discrete Inputs - read boolean inputs (like 0V/5V, 0V/24V, sensors with digital output, closed circuit...)
  2. Coils - write boolean outputs (force some voltage on output, turn on/off relay...)
  3. Input Registers - read analog input (read raw temperature, flow, pressure... usually via voltage or current)
  4. Holding Registers - write analog output (force some raw output value... usually voltage or current)

Beware that you might deal with raw values which you must scale on your side, or with already scaled values expressed in engineering units. Since word type is not quite nice for that, usually 2 16-bit registers are combined to get one floating point 32-bit register.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜