完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
FFT是DFT的快速计算方法,在信号处理中具有“万金油”一般的作用。在STM32中依然能够对信号进行快速傅里叶变换,从而把信号的特征从频域很好地展现出来。本程序利用固定数组进行256点FFT运算,对STM32的硬件和外围设备初始化不再介绍。
平台:STM32F103C8T6 库:标准固件库V3.5.0 DSP库:V.1.4.5 单片机内调用的DSP函数为复数FFT运算,也就是说,256点的FFT需要将256个复数输入算法,得到256点复数后再求模值即可。 需要注意的是,最后需将倒序的运算结果重新排序为正序。 准备工作: 正余弦表: 1.0f,0.0f, 0.999699f,0.0245412f, 0.998795f,0.0490677f, 0.99729f,0.0735646f, 0.995185f,0.0980171f, 0.99248f,0.122411f, 0.989177f,0.14673f, 0.985278f,0.170962f, 0.980785f,0.19509f, 0.975702f,0.219101f, 0.970031f,0.24298f, 0.963776f,0.266713f, 0.95694f,0.290285f, 0.949528f,0.313682f, 0.941544f,0.33689f, 0.932993f,0.359895f, 0.92388f,0.382683f, 0.91421f,0.405241f, 0.903989f,0.427555f, 0.893224f,0.449611f, 0.881921f,0.471397f, 0.870087f,0.492898f, 0.857729f,0.514103f, 0.844854f,0.534998f, 0.83147f,0.55557f, 0.817585f,0.575808f, 0.803208f,0.595699f, 0.788346f,0.615232f, 0.77301f,0.634393f, 0.757209f,0.653173f, 0.740951f,0.671559f, 0.724247f,0.689541f, 0.707107f,0.707107f, 0.689541f,0.724247f, 0.671559f,0.740951f, 0.653173f,0.757209f, 0.634393f,0.77301f, 0.615232f,0.788346f, 0.595699f,0.803208f, 0.575808f,0.817585f, 0.55557f,0.83147f, 0.534998f,0.844854f, 0.514103f,0.857729f, 0.492898f,0.870087f, 0.471397f,0.881921f, 0.449611f,0.893224f, 0.427555f,0.903989f, 0.405241f,0.91421f, 0.382683f,0.92388f, 0.359895f,0.932993f, 0.33689f,0.941544f, 0.313682f,0.949528f, 0.290285f,0.95694f, 0.266713f,0.963776f, 0.24298f,0.970031f, 0.219101f,0.975702f, 0.19509f,0.980785f, 0.170962f,0.985278f, 0.14673f,0.989177f, 0.122411f,0.99248f, 0.0980171f,0.995185f, 0.0735646f,0.99729f, 0.0490677f,0.998795f, 0.0245412f,0.999699f, 6.12323e-17f,1.0f, -0.0245412f,0.999699f, -0.0490677f,0.998795f, -0.0735646f,0.99729f, -0.0980171f,0.995185f, -0.122411f,0.99248f, -0.14673f,0.989177f, -0.170962f,0.985278f, -0.19509f,0.980785f, -0.219101f,0.975702f, -0.24298f,0.970031f, -0.266713f,0.963776f, -0.290285f,0.95694f, -0.313682f,0.949528f, -0.33689f,0.941544f, -0.359895f,0.932993f, -0.382683f,0.92388f, -0.405241f,0.91421f, -0.427555f,0.903989f, -0.449611f,0.893224f, -0.471397f,0.881921f, -0.492898f,0.870087f, -0.514103f,0.857729f, -0.534998f,0.844854f, -0.55557f,0.83147f, -0.575808f,0.817585f, -0.595699f,0.803208f, -0.615232f,0.788346f, -0.634393f,0.77301f, -0.653173f,0.757209f, -0.671559f,0.740951f, -0.689541f,0.724247f, -0.707107f,0.707107f, -0.724247f,0.689541f, -0.740951f,0.671559f, -0.757209f,0.653173f, -0.77301f,0.634393f, -0.788346f,0.615232f, -0.803208f,0.595699f, -0.817585f,0.575808f, -0.83147f,0.55557f, -0.844854f,0.534998f, -0.857729f,0.514103f, -0.870087f,0.492898f, -0.881921f,0.471397f, -0.893224f,0.449611f, -0.903989f,0.427555f, -0.91421f,0.405241f, -0.92388f,0.382683f, -0.932993f,0.359895f, -0.941544f,0.33689f, -0.949528f,0.313682f, -0.95694f,0.290285f, -0.963776f,0.266713f, -0.970031f,0.24298f, -0.975702f,0.219101f, -0.980785f,0.19509f, -0.985278f,0.170962f, -0.989177f,0.14673f, -0.99248f,0.122411f, -0.995185f,0.0980171f, -0.99729f,0.0735646f, -0.998795f,0.0490677f, -0.999699f,0.0245412f, -1.0f,1.22465e-16f, -0.999699f,-0.0245412, -0.998795f,-0.0490677, -0.99729f,-0.0735646f, -0.995185f,-0.0980171, -0.99248f,-0.122411f, -0.989177f,-0.14673f, -0.985278f,-0.170962f, -0.980785f,-0.19509f, -0.975702f,-0.219101f, -0.970031f,-0.24298f, -0.963776f,-0.266713f, -0.95694f,-0.290285f, -0.949528f,-0.313682f, -0.941544f,-0.33689f, -0.932993f,-0.359895f, -0.92388f,-0.382683f, -0.91421f,-0.405241f, -0.903989f,-0.427555f, -0.893224f,-0.449611f, -0.881921f,-0.471397f, -0.870087f,-0.492898f, -0.857729f,-0.514103f, -0.844854f,-0.534998f, -0.83147f,-0.55557f, -0.817585f,-0.575808f, -0.803208f,-0.595699f, -0.788346f,-0.615232f, -0.77301f,-0.634393f, -0.757209f,-0.653173f, -0.740951f,-0.671559f, -0.724247f,-0.689541f, -0.707107f,-0.707107f, -0.689541f,-0.724247f, -0.671559f,-0.740951f, -0.653173f,-0.757209f, -0.634393f,-0.77301f, -0.615232f,-0.788346f, -0.595699f,-0.803208f, -0.575808f,-0.817585f, -0.55557f,-0.83147f, -0.534998f,-0.844854f, -0.514103f,-0.857729f, -0.492898f,-0.870087f, -0.471397f,-0.881921f, -0.449611f,-0.893224f, -0.427555f,-0.903989f, -0.405241f,-0.91421f, -0.382683f,-0.92388f, -0.359895f,-0.932993f, -0.33689f,-0.941544f, -0.313682f,-0.949528f, -0.290285f,-0.95694f, -0.266713f,-0.963776f, -0.24298f,-0.970031f, -0.219101f,-0.975702f, -0.19509f,-0.980785f, -0.170962f,-0.985278f, -0.14673f,-0.989177f, -0.122411f,-0.99248f, -0.0980171f,-0.995185, -0.0735646f,-0.99729f, -0.0490677f,-0.998795, -0.0245412f,-0.999699, -1.83697e-16f,-1.0f, 0.0245412f,-0.999699f, 0.0490677f,-0.998795f, 0.0735646f,-0.99729f, 0.0980171f,-0.995185f, 0.122411f,-0.99248f, 0.14673f,-0.989177f, 0.170962f,-0.985278f, 0.19509f,-0.980785f, 0.219101f,-0.975702f, 0.24298f,-0.970031f, 0.266713f,-0.963776f, 0.290285f,-0.95694f, 0.313682f,-0.949528f, 0.33689f,-0.941544f, 0.359895f,-0.932993f, 0.382683f,-0.92388f, 0.405241f,-0.91421f, 0.427555f,-0.903989f, 0.449611f,-0.893224f, 0.471397f,-0.881921f, 0.492898f,-0.870087f, 0.514103f,-0.857729f, 0.534998f,-0.844854f, 0.55557f,-0.83147f, 0.575808f,-0.817585f, 0.595699f,-0.803208f, 0.615232f,-0.788346f, 0.634393f,-0.77301f, 0.653173f,-0.757209f, 0.671559f,-0.740951f, 0.689541f,-0.724247f, 0.707107f,-0.707107f, 0.724247f,-0.689541f, 0.740951f,-0.671559f, 0.757209f,-0.653173f, 0.77301f,-0.634393f, 0.788346f,-0.615232f, 0.803208f,-0.595699f, 0.817585f,-0.575808f, 0.83147f,-0.55557f, 0.844854f,-0.534998f, 0.857729f,-0.514103f, 0.870087f,-0.492898f, 0.881921f,-0.471397f, 0.893224f,-0.449611f, 0.903989f,-0.427555f, 0.91421f,-0.405241f, 0.92388f,-0.382683f, 0.932993f,-0.359895f, 0.941544f,-0.33689f, 0.949528f,-0.313682f, 0.95694f,-0.290285f, 0.963776f,-0.266713f, 0.970031f,-0.24298f, 0.975702f,-0.219101f, 0.980785f,-0.19509f, 0.985278f,-0.170962f, 0.989177f,-0.14673f, 0.99248f,-0.122411f, 0.995185f,-0.0980171f, 0.99729f,-0.0735646f, 0.998795f,-0.0490677f, 0.999699f,-0.0245412f 调用arm_cfft_radix4_f32.c文件内的void arm_radix4_butterfly_f32(float * pSrc,uint16_t fftLen,const float * pCoef,uint16_t twidCoefModifier);函数,在这个函数中,*pSrc指向原始数据,fftLen为FFT点数,twiddleCoef为正余弦表,最后一个形参赋值为1即可。 进行完毕FFT转换后,结果为倒序,再通过Rader arithmetic 转换,算法原型如下(忘记出处了。。。): int array[8]={0,1,2,3,4,5,6,7}; int i,j,k; int N = 8; int temp; j = 0; for(i = 0; i < N -1; i ++) { if(i < j) { temp = array; array = array[j]; array[j] = temp; } k = N >> 1; while( k <= j) { j = j - k; k >>= 1; } j = j + k; } for( i = 0; i < N; i ++) printf("%d ",array); printf("n"); return 0; 进行到这里,FFT运算已经完成了,接下来对这个结果在Matlab中进行验证,得出误差在0.00001,符合精度要求。如果进行512点,1024点,2048点FFT,则需要将表进行更换再计算。由于本次只进行了256点的FFT,所以,其他的正余弦表不再贴出。 |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1618 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1545 浏览 1 评论
979 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
683 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1597 浏览 2 评论
1864浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
645浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
516浏览 3评论
532浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
505浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 19:09 , Processed in 0.851879 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号