A lot of logic has been updated for the v1.6 protocol
This commit is contained in:
parent
93c676e1cb
commit
13781723e0
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.vscode/*
|
||||
tasks.json
|
||||
|
839
protocol.c
839
protocol.c
File diff suppressed because it is too large
Load Diff
45
protocol.h
45
protocol.h
@ -19,8 +19,8 @@
|
||||
#define FRAME_HEADER 0xA55A5AA5
|
||||
#define FRAME_TAIL 0x5AA5A55A
|
||||
#define READ_ACK_TIMEOUT 50
|
||||
#define ACK_OK 0x0001
|
||||
#define ACK_FAILED 0x0000
|
||||
#define ACK_OK 0x0000
|
||||
#define ACK_FAILED 0x0001
|
||||
#define ACK_OTHER 0x0002
|
||||
|
||||
// 功能码定义
|
||||
@ -347,9 +347,9 @@ typedef enum {
|
||||
|
||||
// 3. 泵状态
|
||||
typedef enum {
|
||||
PUMP_STOP = 0,
|
||||
PUMP_CLOCKWISE = 1,
|
||||
PUMP_ANTICLOCKWISE = 2
|
||||
PUMP_STATUS_STOP = 0,
|
||||
PUMP_STATUS_CLOCKWISE = 1,
|
||||
PUMP_STATUS_ANTICLOCKWISE = 2
|
||||
} PumpStatus;
|
||||
|
||||
// 4. 泵速度范围
|
||||
@ -377,16 +377,13 @@ typedef enum {
|
||||
|
||||
// 三通阀结构体
|
||||
typedef struct {
|
||||
uint8_t angle1; // 阀门1角度 (120/210)
|
||||
uint8_t angle2; // 阀门2角度 (120/210)
|
||||
uint8_t angle[2]; // 阀门角度 (120/210)
|
||||
} ValveStatus_t;
|
||||
|
||||
// 泵结构体
|
||||
typedef struct {
|
||||
uint8_t status1; // 泵1运行状态 (停止/顺时针/逆时针)
|
||||
uint8_t status2; // 泵2运行状态 (停止/顺时针/逆时针)
|
||||
uint8_t speed1; // 泵1速度百分比 (0-100)
|
||||
uint8_t speed2; // 泵2速度百分比 (0-100)
|
||||
uint8_t status[2]; // 泵运行状态 (停止/顺时针/逆时针)
|
||||
uint8_t speed[2]; // 泵速度百分比 (0-100),设置值
|
||||
} PumpStatus_t;
|
||||
|
||||
// 设备状态结构体,用于上报HOST
|
||||
@ -395,7 +392,8 @@ typedef struct {
|
||||
ValveStatus_t valves; // 两个三通阀状态
|
||||
PumpStatus_t pumps; // 两个泵状态
|
||||
uint8_t bubbleStatus; // 气泡状态
|
||||
uint8_t stopStatus; // 急停状态
|
||||
uint16_t activityMeter; // 活度计mCi
|
||||
uint8_t estopStatus; // 急停状态
|
||||
uint8_t errorCode; // 错误码
|
||||
uint8_t initStatus; // 初始化状态
|
||||
} DeviceStatus_t;
|
||||
@ -404,21 +402,28 @@ typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
DeviceStatus_t ds;
|
||||
uint32_t speed[4];//实时速度
|
||||
uint32_t pos[4];//实时位置
|
||||
uint32_t valvesSpeed[2];//实时速度
|
||||
uint8_t valvesSpeedPercent[2];//实时速度百分比
|
||||
uint32_t valvesPos[2];//实时位置
|
||||
uint32_t pumpsSpeed[2];//实时速度
|
||||
uint8_t pumpsSpeedPercent[2];//实时速度百分比
|
||||
uint32_t pumpsPos[2];//实时位置
|
||||
uint16_t rst;//RTU命令执行结果
|
||||
|
||||
} SystemStatus_t;
|
||||
} SystemStatus_t;//包含需要上报的状态及附加状态
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t name[20];
|
||||
uint8_t id;
|
||||
uint32_t maxSpeed;
|
||||
uint32_t maxAccel;
|
||||
uint32_t maxDecel;
|
||||
uint32_t speed;//满速
|
||||
uint32_t accel;
|
||||
uint32_t decel;
|
||||
uint16_t fullCount;//电机总步数,用于根据角度估算需要移动的步数
|
||||
int16_t offsetPos;//电机偏移位置,用于补偿电机移动误差
|
||||
uint8_t speedPercent;//设置速度百分比数,如100表示100%
|
||||
uint8_t torque;//堵转力矩百分比,堵转转矩阈值应大于找寻原点过程中的实际运行转矩,且一般应小于最大转矩,以避免触发堵转故障保护
|
||||
uint8_t timeout;//回归超时时间,单位s
|
||||
} MotorDefaultParam_t;
|
||||
|
||||
|
||||
@ -434,10 +439,8 @@ extern DeviceStatus_t deviceStatus;
|
||||
|
||||
// 函数声明
|
||||
void ProcessHostCommand(uint8_t *rxBuf, uint8_t rxLen);
|
||||
void DecodePumpAlarmMsg(uint16_t reg4001);
|
||||
void DecodePumpStatusMsg(uint16_t reg4002);
|
||||
void runPumpDemo(void);
|
||||
void runVavleDemo(void);
|
||||
void runValveDemo(void);
|
||||
void updateSystemStatus(void);
|
||||
void initCTLSystem(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user