Download Analog to Digital Conversion - Lecture Slides | ECE 331 and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!
Module Learning Objectives, Students should be able to:
Analog to Digital
Conversion (ADC)
Background
Module 10: Part 1 (M10.1)
Describe motivation for ADCs in microcontrollers
Explain basic operating principles of ADCs
Calculate analog values of ADC digital results and vice versa
Describe the ADC peripheral module for the KL25Z
microcontroller
ECE 331
Prof. Nihar Mahapatra (adapted from Prof. A. Mason’s lecture notes; other sources listed at the end) Analog-to-Digital Converters
Terminology
o analog-to-digital converter = ADC = A/D = AtoD
Function
o transform an analog signal into a digital signal for use
(calculation, storage, decision making) in a digital system e.g.,
a microcontroller
Motivation
o the real world is analog
o A/D needed to interface real world to digital systems
- monitoring of real world events/phenomena
- electronic intelligent feedback control of real world M10: Analog 2 real world transducer A/D digital system control monitoring micro- controller ANALOG DIGITAL
Transducers
Transducer
o a device that converts a primary form of energy into a corresponding signal with a different energy form
- Primary Energy Forms: o take form of a sensor or an actuator
Sensor (e.g., thermometer)
o a device that detects/measures a signal or stimulus o acquires information from the “real world”
Actuator (e.g., heater)
o a device that generates a signal or stimulus 3 real world sensor actuator intelligent feedback system mechanical, thermal, electromagnetic, optical, chemical, etc. Common Transducers Conventional Transducers large, but generally reliable; based on older technology
o thermocouple:
o compass (magnetic):
Microelectronic Sensors millimeter sized; highly sensitive; less robust
o photodiode/phototransistor:
- infrared detectors, proximity/intrusion alarms
o piezoresisitve pressure sensor:
o microaccelerometers:
o chemical sensors:
o biosensors:
temperature difference
direction
photon energy (light)
air/fluid pressure
vibration, ∆-velocity (car crash)
O 2 , CO 2 , Cl, Nitrates (explosives)
DNA profile, disease biomarkers
M10: Analog 4
A/D Conversion Process
Sampling rate
o What is sampling? strobe light example o Nyquist criterion: minimum sample frequency ( fs ) should be twice the highest frequency content ( fh ) of the sampled signal fs >= 2 fh o Time interval between samples: Ts = 1/ fs o Anti-aliasing filter: use LPF with fcutoff = fh
- Example: sample human voice at 8 KHz, use 4 KHz LPF to prevent aliasing
Encoding
o Provides unique binary code for every discrete voltage step between VRH and VRL o n = #steps = 2b, b= #bits 7 5V 3 - bit encoding example EXAMPLE: What voltage is encoded by 101? 101 3.57 V Sampling & Aliasing 100 Hz signal sampled at 1600 Hz osample freq. >> highest data freq.
- fs >> fh ofrequency response correctly shows frequency of the data signal M10: Analog 8 A signal with DC, 100 Hz and 400 Hz sampled at 1600 Hz osample freq. >> highest data freq.
- fs >> fh ofrequency response correctly shows all 3 frequencies in the data signal Sampled Data
0 1 2 3 0 2 4 6 8 10 Time (ms) Voltage (V) Sampled Data T rue Data FFT Magnitude
0.0 0.2 0.4 0.6 0.8 1. Frequency (kHz) Voltage (V) Sampled Data
0 1 2 3 0 2 4 6 8 10 Time (ms) Voltage (V) Sampled Data T rue Data FFT Magnitude
0.0 0.2 0.4 0.6 0.8 1. Frequency (kHz) Voltage (V) source: Bard, Gerstlauer, Valvano, Yerraballi
Sampling & Aliasing 1500 Hz signal sampled at 1600 Hz osample freq. NOT >> highest data freq.
- fs ≈ fh ofrequency response incorrectly shows frequency of 100Hz, not 1500Hz othis is called aliasing 9 2200 Hz signal sampled at 2000 Hz oanother example of aliasing when fs is not > 2fh Sampled Data
0 1 2 3 0 2 4 6 8 10 Time (ms) Voltage (V) Sampled Data T rue Data FFT Magnitude
0.0 0.2 0.4 0.6 0.8 1. Frequency (kHz) Voltage (V) source: Bard, Gerstlauer, Valvano, Yerraballi A/D Conversion Process
Quantization: number of discrete levels the analog signal is
divided into between VRH and VRL
o #steps = 2b o more levels (steps) better representation of sampled signal
Resolution: voltage per step
o Resolution = (VRH - VRL)/number of steps = (VRH - VRL)/2b o Analog value: Vanalog = Vdigital * Resolution + VRL
Data rate: # of A/D result bits per second, d = fsb
M10: Analog 10 EXAMPLE: VRH = 5 V, VRL = 0 V, quantization = 256 levels
bits =?
256 = 2b^ b = 8 Resolution =? voltage per step = (5V - 0V)/(256 steps) = 19.53 mV/step
Module Learning Objectives, Students should be able to:
Analog to Digital
Conversion (ADC)
KL25Z Analog Module
Module 10: Part 2 (M10.2)
Describe motivation for ADCs in microcontrollers
Explain basic operating principles of ADCs
Calculate analog values of ADC digital results and vice versa
Describe the ADC peripheral module for the KL25Z
microcontroller
ECE 331
Prof. Nihar Mahapatra (adapted from Prof. A. Mason’s lecture notes; other sources listed at the end) KL25Z Analog Module 16 - bit SAR ADC oSAR = successive approximation
- see next slide o 7 - 14 input channels
- depends on KL25Z model ohardware and software interrupts 12 - bit DAC (digital to analog converter ) o1 channel, outputs an analog voltage based on 12-bit programmable setting
- each DAC bit is 1/2^12 - th (0.00024) of DAC reference voltage
- VA = Vref * (2-^12 * DAC_VALUE) oDAC can be a chip output or reference source to the analog comparator M10: Analog 14 High speed analog comparator oCompares external analog voltage on a pin to:
- another external analog voltage on a pin
- an internal reference voltage oComparator results:
- input signal is higher than or lower than the reference voltage oFeatures
- two 8 - input multiplexors for both the inverting and non-inverting inputs
- two internal reference voltage sources set by 6-bit DACs
Successive Approximation Register (SAR) ADC
Constantly compares input voltage to reference value set by an
internal digital-to-analog converter (DAC)
DAC value cuts voltage range in half each cycle to approach
input value
o each cycle one more bit of resolution
Final binary value stored in a successive approximation
register
15 bit bit bit3 bit Example: What is 3b ADC result for 1.75V? bit 1? bit 2? bit 3? 0 1 0 010 , (4b) = 0101 References
J.W. Valvano, Introduction to ARM Cortex-M Microcontrollers
(Embedded Systems Vol. 1), 4th^ Ed, 2013, ISBN: 978-
J. Yiu, The Definitive Guide to the ARM Cortex-M0 , Elsevier,
2011, ISBN: 978- 0 - 12 - 385477 - 3.
J. Yiu, The Definitive Guide to ARM Cortex-M0 and Cortex-M0+
Processors , Elsevier, 2 nd^ Edition, 2015, ISBN: 978 - 0 - 12 -
16