快速傅立葉變換FFT算法實驗_第1頁
快速傅立葉變換FFT算法實驗_第2頁
快速傅立葉變換FFT算法實驗_第3頁
快速傅立葉變換FFT算法實驗_第4頁
快速傅立葉變換FFT算法實驗_第5頁
已閱讀5頁,還剩1頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、. 快速傅立葉變換(FFT)算法實驗實驗?zāi)康模?. 加深對DFT 算法原理和基本性質(zhì)的理解;2. 熟悉FFT 的算法原理和FFT 子程序的算法流程和應(yīng)用;3. 學(xué)習(xí)用FFT 對連續(xù)信號和時域信號進行頻譜分析的方法。程序流程圖:傅立葉變換是一種將信號從時域到頻域的變換形式,是聲學(xué)、語音、電信和信號處理等領(lǐng)域中的一種重要分析工具。離散傅立葉變換(DFT)是連續(xù)傅立葉變換在離散系統(tǒng)中的表現(xiàn)形式,由于DFT 的計算量很大,因此在很長時間內(nèi)其應(yīng)用受到很大的限制??焖俑盗⑷~變換(FFT)是離散傅立葉變換的一種高效運算方法。由于我們在計算DFT 時一次復(fù)數(shù)乘法需用四次實數(shù)乘法和二次實數(shù)加法;一次復(fù)數(shù)加法則需

2、二次實數(shù)加法。運算一個X(k)需要4N 次復(fù)數(shù)乘法及2N+2(N-1)=2(2N-1)次實數(shù)加法。所以整個DFT運算總共需要4N2 次實數(shù)乘法和N*2(2N-1)=2N(2N-1)次實數(shù)加法。如此一來,計算時乘法次數(shù)和加法次數(shù)都是和N2 成正比的,當(dāng)N 很大時,運算量是可觀的,因而需要改進對DFT 的算法減少運算速度。我們可以將DFT 運算中有些項合并。我們先設(shè)序列長度為N=2L,L 為整數(shù)。將N=2L 的序列x(n)(n=0,1,,N-1),按N的奇偶分成兩組,也就是說我們將一個N 點的DFT 分解成兩個N/2 點的DFT,他們又重新組合成一個如下式所表達(dá)的N 點DFT:一般來說,輸入被假定

3、為連續(xù)的。當(dāng)輸入為純粹的實數(shù)的時候,我們就可以利用左右對稱的特性更好的計算DFT。這樣的RFFT 優(yōu)化算法是包裝算法:首先2N 點實數(shù)的連續(xù)輸入稱為“進包”。其次N 點的FFT 被連續(xù)運行。最后作為結(jié)果產(chǎn)生的N 點的合成輸出是“打開”成為最初的與DFT 相符合的2N 點輸入。使用這一思想,我們可以劃分FFT 的大小,它有一半花費在包裝輸入O(N)的操作和打開輸出上。AD原理圖源程序*include<math.h>*include"DSP2833x_Device.h"/ DSP2833x Headerfile Include File*include"D

4、SP2833x_Examples.h"/ DSP2833x Examples Include Fi*include"comm.h"*include"i_cmplx.h"*include"ext_inf.h"/*/*if (CPU_FRQ_150MHZ) / Default - 150 MHz SYSCLKOUT*define ADC_MODCLK 0x3 / HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz*endif*if (CPU_FRQ_100MHZ)*de

5、fine ADC_MODCLK 0x2 / HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2) = 25.0 MHz*endif*define ADC_CKPS 0x1 / ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz*define ADC_SHCLK 0xf / S/H width in ADC module periods = 16 ADC clocks*define AVG 1000 / Average sample limit*define ZOFFSET 0x00 /

6、 Average Zero offset*define BUF_SIZE 160 / Sample buffer size/*/unsignedint SampleLong;*define SAMPLELONG 3/unsignedint Ad_data1536=0;unsignedint Ad_data11536=0;unsignedint convcount = 0;volatileunsignedint adconvover =0;/int m=0;double n;double p,q;COMPLEX DDataBuffer512=0;Uint32 mod512;/unsignedin

7、t i;/*/ Prototype statements for functions found within this erruptvoidadc_isr(void);/*/voidmain(void)*if SAMPLELONG=1SampleLong =256;*endif*if SAMPLELONG=2SampleLong =512;*endif*if SAMPLELONG=3SampleLong =1024;*endif/ Step 1. Initialize System Control:/ PLL, WatchDog, enable Peripheral Cloc

8、ks/ This example function is found in the DSP2833x_SysCtrl.c file. InitSysCtrl();/ Step 2. Initialize GPIO:/ This example function is found in the DSP2833x_Gpio.c file and/ illustrates how to set the GPIO to it's default state. InitGpio(); / Skipped for this example/ Step 3. Clear all interrupts

9、 and initialize PIE vector table:/ Disable CPU interrupts DINT;/ Initialize the PIE control registers to their default state./ The default state is all PIE interrupts disabled and flags/ are cleared./ This function is found in the DSP2833x_PieCtrl.c file. InitPieCtrl();/ Disable CPU interrupts and c

10、lear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000;/ Initialize the PIE vector table with pointers to the shell Interrupt/ Service Routines (ISR)./ This will populate the entire table, even if the interrupt/ is not used in this example. This is useful for debug purposes./ The shell ISR routine

11、s are found in DSP2833x_DefaultIsr.c./ This function is found in DSP2833x_PieVect.c. InitPieVectTable();/ Interrupts that are used in this example are re-mapped to/ ISR functions found within this file. EALLOW; / This is needed to write to EALLOW protected register PieVectTable.ADCINT = &adc_isr

12、; EDIS; / This is needed to disable write to EALLOW protected registers/ Step 4. Initialize all the Device Peripherals:/ This function is found in DSP2833x_InitPeripherals.c/ InitPeripherals(); / Not required for this example InitAdc(); / For this example, init the ADC/ Step 5. User specific code, e

13、nable interrupts:/ Enable ADCINT in PIE PieCtrlRegs.PIEIER1.bit.INTx6 = 1; IER |= M_INT1; / Enable CPU Interrupt 1 EINT; / Enable Global interrupt INTM ERTM; / Enable Global realtime interrupt DBGM AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK; AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS; AdcRegs.ADCTRL1.bit.S

14、EQ_CASC = 1; / 0 Non-Cascaded Mode; 1 Cascaded Mode AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 0x1; AdcRegs.ADCTRL2.bit.RST_SEQ1 = 0x1; AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x6; AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 15; AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 0x1 ; for(;)if (adconvover=1)for(i=0;i<(SampleLong/2);i+)DDa

15、taBufferi.real=Ad_data2*i; /short int DDataBufferi.imag=Ad_data2*i+1; /short intswitch(SampleLong)case 256:/*256 point*/ fft256(DDataBuffer,256); m=0;for(i=0;i<128;i+) p=DDataBufferi.real; q=DDataBufferi.imag; n=(long)p*(long)p+(long)q*(long)q; modm=sqrt(n); m+; break;case 512: /*512 point*/ fft5

16、12(DDataBuffer,512); m=0;for(i=0;i<256;i+) p=DDataBufferi.real; q=DDataBufferi.imag; n=(long)p*(long)p+(long)q*(long)q; modm=sqrt(n); m+; break;case 1024: /*1024 point*/ fft1024(DDataBuffer,1024); m=0;for(i=0;i<512;i+) p=DDataBufferi.real; q=DDataBufferi.imag; n=(long)p*(long)p+(long)q*(long)q; modm=sqrt(n); m+; break; adconvover=0; convcount =0; interruptvoidadc_isr(void)/ If 40 conversions have been logged, start overif(convcount = SampleLong) adconvover = 1; else Ad_dataconvcount = AdcRegs.ADCRESULT0 >>4; convcou

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論