add valve functions

This commit is contained in:
murmur 2024-12-11 23:32:34 +08:00
parent 03e00b4099
commit 2c83a66633
2 changed files with 85 additions and 8 deletions

View File

@ -398,8 +398,74 @@ void DecodePumpStatusMsg(uint16_t reg4002) {
return 0;
}
// valve
/*
# 轮廓位置模式,配置流程
1.
00B1h=0 03C2h=0x01使
1.1 CIA402
1.2
2.
2.1 03E7h
2.2 03F8h (/s)
2.3 03FCh(/s2)
2.4 03FEh(/s2)
3.使使
0380h= 0x060x07 0x0F使
4.使
0380h= 0x2F0x3F
5.
03C8h ()
# 堵转找寻原点方式,配置流程
1.
0416h=37;17=18=
2.
0170h=3000172h=50
3.
00B1h=0 03C2h=0x06使
4.
0417h= 10000 (0419h)=1000;
5.
041Bh=200000
6.
(0380h)= 0x060x070x0F0x1F
*/
static uint8_t SetValveMode(uint8_t index, uint16_t mode) {
WritePump1Reg(index, RTU_VALVE_CMD_CTL_MODE, mode);
}
static uint8_t SetValveRunMode(uint8_t index, uint16_t mode) {
WritePump1Reg(index, RTU_VALVE_CMD_RUN_MODE, mode);
}
// PP=轮廓位置模式
static uint8_t SetValvePPPos(uint8_t index, uint16_t pos) {
WritePump1Reg(index, RTU_VALVE_CMD_PP_POS, pos);
}
static uint8_t SetValvePPSpeed(uint8_t index, uint16_t speed) {
WritePump1Reg(index, RTU_VALVE_CMD_PP_SPEED, speed);
}
static uint8_t SetValvePPAcc(uint8_t index, uint16_t acc) {
WritePump1Reg(index, RTU_VALVE_CMD_PP_ACCEL, acc);
}
static uint8_t SetValvePPDec(uint8_t index, uint16_t dec) {
WritePump1Reg(index, RTU_VALVE_CMD_PP_DECEL, dec);
}
// HM=原点回归模式
static uint8_t SetValveHomeMode(uint8_t index, uint16_t mode) {
WritePump1Reg(index, RTU_VALVE_CMD_HOME_MODE, mode);
}
static uint8_t SetValveHomeSpeed(uint8_t index, uint16_t speed) {
WritePump1Reg(index, RTU_VALVE_CMD_HOME_SPEED, speed);
}
static uint8_t SetValveHomeAcc(uint8_t index, uint16_t acc) {
WritePump1Reg(index, RTU_VALVE_CMD_HOME_ACCEL, acc);
}
static uint8_t SetValveFunc(uint8_t index, uint16_t func) {
WritePump1Reg(index, RTU_VALVE_CMD_FUNC, func);
}
// 定时1s更新设备状态
// 活度计通过网口获取

View File

@ -269,15 +269,26 @@ const uint8_t statusInfo[16][32]={
| 使 | 0380h |
+------------------------------------+------------+
*/
#define RTU_VALVE_CMD_CTL_MODE 0x00B1 // 阀门控制模式
#define RTU_VALVE_CMD_RUN_MODE 0x03C2 // 阀门运行模式
#define RTU_VALVE_CMD_ORIGIN_MODE 0x0416 // 阀门原点回归模式
#define RTU_VALVE_CMD_ORIGIN_SPEED 0x0417 // 阀门原点回归速度
#define RTU_VALVE_CMD_ORIGIN_ACCEL 0x041B // 阀门原点回归加速度
#define RTU_VALVE_CMD_ENABLE 0x0380 // 阀门使能
#define RTU_VALVE_CMD_DISABLE 0x0380 // 阀门失能
#define RTU_VALVE_CMD_RUN_ORIGIN 0x0380 // 阀门运行原点回归
#define RTU_VALVE_CMD_CTL_MODE 0x00B1 // 阀门控制模式
#define RTU_VALVE_CMD_RUN_MODE 0x03C2 // 阀门运行模式
#define RTU_VALVE_CMD_PP_POS 0x03E7 // 阀门轮廓位置
#define RTU_VALVE_CMD_PP_SPEED 0x03F8 // 阀门轮廓速度
#define RTU_VALVE_CMD_PP_ACCEL 0x03FC // 阀门轮廓加速度
#define RTU_VALVE_CMD_PP_DECEL 0x03FE // 阀门轮廓减速度
#define RTU_VALVE_CMD_HOME_MODE 0x0416 // 阀门原点回归方式
#define RTU_VALVE_CMD_HOME_SPEED 0x0417 // 阀门原点回归速度
#define RTU_VALVE_CMD_HOME_ACCEL 0x041B // 阀门原点回归加速度
#define RTU_VALVE_CMD_FUNC 0x0380 // 阀门控制
#define RTU_VALVE_CFG_CTL_CIA402 0x0000 // 为CIA402模式
#define RTU_VALVE_CFG_MODE_HM 0x0001 // 原点回归模式(HM)
#define RTU_VALVE_CFG_MODE_PP 0x0006 // 轮廓位置模式(PP)
#define RTU_VALVE_CFG_ENABLE 0x0006 // 准备
#define RTU_VALVE_CFG_DISABLE 0x0007 // 失能
#define RTU_VALVE_CFG_RUN 0x000F // 运行
#define RTU_VALVE_CFG_RUN_ORIGIN 0x001F // 运行原点回归
// 错误码定义
typedef enum {