Download presentation

Presentation is loading. Please wait.

Published byLouisa Kelly Modified over 2 years ago

1
12-1 EE 319K Introduction to Microcontrollers Lecture 12: A/D Conversion and Lab 8 Read Book Sections 10.2 and 11.4

2
12-2 Ramesh Yerraballi A/D and D/A Conversion Basics Digitization:Amplitude and time quantizing

3
12-3 Ramesh Yerraballi Nyquist Theory If a signal is sampled at f s then the digital samples only contain frequency components from 0 to (1/2)f s Conversely, if the analog signal does contain frequency components larger than (1/2)f s, then there will be an aliasing error. Aliasing is when the digital signal appears to have a different frequency than the original analog signal. Say, V(t) = A sin(2πft + ) Nyquist theory says that if f s is strictly greater than twice f, then one can determine A f and from the digital samples. But if f s is less than or equal to 2f, then the apparent frequency, as predicted by analyzing the digital samples, will be shifted to a frequency between 0 and (1/2)f s

4
12-4 Ramesh Yerraballi.. Nyquist Theory

5
12-5 Ramesh Yerraballi A/D and D/A Conversion Basics Range of the system is the maximum minus the minimum values Precision of the system defines the number of values from which the amplitude of the digital signal is selected. (Alternatives) Resolution is the smallest change in value that is significant. Range = Precision x Resolution

6
12-6 Ramesh Yerraballi A/D Converter Example Analog to digital Converter Analog input 0 ≤ V in ≤ +5 Digital output 0 ≤ ATD0DR0 ≤ 255 oDigital Output is about 256*V in /5 oOr Digital Output is about 255*V in /5 0 +5 0 255 Analog Digital V in 0.00 1.50cm Analog D

7
12-7 Ramesh Yerraballi 9S12 has 16 Analog Inputs AD1 AD0 One Control Register per ADC module: ATD0CTL2 and ATD1CTL2

8
12-8 Ramesh Yerraballi Port AD0 ATD0CTL2=$80 ; set bit 7 to 1 to enable ADC ATD0CTL3=$08 ; sequence length = 1 SRES8 ; 1 for 8-bit values, 0 for 10-bit values

9
12-9 Ramesh Yerraballi ADC Clock The ADC has an internal clock that controls how fast the ADC runs Not how many samples it takes but how fast the conversion (A/D) works. Speed controlled by 5-bit value in the lower 5- bits (PRS5-PRS1) of ATD0CTL4 Say this value is m (e.g., 00100 => m=4) The ATD internal clock speed is given by: (1/2)E/(m+1) where E is the E clock speed Say we want this speed to be 1 MHz, So for: oE-clock speed of 4 MHz m is set to 1 oE-clock speed of 8 MHz m is set to 3 oE-clock speed of 24 MHz m is set to 11 Internal clock speed can range from 500 kHz to 2 MHz

10
12-10 Ramesh Yerraballi Other settings ATD0CTL5 write channel number (analog input) to start ADC channel number $80 to $87 (CC:CB:CA) ATD0STAT bit 7 SCF cleared by write to ATD0CTL5 (i.e., starting a new conversion) or just write 1 to it set when ADC finished ATD0DR0 first 8/10-bit ADC result precision 8/10-bit, 256/1024 alternatives range 0 to +5V resolution (5-0)/255 0.02 V ; (5-0)/1023 0.005 V 1.5/255 0.006 cm; 1.5/1023 0.0015 cm

11
12-11 Ramesh Yerraballi 8-bit Conversion Example Digital o/p = 255 * V in /5 Ex1: V in = 1.50 => Dig out = Integer approx (255 * 1.50/5) = 76 = $4C = %01001100 Ex2: V in = 3.75 => Dig out = Integer approx (255 * 3.75/5) = 191 = $BF = %10111111

12
12-12 Ramesh Yerraballi 10-bit Conversion Example Digital o/p = 1023 * V in /5 Ex1: V in = 0.005 => Dig out = Integer approx (1023 * 0.005/5) = 1 = $001 = %0000000001 Ex2: V in = 3.750 => Dig out = Integer approx (1023 * 3.750/5) = 768 = $300 = %1100000000

13
12-13 Ramesh Yerraballi Complete ADC Example Tut3 in TExaS is an ADC example See ADC Driver ADC_Init oTurns it on oSets it to 10-bit mode ADC_In owrite channel number to ATD0CTL5 owait for SCF flag in ATD0STAT oread 10-bit result from ATD0DR0 SCI_OutDec

14
12-14 Ramesh Yerraballi Lab 8: Design a Position Meter Hardware Transducer Electronics ADC Software ADC device driver Timer routines oOutput compare interrupts LCD driver Measurement system oHow fast to update oFixed-point number system oAlgorithm to convert ADC into position

15
12-15 Ramesh Yerraballi Lab8: Data Flow Graph 1.50 cm 1.50 255

16
12-16 Ramesh Yerraballi Lab8: Transducer A transducer converts some observable phenomena (temperature, pressure, opening, position, speed etc. to a analog form that can then be digitized. A potentiometer converts position to a resistance Solder wires to pins 1,2,3 Glue potentiometer to a solid base Position metric ruler (for calibration and testing) Create a hair-line cursor

17
12-17 Ramesh Yerraballi Lab8: Circuit What is R 12 + R 23 at all times? What are R 12 and R 23 when cursor is at 1 cm? What is V in when cursor is at 1 cm? What is ATD0DR0 when cursor is at 1 cm? What do you want to display on the LCD when cursor is at 1 cm?

18
12-18 Ramesh Yerraballi Lab8: Call Graph

19
12-19 Ramesh Yerraballi Convert ADC data into integer part of fixed-point Three possibilities The relationship between the ADC data and what it represents is expressible as an equation The relationship is expressible as a partially complete table and we use interpolation to infer the missing The relationship is expressible as a complete table and we perform explicit table lookup

20
12-20 Ramesh Yerraballi Equation for Temperature Example Complex Equation let n be ADC (0 to 1023) V = 5.0*n/1023 (in volts) R = 18.31 + 5.312*V (in k) T = 1/(H 0 +H 1 ln(R)) -273.15 (in o C) (H 0 = 0.002486844, H 1 = 0.000243014) I = 100*T (in 0.01 o C) Simple Equation I = 3971 – 1.9768*n

21
12-21 Ramesh Yerraballi Muls and Divs mulunsigned A*B into D emulunsigned D*Y into 32-bit Y:D emulssigned D*Y into Y:D idivunsigned D/X into X, D remainder idivssigned D/X into X, D remainder fdivunsigned (D:0)/X into X, D remainder edivunsigned (Y:D)/X into Y, D remainder edivssigned (Y:D)/X into Y, D remainder

22
12-22 Ramesh Yerraballi Examples 1. Count (0 to 199) = (5/9) * Angle (0 to 359) * Count =(5*Angle)/9 ldd Angle ldy #5 emul ;(Y:D)= 5*Angle ldx #9 ediv ;Y=(5*Angle)/9 sty Count 2. Angle (0 to 359) = (9/5) * Count(0 to 199) * Angle =(9*Count)/5 ≈ (65536*Count)/36409 ldd Count ldx #36409 fdiv stx Angle 3. Column (0 to 6) = (7/256) * Xpos (0 to 255) * Column =(7*Xpos)/256 ldaa Xpos ldab #7 mul ;RegD=7*Xpos staa Column ;RegA=(7*Xpos)/256

23
12-23 Ramesh Yerraballi Promotion/Demotion Unsigned 8 to 16-bit promotion ;to promote RegB into RegD clra ; to promote RegA into RegX tfr A,B clra tfr D,X Signed 8 to 16-bit promotion sex A,D (same as tfr A,D ) sex B,D (same as tfr B,D ) sex A,X (same as tfr A,X ) sex B,X (same as tfr B,X ) sex A,Y (same as tfr A,Y ) sex B,Y (same as tfr B,Y ) 16 to 8-bit demotion (signed or unsigned) tfr D,A tfr D,B tfr X,A tfr X,B tfr Y,A tfr Y,B

24
12-24 Ramesh Yerraballi Equation for Temperature Example Complex Equation let n be ADC (0 to 1023) V = 5.0*n/1023 (in volts) R = 18.31 + 5.312*V (in k) T = 1/(H 0 +H 1 ln(R)) -273.15 (in o C) (H 0 = 0.002486844, H 1 = 0.000243014) I = 100*T (in 0.01 o C) Simple Equation I = 3971 – 1.9768*n Using fdiv, find m such that 65536/m = 1.9768 m = 65536/1.9768 = 33152.5698 ≈ 33153 * Reg D has ADC result, 0 to 1023 ldx #33153 fdiv pshx ; 1.9768*n ldd #3971 subd 2,SP+ std I ; 0.01 C

25
12-25 Ramesh Yerraballi Simple Equation

26
12-26 Ramesh Yerraballi Interpolation We will look at examples in TExaS help system 8-bit table access on the 6812 16-bit table access on the 6812 Basic idea Y L - Y 1 Y 2 - Y 1 X L - X 1 X 2 - X 1 Y L = Y 1 + B *(Y 2 - Y 1 ) = B The TBL Instruction does this

27
12-27 Ramesh Yerraballi Back to Lab 8 Sample ADC every 0.2s Map (Data: 0 to 255) into (Position: 0000 to +1500) Option A: Use a linear function Position = 1500*(Sample)/255 (NOT THIS ONE) Option B : Use a paired calibration table (S[i],P[i]) S[i] are ADC samples measured at corresponding positions P[i] Given sample, find i such that S[i]<=sample~~
{
"@context": "http://schema.org",
"@type": "ImageObject",
"contentUrl": "http://images.slideplayer.com/14/4275217/slides/slide_27.jpg",
"name": "12-27 Ramesh Yerraballi Back to Lab 8 Sample ADC every 0.2s Map (Data: 0 to 255) into (Position: 0000 to +1500) Option A: Use a linear function Position = 1500*(Sample)/255 (NOT THIS ONE) Option B : Use a paired calibration table (S[i],P[i]) S[i] are ADC samples measured at corresponding positions P[i] Given sample, find i such that S[i]<=sample~~~~
~~

Similar presentations

Presentation is loading. Please wait....

OK

15-348 Embedded Systems Lecture 5 January 25 th, 2016.

15-348 Embedded Systems Lecture 5 January 25 th, 2016.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on six sigma Ppt on porter's five forces example Convert doc file to ppt online Ppt on natural and artificial satellites of planets Ppt on unity in diversity slogans Ppt on book of revelation Ppt on phonetic transcription ipa Ppt on christianity in india File type ppt on cybercrime Ppt on computer languages list