SEP600
Embedded System
Module 4: Analog I/O, Resolution, and Sampling
Course Outline
Module 1: Introduction and Review
Module 2: Transistor and Op-Amp
Module 3: Digital I/O and Analog Output
Module 4: Analog Input, Resolution, and Sampling
Module 5: RTOS and Multithreading
Module 6: Serial, SPI, I2C, CAN
2
Review: Op-Amp and Digital I/O
●
Buffer/Voltage Follower
●
Addition, Subtraction,
Integration
●
Amplification
●
Filtering
Source: Wikipedia: Op Amp
Digital Output: Digital Input:
3
Typical Op-Amp Are NOT Rail-to-Rail
LM741 Circuit LM358 Circuit
4
Digital-to-Analog Converter (DAC)
Circuitry that convert binary input (0s and 1s) into an analog
voltage output (Vo)
0001
0010
0100
0100
0011
0101
...
Source: Toulson Fig 4.1 Source: Toulson Fig 4.3
5
Analog-to-Digital Converter (ADC)
Circuitry that convert analog input voltage (Vin) to binary
number (0s and 1s)
– measures the input voltage
0001
0010
0100
0100
0011
0101
Source: Toulson Fig 4.5
...
6
Analog-to-Digital Converter (ADC)
Only analog signal within the
conversion range can be
converted
Resolution - how precisely an ADC can
convert and represent a given input voltage
Vi n D – digital value Vr
D= 2 Vi – voltage input resolution=
Vr Vr – voltage reference 2
n Source: Toulson Fig 5.2
7
Quantization Error
Quantization interval (Q) is the smallest digital division of
the ADC and have the same value as the resolution
Quantization error is the difference between the voltage
represented by the binary output and VIN
V ADCmin −V ADCmax V IN −V ADCmin
Q= code=round down
n Q
8
Quantization Error
●
Maximum quantization error is +Q (not ±Q/2) for an ADC
because any VIN in the range of [VIN, VIN + Q) will be coded
to VIN
V ADCmin −V ADCmax V IN −V ADCmin
Q= code=round down
n Q
9
Example
Determine the smallest analog change that can be resolved
by a 3-bit converter assuming the power source is 10V.
10
Example
Determine the smallest analog change that can be resolved
by a 3-bit converter assuming the power source is 10V.
Vr 10 V
resolution= n = 3 =1.25 V
2 2
11
Example
What is the resolution required of an ADC for positive
measurements with an error less than 1 micrometer over a
range of measurements of 1mm?
12
Example
What is the resolution required of an ADC for positive
measurements with an error less than 1 micrometer over a
range of measurements of 1mm?
Q<1 μ m
13
Example
Given a 3-bit ADC with VADCmax = 1.5V, VADCmin = -2V. What is
the digital representation of Vin = 1.2V?
14
Example
Given a 3-bit ADC with VADCmax = 1.5V, VADCmin = -2V. What is
the digital representation of Vin = 1.2V?
V max −V min 1.5 V−(−2 V)
resolution= = =0.4375 V
2
n
8
V i n 1.2 V−(−2 V) 3 3.2 V
D= 2 = 2= 8≈7=111
Vr 1.5 V−(−2 V) 3.5 V
15
Example
Given a 3-bit ADC with VADCmax = 5.25V, VADCmin = 0V, and
code = 2. Estimate the range of possible input voltage VIN?
16
Example
Given a 3-bit ADC with VADCmax = 5.25V, VADCmin = 0V, and
binary output code = 010. Estimate the range of possible
input voltage VIN?
V max −V min 5.25 V−0
resolution= = =0.65625 V
2
n
8
V IN −V ADCmin V IN
code=round down ⇒ 010= V
Q 0.65625
V IN =(010)(0.65625)=[1.3125, 1.96875)
17
Clipping
Clipping will result if VIN exceeds the range ADC
operation:
– If VIN > VADCmax, then V_S VOUT = VADCmax
– If VIN < VADCmin, then VOUT = VADCmin
18
Sampling
How often should
we take a
measurement?
19
Sampling Theorem
Sampling theorem (Shannon, Nyquist) gives limits
●
Sampling rate must be faster than twice the
highest frequency present (even if the highest
frequency is noise) to preserve knowledge of the original
signal’s frequency content.
f s >2 f max
Slower sampling preserves amplitude information, but
suggests incorrect frequency content (known as aliasing).
20
Under-sampling -> Aliasing
Source: Wilmshurst Fig 5.3 and 5.4
One way to reduce aliasing is to use an
analog filter (low-pass) to remove
frequencies (noise) above fs / 2
21
Irreversible Information Loss
●
Quantization, Clipping, and Aliasing are all irreversible
information loss when using ADC
●
Increasing the number of bits lowers information loss, but
usually raises the cost and processing time
22
Successive Approximation ADC
●
Used for wide variety of applications
●
Conversion time: 1 – 100 µsec (slower than flash ADC)
●
Easily extensible to higher precision
●
Precision is limited by the quality of the components
23
Successive Approximation ADC (Binary Search)
●
Used for wide variety of applications
●
Conversion time: 1 – 100 µsec (slower than flash ADC)
●
Easily extensible to higher precision
●
Precision is limited by the quality of the components
24
Successive Approximation ADC (Binary Search)
●
Quite resource expensive so it’s usually used with a
multiplexer
– Many channels feed to a single converter
●
Effective conversion speed for multiplexed ADC depends
on number of channels used
●
Sample-and-hold normally precedes the converter
25
Sample and Hold
●
ADCs need time to convert the input voltage. If the signal
varies during this time it leads to erroneous readings.
26
Simple Comparator as 1-bit ADC
27
Flash ADC Circuit
●
Extending beyond 1-bit ADC
●
Uses comparators to determine
input voltage range
●
Multiplexer converts comparator
output to digital value
●
Fast! Typical conversion time: 10-
500nsec
●
Typically, 4 to 8 bit precision
– 8 bits requires 255 comparators
28
FRDM-K64K ADC
●
16x ADC
29
Summary: Analog I/O and Sampling
Analog signal can be DAC ADC
obtained from PWM
with RC smoothing
D Vi n
V o= n V r D= 2
Vr
f s >2 f max
2
Vr V ADCmin −V ADCmax
resolution= n Q=
2 n 30
Course Outline
Module 1: Introduction and Review
Module 2: Transistor and Op-Amp
Module 3: Digital I/O and Analog Output
Module 4: Analog Input, Resolution, and Sampling
Module 5: RTOS and Multithreading
Module 6: Serial, SPI, I2C, CAN
31