feat(FOC): 优化FOC控制逻辑与热管理机制
- 移除冗余的三值约束宏定义 `_constrain3` - 修改关机逻辑,引入 `thermal_uncontrol` 标志替代旧 shut_down 计数方式 - 调整恢复函数中错误标志位清零逻辑 - 将部分 uint8_t 类型成员变量改为 bool 类型以提高可读性 - 在类中添加电源电压成员变量并调整 PID 参数初始化 - 移除 PID 控制器中不必要的 CAN 测试代码 - 添加 thermal 控制相关文件引用及初始化 - 使用 switch 替代多重 if-else 提高控制模式处理效率 - 引入基于定时器的任务负载均衡调度机制 - 初始化热量控制器并在主循环中调用更新逻辑
This commit is contained in:
@@ -7,17 +7,17 @@ class FOC_Controlroller {
|
||||
public:
|
||||
FOC_Controlroller();
|
||||
|
||||
float control_mode = 0;
|
||||
u8 control_mode = 0;
|
||||
float limit_voltage = 0.0f;
|
||||
float limit_velocity = 0.0f;
|
||||
float target_angle = 0.0f;
|
||||
float target_velocity = 0.0f;
|
||||
float rt_angle = 0.0f;
|
||||
float rt_velocity = 0.0f;
|
||||
u8 over_current = 0;
|
||||
u8 temp_error = 0;
|
||||
u8 voltage_error = 0;
|
||||
u8 is_shut_down = 0;
|
||||
bool thermal_uncontrol = 0;
|
||||
bool voltage_error = 0;
|
||||
bool is_shut_down = 0;
|
||||
float voltage_power_supply = 24.0f; // 电源电压
|
||||
|
||||
float velocity_open_loop();
|
||||
float angle_control(float target_angle);
|
||||
@@ -35,10 +35,9 @@ class FOC_Controlroller {
|
||||
float shaft_angle = 0;
|
||||
float Ualpha, Ubeta = 0, Ua = 0, Ub = 0, Uc = 0;
|
||||
float zero_electric_angle = 0;
|
||||
float voltage_power_supply = 24.0f; // 电源电压
|
||||
float v_half = voltage_power_supply * 0.5f; // 电源电压的一半
|
||||
|
||||
PIDController vel_loop =PIDController{1.75f, 1.0f, 0.0002f, 1000000, voltage_power_supply};
|
||||
PIDController vel_loop =PIDController{1.8f, 1.2f, 0.0002f, 1000000, voltage_power_supply};
|
||||
PIDController angle_loop =
|
||||
PIDController{140.0f, 80.0f, 0.005f, 10000000, voltage_power_supply};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user