Está en la página 1de 1

Pgina 1 Robot Platform | Knowledge | ADC Programming in Atmega8

27/07/2014 10:04:55 a.m. http://www.robotplatform.com/knowledge/ADC/adc_tutorial_4.html


Search
home
electronics
howto
tools
knowledge
forum
news
ADC in Atmega8 Summary
If youhavedirectlyjumpedtothissection, thenfor adetailedexplanationonADC readthistutorial fromthebeginning. Tosummarizewhatever we
learnt till now:
Signalsareset of valuesthat conveyinformationandaremeasuredbyanyindependentattributeliketimeor
space. Analogsignalsarereal worldsignalsarounduslikesoundandlight. Digital signalsareanalog
equivalentsindigital or numericformatwhicharewell understoodbydigital systemslikemicrocontrollers.
ADC isonesuchhardwarewhichmeasuresanalogsignals(Voltage) andproducesadigital equivalent of the
samesignal.
ADC inAVR devicesusesatechniqueknownassuccessiveapproximationbycomparinginput voltagewith
half of referencevoltagegeneratedinternally. Thecomparisoncontinuesbydividingthevoltagefurther
downandupdatingeachbit inADC register by1if input voltageishigh, 0otherwise. Thisprocesslasts8
(for 8bit ADC) or 10(for 10bit ADC) timesandgeneratesresultingbinaryoutput.
WithregardstoAtmega8afewconceptstoknowbeforehandare:
1. AVCC: ThisAVR pinsuppliespower toADC. AVcc must not differ morethan0.3V fromVcc
2. AREF: Another AVR pinwhichcanoptionallybeusedasanexternal voltagereferencepin.
3. VoltageResolution: Thisisthesmallest voltageincrement whichcanbemeasured. For 10bit ADC, therecanbe1024differentvoltagesand
for 8bit ADC, therecanbe256differentvoltages.
4. Input voltagecanbemeasuredas: VIn[V] =(ADCH*256+ADCL) * VRef [V] / 1024for 10bit ADC
5. Input voltagecanbemeasuredas: VIn[V] =(ADCH)* VRef [V]/256for 8bit ADC
6. HardwareunitslikeDAC (Digital toAnalogconverter), Comparator, SHA or S/H (Signal andHold), SAR (Successiveapproximationregister)
together completeADconversion.
7. Most AVR microcontrollershavebuilt inADC whichreducescost andspacefor anexternal ADC
8. Lastly, beinformedthat all ADC pinsareconnectedtoonlyoneinternal ADC, whichmeansyouneedtodooneconversionat atime.
ADC Setup using Atmega8
If youarealreadydizzywiththeboringtheory, thenwakeup; wewill start someprogramming. If youarenot awareof bits, portsandprogramming, I
recommendyoutoreadAVR basicsandcompleteblinkingLEDproject beforeyoustart this, becausePort basicsandprogrammingbasicsarenot
part of thistutorial.
InthissimpleADC project, wewill set upadcinsingleconversionmodewith10bit precision,
completeaconversionandswitchonandoff twoLEDsbasedontheresult
If youhavealreadycompletedblinkingLEDproject, thenyoualreadyhaveall theparts
requiredfor thisproject. Onemorecomponent whichaddstothelistisavariableresistor / pot.
Theimageintheright tellsyouhowandwhat toconnect. Clickonit for apictorial
representationof connections.

También podría gustarte