{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lect12_notes - Foundations of Embedded Systems A Term Fall...

Info icon This preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Foundations of Embedded Systems A Term Fall 2008 Lecture #125 The A/D Converter (ADC12) Reading for Today: User's Guide 20 Reading for Next Class: User's Guide 20 HW #4 (on web): Due Thursday 9/25/08 Lab #2 (on web): Report due 8/ 30/2008 Last Class: More on the stop watch example and using “leap counts” to help maintain time accuracy > > Timer operation is autonomous. Main code runs independently. Only evidence/impact of interrupts is the timer count increasing Analog-to-Digital Converter (ADC12) >> A/D converters have become ubiquitous! ——> YOU will very like need to use them to complete your ECE2799 project and you MQP! --> But, how do they work and how do you use them properly? >> Some ADC basics... \v ,_____,/ Analog-to-Digital Converter (ADC12) >> A/D converters have become ubiquitous! —-> YOU will very like need to use them to complete your ECE2799 project and you MQP! ——> But, how do they work and how do you use them properly? :5 B‘\r\a,~((3 Codes QVe asSC—qned 4o Qixeé V re“ Vo\ i'ucs es =94rmlo$ vol‘l'ocge \S Sampled 4‘6 éime Cn‘lerqls :> Ouipoi eagle 0—5? weaves-l volloccae \evel \g asswnecl >> Some A/D realities... Sample and Hold A/D >> Real—world, non—ideal circuits can lead to non-linearities in conversion results (see “ABC's of ADC's” on class links page) 3) sw‘nldx ‘lramszeml (1A3 valiafic &~Q caifi are real: 9 ialer 84mph“ +emcl 40 WOV‘SPM ‘Mnese eCFeolb >> 12—bit Sample and Hold ADC‘s (or the like) are standard equipment on small uP's like our MSP430 --— Are they any good? Yes and No >> Generally well suited to measuring low to moderate data rate sensors with fixed dynamic range A DC IZ— l/Vb .8 may —»- Temperature {2“}, 900 K 3 PS _.. Pressure L g‘wples per 36C\ —-- Accelerometers >> Probable unsuitable for higher data rate, larger dynamic range --- Most audio qg'OkSPS >> BUT.. as always, it will depend on the Application! What is dynamic range anyway? 3 Key Concepts for Using Analog-to-Digital Converters 1) F ull Scale Range (F SR ) - Max or total range of analog values that can be represented We Pull Sea/(.41 (”anode 0 0++kls ADC L3 23V \ 14%“ 2) Resolution (Single bit resolution) ~ Smallest change in value that can be measured (WILD D531 b'-.+\ For CLVN REC— l‘ZéSOlJ Jr MBA L F S ,1 WW J'Q; 434., a? ‘5‘st 940‘ (:0 prDC. ..——~\ 1* FER: ARV (WA lg: 12. ‘ZC‘SLTLJ "‘b’IOWA BDQV/qoqe : (El—lg Mv 3) Dynamic Range — Ratio of the largest to the smallest values that can be meaured D-DDDDLLDB QDDDDDDDD an Aeakelsélw m2; (Mm . - .D QODrog /\ be '20 QOBLQ D dB QO‘QDDD» mDDD Example: Sigma—Delta ADC typically have better sampling characteristics than a sample and hold ADC. What is the dynamic range and resolution of the 16 bit sigma—delta ADC that is available with the MSP430x3xx family. \ ' Do, "’ SQ D 1 DD D DDS > Some specifications for ADC12 Single 12 bit AnalogtoDigital Converter with built in Sample and Hold 6quer s M A DC \ 7. => 0 +0 90*?5’ 3DOQ+PQ+ {trayg‘lev's cue IQ lof‘ls bdr<l~€ Monotonic with no missing codes 'I . . \ ~ D‘flOno‘l‘OrHC. flo'l- necesgamltj ‘ Lmeoo’ 2'? Masha Sl.“o\n+lfl bowel/l _ :7 S p e L o it A D C' Can accept any of 8 (external) analog inputs or 4 internal analog inputs Domloj ‘C/lpo‘lS [40-147 use same Q3105 6&3 fiml [0! To selec—l ‘H’xose PMS par RDC Okflglocj (“pu‘f PéSEL bhls =1 Selectable voltage references (Vref+ and Vref) L/SUQMO Vmg ; LW or 25v 0, Va (av) \Irz-l; :1 O :‘vSs -»- Analog input voltage 0 to Vcc (Single ended!) —:> Over vollaaf’s (or 0““ “mesa 0m 41>: dQMO\fi{ m icv‘opVOCfSSOWG/ “Oneshot” or continuous operation -— Single input channel or sequence of input channels -- 16 conversion result storage registers (each with its own control register) 3> Can“ \Johfier” YfSU HS Lr’) +A€5< weaim‘ers Ex. A simple digital current meter might measure current by measuring the voltage across a small sensing resistor. Can we use the ADC12 to measure across the range 0 to l A to 1 mA accuracy ? How about 0.: mA accuracy? Cm R59“; VSQAS : Rsens CM +~ - TQ'SV + 12w — _ _. ADC. 5 L00»), 0 t H 58+ fidtfl Q So ‘Hlxaj’ 3,5V—9ifl whkfil \55 our resolorhom 7 O ng ; ,élMV 4099 of L014 :_ .Q‘HMH 404A 9km M‘EQSUF‘Q *0 .leq or "\Qch 4:0 MAE/'65. reolwe. we New Sade “we” , lmFl : 1:52;)“ \ Fse( 2 OHO%A=—>l.02‘lv ", J t afiA— 1-1046, F’sn «Ca; JMA- resoluhon ::>\fl\‘\5 \3 Mrs & “D‘sfimj V0\+.mg7fer(bvm§ MS d\\ Iggefen“ SCQIQS Z st‘llekmf} values 04: C7 . ** Knowing how your external sensor works and how to “map” it to the ADC you ’re using is as critical as knowing how to program the microprocessor to read the ADC” --> As embedded systems engineer, proper interfacing of sensors to ADC is up to YOU! 5£€ T: (081: U 5‘6 € ya ”4 P Le; ADC12 Control and Data Registers (MSP430 Users Guide Ch 20) > > ADC 12 conversion core configured using ADC12CTLO and ADC12CTLl. ‘ I + S ‘1 M l € ' ADC12CTLO controls the following options 833 p —-— _.__P —- Sample and Hold time (SHTlx and SHTOx) Q U se 2 Kkm {2 l‘e \/ celU € 5 . ~ 5 -- Multiple sample conversion method (MSC) = L 0 ‘l 5 0 7C C O’Vc‘fl ”“94 l on / —- Reference Voltages (REF_25 and REF__ON) g. (4.)" l\ nee A +0 serl‘ + he 56 , “ADCIZONbit é: ‘l‘ums on ADC b5 Aelgull‘i'l‘ 1S OPP -- Enable and start conversion (ENC and ADCI 25C) 6:— ‘rhe 5e s R; v + measuremen'l -— Overflow/Conversion time interrupt enables (ADC120VIE, ADC12TVIE) ADC12CTL1 controls the following options -- Conversion start address (CSTART ADDx) —- Sample and hold source select (SI-18x) :7 SM w lmajl’ s Janis CW ADC IZ SC. lol+ 0r ‘Ixmer -- Sample and Hold pulse mode selectable (SHP) SHP;| -- Invert signal sample and hold (ISSH) -- ADC12 clock divider (ADCI 2DIVx) —— ADC12 clock source select(ADCSSELx) = A Dc 42. 05c (s'M H23 0 r Ace K, SMCL K or- M CLK -- Conversion mode select (CONSEQx) Single 0r Moliiple Channels, 5ln5le 0’ COM‘LM‘JO‘JS SkMPllns -- ADC12 busy/conversion not complete bit (ADCIZBSY) fiDCJ2.Eusy=;| meemgon NOT Acne Vel > > Results from each channel are stored in the low 12 bits of one of 16 Conversion Memory Registers (ADC12MEMx) >< >< Ix “fii‘lll‘lll. > > Each memory register has a corresponding Conversion Memory Control Register (ADC12MCTLx) Each ADC12MCTLX controls the following options for its Memory Register -- End of Sequence (EOS) -- Select Reference Voltages (SREFx) -- Analog input channel selection (INCHx) So what does the programmer need to do to use ADC12? 1) Select ADC Core Behavior: Keep it Simple 8: Use examples! -- Select Clock source (ADCIZSSEL) 00 = ADClZOSC ~ SMHz 01 = ACLK 10 = MCLK 11 = SMCLK -- And divider ADC12DIV_0 = 000 = divide by 1 ADC12DIV_7 = 111 = divide by 8 -- Sample and hold behavior > > SHSx = Trigger Source Select 00 — ADClZSC bit = single conversions 0 1 , l O , 1 1 = use timers (periodic conversions) >> SHP = 1 (usually) -- Reference Voltages REF2_5V = 1 for Vren = 2.5V REF2_5V = 0 for Vref+ = 1.5V REF_ON= 1 turns internal reference on 2) Select Conversion Mode required: -- Single channel, sequence of channels, single or repeated conversion 3) Select input channel(s): INCHx bits in ADCMCTLX registers > > Has 8 {external) analog input signals or 4 internal analog inputs "7 Pé Pins 0 ‘ 7 Defined as INCH_O to INCH_11 > > Internal input channels 8h, 9h and 11h (INCHx = 1000, 1001, 1011) connected to different reference voltages > > Internal input channel 10h (INCHX = 1010) measures is connected to an internal Temperature Sensor. \/ > > ADC12‘s 8 Analog Inputs A0 - A7 are multiplexed with Port 6 pins! Port Selection (P6SEL) bits for those pins should be 1 = Function Select 4) Enable appropriate interrupts (ADC12IE) - .) 1.? 30251 (e A -— Write ISR (Should handle all 18 possible ADC interrupts with some default behavior a switch statement) -- Usually configure interrupts when doing repeated conversions 5) Enable and Start Conversion(s) --> If required (i.e. not using interrupts) Poll for completion 6 *1 CON“ “’ 5 ‘ O V‘ Ex. Continuing on with the digital current meter, assume that the gain G is set so 1A equals the full scale voltage of 2.5V. Assume that the the analog input voltage is applied to A0. How would we set the ADC12 registers? Que: Abcosc .=> 40cm. 35:00 ~> Selec‘i- QLo¢/¢ =751r\c_)\~e “494.5qu (5H5). ; Aboasc bI-l Moe—16> WW 25v (W _=>:L3m_\ a 0000 aid/(W4 (“OH in Abmzmm¢ dc ano+ chasvwxd M (15 7pm,? = coco ">1 CW So ”0+ M gn4arrop+s S> IssuE aka/Lie Canvevs‘tms ~1- 5+6Lv+ (Ont/€V$;Ol4 C ENC) (A'Dczz SC.) // Some code to implement the current meter above.... unsigned int in_value, busy; // Initialize control register ADC12CTLO = 0110 0110 0111 0000 // SHTlx and SHTOx = 66h (both 128 clks), MCS = 0 = no burst mode // REF2_5V = 3 (2.5V), REFON = 1 = use internal reference voltage // and ADClZON = 1 = turn ADC on ‘5 5 5‘ ADClZCTLO = SHTO 6 + SHTl 6 + REF2 5 + REFON + ADClZON; ( _ _.- _, _ . leave as (5 // Initialize control register ADC12CTL1 = 0000 0010 0000 0000 // CSTART ADDx = 0000 = start conversion with ADClZMEMO, // SHSx = 00 — use SW conversion initiation trigger, ADC125C bits // SHP = l = SAMPCON signal sourced from sampling timer, // ISSH = 0 = sample input signal not inverted, // ADClZDIVx = 000= divide ADC12CLK by 1, // ADClZSSEL=00= ADC Clock ADClZOSC (~5 MHz), // CONSEQx = 00 single channel, single conversion, lf“’ 8*L+ // ADCIZBUSY = 0 = no ADC operation active ADClZCTLl = SHP; w // Set conversion memory control register ADClZMCTLO = 0001 0000 // EOS = 0, SREF =001 -—>Voltage refs = GND to (Vref+) // INCHX = 0000 = analog input from A0 ADClZMCTLO = SREF_1 + INCH 0; KSK. .-\> P6SEL |= BITO; // Set Port 6 Pin 0 in FUNCTION mode for ADC //Enable and start (single) conversion .9 ADClZCTLO |= ADClZSC + ENC; busy = 1; while (busy != O) // Wait until conversion complete busy = ADClZCTLl & ADClZBUSY; //Check BUSY bit (polling!) inhvalue = ADClZMEMO & OxOFFF; // keep only low 12 bits ?’\§qse -D 9 \00‘5 3166“ ) «w;_._..- ¥ éwfl‘” Wg‘\\\ \ ECE 2801 — Foundations of Embedded Computer Systems Mid-term +/- Survey Plus + : Something about ECE3801 that is working for me is... Minus - : Something aboutR801 that is not working or is missing for me is... What can the instructor do (starting tomorrow!) to make this a better course? What can the I do (starting tomorrow!) to get more from this course? ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern