Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common function code protocols in Modbus

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what the common Modbus functional code protocols are, I hope you will gain something after reading this article, let's discuss it together!

01H-read coil status

1) description: read slave coil register, bit operation, readable single or multiple

2) send instructions: suppose the slave address bit 0x01, register start address 0x0023, register end resist 0x0038, a total of 21 coils are read. The diagram of the protocol is as follows:

3) response: each bit of the returned data corresponds to the coil status, 1m / m / m / o / off, as shown in the following figure

In the above table, data1 represents the coil state of 0x0023-0x002a, and the lowest bit of data1 represents the coil state of the lowest address, which can be understood as small end mode.

Data2 represents the coil status of the address 0x002b-0x0033, as shown in the following table:

Data3 indicates the coil status of the address 0x0034-0x0038, which is less than 8 bits, and the high byte fill is 0, as shown in the following table:

02H-read discrete input state

1): read discrete input register, bit operation, readable single or multiple, protocol similar to function code 0X01 protocol, save here

03H-read hold register

1) description: read hold register, byte instruction operation, readable single or multiple

2) send instructions: slave address 0x01, hold register start address 0x0032, read 2 hold registers

3) response:

Data storage order

04H-read input register

1) description: read input register, byte instruction operation, readable single or multiple

2) send instruction: same as 03H

3) response: same as 03H

05H-write a single coil

1) description: write a single coil, bit operation, only one, write 0xff00 to set the coil state to ON, write 0x0000 to set the coil state to OFF

2) send instruction: set 0x0032 coil to ON

3) response: same as sending instruction

06H-write a single hold register

1) description: write a single hold register, byte instruction operation, only one

2) send instruction: write 0x0032 to keep register as 0x1232

3) response: same as sending instruction

0FH-write multiple coils

1) description: write multiple coil registers. A bit value of "1" in the data area indicates that the requested corresponding coil state is ON, and if a bit value is "0", the state is OFF.

2) send instructions: coil address is 0x04a5, write 12 coils

In the figure above, DATA1 is 0x0c, which means:

DATA2 is 0x02, less than 8 bits, high byte filling 0:

3) response:

10H-write multiple hold registers

1) description: write multiple hold registers, byte instruction operation, can write multiple

2) send instructions: keep the starting address of the register as 0x0034 and write 2 registers with 4 bytes of data

3) response:

After reading this article, I believe you have a certain understanding of "what are the common functional code protocols of Modbus". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report