SlideShare a Scribd company logo
1 of 18
Wireless Embedded Systems
Aaron Schulman
CSE190 Winter 2020
Lecture 11
Interfacing with
The Analog World
2
We live in an analog world
• Everything in the physical world is an analog signal
– Sound, light, temperature, pressure
• Need to convert into electrical signals
– Transducers: converts one type of energy to another
• Electro-mechanical, Photonic, Electrical, …
– Examples
• Microphone/speaker
• Thermocouples
• Accelerometers
3
Going from analog to digital
• What we want…
• How we get there?
Software
Sensor ADC
Physical
Phenomena
Voltage or
Current
ADC Counts Engineering
Units
Physical
Phenomena
Engineering
Units
4
Representing an analog signal digitally
• How do we represent an analog signal (e.g. continuous voltage)?
– As a time series of discrete values
 On MCU: read ADC data register (counts) periodically (Ts)
)
(x
fsampled
)
(x
f
t
S
T
Voltage
(continuous)
Counts
(discrete)
5
Choosing the sample rate
• What sample rate do we need?
– Too little: we can’t reconstruct the signal we care about
– Too much: waste computation, energy, resources
)
(x
fsampled
)
(x
f
t
6
Shannon-Nyquist sampling theorem
• If a continuous-time signal contains no frequencies higher than ,
it can be completely determined by discrete samples taken at a rate:
• Example:
– Humans can process audio signals 20 Hz – 20 KHz
– Audio CDs: sampled at 44.1 KHz
)
(x
f max
f
max
samples 2 f
f 
7
Use anti-aliasing filters on ADC inputs to
ensure that Shannon-Nyquist is satisfied
• Aliasing
– Different frequencies are indistinguishable when they are
sampled.
• Condition the input signal using a low-pass filter
– Removes high-frequency components
– (a.k.a. anti-aliasing filter)
Do I really need to filter my input
signal?
• Short answer: Yes.
• Longer answer: Yes, but sometimes it’s already
done for you.
– Many (most?) ADCs have a pretty good analog
filter built in.
– Those filters typically have a cut-off frequency just
above ½ their maximum sampling rate.
• Which is great if you are using the maximum sampling
rate, less useful if you are sampling at a slower rate.
8
9
Choosing the range

r
V
t
Range Too Small

r
V
t
Range Too Big

r
V

r
V
t
Ideal Range

r
V

r
V
• Fixed # of bits (e.g. 8-bit ADC)
• Span a particular input voltage range
• What do the sample values represent?
– Some fraction within the range of values
 What range to use?
10
Choosing the granularity
• Resolution
– Number of discrete values that
represent a range of analog values
– 12-bit ADC
• 4096 values
• Range / 4096 = Step
Larger range  less info / bit
• Quantization Error
– How far off discrete value is from actual
– ½ LSB  Range / 8192
Larger range  larger error
11
Converting between voltages,
ADC counts, and engineering units
• Converting: ADC counts  Voltage
• Converting: Voltage  Engineering Units
ADC
N
NADC = 4095´
Vin -Vr-
Vr+ -Vr-
Vin = NADC ´
Vr+ -Vr-
4095
t

r
V

r
V
in
V
00355
.
0
986
.
0
TEMP
986
.
0
)
TEMP
(
00355
.
0
TEMP
C
C
TEMP




V
V
12
A note about sampling and arithmetic*
• Converting values in fixed-point MCUs
float vtemp = adccount/4095 * 1.5;
float tempc = (vtemp-0.986)/0.00355;
 vtemp = 0! Not what you intended, even when vtemp is a float!
 tempc = -277 C
• Fixed point operations
– Need to worry about underflow and overflow
• Floating point operations
– They can be costly on the embedded system
00355
.
0
986
.
0
TEMP TEMP
C


V
VTEMP = NADC ´
Vr+ -Vr-
4095
$ cat arithmetic.c
#include <stdio.h>
int main() {
int adccount = 2048;
float vtemp;
float tempc;
vtemp = adccount/4095 * 1.5;
tempc = (vtemp-0.986)/0.00355;
printf("vtemp: %fn", vtemp);
printf("tempc: %fn", tempc);
}
$ gcc arithmetic.c
$ ./a.out
vtemp: 0.000000
tempc: -277.746490
13
Try it out for yourself…
Oversampling
• One interesting trick is that you can use
oversampling to help reduce the impact of
quantization error.
– Let’s look at an example of oversampling plus
dithering to get a 1-bit converter to do a much
better job…
14
Oversampling a 1-bit ADC w/ noise &
dithering (cont)
15
t
1
0
Count
Voltage
500 mV
0 mV
375 mV
N1 = 11
N0 = 32
uniformly
distributed
random noise
±250 mV
“upper edge”
of the box
Vthresh = 500 mV
V
rand
=
500
mV
Note:
N1 is the # of ADC counts that = 1 over the sampling window
N0 is the # of ADC counts that = 0 over the sampling window
Oversampling a 1-bit ADC w/ noise &
dithering (cont)
• How to get more than 1-bit out of a 1-bit ADC?
• Add some noise to the input
• Do some math with the output
• Example
– 1-bit ADC with 500 mV threshold
– Vin = 375 mV  ADC count = 0
– Add ±250 mV uniformly distributed random noise to
Vin
– Now, roughly
• 25% of samples (N1) ≥ 500 mV  ADC count = 1
• 75% of samples (N0) < 500 mV  ADC count = 0
16
17
Can use dithering to deal with quantization
• Dithering
– Quantization errors can result in
large-scale patterns that don’t
accurately describe the analog
signal
– Oversample and dither
– Introduce random (white) noise
to randomize the quantization
error.
Direct Samples Dithered Samples
18
Selection of a DAC (digital to analog converter)
• Error/Accuracy/Resolution: Quantizing error
represents the difference between an actual
analog value and its digital representation.
Ideally, the quantizing error should not be
greater than ± 1⁄2 LSB.
Output Voltage Range -> Input Voltage Range
• Output Settling Time -> Conversion Time
• Output Coding (usually binary)

More Related Content

Similar to lecture11-analog.pptx

Data converter fundamentals
Data converter fundamentalsData converter fundamentals
Data converter fundamentalsAbhishek Kadam
 
Analog to digital conversion
Analog to digital conversionAnalog to digital conversion
Analog to digital conversionEngr Ahmad Khan
 
analog to digital adn digital to analog .ppt
analog to digital adn digital to analog .pptanalog to digital adn digital to analog .ppt
analog to digital adn digital to analog .pptdaredevil15082004
 
Raspberry Pi - Lecture 4 Hardware Interfacing Special Cases
Raspberry Pi - Lecture 4 Hardware Interfacing Special CasesRaspberry Pi - Lecture 4 Hardware Interfacing Special Cases
Raspberry Pi - Lecture 4 Hardware Interfacing Special CasesMohamed Abdallah
 
Sensors And Actuators
Sensors And ActuatorsSensors And Actuators
Sensors And ActuatorsJinesh Patel
 
ADC Conveter Performance and Limitations.ppt
ADC Conveter Performance and Limitations.pptADC Conveter Performance and Limitations.ppt
ADC Conveter Performance and Limitations.pptBEVARAVASUDEVAAP1813
 
Adc and dac
Adc and dacAdc and dac
Adc and dacboarddk1
 
analog to digital converter.ppt
analog to digital converter.pptanalog to digital converter.ppt
analog to digital converter.pptDreamers6
 
Analog to digital converter (ADC)
Analog to digital converter (ADC)Analog to digital converter (ADC)
Analog to digital converter (ADC)SHIV DUTT
 
Fundamental of MSD Module-III Part-a.ppt
Fundamental of MSD Module-III Part-a.pptFundamental of MSD Module-III Part-a.ppt
Fundamental of MSD Module-III Part-a.pptBEVARAVASUDEVAAP1813
 
Analog mixed vlsi notes
Analog mixed vlsi notesAnalog mixed vlsi notes
Analog mixed vlsi notesathiulla
 
signal processing in software and electric field sensing
signal processing in software and electric field sensingsignal processing in software and electric field sensing
signal processing in software and electric field sensingomidsalangi1
 
Analog sensor Part-9
Analog sensor Part-9Analog sensor Part-9
Analog sensor Part-9Techvilla
 
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
UNIT 4 & 5 - I         nterfacing_Lecture7.pptxUNIT 4 & 5 - I         nterfacing_Lecture7.pptx
UNIT 4 & 5 - I nterfacing_Lecture7.pptxnaveen088888
 

Similar to lecture11-analog.pptx (20)

Data converter fundamentals
Data converter fundamentalsData converter fundamentals
Data converter fundamentals
 
Analog to digital conversion
Analog to digital conversionAnalog to digital conversion
Analog to digital conversion
 
analog to digital adn digital to analog .ppt
analog to digital adn digital to analog .pptanalog to digital adn digital to analog .ppt
analog to digital adn digital to analog .ppt
 
Raspberry Pi - Lecture 4 Hardware Interfacing Special Cases
Raspberry Pi - Lecture 4 Hardware Interfacing Special CasesRaspberry Pi - Lecture 4 Hardware Interfacing Special Cases
Raspberry Pi - Lecture 4 Hardware Interfacing Special Cases
 
Sensors And Actuators
Sensors And ActuatorsSensors And Actuators
Sensors And Actuators
 
ADC Conveter Performance and Limitations.ppt
ADC Conveter Performance and Limitations.pptADC Conveter Performance and Limitations.ppt
ADC Conveter Performance and Limitations.ppt
 
Adc &amp;dac ppt
Adc &amp;dac pptAdc &amp;dac ppt
Adc &amp;dac ppt
 
Adc and dac
Adc and dacAdc and dac
Adc and dac
 
analog to digital converter.ppt
analog to digital converter.pptanalog to digital converter.ppt
analog to digital converter.ppt
 
Data convertors
Data convertorsData convertors
Data convertors
 
Unit 6.pptx
Unit 6.pptxUnit 6.pptx
Unit 6.pptx
 
ADC & DAC
ADC & DAC ADC & DAC
ADC & DAC
 
Analog to digital converter (ADC)
Analog to digital converter (ADC)Analog to digital converter (ADC)
Analog to digital converter (ADC)
 
Computer hardware
Computer hardware Computer hardware
Computer hardware
 
Fundamental of MSD Module-III Part-a.ppt
Fundamental of MSD Module-III Part-a.pptFundamental of MSD Module-III Part-a.ppt
Fundamental of MSD Module-III Part-a.ppt
 
Analog mixed vlsi notes
Analog mixed vlsi notesAnalog mixed vlsi notes
Analog mixed vlsi notes
 
signal processing in software and electric field sensing
signal processing in software and electric field sensingsignal processing in software and electric field sensing
signal processing in software and electric field sensing
 
Adc f05
Adc f05Adc f05
Adc f05
 
Analog sensor Part-9
Analog sensor Part-9Analog sensor Part-9
Analog sensor Part-9
 
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
UNIT 4 & 5 - I         nterfacing_Lecture7.pptxUNIT 4 & 5 - I         nterfacing_Lecture7.pptx
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
 

Recently uploaded

Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

lecture11-analog.pptx

  • 1. Wireless Embedded Systems Aaron Schulman CSE190 Winter 2020 Lecture 11 Interfacing with The Analog World
  • 2. 2 We live in an analog world • Everything in the physical world is an analog signal – Sound, light, temperature, pressure • Need to convert into electrical signals – Transducers: converts one type of energy to another • Electro-mechanical, Photonic, Electrical, … – Examples • Microphone/speaker • Thermocouples • Accelerometers
  • 3. 3 Going from analog to digital • What we want… • How we get there? Software Sensor ADC Physical Phenomena Voltage or Current ADC Counts Engineering Units Physical Phenomena Engineering Units
  • 4. 4 Representing an analog signal digitally • How do we represent an analog signal (e.g. continuous voltage)? – As a time series of discrete values  On MCU: read ADC data register (counts) periodically (Ts) ) (x fsampled ) (x f t S T Voltage (continuous) Counts (discrete)
  • 5. 5 Choosing the sample rate • What sample rate do we need? – Too little: we can’t reconstruct the signal we care about – Too much: waste computation, energy, resources ) (x fsampled ) (x f t
  • 6. 6 Shannon-Nyquist sampling theorem • If a continuous-time signal contains no frequencies higher than , it can be completely determined by discrete samples taken at a rate: • Example: – Humans can process audio signals 20 Hz – 20 KHz – Audio CDs: sampled at 44.1 KHz ) (x f max f max samples 2 f f 
  • 7. 7 Use anti-aliasing filters on ADC inputs to ensure that Shannon-Nyquist is satisfied • Aliasing – Different frequencies are indistinguishable when they are sampled. • Condition the input signal using a low-pass filter – Removes high-frequency components – (a.k.a. anti-aliasing filter)
  • 8. Do I really need to filter my input signal? • Short answer: Yes. • Longer answer: Yes, but sometimes it’s already done for you. – Many (most?) ADCs have a pretty good analog filter built in. – Those filters typically have a cut-off frequency just above ½ their maximum sampling rate. • Which is great if you are using the maximum sampling rate, less useful if you are sampling at a slower rate. 8
  • 9. 9 Choosing the range  r V t Range Too Small  r V t Range Too Big  r V  r V t Ideal Range  r V  r V • Fixed # of bits (e.g. 8-bit ADC) • Span a particular input voltage range • What do the sample values represent? – Some fraction within the range of values  What range to use?
  • 10. 10 Choosing the granularity • Resolution – Number of discrete values that represent a range of analog values – 12-bit ADC • 4096 values • Range / 4096 = Step Larger range  less info / bit • Quantization Error – How far off discrete value is from actual – ½ LSB  Range / 8192 Larger range  larger error
  • 11. 11 Converting between voltages, ADC counts, and engineering units • Converting: ADC counts  Voltage • Converting: Voltage  Engineering Units ADC N NADC = 4095´ Vin -Vr- Vr+ -Vr- Vin = NADC ´ Vr+ -Vr- 4095 t  r V  r V in V 00355 . 0 986 . 0 TEMP 986 . 0 ) TEMP ( 00355 . 0 TEMP C C TEMP     V V
  • 12. 12 A note about sampling and arithmetic* • Converting values in fixed-point MCUs float vtemp = adccount/4095 * 1.5; float tempc = (vtemp-0.986)/0.00355;  vtemp = 0! Not what you intended, even when vtemp is a float!  tempc = -277 C • Fixed point operations – Need to worry about underflow and overflow • Floating point operations – They can be costly on the embedded system 00355 . 0 986 . 0 TEMP TEMP C   V VTEMP = NADC ´ Vr+ -Vr- 4095
  • 13. $ cat arithmetic.c #include <stdio.h> int main() { int adccount = 2048; float vtemp; float tempc; vtemp = adccount/4095 * 1.5; tempc = (vtemp-0.986)/0.00355; printf("vtemp: %fn", vtemp); printf("tempc: %fn", tempc); } $ gcc arithmetic.c $ ./a.out vtemp: 0.000000 tempc: -277.746490 13 Try it out for yourself…
  • 14. Oversampling • One interesting trick is that you can use oversampling to help reduce the impact of quantization error. – Let’s look at an example of oversampling plus dithering to get a 1-bit converter to do a much better job… 14
  • 15. Oversampling a 1-bit ADC w/ noise & dithering (cont) 15 t 1 0 Count Voltage 500 mV 0 mV 375 mV N1 = 11 N0 = 32 uniformly distributed random noise ±250 mV “upper edge” of the box Vthresh = 500 mV V rand = 500 mV Note: N1 is the # of ADC counts that = 1 over the sampling window N0 is the # of ADC counts that = 0 over the sampling window
  • 16. Oversampling a 1-bit ADC w/ noise & dithering (cont) • How to get more than 1-bit out of a 1-bit ADC? • Add some noise to the input • Do some math with the output • Example – 1-bit ADC with 500 mV threshold – Vin = 375 mV  ADC count = 0 – Add ±250 mV uniformly distributed random noise to Vin – Now, roughly • 25% of samples (N1) ≥ 500 mV  ADC count = 1 • 75% of samples (N0) < 500 mV  ADC count = 0 16
  • 17. 17 Can use dithering to deal with quantization • Dithering – Quantization errors can result in large-scale patterns that don’t accurately describe the analog signal – Oversample and dither – Introduce random (white) noise to randomize the quantization error. Direct Samples Dithered Samples
  • 18. 18 Selection of a DAC (digital to analog converter) • Error/Accuracy/Resolution: Quantizing error represents the difference between an actual analog value and its digital representation. Ideally, the quantizing error should not be greater than ± 1⁄2 LSB. Output Voltage Range -> Input Voltage Range • Output Settling Time -> Conversion Time • Output Coding (usually binary)