3.2 周期(頻率),幅值,相位分析
原理
FFT變換結(jié)果,幅值最大的橫坐標(biāo)對應(yīng)信號頻率,縱坐標(biāo)對應(yīng)幅度。幅值最大的為out[m]=val;則信號頻率f0=(Fs/N)m ,信號幅值Vpp=val/(N/2)。N為FFT的點(diǎn)數(shù),F(xiàn)s為采樣頻率。相位Pha=atan2(a, b)弧度制,其中ab是輸出虛數(shù)結(jié)果的實(shí)部和虛部。
添加命令行
shell_fun.h中
void FrqFun(void* param);
shell_fun.c中
#include "frq.h"
shell_cmd_list中添加一行
{ (const uint8_t*)"frt", FrqFun, "frq"},
添加命令執(zhí)行函數(shù)
void FrqFun(void* param)
{
Frq_main();
}
實(shí)現(xiàn)代碼
Frq.c
#include "arm_math.h"
#include "arm_const_structs.h"
#include < stdio.h >
#define TEST_LENGTH_SAMPLES 2048
#define FS 10000
extern float32_t testInput_f32_10khz[TEST_LENGTH_SAMPLES];
static float32_t testOutput[TEST_LENGTH_SAMPLES/2];
static uint32_t fftSize = 1024;
static uint32_t ifftFlag = 0;
static uint32_t doBitReverse = 1;
static arm_cfft_instance_f32 varInstCfftF32;
static int testIndex = 0;
static float testtmp_f32_10khz[2048];
static int32_t adcbuffer[2048];
int32_t frq_main(void)
{
arm_status status;
float32_t maxValue;
status = ARM_MATH_SUCCESS;
status=arm_cfft_init_f32(&varInstCfftF32,fftSize);
//memcpy(testtmp_f32_10khz,testInput_f32_10khz,sizeof(testInput_f32_10khz));
adc_samp(adcbuffer,2048);
for(int i=0; i< 2048;i ++)
{
testtmp_f32_10khz[i] = (float)adcbuffer[i];
}
arm_cfft_f32(&varInstCfftF32, testtmp_f32_10khz, ifftFlag, doBitReverse);
arm_cmplx_mag_f32(testtmp_f32_10khz, testOutput, fftSize);
/* Calculates maxValue and returns corresponding BIN value */
arm_max_f32(testOutput, fftSize, &maxValue, &testIndex);
float freq = (FS/TEST_LENGTH_SAMPLES)*testIndex;
float vpp = maxValue/(TEST_LENGTH_SAMPLES/2);
float pha = atan2(testOutput[2*testIndex],testOutput[2*testIndex+1]);
printf("freq=%f,vpp=%f,pha=%frn",freq,vpp,pha);
}
/** endlink */
Frq.h
#ifndef FRQ_H
#define FRQ_H
int frq_main(void);
#endif
測試
輸入frq開始測試印如下
實(shí)時(shí)采集測試
此時(shí)采集的是音頻背景聲,噪聲很小,所以頻率為0
審核編輯:湯梓紅
-
英飛凌
+關(guān)注
關(guān)注
68文章
2335瀏覽量
140381 -
PSoC
+關(guān)注
關(guān)注
12文章
175瀏覽量
93240 -
信號處理
+關(guān)注
關(guān)注
48文章
1055瀏覽量
103994 -
FFT
+關(guān)注
關(guān)注
15文章
444瀏覽量
60805 -
頻率
+關(guān)注
關(guān)注
4文章
1560瀏覽量
60197 -
開發(fā)板
+關(guān)注
關(guān)注
25文章
5620瀏覽量
103507 -
RTT
+關(guān)注
關(guān)注
0文章
66瀏覽量
17586
發(fā)布評論請先 登錄
【英飛凌PSoC 6 RTT開發(fā)板試用】信號處理前端之濾波

【英飛凌PSoC 6 RTT開發(fā)板試用】信號處理前端之極值檢測

【新品發(fā)布】英飛凌PSoC 6 RTT物聯(lián)網(wǎng)開發(fā)板內(nèi)容詳解
【資料下載】英飛凌PSoC 6 RTT物聯(lián)網(wǎng)開發(fā)板
【新品試用】英飛凌PSoC 6 RTT開發(fā)板試用活動(dòng)
【英飛凌PSoC 6 RTT開發(fā)板試用】
英飛凌聯(lián)合 RT-Thread 發(fā)布 PSoC? 62 with CAPSENSE ? evaluation kit開發(fā)板
【英飛凌PSoC 6 RTT開發(fā)板試用】信號處理前端之諧波分析

基于PSOC6開發(fā)板構(gòu)建的智能小車

基于 Infineon PSoC?62開發(fā)板的信號處理前端虛擬示波器-工具集

【英飛凌測評】英飛凌PSoC? 62開發(fā)板試用報(bào)告-LCD ILI9341 8080 DEMO

玩轉(zhuǎn)PSoC 6 RTT積木式開發(fā)套件,實(shí)現(xiàn)毫米波雷達(dá)等實(shí)用功能

評論