参考网上的例子使用stm32f103的dsp库进行FFT运算:http://heroxx.blog.163.com/blog/static/5423580201071110383980/
模拟输入信号为:包含3种频率正弦波(50Hz,2500Hz,2550Hz),幅值为均为4000
fx = 4000 * sin(PI2*i*50.0/Fs) + 4000 * sin(PI2*i*2500.0/Fs)+ 4000*sin(PI2*i*2550.0/Fs);
lBUFIN = ((signed short)fx) << 16;
64点FFt,采样率3200Hz
幅值计算: void GetPowerMag()
{
signed short lX,lY;
float X,Y,Mag;
unsigned short i;
for(i=0; i<NPT/2; i++)
{
lX = (lBUFOUT << 16) >> 16;
lY = (lBUFOUT >> 16);
X = NPT * ((float)lX) / 32768;
Y = NPT * ((float)lY) / 32768;
Mag = sqrt(X * X + Y * Y) / NPT;
lBUFMAG = (u32)(Mag * 65536);
}
}
计算幅值结果如作者图:
请问如何根据以上数据出现的峰值或其他方法验证它的正确性呢? 请大神指导指导,谢谢!!:)
|