Professional Documents
Culture Documents
UnderstandingFFTsandWindowingNationalInstruments
UnderstandingFFTsandWindowing
PublishDate:may04,2015
Overview
Learnaboutthetimeandfrequencydomain,fastFouriertransforms(FFTs),andwindowingaswellashowyoucanusethem
toimproveyourunderstandingofasignal.ThistutorialispartoftheInstrumentFundamentalsseries.
TableofContents
1.UnderstandingtheTimeDomain,FrequencyDomain,andFFT
2.Windowing
3.Summary
4.AdditionalInstrumentationResources
1.UnderstandingtheTimeDomain,FrequencyDomain,andFFT
TheFouriertransformcanbepowerfulinunderstandingeverydaysignalsandtroubleshootingerrorsinsignals.Althoughthe
Fouriertransformisacomplicatedmathematicalfunction,itisntacomplicatedconcepttounderstandandrelatetoyour
measuredsignals.Essentially,ittakesasignalandbreaksitdownintosinewavesofdifferentamplitudesandfrequencies.
Letstakeadeeperlookatwhatthismeansandwhyitisuseful.
AllSignalAretheSumofSines
Whenlookingatrealworldsignals,youusuallyviewthemasavoltagechangingovertime.Thisisreferredtoasthetime
domain.Fourierstheoremstatesthatanywaveforminthetimedomaincanberepresentedbytheweightedsumofsines
andcosines.Forexample,taketwosinewaves,whereoneisthreetimesasfastastheotherorthefrequencyis1/3the
firstsignal.Whenyouaddthem,youcanseeyougetadifferentsignal.
Figure1.Whenyouaddtwosignals,yougetanewsignal.
Nowimagineifthatsecondwavewasalso1/3theamplitude.Thistime,justthepeaksareaffected.
http://www.ni.com/whitepaper/4844/en/
1/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
Figure2.Adjustingtheamplitudewhenaddingsignalsaffectsthepeaks.
Imagineyouaddedathirdsignalthatwas1/5theamplitudeandfrequencyoftheoriginalsignal.Ifyoucontinuedinthis
fashionuntilyouhitthenoisefloor,youmightrecognizetheresultingwaveform.
Figure3.Asquarewaveisthesumofsines.
Youhavenowcreatedasquarewave.Inthisway,allsignalsinthetimedomaincanberepresentedbyaseriesofsines.
Althoughitisprettyneatthatyoucanconstructsignalsinthisfashion,whydoyouactuallycare?Becauseifyoucan
constructasignalusingsines,youcanalsodeconstructsignalsintosines.Onceasignalisdeconstructed,youcanthen
seeandanalyzethedifferentfrequenciesthatarepresentintheoriginalsignal.Takealookatafewexampleswhere
beingabletodeconstructasignalhasprovenuseful:
Ifyoudeconstructradiowaves,youcanchoosewhichparticularfrequencyorstationyouwanttolistento.
Ifyoudeconstructaudiowavesintodifferentfrequenciessuchasbassandtreble,youcanalterthetonesor
frequenciestoboostcertainsoundstoremoveunwantednoise.
Ifyoudeconstructearthquakevibrationsofvaryingspeedsandstrengths,youcanoptimizebuildingdesignstoavoid
thestrongestvibrations.
Ifyoudeconstructcomputerdata,youcanignoretheleastimportantfrequenciesandleadtomorecompact
representationsinmemory,otherwiseknownasfilecompression.
DeconstructingSignalsUsingtheFFT
TheFouriertransformdeconstructsatimedomainrepresentationofasignalintothefrequencydomainrepresentation.
Thefrequencydomainshowsthevoltagespresentatvaryingfrequencies.Itisadifferentwaytolookatthesamesignal.
http://www.ni.com/whitepaper/4844/en/
2/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
Adigitizersamplesawaveformandtransformsitintodiscretevalues.Becauseofthistransformation,theFourier
transformwillnotworkonthisdata.Instead,thediscreteFouriertransform(DFT)isused,whichproducesasitsresultthe
frequencydomaincomponentsindiscretevalues,orbins.ThefastFourier(FFT)isanoptimizedimplementationofa
DFTthattakeslesscomputationtoperformbutessentiallyjustdeconstructsasignal.
TakealookatthesignalfromFigure1above.Therearetwosignalsattwodifferentfrequenciesinthiscase,thesignal
hastwospikesinthefrequencydomainoneateachofthetwofrequenciesofthesinesthatcomposedthesignalinthe
firstplace.
Figure4.Whentwosinewavesofequalamplitudeareadded,theyresultintwospikesinthefrequencydomain.
Theamplitudeoftheoriginalsignalisrepresentedontheverticalaxis.IfyoulookatthesignalfromFigure2abovewhere
therearetwodifferentsignalsatdifferentamplitudes,youcanseethatthemostprominentspikecorrespondstothe
frequencyofthehighestvoltagesinesignal.Lookingatasignalinthetimedomain,youcangetagoodideaofthe
originalsignalbyknowingatwhatfrequenciesthelargestvoltagesignalsoccur.
Figure5.Thehighestspikeisthefrequencyofthelargestamplitude.
Itcanalsobehelpfultolookattheshapeofthesignalinthefrequencydomain.Forinstance,letstakealookatthe
squarewaveinthefrequencydomain.Wecreatedthesquarewaveusingmanysinewavesatvaryingfrequenciesas
such,youwouldexpectmanyspikesinthesignalinthefrequencydomainoneforeachsignaladded.Ifyouseeanice
rampinthefrequencydomain,youknowtheoriginalsignalwasasquarewave.
http://www.ni.com/whitepaper/4844/en/
3/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
Figure6.Thefrequencydomainofasinewavelookslikearamp.
Sowhatdoesthislooklikeintherealworld?Manymixedsignaloscilloscopes(MSO)haveanFFTfunction.Below,you
canseewhatanFFTofasquarewavelookslikeonamixedsignalgraph.Ifyouzoomin,youcanactuallyseethe
individualspikesinthefrequencydomain.
Figure7.TheoriginalsinewaveanditscorrespondingFFTaredisplayedinthetopimage,whilethebottomimageisa
zoomedinportionoftheFFTwhereyoucanseetheindividualspikes.
Lookingatsignalsinthefrequencydomaincanhelpwhenvalidatingandtroubleshootingsignals.Forinstance,sayyou
haveacircuitthatissupposedtooutputasinewave.Youcanviewtheoutputsignalontheoscilloscopeinthetime
domaininFigure8below.Itlooksprettygood!
http://www.ni.com/whitepaper/4844/en/
4/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
Figure8.Ifthesetwowaveswereadded,theywouldlooklikeaperfectsinewavebecausetheyaresosimilar.
However,whenyouviewthesignalinthefrequencydomain,youexpectonlyonespikebecauseyouareexpectingto
outputasinglesinewaveatonlyonefrequency.However,youcanseethatthereisasmallerspikeatahigherfrequency
thisistellingyouthatthesinewaveisntasgoodasyouthought.Youcanworkwiththecircuittoeliminatethecauseofthe
noiseaddedatthatparticularfrequency.Thefrequencydomainisgreatatshowingifacleansignalinthetimedomain
actuallycontainscrosstalk,noise,orjitter.
Figure9.LookingattheseeminglyperfectsinewavefromFigure8,youcanseeherethatthereisactuallyaglitch.
2.Windowing
AlthoughperforminganFFTonasignalcanprovidegreatinsight,itisimportanttoknowthelimitationsoftheFFTandhowto
improvethesignalclarityusingwindowing.
WhatisWindowing
WhenyouusetheFFTtomeasurethefrequencycomponentofasignal,youarebasingtheanalysisonafinitesetof
data.TheactualFFTtransformassumesthatitisafinitedataset,acontinuousspectrumthatisoneperiodofaperiodic
signal.FortheFFT,boththetimedomainandthefrequencydomainarecirculartopologies,sothetwoendpointsofthe
timewaveformareinterpretedasthoughtheywereconnectedtogether.Whenthemeasuredsignalisperiodicandan
integernumberofperiodsfilltheacquisitiontimeinterval,theFFTturnsoutfineasitmatchesthisassumption.
http://www.ni.com/whitepaper/4844/en/
5/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
Figure10.Measuringanintegernumberofperiods(top)givesanidealFFT(bottom).
However,manytimes,themeasuredsignalisntanintegernumberofperiods.Therefore,thefinitenessofthemeasured
signalmayresultinatruncatedwaveformwithdifferentcharacteristicsfromtheoriginalcontinuoustimesignal,andthe
finitenesscanintroducesharptransitionchangesintothemeasuredsignal.Thesharptransitionsarediscontinuities.
Whenthenumberofperiodsintheacquisitionisnotaninteger,theendpointsarediscontinuous.Theseartificial
discontinuitiesshowupintheFFTashighfrequencycomponentsnotpresentintheoriginalsignal.Thesefrequencies
canbemuchhigherthantheNyquistfrequencyandarealiasedbetween0andhalfofyoursamplingrate.Thespectrum
yougetbyusingaFFT,therefore,isnottheactualspectrumoftheoriginalsignal,butasmearedversion.Itappearsasif
energyatonefrequencyleaksintootherfrequencies.Thisphenomenonisknownasspectralleakage,whichcausesthe
finespectrallinestospreadintowidersignals.
Figure11.Measuringanonintegernumberofperiods(top)addsspectralleakagetotheFFT(bottom).
YoucanminimizetheeffectsofperforminganFFToveranonintegernumberofcyclesbyusingatechniquecalled
windowing.Windowingreducestheamplitudeofthediscontinuitiesattheboundariesofeachfinitesequenceacquiredby
thedigitizer.Windowingconsistsofmultiplyingthetimerecordbyafinitelengthwindowwithanamplitudethatvaries
smoothlyandgraduallytowardzeroattheedges.Thismakestheendpointsofthewaveformmeetand,therefore,results
inacontinuouswaveformwithoutsharptransitions.Thistechniqueisalsoreferredtoasapplyingawindow.
http://www.ni.com/whitepaper/4844/en/
6/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
Figure12.Applyingawindowminimizestheeffectofspectralleakage.
WindowingFunctions
Thereareseveraldifferenttypesofwindowfunctionsthatyoucanapplydependingonthesignal.Tounderstandhowa
givenwindowaffectsthefrequencyspectrum,youneedtounderstandmoreaboutthefrequencycharacteristicsof
windows.
Anactualplotofawindowshowsthatthefrequencycharacteristicofawindowisacontinuousspectrumwithamainlobe
andseveralsidelobes.Themainlobeiscenteredateachfrequencycomponentofthetimedomainsignal,andtheside
lobesapproachzero.Theheightofthesidelobesindicatestheaffectthewindowingfunctionhasonfrequenciesaround
mainlobes.Thesideloberesponseofastrongsinusoidalsignalcanoverpowerthemainloberesponseofanearby
weaksinusoidalsignal.Typically,lowersidelobesreduceleakageinthemeasuredFFTbutincreasethebandwidthofthe
majorlobe.Thesideloberolloffrateistheasymptoticdecayrateofthesidelobepeaks.Byincreasingthesideloberoll
offrate,youcanreducespectralleakage.
Selectingawindowfunctionisnotasimpletask.Eachwindowfunctionhasitsowncharacteristicsandsuitabilityfor
differentapplications.Tochooseawindowfunction,youmustestimatethefrequencycontentofthesignal.
Ifthesignalcontainsstronginterferingfrequencycomponentsdistantfromthefrequencyofinterest,choosea
smoothingwindowwithahighsideloberolloffrate.
Ifthesignalcontainsstronginterferingsignalsnearthefrequencyofinterest,chooseawindowfunctionwithalow
maximumsidelobelevel.
Ifthefrequencyofinterestcontainstwoormoresignalsveryneartoeachother,spectralresolutionisimportant.In
thiscase,itisbesttochooseasmoothingwindowwithaverynarrowmainlobe.
Iftheamplitudeaccuracyofasinglefrequencycomponentismoreimportantthantheexactlocationofthe
componentinagivenfrequencybin,chooseawindowwithawidemainlobe.
Ifthesignalspectrumisratherflatorbroadbandinfrequencycontent,usetheuniformwindow,ornowindow.
Ingeneral,theHanning(Hann)windowissatisfactoryin95percentofcases.Ithasgoodfrequencyresolutionand
reducedspectralleakage.Ifyoudonotknowthenatureofthesignalbutyouwanttoapplyasmoothingwindow,start
withtheHannwindow.
Evenifyouusenowindow,thesignalisconvolvedwitharectangularshapedwindowofuniformheight,bythenatureof
takingasnapshotintimeoftheinputsignalandworkingwithadiscretesignal.Thisconvolutionhasasinefunction
characteristicspectrum.Forthisreason,nowindowisoftencalledtheuniformorrectangularwindowbecausethereis
stillawindowingeffect.
TheHammingandHannwindowfunctionsbothhaveasinusoidalshape.Bothwindowsresultinawidepeakbutlowside
lobes.However,theHannwindowtoucheszeroatbothendseliminatingalldiscontinuity.TheHammingwindowdoesnt
quitereachzeroandthusstillhasaslightdiscontinuityinthesignal.Becauseofthisdifference,theHammingwindow
http://www.ni.com/whitepaper/4844/en/
7/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
doesabetterjobofcancellingthenearestsidelobebutapoorerjobofcancelinganyothers.Thesewindowfunctionsare
usefulfornoisemeasurementswherebetterfrequencyresolutionthansomeoftheotherwindowsiswantedbut
moderatesidelobesdonotpresentaproblem.
Figure13.HammingandHannwindowingresultinawidepeakbutnicelowsidelobes.
TheBlackmanHarriswindowissimilartoHammingandHannwindows.Theresultingspectrumhasawidepeak,but
goodsidelobecompression.Therearetwomaintypesofthiswindow.The4termBlackmanHarrisisagoodgeneral
purposewindow,havingsideloberejectioninthehigh90sdBandamoderatelywidemainlobe.The7termBlackman
Harriswindowfunctionhasallthedynamicrangeyoushouldeverneed,butitcomeswithawidemainlobe.
http://www.ni.com/whitepaper/4844/en/
8/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
Figure14.TheBlackmanHarrisresultsinawidepeak,butgoodsidelobecompression.
AKaiserBesselwindowstrikesabalanceamongthevariousconflictinggoalsofamplitudeaccuracy,sidelobedistance,
andsidelobeheight.ItcomparesroughlytotheBlackmanHarriswindowfunctions,butforthesamemainlobewidth,the
nearsidelobestendtobehigher,butthefurtheroutsidelobesarelower.Choosingthiswindowoftenrevealssignals
closetothenoisefloor.
Theflattopwindowissinusoidalaswell,butitactuallycrossesthezeroline.Thiscausesamuchbroaderpeakinthe
frequencydomain,whichisclosertothetrueamplitudeofthesignalthanwithotherwindows.
Figure15.Theflattopwindowresultsinmoreaccurateamplitudeinformation.
Thesearejustafewofthepossiblewindowfunctions.Thereisnouniversalapproachforselectingawindowfunction.
However,thetablebelowcanhelpyouinyourinitialchoice.Alwayscomparetheperformanceofdifferentwindow
functionstofindthebestonefortheapplication.
http://www.ni.com/whitepaper/4844/en/
9/10
7/10/2016
UnderstandingFFTsandWindowingNationalInstruments
3.Summary
Allsignalsinthetimedomaincanberepresentedbyaseriesofsines.
AnFFTtransformdeconstructsatimedomainrepresentationofasignalintothefrequencydomainrepresentationto
analyzethedifferentfrequenciesinasignal.
Thefrequencydomainisgreatatshowingyouifacleansignalinthetimedomainactuallycontainscrosstalk,noise,or
jitter.
Spectralleakageiscausedbydiscontinuitiesintheoriginal,nonintegernumberofperiodsinasignalandcanbeimproved
usingwindowing.
Windowingreducestheamplitudeofthediscontinuitiesattheboundariesofeachfinitesequenceacquiredbythedigitizer.
Nowindowisoftencalledtheuniformorrectangularwindowbecausethereisstillawindowingeffect.
Ingeneral,theHanningwindowissatisfactoryin95percentofcases.Ithasgoodfrequencyresolutionandreduced
spectralleakage.
Youshouldcomparetheperformanceofdifferentwindowfunctionstofindthebestonefortheapplication.
4.AdditionalInstrumentationResources
MultifunctioninstrumentsIntegratedbenchtopinstrumentsintoasingle,fixedfunctiondevice.
(http://www.ni.com/virtualbench/whatis/)
Learnaboutanallinoneinstrumentthatcombinesamixedsignaloscilloscope,afunctiongenerator,adigitalmultimeter,a
programmableDCpowersupply,anddigitalI/OintoonedeviceandworkswithyourPCoriPadforefficientcircuitdesign
debuggingandvalidation.
ExploreOscilloscopesBuiltforTest(http://www.ni.com/whitepaper/51981/en/)
Oscilloscopesareessentialinstrumentsatthecoreofavarietyofapplications,makingthemanecessityforautomatedtest
systems.Consideramodularsolutionifyourapplicationrequiresmeasuring,analyzing,orprocessingdatademandsfast
throughputorrequiresasmallformfactorwithminimalpowerconsumption.
Forthecompletelistoftutorials,returntotheInstrumentFundamentalsmainpage(http://www.ni.com/tutorial/3214/en/).
http://www.ni.com/whitepaper/4844/en/
10/10