我是 DSP 新手,正在学习一些东西,并在这里寻求专家的一些建议。我正在使用 CMSIS DSP lib 来获取 10 Hz + 30 Hz 组合的虚拟输入信号的频率响应。下面是我正在使用的代码。
#include "arm_math.h"
#include "arm_const_structs.h"
/* std */
#include <stdio.h>
/* --------------------------------------------------------------------------------------
* CMSIS DSP related
* -------------------------------------------------------------------------------------- */
float32_t input[2048] = { // combination of 10 Hz and 30 Hz signals
};
float32_t output[2048] = {0};
uint32_t fftSize = 1024; // fft size
uint32_t ifftFlag = false; // forward fft i.e. time--->frequency
uint32_t doBitReverse = true; // enable bit reversal
/* --------------------------------------------------------------------------------------
* Main
* -------------------------------------------------------------------------------------- */
int main(void)
{
...
for(uint16_t i = 0 ; i < fftSize ; i = i+2){
//input[i] = 0.000000000000000;
}
INV_MSG(INV_MSG_LEVEL_INFO, "[Input]===>");
for(uint16_t i = 0, j = 1 ; i < fftSize ; i++, j++){
INV_MSG(INV_MSG_LEVEL_INFO, "%hu ,%f\r", j, input[i]);
inv_delay_ms(1);
}
arm_cfft_f32(&arm_cfft_sR_f32_len512, input, ifftFlag, doBitReverse); // Process the data through the CFFT/CIFFT module
arm_cmplx_mag_f32(input, output, fftSize / 2); // Process the data through the Complex Magnitude Module for calculating the magnitude at each bin
INV_MSG(INV_MSG_LEVEL_INFO, "================");
INV_MSG(INV_MSG_LEVEL_INFO, "[Magnitude]===>");
INV_MSG(INV_MSG_LEVEL_INFO, "================");
for(uint16_t i = 0 ; i < fftSize / 2 ; i++){
INV_MSG(INV_MSG_LEVEL_INFO, "%f", output[i]);
inv_delay_ms(1);
}
while(1);
}
我在这里有两个案例(更多细节、波形等显示在附加的电子表格/下图中)。案例 1 显示了输入样本的响应,其中 real 和 img 交错且 img 值为 0。案例 2 也是如此,只是这次输入样本只有实数值。
问题 1:输入数据 Case-1 或 Case-2 的正确方法是什么?
问题 2:为什么 Case-1 和 Case-2 的响应相同,而输入的填充方式如上所述不同?
问题 3:我们应该在 10 Hz 和 30 Hz 处看到峰值,但在图中,我们可以看到它略有变化 - 关于为什么会发生这种情况以及如何获得更好结果的任何见解?