实现完整串口指令协议:模式切换、手动控制、PID在线调参
- 新增 PIDClear() 仅清运行时状态,保留 Kp/Ki/Kd 等配置 - 命令帧 0xA7 (3B): 自动/手动/调试三模式切换,带模式状态追踪 - 手动控制帧 0xA6 (8B): 解析 motor_speed_base(int16) + angle_velocity(float) - 调试调参帧 0xA8 (38B): 在线更新全部9个 Kp/Ki/Kd 参数 - Command 解析纳入 Task_50ms (20Hz) 定时执行 - 添加通信协议文档 docs/通信协议.md
This commit is contained in:
@@ -143,6 +143,30 @@ void PIDInit(PIDInstance *pid, PID_Init_Config_s *config)
|
||||
pid->dt = config->T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 清除PID运行时状态(积分、误差、输出等),保留配置参数不变
|
||||
*
|
||||
* @param pid PID实例指针
|
||||
*/
|
||||
void PIDClear(PIDInstance *pid)
|
||||
{
|
||||
pid->Measure = 0;
|
||||
pid->Last_Measure = 0;
|
||||
pid->Err = 0;
|
||||
pid->Last_Err = 0;
|
||||
pid->Last_ITerm = 0;
|
||||
pid->Pout = 0;
|
||||
pid->Iout = 0;
|
||||
pid->Dout = 0;
|
||||
pid->ITerm = 0;
|
||||
pid->Output = 0;
|
||||
pid->Last_Output = 0;
|
||||
pid->Last_Dout = 0;
|
||||
pid->Ref = 0;
|
||||
pid->ERRORHandler.ERRORCount = 0;
|
||||
pid->ERRORHandler.ERRORType = PID_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PID计算
|
||||
* @param[in] PID结构体
|
||||
|
||||
Reference in New Issue
Block a user