feat(FOC): 实现电角度零位自动校准并修复ADC采样干扰问题
- 新增FlashEEPROM用于保存零位校准角,掉电不丢失 - 实现安全的零位校准算法:运行中禁止校准、对齐后重新采样、保存到Flash - 重构ADC架构:分离ADC0(PWM同步电流采样)和ADC1(VBUS/DRV温度轮询) - 解决ADC采样冲突:移除ADC0的regular连续扫描,避免与注入组抢占资源 - 修复VBUS电压读取错误:从DMA缓冲区改为直接ADC1单次转换 - 修正开环控制Uq幅值限幅逻辑,保留符号避免反转时抖动 - 更新CAN协议:电流数据改为有符号16位打包,支持负电流传输 - 调整版本号至v26.8.16.7
This commit is contained in:
@@ -1043,9 +1043,9 @@ u8 CAN_transmiter::CANFD_all_Send() {
|
||||
memset(transmit_data, 0, 32);
|
||||
pack_u16_to_bytes(transmit_data, 0, mcu_temp);
|
||||
pack_u16_to_bytes(transmit_data, 2, motor_temp);
|
||||
pack_u16_to_bytes(transmit_data, 4, u16(u_current_union.f));
|
||||
pack_u16_to_bytes(transmit_data, 6, u16(v_current_union.f));
|
||||
pack_u16_to_bytes(transmit_data, 8, u16(w_current_union.f));
|
||||
pack_current_s16_to_bytes(transmit_data, 4, u_current_union.f);
|
||||
pack_current_s16_to_bytes(transmit_data, 6, v_current_union.f);
|
||||
pack_current_s16_to_bytes(transmit_data, 8, w_current_union.f);
|
||||
transmit_data[10] =
|
||||
(transmit_data[10] & ~0x07) |
|
||||
((MotorStatus & 0x01) | ((MagStatus & 0x01) << 1) |
|
||||
@@ -1277,6 +1277,10 @@ void CAN_transmiter::handle_reset_command(can_receive_message_struct ¤t_me
|
||||
Angle_kalman.init(0);
|
||||
Vel_kalman.init(0);
|
||||
}
|
||||
if (first_byte >> 5 & 0x01) {
|
||||
// 零位校准:施加对齐电压、读传感器角、计算并保存校准角
|
||||
calibrate_zero_position();
|
||||
}
|
||||
#if FOC_DEBUG
|
||||
if (first_byte >> 4 & 0x01) {
|
||||
FOC.cogging_calib_request = true;
|
||||
|
||||
Reference in New Issue
Block a user