You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
2.8 KiB

# 新版线轴小板协议
## 寄存器介绍
| 名称 | 寄存器位数 | 值含义 |
| ------------- | -------------------- | ----------------------------------------------------- |
| K1继电器 | holdingRegisters[0] | 控制器继电器开关,1为开,0为关 |
| K2继电器 | holdingRegisters[1] | 控制器继电器开关,1为开,0为关 |
| K3继电器 | holdingRegisters[2] | 控制器继电器开关,1为开,0为关 |
| K4继电器 | holdingRegisters[3] | 控制器继电器开关,1为开,0为关 |
| 电源控制极性 | holdingRegisters[4] | 1表示反极性,即电源使能所代表的含义反转 |
| 电源控制模式 | holdingRegisters[5] | 1为手动,0为自动 |
| 电源使能 | holdingRegisters[6] | 1表示48V电源通电,0表示不通电 |
| 电源保护超时 | holdingRegisters[7] | 超时时间单位毫秒 |
| 电机转向 | holdingRegisters[8] | 1正转,0反转 |
| 电机速度 | holdingRegisters[9] | 转速单位rpm |
| flash保存魔数 | holdingRegisters[10] | 需要触发flash保存时置为0x37,保存成功后自动恢复成0x01 |
| 预留 | holdingRegisters[11] | 预留 |
## 通讯报文基本格式
注意下文所述的所有报文格式都需要在末尾加MODBUS-CRC16校验,这里统一说一下
### 读寄存器
| 0x34 | 0x03 | 0x00 | 0x01 | 0x00 | 0x02 |
| ------------------ | ------------------------ | -------------- | -------------- | -------------- | -------------- |
| 设备地址固定为0x34 | 命令字(0x03表示读寄存器) | 寄存器地址高位 | 寄存器地址低位 | 寄存器索引高位 | 寄存器索引低位 |
以上述报文为例表示从holdingRegisters[1]开始连续读两个寄存器的值,即 holdingRegisters[1]和holdingRegisters[2]的值
## 写单个寄存器
| 0x34 | 0x06 | 0x00 | 0x01 | 0x00 | 0x01 |
| ------------------ | ------------------------ | -------------- | -------------- | ------------ | ------------ |
| 设备地址固定为0x34 | 命令字(0x06表示写寄存器) | 寄存器位数高位 | 寄存器位数低位 | 写入的值高位 | 写入的值低位 |
以上述报文为例表示给 holdingRegisters[1]寄存器写入1这个值,对照寄存器介绍可知这将导致K2继电器开启
## 写多个寄存器