补偿FIR滤波器的相位延时

This commit is contained in:
hua buduo 2024-11-15 22:23:20 +08:00
parent 44d1520ac2
commit 3d1d4ef834
3 changed files with 10 additions and 9 deletions

View File

@ -121,9 +121,9 @@ float32_t cal_tof(q15_t* x,uint32_t len)
/*****************滤波器**********/ /*****************滤波器**********/
arm_mean_q15(x,50,&dc_offset); // arm_mean_q15(x,50,&dc_offset);
// 信号减去直流分量 // // 信号减去直流分量
arm_offset_q15(x,-dc_offset,x,len); // arm_offset_q15(x,-dc_offset,x,len);
// 转换成浮点数 // 转换成浮点数
// arm_q15_to_float(x,buf,len); // arm_q15_to_float(x,buf,len);
@ -423,8 +423,8 @@ void wind_task(void const * argument)
// dtof = 0; // dtof = 0;
}else{ }else{
// 计算成us // 计算成us
tofx = (tofx/ADC_SAMP_RATE_MHz)+REV_MUTE_DELAY_US-1.0f/DRIVE_FREQ_MHz+0.0001f; tofx = ((tofx-FIR_PHASE_DELAY)/ADC_SAMP_RATE_MHz)+REV_MUTE_DELAY_US-1.0f/DRIVE_FREQ_MHz+0.0001f;
tofy = (tofy/ADC_SAMP_RATE_MHz)+REV_MUTE_DELAY_US-1.0f/DRIVE_FREQ_MHz+0.0001f; tofy = ((tofy-FIR_PHASE_DELAY)/ADC_SAMP_RATE_MHz)+REV_MUTE_DELAY_US-1.0f/DRIVE_FREQ_MHz+0.0001f;
// 通过各通道渡越时间求时间差 // 通过各通道渡越时间求时间差
dtof = tofx-tofy; dtof = tofx-tofy;
@ -470,8 +470,8 @@ void wind_task(void const * argument)
}else{ }else{
// 计算成us // 计算成us
tofx = tofx/ADC_SAMP_RATE_MHz+REV_MUTE_DELAY_US-1.0f/DRIVE_FREQ_MHz+0.000001f; tofx = ((tofx-FIR_PHASE_DELAY)/ADC_SAMP_RATE_MHz)+REV_MUTE_DELAY_US-1.0f/DRIVE_FREQ_MHz+0.000001f;
tofy = tofy/ADC_SAMP_RATE_MHz+REV_MUTE_DELAY_US-1.0f/DRIVE_FREQ_MHz+0.000001f; tofy = ((tofy-FIR_PHASE_DELAY)/ADC_SAMP_RATE_MHz)+REV_MUTE_DELAY_US-1.0f/DRIVE_FREQ_MHz+0.000001f;
// 通过各通道渡越时间求时间差 // 通过各通道渡越时间求时间差
dtof = tofx-tofy; dtof = tofx-tofy;
} }
@ -509,7 +509,7 @@ void wind_task(void const * argument)
av_speed = 0; av_speed = 0;
av_angle = 0; av_angle = 0;
} }
/// term_printf("x:%.2f y:%.2f win_speed %.2f m/s angle %.2f \r\n",av_speedx,av_speedy,av_speed,av_angle); term_printf("x:%.2f y:%.2f win_speed %.2f m/s angle %.2f \r\n",av_speedx,av_speedy,av_speed,av_angle);
} }
///term_printf("win_speed %.2f \r\n",weather_info.wind_velocity); ///term_printf("win_speed %.2f \r\n",weather_info.wind_velocity);

View File

@ -9,6 +9,7 @@
#define numTaps 60 #define numTaps 60
#define FIR_PHASE_DELAY ((numTaps-2)/2)
//const float B[numTaps] = { //const float B[numTaps] = {
// 0.01000739448,-0.0008298238972,-0.002934818622,-0.005351484753,-0.006882067304, // 0.01000739448,-0.0008298238972,-0.002934818622,-0.005351484753,-0.006882067304,
// -0.006692492869,-0.004794952925,-0.002162534744,-0.000337747857,-0.0006400240236, // -0.006692492869,-0.004794952925,-0.002162534744,-0.000337747857,-0.0006400240236,