FFT算法查表法.docx
- 文档编号:2243606
- 上传时间:2022-10-28
- 格式:DOCX
- 页数:9
- 大小:17.96KB
FFT算法查表法.docx
《FFT算法查表法.docx》由会员分享,可在线阅读,更多相关《FFT算法查表法.docx(9页珍藏版)》请在冰豆网上搜索。
FFT算法查表法
ARM或单片机用的FFT算法,用于信号处理。
经过愚昧的本人优化,提高了计算效率
(在aduc7026@41MHzFFT256点环境下运算时间为0.06s左右)
PS:
以下有两部分(fft.h和fft.c)
【复制以下内容改名为fft.h】
#ifndef__FFT_H__
#define__FFT_H__
#include
#ifdefFFT_GLOBALS
#defineFFT_EXT
#else
#defineFFT_EXTextern
#endif
#definePI3.1415926
#defineFFT_POINT8//设置点数(此值变,下面的也要变)(0~11)
#defineSAMPLE_NUM256//可设256或512两种数
//count[n]
//count[]={1,2,4,8,16,32,64,128,256,512,1024,2048}
FFT_EXTfloatdataR[SAMPLE_NUM];
FFT_EXTfloatdataI[SAMPLE_NUM];
FFT_EXTvoidSetData(floatdata,unsignedinti);//采集数据到第i个点(0~SAMPLE_NUM)
FFT_EXTvoidFFT(void);//采样来的数据放在dataR[]数组中
//***************FFT结果数值处理*******************************************************
//计算和返回峰(模)值,k表示第几个值(0~SAMPLE_NUM-1),type为0返回峰值,1返回模值,2返回有效值
FFT_EXTfloatGetPeak(unsignedintk,unsignedinttype);
//FFT_EXTfloatGetPhase(unsignedintk,unsignedinttype);//计算和返回相位,k同上
//type为0返回角度,1返回弧度
//speed为采样速率,返回第k(0~SAMPLE_NUM)个点代表的频率
FFT_EXTfloatGetStepF(floatspeed,unsignedintk);
FFT_EXTfloatGetPower1(unsignedintk);//返回功率谱的第k点
FFT_EXTfloatGetPower2(unsignedintk,floattotal);//返回k点所占的功率百分比(单位是%)total为总功率
FFT_EXTfloatGetTotalPower(void);//计算功率谱总和
FFT_EXTfloatGetTHD(void);//计算失真度
#endif
///////////////////////////////////////////////////////////////////////////////
【复制以下内容改名为fft.c】
//查表式FFT算法
#defineFFT_GLOBALS
#include"fft.h"
#ifSAMPLE_NUM==256
constfloatsin_tab[256]={0.000000,0.024541,0.049068,0.073565,0.098017,0.122411,0.146730,0.170962,0.195090,0.219101,0.242980,0.266713,0.290285,0.313682,0.336890,0.359895,0.382683,
0.405241,0.427555,0.449611,0.471397,0.492898,0.514103,0.534998,0.555570,0.575808,0.595699,0.615232,0.634393,0.653173,0.671559,0.689541,0.707107,
0.724247,0.740951,0.757209,0.773010,0.788346,0.803208,0.817585,0.831470,0.844854,0.857729,0.870087,0.881921,0.893224,0.903989,0.914210,0.923880,
0.932993,0.941544,0.949528,0.956940,0.963776,0.970031,0.975702,0.980785,0.985278,0.989177,0.992480,0.995185,0.997290,0.998795,0.999699,1.000000,
0.999699,0.998795,0.997290,0.995185,0.992480,0.989177,0.985278,0.980785,0.975702,0.970031,0.963776,0.956940,0.949528,0.941544,0.932993,0.923880,
0.914210,0.903989,0.893224,0.881921,0.870087,0.857729,0.844854,0.831470,0.817585,0.803208,0.788346,0.773010,0.757209,0.740951,0.724247,0.707107,
0.689541,0.671559,0.653173,0.634393,0.615232,0.595699,0.575808,0.555570,0.534998,0.514103,0.492898,0.471397,0.449611,0.427555,0.405241,0.382683,
0.359895,0.336890,0.313682,0.290285,0.266713,0.242980,0.219101,0.195090,0.170962,0.146730,0.122411,0.098017,0.073565,0.049068,0.024541,0.000000,
-0.024541,-0.049068,-0.073565,-0.098017,-0.122411,-0.146730,-0.170962,-0.195090,-0.219101,-0.242980,-0.266713,-0.290285,-0.313682,-0.336890,-0.359895,-0.382683,
-0.405241,-0.427555,-0.449611,-0.471397,-0.492898,-0.514103,-0.534998,-0.555570,-0.575808,-0.595699,-0.615232,-0.634393,-0.653173,-0.671559,-0.689541,-0.707107,
-0.724247,-0.740951,-0.757209,-0.773010,-0.788346,-0.803208,-0.817585,-0.831470,-0.844854,-0.857729,-0.870087,-0.881921,-0.893224,-0.903989,-0.914210,-0.923880,
-0.932993,-0.941544,-0.949528,-0.956940,-0.963776,-0.970031,-0.975702,-0.980785,-0.985278,-0.989177,-0.992480,-0.995185,-0.997290,-0.998795,-0.999699,-1.000000,
-0.999699,-0.998795,-0.997290,-0.995185,-0.992480,-0.989177,-0.985278,-0.980785,-0.975702,-0.970031,-0.963776,-0.956940,-0.949528,-0.941544,-0.932993,-0.923880,
-0.914210,-0.903989,-0.893224,-0.881921,-0.870087,-0.857729,-0.844854,-0.831470,-0.817585,-0.803208,-0.788346,-0.773010,-0.757209,-0.740951,-0.724247,-0.707107,
-0.689541,-0.671559,-0.653173,-0.634393,-0.615232,-0.595699,-0.575808,-0.555570,-0.534998,-0.514103,-0.492898,-0.471397,-0.449611,-0.427555,-0.405241,-0.382683,
-0.359895,-0.336890,-0.313682,-0.290285,-0.266713,-0.242980,-0.219101,-0.195090,-0.170962,-0.146730,-0.122411,-0.098017,-0.073565,-0.049068,-0.024541};
#endif
#ifSAMPLE_NUM==512
constfloatsin_tab[512]={0.000000,0.012272,0.024541,0.036807,0.049068,0.061321,0.073565,0.085797,0.098017,0.110222,0.122411,0.134581,0.146730,0.158858,0.170962,0.183040,0.195090,0.207111,0.219101,0.231058,0.242980,0.254866,0.266713,0.278520,0.290285,0.302006,0.313682,0.325310,0.336890,0.348419,0.359895,0.371317,0.382683,
0.393992,0.405241,0.416430,0.427555,0.438616,0.449611,0.460539,0.471397,0.482184,0.492898,0.503538,0.514103,0.524590,0.534998,0.545325,0.555570,0.565732,0.575808,0.585798,0.595699,0.605511,0.615232,0.624859,0.634393,0.643832,0.653173,0.662416,0.671559,0.680601,0.689541,0.698376,0.707107,
0.715731,0.724247,0.732654,0.740951,0.749136,0.757209,0.765167,0.773010,0.780737,0.788346,0.795837,0.803208,0.810457,0.817585,0.824589,0.831470,0.838225,0.844854,0.851355,0.857729,0.863973,0.870087,0.876070,0.881921,0.887640,0.893224,0.898674,0.903989,0.909168,0.914210,0.919114,0.923880,
0.928506,0.932993,0.937339,0.941544,0.945607,0.949528,0.953306,0.9569
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- FFT 算法 查表法