add ReadPumpCNT
This commit is contained in:
parent
057a7706a7
commit
7cfe960bd5
11
protocol.c
11
protocol.c
@ -597,9 +597,14 @@ static uint8_t StopPump(uint8_t index) {
|
|||||||
* @param index 泵索引
|
* @param index 泵索引
|
||||||
* @return 0:成功 其他:失败
|
* @return 0:成功 其他:失败
|
||||||
*/
|
*/
|
||||||
uint8_t ReadPumpHWReg(uint8_t index) {
|
uint16_t ReadPumpHWReg(uint8_t index) {
|
||||||
return ReadPump1Reg(dp.pump[index].id, RTU_PUMP_CMD_HW);
|
return ReadPump1Reg(dp.pump[index].id, RTU_PUMP_CMD_HW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t ReadPumpCNT(uint8_t index) {
|
||||||
|
return ReadPump1Reg(dp.pump[index].id, RTU_PUMP_CMD_CNT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置泵的通信波特率
|
* 设置泵的通信波特率
|
||||||
*
|
*
|
||||||
@ -1589,7 +1594,9 @@ static uint8_t HandlePumpTimeControl(uint8_t *Buff, uint8_t len) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 使用步数方式更靠谱,通过时间和速度计算步数,结束时不用发送停止命令
|
// 使用步数方式更靠谱,通过时间和速度计算步数,结束时不用发送停止命令
|
||||||
int32_t step = direction*time*systemStatus.pumpsSpeed[index]*PUMP_SPEED_RPS;
|
uint16_t cnt = ReadPumpCNT(index);//8000
|
||||||
|
log_d("cnt=%d",cnt);
|
||||||
|
int32_t step = direction*time*systemStatus.pumpsSpeed[index]*cnt;
|
||||||
StopPump(index);//stop first
|
StopPump(index);//stop first
|
||||||
SetPumpStepTarget(index, step);
|
SetPumpStepTarget(index, step);
|
||||||
StartPumpRelativeMove(index);
|
StartPumpRelativeMove(index);
|
||||||
|
@ -214,6 +214,7 @@ static const uint8_t statusInfo[16][60]={
|
|||||||
#define RTU_PUMP_CMD_VE 0x001D // 速度
|
#define RTU_PUMP_CMD_VE 0x001D // 速度
|
||||||
#define RTU_PUMP_CMD_DI 0x001E // 目标位置
|
#define RTU_PUMP_CMD_DI 0x001E // 目标位置
|
||||||
#define RTU_PUMP_CMD_HW 0x006C // 硬件版本40109
|
#define RTU_PUMP_CMD_HW 0x006C // 硬件版本40109
|
||||||
|
#define RTU_PUMP_CMD_CNT 0X0034 //每转所需脉冲数
|
||||||
#define RTU_PUMP_CMD_BR 0x0094 //波特率BR,40149
|
#define RTU_PUMP_CMD_BR 0x0094 //波特率BR,40149
|
||||||
#define RTU_PUMP_CMD_PR 0x0095 //通信协议PR,40150
|
#define RTU_PUMP_CMD_PR 0x0095 //通信协议PR,40150
|
||||||
#define RTU_PUMP_CMD_SPEED 0x000A //瞬时实际速度,40011
|
#define RTU_PUMP_CMD_SPEED 0x000A //瞬时实际速度,40011
|
||||||
|
Loading…
Reference in New Issue
Block a user