单片机类毕业设计外文翻译Word文档格式.docx
《单片机类毕业设计外文翻译Word文档格式.docx》由会员分享,可在线阅读,更多相关《单片机类毕业设计外文翻译Word文档格式.docx(30页珍藏版)》请在冰豆网上搜索。
fS=2fH
AnysamplingfrequencyselectedabovefSisconsideredtobeoversampling,andwhencombinedwithaveragingtechniques,improvestheENOB.Thisispossiblebecauseaveragingtheoversampledresultsalsoaveragesthequantizationnoise,thusimprovingtheSignal-to-NoiseRatio(SNR),whichhasadirecteffectontheENOB.
Foreachbitofaccuracyimprovement,thesignalmustbeoversampledbyafactoroffour,meaningthattherelationshipbetweentheoversamplingfrequencyfOSandsamplingfrequencyfSisasshowninEquation2.
Equation2.OversamplingFrequency
fOS=4x*fS
wherexisthedesiredimprovementontheENOB(forexample,fortwobitsofimprovement,x=2).
Figure1showshowoversamplingimprovestheaccuracyoftheconversionresult.Inthisdiagram,theinputsignalisoversampledby4(samplegroupsareshowningreenandpurple)andaveraged.Thesamplepointsshownillustratethedifferencebetweentheraw,noisysignalandtheaverage;
thenoiseinthisexampleaffecting±
3bitsofaccuracyonanindividualsample.Notethattheaveragedvalues(orangedots)aremuchclosertotheidealvaluethanmostofthesinglesamples.
Averaging
Averagingactsasalow-passfilterontheinputsignal,withthepassbandofthefilternarrowingasthesamplesizeincreases.Whenaveragingconversionresults,therearetwoapproachesthatcanbetaken:
normalaverageorrollingaverage.
NormalAverage
Takingnsamples,addingthem,anddividingtheresultbynisreferredtoasanormalaverage,andisshowninFigure1.Whenusingnormalaveraginginanoversamplingscenario,afterthetechniqueisapplied,thesampledatausedinthecalculationisdiscarded.Thisprocessisrepeatedeverytimetheapplicationneedsanewconversionresult.
Figure1.AveragedConversionResults
Inanapplication,thenormalaveragingapproachisideallyusedincaseswherethesamplingfrequencyislowcomparedtothesamplingrateoftheADC.
Important:
Whenoversamplingbyninanormalaveragingscenario,theeffectiveADCsamplerateisreducedbythatsamefactor.Forexample,oversamplinganinputsignalby4cutsthemaximumeffectiveADCsamplerateby4,meaningthata250K-samples/sADCeffectivelybecomesa62.5K-samples/sADC.
Figure2showsasituationwherenormalaveragingisusedtooversampleaninputsourceby4.Forthisexample,theapplicationrequiresthatanewconversionvaluebeready(averagingcomplete)ateachstepoft(t0,t1,t2,andsoon).
Whenusingaveragingtechniques,thereisaslightdelayassociatedwiththecalculatedconversionresultsinceitcorrespondstotheaverageofthelastnsamples.ThedelaycanbecalculatedusingtheformulashowninEquation3.
Equation3.AveragedSampleDelay
tdelay=(tSn–tS0)/2+tprocess
wheretS0isthetimeatwhichthefirstsampleoftheaverageoccurs,andtSniswherethelastsampleoccurs.Thetimerequiredbytheinterrupthandlertoprocessthesampledataandcalculatetheaveragetprocesstosupplytotheapplicationisalsofactoredintotheequation.InFigure2,thedelayedconversionresultishighlightedinorange.
RollingAverage
Arollingaverageusesasamplebufferofthenmostrecentsamplesintheaveragingcalculation,allowingtheADCtosampleatitsmaximumrate(theADCsamplerateisnotreducedbynasinnormalaveraging),makingitideallysuitedforapplicationsrequiringoversamplingandhighersamplerates.Thesamplebuffercanbeprefilledwithvalidsampledata(bytakingn–1samplespriortothefirst“real”datapoint),orcanbeleftinanunknownstate,dependingontheapplication.Thedisadvantageofnotprefillingthebufferisthatthefirstn–1samplescontaininvaliddataandadverselyaffecttherollingaveragecalculation.Ifacceptablebytheapplication,bufferpaddingcanbeeliminatedifthesoftwarecanaccountforthepossibilityofthefirstn–1samplesbeingskewed.
Figure3showsanexampleofoversamplingwitharollingaverage.Thediagramshowsacasewheretheinputsignalisoversampledby4,meaningthatthesamplebufferusesthe4mostrecentsamplestocalculatetheaverage.Inthisexample,theapplicationrequiresanewsampleateachstepoft.Beforethefirstoversampledresultiscalculatedatt0,thesamplebuffercollectsthreesamplessothatthefirstdatasuppliedtotheapplicationisvalid.
Figure2.NormalAveraging
Whenusingarollingaverage,thesamesampledelaycalculatedbyEquation3applies.InFigure3,thedelayedvaluesfort0,t1andt2(shownasd0,d1andd2,respectively)arehighlightedinorange.
Usingarollingaverageaddsadditionalprocessingoverheadduetothesamplebuffermanipulationthatmustbeperformedduringeachinterrupt.
Implementation
LuminaryMicro’ssamplesequencerarchitectureintheADCmakesoversamplingsimplebyallowingforupto17uniquesamples(fromanyoftheanalogchannels)tobecollectedusingasingletrigger.Thisallowsforflexibilityinsoftwarebyprovidingthemeansforanapplicationtooversampleanumberofchannelsatanygiventime.
ThissectionshowsvariousimplementationsofoversamplingusingtheStellarismicrocontrollers.Therearenumerousmethodsthatworkusingcombinationsofsamplesequencerconfigurations,ADCtriggersandinterrupts,however,theexamplesshownherefocusontechniquesthataremostlikelytobeused.
AlltheexamplecodeusestheStellarisFamilyDriverLibraryADCfunctions.ThesourcecodefortheDriverLibraryandthesoftwareexamplesshowninthisapplicationnotecanbefoundontheLuminaryMicrowebsiteat.
Figure3.RollingAverage
OversamplingUpto8TimesUsingtheDriverLibraryFunctions
TheStellarisDriverLibraryhasbuilt-infunctionsthatallowoversamplingupto8times.Formostapplications,thislevelofoversamplingissufficientsincetheimprovementontheENOBisapproximately1.4bits.
UsingtheDriverLibraryoversamplingfunctionsistheeasiestwaytooversampletheinputsignal.Themaindifferencebetweenconfiguringa“typical”ADCconversionandanoversampledconversionisthefunctioncalls.TheoversamplingfunctionshaveanADCSoftwareOversampleprefix,andareeasilydistinguishedfromthestandardADCfunctions.
OncetheparametersfortheADCconversionprocessaredetermined(samplefrequency,triggersource,channel,andsoon),writingthecodeisstraight-forward.Forexample,thecodetosetupa10-msperiodicconversion(triggeredbyatimer)thatisoversampledby8consistsofthecodesegmentsshowninExample1.
Example1.8xOversamplingwiththeDriverLibraryFunctions
CodeSegment1.a.ADCConfiguration–DriverLibraryFunctions
//
//InitializetheADCtooversamplechannel1by8xusingsequencer0.
//Sequencerwillbetriggeredbyoneofthegeneral-purposetimers.
ADCSequenceConfigure(ADC_BASE,0,ADC_TRIGGER_TIMER,0);
ADCSoftwareOversampleConfigure(ADC_BASE,0,8);
ADCSoftwareOversampleStepConfigure(ADC_BASE,0,0,(ADC_CTL_CH1\
|ADC_CTL_IE|ADC_CTL_END));
//InitializeTimer0totriggeranADCconversiononceevery10milliseconds
TimerConfigure(TIMER0_BASE,TIMER_CFG_32_BIT_PER);
TimerLoadSet(TIMER0_BASE,TIMER_A,SysCtlClockGet()/100);
TimerControlTrigger(TIMER0_BASE,TIMER_A,true);
TheADCconfigurationshowninCodeSegment1.adictatesthataninterruptoccurwhensamplingcompletes,meaningthataninterrupthandlermustbeimplemented(seeCodeSegment1.b).SincetheDriverLibraryoversamplingfunctionsautomaticallyaveragethesampleddata,theinterrupthandlerfunctionisrelativelybasic.Keepinmindthathavingtheaveragecalculatedduringeachinterruptaddscomputationaloverheadtotheinterrupthandler.
CodeSegment1.b.ADCInterruptHandler
void
ADCIntHandler(void)
{
longlStatus;
//
//CleartheADCinterrupt
ADCIntClear(ADC_BASE,0);
//GetaverageddatafromtheADC
lStatus=ADCSoftwareOversampleDataGet(ADC_BASE,0,&
g_ulAverage);
//PlaceholderforADCprocessingcode
}
Withtheconfigurationstepsandinterrupthandlerinplace,theconversionprocessisinitiated.Beforethetimeristurnedon(beginscounting),theADCsequencerandinterruptmustbeenabled(seeCodeSegment1.c).
CodeSegment1.c.EnablingtheADCandInterrupts
//EnableADCsequencer0anditsinterrupt(inboththeADCandNVIC)
ADCSequenceEnable(ADC_BASE,0);
ADCIntEnable(ADC_BASE,0);
IntEnable(INT_ADC0);
//Enablethetimerandstartconversionprocess
TimerEnable(TIMER0_BASE,TIMER_A);
OversamplingMoreThan8TimesUsingMultipleSequencersoraTimer
TheDriverLibraryoversamplingfunctionsarelimitedtooversamplingby8times