In the Modbus protocol, commonly used data types include the following:
- Coils: The Coils data type represents the state of a single switch, which can indicate on/off, true/false, and other states. It can only read and write a single bit, and can be read or written using function codes 01H or 05H.
- Discrete inputs: The D discrete inputs data type represents the state of the input and can only be read, not written. The function code 02H can be used to perform read operations on Discrete inputs.
- 16 bit unsigned integers (Input Register): The Input Register data type represents unsigned 16 bit integers that can only be read and not written. The function code 04H can be used to perform read operations on the Input Register.
- 16 bit signed integers (Holding Register): The data type of Holding Register represents a signed 16 bit integer that can be read and written. Function codes 03H or 06H can be used to perform read and write operations on Holding Register.
The difference between these data types lies in their functions and operation types. Coil and Discrete Input can only be read, while Input Register and Holding Register can be read and written. In addition, Input Register and Holding Register also distinguish between signed and unsigned types. In practical applications, appropriate data types are selected for communication and operation based on different application scenarios and the types of data that need to be collected.
Leave a Reply