- 1. 一、联网拓扑
- 2. 二、address设置
- 3. 三、通信协议
- 4. 3.1 协议简介
- 5. 3.2 Communication parameters
- 6. 3.3 通信异常处理
- 7. 3.4 通信function code
- 8. 四、例程
- 9. 4.1 串口Tools测试

一、联网拓扑
本设备采用集中联网控制方式,确保设备间稳定高效通信。
二、address设置
- 进入设置:设备开机状态下,长按“模式”和“风速”按键,进入address设置模式。
- Switch位数:通过按“模式”键来Switchaddress位数。
- 退出设置:按“风速”按键退出address设置模式。
三、通信协议
3.1 协议简介
本设备采用国际通用的 MODBUS-RTU 通信协议,进行 RS485 半双工通信。主机读dataFunction号为 0x03,写Function号为 0x10 或 0x06,采用 16 位 CRC verification,若校验Error则不回应。
3.2 Communication parameters
- Baud rate:9600
- data format:
- start位:1位
- data bit:8位
- stop bit:1位
- check digit:无
- Device address范围:0x01~0xFE
3.3 通信异常处理
- 异常应答:当出现异常应答时,将Function号的最高位置 1。例如,主机RequestFunction号为 0x03,则从机返回的Function号对应项为 0x83。
- ErrorType码:
- 0x01:function code非法(设备不支持receive到的Function号)
- 0x02:data bit置非法(主机指定的data bit置超出了设备的范围)
- 0x03:data值非法(主机send的data值超出了设备对应的data范围)
示例:若主机Requestfunction code为 0x04,从机异常应答data包为 0x01 0x84 0x01 0x82 0xc0。
3.4 通信function code
Device address默认值:0x01
3.4.1 读单/多register
主机send(读多register示例):
| byte位置 | 内容描述 | 示例值(hexadecimal) |
|---|---|---|
| 1 | Device address | 0x01 |
| 2 | function code | 0x03 |
| 3 | starting address高位 | 0x00 |
| 4 | starting address低位 | 0x00 |
| 5 | data字长高位 | 0x00 |
| 6 | data字长低位 | 0x10 |
| 7 | CRC 码高位 | 0x44 |
| 8 | CRC 码低位 | 0x06 |
从机正常应答:
| byte位置 | 内容描述 | 示例值(hexadecimal) |
|---|---|---|
| 1 | Device address | 0x01 |
| 2 | function code | 0x03 |
| 3 | databyte count | 0x10 |
| 4-5 | data 1 高低位 | 0x00 0x00 |
| 6-7 | data 2 高低位 | 0x00 0x12 |
| 8-9 | data 3 高低位 | 0x00 0x0d |
| 10-11 | data 4 高低位 | 0x00 0x02 |
| 12-13 | data 5 高低位 | 0x00 0x00 |
| 14-15 | data 6 高低位 | 0x00 0x00 |
| 16-17 | data 7 高低位 | 0x00 0x00 |
| 18-19 | data 8 高低位 | 0x00 0x00 |
| 20-21 | data 9 高低位 | 0x00 0x00 |
| 22-23 | data 10 高低位 | 0x00 0x00 |
| 24 | CRC 码高位 | 0x6f |
| 25 | CRC 码低位 | 0xc5 |
3.4.2 写单路register
主机send:
| byte位置 | 内容描述 | 示例值(hexadecimal) |
|---|---|---|
| 1 | Device address | 0x01 |
| 2 | function code | 0x06 |
| 3 | register address高位 | 0x00 |
| 4 | register address低位 | 0x02 |
| 5 | 写入data高位 | 0x00 |
| 6 | 写入data低位 | 0x19 |
| 7 | CRC 码高位 | 0xE9 |
| 8 | CRC 码低位 | 0xC0 |
从机应答:
| byte位置 | 内容描述 | 示例值(hexadecimal) |
|---|---|---|
| 1 | Device address | 0x01 |
| 2 | function code | 0x06 |
| 3 | register address高位 | 0x00 |
| 4 | register address低位 | 0x02 |
| 5 | 写入data高位 | 0x00 |
| 6 | 写入data低位 | 0x19 |
| 7 | CRC 码高位 | 0xE9 |
| 8 | CRC 码低位 | 0xC0 |
3.4.3 写多路register
主机send:
| byte位置 | 内容描述 | 示例值(hexadecimal) |
|---|---|---|
| 1 | Device address | 0x01 |
| 2 | function code | 0x10 |
| 3 | register address高位 | 0x00 |
| 4 | register address低位 | 0x00 |
| 5 | data字长高位 | 0x00 |
| 6 | data字长低位 | 0x01 |
| 7 | databyteLength | 0x02 |
| 8 | 写入data高位 | 0x00 |
| 9 | 写入data低位 | 0x55 |
| 10 | CRC 码高位 | 0x66 |
| 11 | CRC 码低位 | 0x6f |
从机应答:
| byte位置 | 内容描述 | 示例值(hexadecimal) |
|---|---|---|
| 1 | Device address | 0x01 |
| 2 | function code | 0x10 |
| 3 | register address高位 | 0x00 |
| 4 | register address低位 | 0x00 |
| 5 | data字长高位 | 0x00 |
| 6 | data字长低位 | 0x01 |
| 7 | CRC 码高位 | 0x91 |
| 8 | CRC 码低位 | 0xc5 |
3.4.4 register address映像表
| Serial number | register address | 变量名称 | 默认值 | byte count | 取值范围描述 | 读写允许 |
|---|---|---|---|---|---|---|
| 1 | 0x0000 | switch机 | 0x0000 | 2 | 0x0001 开机,0x0000 关机 | R/W |
| 2 | 0x0001 | 当前temperature | 0x0000 | 2 | 10 进制format,0-51(0x0012 表示 18 度) | R |
| 3 | 0x0002 | 设定temperature | 0x0014 | 2 | 10 进制format,以temperature设定允许值为限(0x0012 表示 18 度) | R/W |
| 4 | 0x0003 | 模式 | 0x0000 | 2 | 0x0000 制冷,0x0001 采暖,0x0002 通风 | R/W |
| 5 | 0x0004 | 风速 | 0x0000 | 2 | 自动 0x0000,低速 0x0001,中速 0x0002,高速 0x0003 | R/W |
| 6 | 0x0005 | 制冷阀门状态(二管制阀) | 0x0000 | 2 | Close 0x0000,Open 0x0001 | R |
| 7 | 0x0006 | 采暖阀门状态 | 0x0000 | 2 | Close 0x0000,Open 0x0001 | R |
| 8 | 0x0007 | 锁键状态 | 0x0000 | 2 | Close 0x0000,Open 0x0001(Open时按键Invalid) | R/W |
| 9 | 0x0008 | temperature设定最低允许值 | 0x000a | 2 | 10 进制format,0-15(0x0012 表示 18 度) | R/W |
| 10 | 0x0009 | temperature设定最高允许值 | 0x001e | 2 | 10 进制format,20-30(0x0012 表示 18 度) | R/W |
备注:CRC 仅供参考,以 MODSCAN32 通信为准。
四、例程
4.1 串口Tools测试
4.1.1 读取register
senddata包:01 03 00 00 00 05 85 C9
sendParse:
- 01:Device address
- 03:读取function code
- 00 00:register开始address
- 00 05:registerEndaddress
- 85 C9:CRC verification码
返回data包:01 03 0A 00 01 00 1E 00 19 00 00 00 03 8A E4
返回Parse:
- 01:Device address
- 03:读取function code
- 0A:10 个data
- 00 01:开机状态
- 00 1E:当前temperature(0x1e=30 摄氏度)
- 00 19:设置temperature(0x19=25 摄氏度)
- 00 00:制冷模式
- 00 03:风速高速
- 8A E4:CRC verification码
4.1.2 写设置temperatureregister
senddata包:01 06 00 02 00 19 E9 C0
sendParse:
- 01:Device address
- 06:写入function code
- 00 02:register address 2(当前temperature)
- 00 19:当前temperature值(0x19=25 摄氏度)
- E9 C0:CRC verification码
返回data包:01 06 00 02 00 19 E9 C0
4.1.3 读取锁register
senddata包:01 03 00 07 00 01 01
sendParse:
- 01:Device address
- 03:读取function code
- 00 07:开始register address
- 00 01:读取number of registers
返回data包:01 03 02 00 01 79 84
返回Parse:
- 01:Device address
- 03:读取function code
- 02:返回dataquantity
- 00 01:锁状态(0x00 Close,0x01 Open)
- 79 84:CRC verification码
4.1.4 写锁register
senddata包:01 06 00 07 00 00
sendParse:
- 01:Device address
- 06:写入function code
- 00 07:按键锁register address
- 00 00:Close锁(00),01 为锁
返回data包:01 06 00 07 00 00 38 0B
发表回复