FFT spectrum analyzer数字信号处理第二次大作业.docx
《FFT spectrum analyzer数字信号处理第二次大作业.docx》由会员分享,可在线阅读,更多相关《FFT spectrum analyzer数字信号处理第二次大作业.docx(15页珍藏版)》请在冰点文库上搜索。
FFTspectrumanalyzer数字信号处理第二次大作业
FFTspectrumanalyzer
basedonMatlab
NAME
:
XXXXX
StudentID
:
00000000000
Professor
:
何岭松
Date
:
2013-10-08
Abstract
Fouriertransformispowerfulmethodinsignalprocess.Itcantransformthesignalfromtimedomaintofrequencydomain.Infrequencydomainsomecharacteristicismoreobviousthanitintimedomain.Forthediscretesignal,thereisDiscreteFourierTransform(DFT).ButtheamountofcalculationinDFTislarge,tospeedupincalculation,thereisFastFourierTransform(FFT).ForDFTandFFT,asthespectrumisdiscrete,andonlythefrequencysamplingpointiscalculated,itcausedthefenceeffect.Andtheenergyleakageforcycleextension.Toreducethefenceeffect,windowfunctionisneeded.
Inthisproject,FFTisusedtoanalyzethespectrumofthesignal.Thesignalcanbegeneratedinthreeways,signalgenerator,readfromwavfilesandinputfromthesoundcard.Toreducethefenceeffect,windowfunctionissupported.
Keywords:
FFTwavfilesoundcardinputwindowfunction
Content
1.Introduction1
2.Method2
2.1Signalspectrumanalysis2
2.1.1ContinuousFourierTransform2
2.1.2DiscreteFourierTransform(DFT)2
2.1.3FastFourierTransform(FFT)3
2.2WindowFunction3
2.3SignalSource4
2.4Zoomspectrum5
3.Results5
3.1Interfaceoftheprogram5
3.2FFTthesignalfromsignalgenerator7
3.3Readthewavfileandspectrumanalysis9
3.4Soundcardinputandspectrumanalysis10
3.5ZoomFFT10
3.6Windowfunction10
4.Conclusions13
5.References13
1.Introduction
Oneofthemostcommonlyusedmethodinsignalprocessingisthespectrumanalysis.Ittransformthesignalfromtimedomaintofrequencydomain.Forsomesignal,thetimedomainanalysisisverydifficult,andsomecharacteristicsishardtoobtainfromtimedomainanalysis,suchasifthesignalhasacycle,thecompositionofthesignal.Thosecharacteristicsisveryclearinfrequencydomain.
ThemethodthattransformthesignalfromtimedomainintofrequencydomainisFourierTransform.Forthecontinuoussignal,integrationiscalculated.Forthediscretesignal,thereistheDiscreteFourierTransform(DFT).Thesummationisinsteadtheintegration.Asthesummationislargecalculation,especiallywhenthesamplepointislarge.AgoodwaytospeedupthecalculationistheFastFourierTransform(FFT).FFTismuchfastertheDFT,especiallywhenthesamplepointislarge.Forexample,forasignalof1024points,theFFTisfasterthantheDFT100times.
Generally,thesignaliscontinuous,whenwegetthesignal,wediscretethesignalwithasamplesignal.ForDFTorFFT,wediscretethespectrum,andonlycalculatethefrequencysamplingpoints.Thefrequencythatwedon’tsampledisignored,whichcausedtheFenceEffect.Forthesignalislongintime,it’snotpossibletosamplethewholesignal.Infact,onlyasectionofthesignalissampled,andthenextendthesignalwiththecycleassampled.Thesignalofcycleextensionisdifferentwiththeoriginal.Thiscausedtheenergyleakage.Toreducethefenceeffect,windowfunctionisused.Inthisproject5windowfunctionissupported,theyarerectanglewindow,trianglewindow,hanningwindow,hammingwindowandblackmanwindow.Usercanselectdifferentwindowfunctionbyagroupofradiobutton.
TheresultofDFTorFFTisgivingthewholespectrum.Insomecase,wejustinterestonalittlerangeofthespectrum.Forthiscase,zoomtechniquesofthespectrumisneeded.Inthisproject,it’sincluded.
Inthisproject,thesourcesignalthattobeanalyzeisgeneratedinthreeways,signalgenerator,readfromwavfileandrecordfromsoundcard.
2.Method
2.1Signalspectrumanalysis
Thespectrumanalysisisoneofthemostcommonlymethodinsignalprocessing.Forsomecharacteristicofthesignalistimedomainisnoteasytoget,ittransformthesignaloftimedomainintofrequencydomain,andanalyzethesignalinfrequencydomain.
2.1.1ContinuousFourierTransform
Forthecontinuoussignal,theFouriertransformisshowas
isthesignalintimedomain.
isthesignalinfrequencydomain.Forthesignaliscontinuous,tocalculatetheformofthesignalinfrequencyintegrationisneeded.
2.1.2DiscreteFourierTransform(DFT)
Asdigitalsignalisnotcontinuousbutdiscrete.It’simpossibletocalculateallfrequencypoints.Tocalculatethespectrum
it’sfirsttodiscretethefrequency:
Nisthesizeofsamplepoint,andFsisthesamplefrequency.Then,thefrequencypointis
Finally,thespectrumofthesignalis
k=0,1,2,...,N-1
Where,Nisthesizeofsamplepoint,
2.1.3FastFourierTransform(FFT)
From2.1.2,wefindthatDFTcancalculatetheX(f),butifweextendit,wegetthis.
Where
Fromthis,wecanfindthatalargecalculationsofsineandcosinearerepeat.Ifwereducetheserepeatcalculation,itwillbemuchfaster.That’swhatFFThasdone.Asit’sname,FFTisfasterthanDFT,thelargerthepointsare,thefastertheFFTiscomparedwithDFT.Forasignalof1024points,theFFTis100timesfasterthenDFT.
2.2WindowFunction
AsDFTandFFT,spectrumisdiscrete,andonlycalculatethefrequencysamplingpoint,andotherpointisnot.SoFenceeffectiscaused,andsomeinformationofthespectrumismissed.
Thesignalintimedomainislong,evensomeareendless.It’simpossibletosampleallthesignal.Infact,thecommonmethodissampleasectionasacycleofthesignal,andthenextendthesignal.Asthesignalofcycleextensionisdifferentwiththeoriginalsignal,Energyleakageiscaused.Fromthemathematicalpointofview,thisprocesscanbedescribedas
x(t):
Originalsignal.
w(t):
Cutoffwindowfunction
y(t):
Extensionsignal.
Theenergyleakageisnotalwaysbadforanalysis.Itreducedthefenceeffect,especiallywhenaappropriatewindowfunctionw(t)ischosen.
Thereare5windowfunctionissupportedinthisproject,theyareRectangleWindow,TriangleWindow,HanningWindow,HammingWindowandBlackmanWindow.Themathematicexpressionofthewindowfunctionsarelistintable1.
Table1themathematicexpressionandtheAmplitudecorrectioncoefficient.
Windowfunction
Mathematicexpression
Amplitudecorrectioncoefficient
Rectanglewindow
1
Hanningwindow
2
Hammingwindow
1.852
Trianglewindow
2
Blackmanwindow
2.381
2.3SignalSource
Inthisprojectthesignalgeneratedinthreeways.ThefirstisfromthesignalgeneratorbasedonMatlab,thesecondisreadfromwavfilesandthethirdisfromcomputer’ssoundcard.
Forthesignalgenerator,theprogramsupport4types,sine,cosine,squareandtrianglewave.Theexpressionofthewaveislistintable2.
Table2theexpressionofthesignal
Signaltype
Mathematicexpression
Sinewave
Cosinewave
Squarewave
Trianglewave
InMatlab,therefunctionstoreadsignalfromwavfileandrecordfromthesoundcard.Thefunctiontoreadwavfileis
[Y,Fs,NBITS]=wavread(FILE);
Yisthedatareadfromthewavfile,Fsisthesamplerate,andNBITSisthenumberofbitspersampleusedtoencodethedatainthefile.
2.4Zoomspectrum
ForthenormalFFT,itshowsallthefrequency.Sometimes,thecharacteristicsfocusedonlyinasmallrangeinfrequency.FromthespectrumfromthenormalFFT,it’snotconvenienttoobservethesignal.Thus,zoomspectrumisneeded.
Intheproject,atfirstwemakethesignalaZtransform,andthenanalyzethesignal.Sothespectrumisintherangethatweinterestedin.
3.Results
3.1Interfaceoftheprogram
Thefinalinterfaceoftheprogramisshowinfig.3.1
Fig.3.1thefinalinterfaceoftheprogram
Asshowninfig.3.1,theinterfacedivide6parts.Thefirstpartistwoaxes.Theyshowthesignalintimedomainandfrequencydomainrespectively.
Thesecondpartisthewindowfunctionselectionpart.Inthispart,fivewindowfunctionaresupported.TheyareRectanglewindow,Trianglewindow,Hanningwindow,HammingwindowandBlackmanwindow.Thispartisshowninfig.3.2.
Thethirdpartisthesignalgenerator.Itsimilarwithproject1.It’snomoredetaildiscussedhere.It’sshowninfig.3.3
Fig3.2windowfunctionselectionfig.3.3signalgenerator
Theforthpartisthereadwavfilepart.Fromthepushbuttonselectwavfileusercanselectthewavfile.Theretwoedittextboxinthispart,withwhichtheusercansetthesamplesection.Thispartisshowninfig3.4.
Thefifthpartistherecordpart.Withthispart,theusercaninputthesoundfromthecomputer’ssoundcard.Thereare4parametersshouldbeset,theyaresamplepoint,sampleFrequency,channelofthesoundandthenumberofthedatatoencode.It’sshowinfig3.5
Thesixthpartisfrequencyspectrumrefinement.Withthispart,usercanzoomtheinterestedfrequencyrange.Thispartisshowninfig3.6
Fig3.4wavfilereadpartfig3.5soundcardinputpart
Fig3.6Frequencyspectrumrefinementpart
3.2FFTthesignalfromsignalgenerator
Thesignalthatsignalgeneratorgeneratedisthestandardsignal.Theyaresinewave,cosinewave,squarewaveandtrianglewave.Thetimeandfrequencydomainwaveformisshowninfig3.7tofig.3.10.
Fig.3.7thesinewavegenerator(
)
Fig.3.8thecosinewavegenerator(
)
Fig.3.9thesquarewave(
)
Fig.3.10thetrianglewave(
)
3.3Readthewavfileandspectrumanalysis
Fig.3.11Thetelephonedialtonesimulation
Thisfigisreadawavfileandsamplethe1to30720points.
3.4Soundcardinputandspectrumanalysis
Fig3.12thewaveformofthesoundinputfromsoundcard
Fig3.12showsthewaveforminputfromthesoundcard.Thenumberofsamplepointis20480,samplefrequency