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

Slides:



Advertisements
Similar presentations
11-1 Bard, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 11: Data Acquisition, Numerical Fixed-Point Calculations, Lab.
Advertisements

Mark Neil - Microprocessor Course 1 Device Drivers – Digital Voltmeter.
Analog-to-Digital Converter (ADC) And
Analogue to Digital Conversion By Cap’n Tim Johnson, PE Prepared 11/12/2013.
ECE 265 – LECTURE 14 Analog Signal Acquisition The A/D converters 5/14/ ECE265.
10-1 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 10: Sampling, Analog-to-Digital.
Digital to Analog and Analog to Digital Conversion
©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 14 Connecting with Analog.
4-Integrating Peripherals in Embedded Systems (cont.)
Analog to Digital Conversion. Introduction  An analog-to-digital converter (ADC, A/D, or A to D) is a device that converts continuous signals to discrete.
Data Acquisition Risanuri Hidayat.
Analog to Digital Conversion. 12 bit vs 16 bit A/D Card Input Volts = A/D 12 bit 2 12 = Volts = Volts = 2048 −10 Volts = 0 Input Volts.
Chapter 11 Analog I/O Interfacing From Introduction to Embedded Systems by Valvano.
Shuvra Das University of Detroit Mercy
Presented by- Md. Bashir Uddin Roll: Dept. of BME KUET, Khulna-9203.
Lecture 9: D/A and A/D Converters
Analogue to Digital Conversion
68HC11 Analog I/O Chapter 12.
Unit 4 Sensors and Actuators
Data acquisition and manipulation
ECE 371 – Unit 15 Data Acquisition Systems A/Ds in MC9S12DPS56B Microcontroller.
Analog-to-Digital Converter (ADC)
Introduction to Data Conversion
Discussion #25 – ADCECEN 3011 Conversion Mosiah 5:2 2 And they all cried with one voice, saying: Yea, we believe all the words which though has spoken.
ADC STUDENT LECTURE Andrew Brown Jonathan Warner Laura Strickland.
EET260: A/D and D/A converters
H. Huang Transparency No.11-1 The 68HC11 Microcontroller Chapter 11: 68HC11 Analog to Digital Converter The 68HC11 Microcontroller Han-Way Huang Minnesota.
Railway Foundation Electronic, Electrical and Processor Engineering.
11-1 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 11: Data Acquisition, Numerical.
Data Acquisition. Data Acquisition System Analog Signal Signal Conditioner ADC Digital Processing Communication.
Week #7 Data Acquisition System, Part (A)
11 Lecture Slides ME 3222 Kinematics and Control Lab Lab 2 AD DA and Sampling Theory By Dr. Debao Zhou.
Computer Based Data Acquisition Basics. Outline Basics of data acquisition Analog to Digital Conversion –Quantization –Aliasing.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
Electronics Involves the use of devices and circuits to control the flow of electric current to achieve some purpose. These circuits contain: Resistors,
EE 319K Introduction to Microcontrollers
1 ATD10B8CV2 on MC9SI2C By: Yuchun Huang. 2 ADC ADC Power Supply.
Data Acquisition Systems
ELN5622 Embedded Systems Class 7 Spring, 2003 Aaron Itskovich
SIGMA-DELTA ADC SD16_A Sigma-Delta ADC Shruthi Sujendra.
Revised: Aug 1, ECE 263 Embedded System Design Lessons HC12 Analog-to-Digital (ATD) Converter System.
9-1 EE 319K Introduction to Microcontrollers Lecture 9:I/O Synchronization; LCD Interfacing; Implementing Local Variables using a Stack Frame; Parameter.
V. Rouillard  Introduction to measurement and statistical analysis DIGITAL SAMPLING - DIGITISATION Digital sampling is mainly used in data acquisition.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 1P. 1Winter Quarter Data Acquisition System Fundamentals Lab 1.
8-1 EE 319K Introduction to Microcontrollers Lecture 8:Fixed Point Numbers, Local Variables, Binding, Allocation, Access, Deallocation.
Analog Capture- Port E. Digital to Analog and Analog to Digital Conversion D/A or DAC and A/D or ADC.
Analog to Digital Converters
Digital Control CSE 421.
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
Data acquisition is the process of sampling signals that measure real world physical conditions and converting the resulting samples into digital numeric.
Data Acquisition System
ECE 2799 Electrical and Computer Engineering Design ANALOG to DIGITAL CONVERSION Prof. Bitar Last Update:
Lecture 2 Analog to digital conversion & Basic discrete signals.
Analog to Digital Conversion - ADC Mark Neil - Microprocessor Course 1 Device Drivers – Measuring Voltages.
Embedded Systems Lecture 5 January 25 th, 2016.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
H. Huang Transparency No.10-1 The 68HC12 Microcontroller Chapter 10 68HC12 Analog to Digital Converter.
Electronic instrumentation Digitization of Analog Signal in TD
1 Lab 4: D/A Converter Lab 4: D/A Converter This is a simple resistive network for a D/A converter Port 1, Port 0 are digital inputs ==> 00 (minimum),
EE 319K Introduction to Embedded Systems
FOR MORE CLASSES VISIT   ECET 340 Week 1 HomeWork 1  ECET 340 Week 1 iLab 1  ECET 340 Week 2 HomeWork 2  ECET 340 Week 2 iLab.
MECH 373 Instrumentation and Measurements
Digital Control CSE 421.
Chapter 12: Analog-to-Digital Converter
EE 319K Introduction to Embedded Systems
Microcontroller Applications
Analog-to-Digital Converter
Signal conditioning.
ADC and DAC Data Converter
Presentation transcript:

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

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

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

12-4 Ramesh Yerraballi.. Nyquist Theory

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

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 / Analog Digital V in cm Analog D

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

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

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., => 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

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  V 1.5/255  cm; 1.5/1023  cm

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 = % Ex2: V in = 3.75 => Dig out = Integer approx (255 * 3.75/5) = 191 = $BF = %

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

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

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

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

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

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?

12-18 Ramesh Yerraballi Lab8: Call Graph

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

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 = *V (in k) T = 1/(H 0 +H 1 ln(R)) (in o C) (H 0 = , H 1 = ) I = 100*T (in 0.01 o C) Simple Equation I = 3971 – *n

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

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

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

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 = *V (in k) T = 1/(H 0 +H 1 ln(R)) (in o C) (H 0 = , H 1 = ) I = 100*T (in 0.01 o C) Simple Equation I = 3971 – *n Using fdiv, find m such that 65536/m = m = 65536/ = ≈ * Reg D has ADC result, 0 to 1023 ldx #33153 fdiv pshx ; *n ldd #3971 subd 2,SP+ std I ; 0.01 C

12-25 Ramesh Yerraballi Simple Equation

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

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<S[i+1]  Use linear interpolation (look up etbl in TExaS help)  position = P[i]+((sample-S[i])*(P[i+1]-P[i]))/(S[i+1]-S[i])  Option C : Create a 255-entry calibration table (P[ATD0DR0L])  Fixed-Point output  1234 is displayed as “1.234 cm”