add ReadPumpCNT

This commit is contained in:
CSSC-WORK\murmur 2025-01-03 11:25:55 +08:00
parent 057a7706a7
commit 7cfe960bd5
2 changed files with 10 additions and 2 deletions

View File

@ -597,9 +597,14 @@ static uint8_t StopPump(uint8_t index) {
* @param index
* @return 0: :
*/
uint8_t ReadPumpHWReg(uint8_t index) {
uint16_t ReadPumpHWReg(uint8_t index) {
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 {
// 使用步数方式更靠谱,通过时间和速度计算步数,结束时不用发送停止命令
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
SetPumpStepTarget(index, step);
StartPumpRelativeMove(index);

View File

@ -214,6 +214,7 @@ static const uint8_t statusInfo[16][60]={
#define RTU_PUMP_CMD_VE 0x001D // 速度
#define RTU_PUMP_CMD_DI 0x001E // 目标位置
#define RTU_PUMP_CMD_HW 0x006C // 硬件版本40109
#define RTU_PUMP_CMD_CNT 0X0034 //每转所需脉冲数
#define RTU_PUMP_CMD_BR 0x0094 //波特率BR40149
#define RTU_PUMP_CMD_PR 0x0095 //通信协议PR40150
#define RTU_PUMP_CMD_SPEED 0x000A //瞬时实际速度,40011