feat(FOC): 添加快速电压检测功能和PWM调试模式
新增基于跌幅检测的快速电压保护机制,在100us周期内响应电压异常, 当电压跌幅超过阈值或低于绝对下限时立即关机保护。同时添加PWM输出 调试模式便于硬件测试。 BREAKING CHANGE: 重构了电压检测逻辑,采用峰值跟踪算法替代固 定阈值检测,提高在动态供电环境下的可靠性
This commit is contained in:
+5
-1
@@ -43,6 +43,7 @@ static FOCFunctionPtr control_functions[] = {
|
||||
&FOC_Controller::MIT_Mode, // 4: MIT 模式
|
||||
&FOC_Controller::current_control, // 5: 电流闭环控制
|
||||
&FOC_Controller::velocity_open_loop, // 6: 速度开环控制
|
||||
&FOC_Controller::PWM_out, // 0: 占空比置
|
||||
};
|
||||
int main(void) {
|
||||
u8 init_status = hardware_init();
|
||||
@@ -106,12 +107,15 @@ void do_task(u32 currentTasks) {
|
||||
if (currentTasks & (1 << TASK_MOTOR_CONTROL)) { // 电机控制任务 (最高优先级)
|
||||
motor_runtime_50us++;
|
||||
|
||||
// 快速电压检测(每100us执行一次,响应时间 < 200us)
|
||||
FOC.fast_voltage_check();
|
||||
|
||||
// 静态变量用于跟踪上一次的控制模式
|
||||
static int last_control_mode = -1;
|
||||
|
||||
// 边界检查,防止数组越界
|
||||
if (FOC.control_mode >= 0 &&
|
||||
FOC.control_mode < 7) { // 更新为 7 个控制模式
|
||||
FOC.control_mode < 8) { // 更新为 8 个控制模式
|
||||
|
||||
// 检查控制模式是否发生变化
|
||||
if (FOC.control_mode != last_control_mode) {
|
||||
|
||||
Reference in New Issue
Block a user