You are on page 1of 22

Introduction to Digital Data Acquisition:

Sampling

Physical world is analog

n  Digital systems need to


q  Measure analog quantities
n  Switch inputs, speech waveforms, etc
q  Control analog systems
n  Computer monitors, automotive engine control, etc
n  Analog-to-digital: A/D converter (ADC)
q  Example: CD recording
n  Digital-to-analog: D/A converter (DAC)
q  Example: CD playback

CSE466 1
A little background

n  For periodic waveforms, the duration of the waveform


before it repeats is called the period of the waveform

Frequency

n  the rate at which a regular vibration pattern repeats itself


(frequency = 1/period)

CSE466 2
Frequency of a Waveform

n  The unit for frequency is cycles/second, also called Hertz


(Hz).
n  The frequency of a waveform is equal to the reciprocal of
the period.

Frequency of a Waveform

n  Examples:
frequency = 10 Hz
period = .1 (1/10) seconds

frequency = 100 Hz
period = .01 (1/100) seconds

frequency = 261.6 Hz (middle C)


period = .0038226 (1/ 261.6) seconds

CSE466 3
Waveform Sampling
n  To represent waveforms in digital systems, we
need to digitize or sample the waveform.

•  side effects of digitization:


•  introduces some noise
•  limits the maximum upper frequency range

Sampling Rate

n  The sampling rate (SR) is the rate at which amplitude


values are digitized from the original waveform.

q  CD sampling rate (high-quality):


SR = 44,100 samples/second
q  medium-quality sampling rate:
SR = 22,050 samples/second
q  phone sampling rate (low-quality):
SR = 8,192 samples/second

CSE466 4
Sampling Rate

n  Higher sampling rates


allow the waveform to be
more accurately
represented

Digital Data Acquisition

n  Data Representation - Digital vs. Analog


n  Analog-to-Digital Conversion
n  Number Systems
q  Binary Numbers
q  Binary Arithmetic
n  Sampling & Aliasing

CSE466 5
Analog-to-Digital Conversion

n  Converts analog voltages to binary integers.


Sampling
Binary
Analog
ADC Integers
Voltage
(0s & 1s)
1.5

0.5
Voltage

-0.5

-1

-1.5
0 1 2 3 4 5 6 7 8 9
Time

Analog-to-Digital Conversion

•  ADC calibration
Integer
Code 7
6
5
4
Calibration
Curve 3
( 3 bit ADC) 2
1
0 Analog
Voltage
0 0.5 1.0 1.5 2.0 2.5 3.0 3.5

CSE466 6
Analog-to-Digital Conversion

n  Input Range


q  Unipolar: ( 0, VADCMAX )
q  Bipolar: ( -VADCMAX , +VADCMAX ) (Nominal Range)
q  Clipping:
If |VIN| > |VADCMAX|, then |VOUT| = |VADCMAX|

VADCMAX
time

-VADCMAX

Analog-to-Digital Conversion

n  Quantization Interval (Q)


q  n bit ADC, the input range is divided into 2n-1 intervals.

q  3 bit ADC: VADCMAX − VADC min


Q=
2n − 1
Integer Integer
Code 7 Code 7
6 6
5 5
4 4

3 3
2 2
1 1
0 Analog 0 Analog
Voltage Voltage
0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 -2 -1.5 -1.0 -.5 0.0 0.5 1.0 1.5

CSE466 7
Analog-to-Digital Conversion

n  Voltage to Integer Code


q  n bit ADC
Q VIN
Voltage: VADCmin VADCMAX

Code: 0 2n-1
-2n-1 2n-1-1
Positive Coding: Positive and Negative Coding:
⎡ V − VADC min ⎤ ⎡ V ⎤
Code = Round ⎢ IN ⎥ Code = Round ⎢ IN ⎥
⎣ Q ⎦ ⎣ Q ⎦

Why A/D-conversion?

Analog Analog
Analog signal ADC DAC signal Analog
input processing Processing output

Digital signal processing


Single chip

n  Signals are analog by nature •  ADC bottle necks:


n  ADC necessary for DSP •  Dynamic range
n  Digital signal processing •  Conversion speed
provides: •  Power consumption
q  Close to infinite SNR

q  Low system cost

q  Repetitive system

CSE466 8
A/D-converter basics

t t t n ⋅ TS

f f
f IN f IN
f
f IN FS / 2 FS
Sample & hold
vIN , A (t ) vIN (t )
Anti-alias
Quantizer DOUT [n]
filter

FS Time discrete Time discrete


Time continuos Amplitude discrete
Amplitude continuos Amplitude continuos

Sampling
clock
ideal
DOUT [n] = Gideal ⋅ vIN (n ⋅ Ts ) + q( n )
real
DOUT [n] = Gideal ⋅ (1 + ε ) ⋅ vIN (n ⋅ Ts ) + q( n ) + eoffset ( n ) + enoise ( n ) + e jitter ( n ) + edistortion ( n )

The Theory

n  Sampling theory is a subset of


communications theory
q  Same basic math
n  Want to record signal, not noise
q  Quantization: Conversion from
analog to discrete values
q  Coding: Assigning a digital word to
each discrete value
n  Thermometer code, Gray code...
n  Quantization adds noise
q  Analog signal is continuous
q  Digital representation is
approximate
q  Difference (error) is noiselike

CSE466 9
Some terminology

n  Resolution (n): Number of states in bits


q  Example: A 3-bit A/D
n  Full-scale range (FSR): The input or output voltage
range
q  Example: ADC inputs outside the FSR are always 111 or 000
FSR
n  Step size (Q): 2n Q
n  RMS quantization error: 12

q  RMS value of triangle wave

Quantization noise

VFSR
• N-bit converter: δ=
2N

CSE466 10
Quantization noise

n  SNR for ideal ADC:


n  Noise energy:
Vin( RMS )
1 δ /2 2 δ2 SNR = 20 log( )
VQ ( RMS ) = ∫ VQ dVQ = VQ ( RMS )
δ −δ / 2 12
3
•  Signal energy: SNR = 20 log(2 N ⋅ )
2
δ ⋅ 2N
Vin( RMS ) = SNR = 6.02 × N + 1.76[dB]
2 2

Quantization noise

n  SNR for ideal ADC:


n  Noise energy:
Vin( RMS )
1 δ /2 2 δ2 SNR = 20 log( )
VQ ( RMS ) = V
∫ Q QdV = VQ ( RMS )
δ −δ / 2 12
3
•  Signal energy: SNR = 20 log(2 N ⋅ )
2
δ ⋅ 2N
Vin( RMS ) = SNR = 6.02 × N + 1.76[dB]
2 2

CSE466 11
D/A converters

n  Easier to design and use than A/


Ds
n  Types
q  Weighted current source DAC
q  R–2R DAC
q  Multiplying DAC
n  Need to smooth the output

You will use DACs

n  DAC specs are tricky!


q  Check the errors
q  Check the settling
n  Vendors use deceptive
advertising
q  16-bit DAC!!!
n  But errors may give only 12-
bit accuracy
n  You have to figure this out
from the specs

Datel Data Acquisition and


Conversion Handbook

CSE466 12
A/D converters

n  Hard to design


n  Contain digital parts
q  Encoders
q  FSMs
n  Many types
q  Successive approximation
q  Flash
q  Pipelined-flash
q  Integrating
q  Sigma-delta
q  Charge balanced
q  Folding
q  Others

Example: Flash A/D

n  Advantages
q  Ultra-fast
n  Disadvantages
q  High power
q  Low resolution
q  Metastability
n  Sample/hold improves
performance

CSE466 13
Example: Successive approximation ADC

n  Advantages
q  Low power
q  High resolution
n  Disadvantages
q  Slow
n  Problem: DAC must
settle to LSB
accuracy at every
step

Datel Data Acquisition and


Conversion Handbook

Sampling

n  Quantizing a signal


1) We sample it
2) We encode the samples
n  Questions:
q  How fast do we sample?
q  How do we so this in
hardware?
q  What resolution do we
need?

Datel Data Acquisition and


Conversion Handbook

CSE466 14
Shannon's sampling theorem

If a continuous, band-limited signal


contains no frequency components
higher than fc, then we can recover the
original signal without distortion if we
sample at a rate of at least 2fc samples/
second

✦  2fc is called the Nyquist rate

✦  Real life
➭  Sample at 2.5fc or faster
➭  Sample clock should not be coherent
with the input signal

http://www.videomicroscopy.com/vancouverlecture/nyquist.htm

Frequency domain analysis

n  Take the Fourier Transform of the signal


q  Shows a signal’s frequency components
n  Undersampled frequency components fold back!

Datel Data Acquisition and


Conversion Handbook

CSE466 15
Sampling speed versus bit resolution

n  Hardware issues


q  Sampling speed depends
on bit resolution
n  Think time constants
−t
n 
Settling error = e τ

n  Examples:
q  8-bit resolution takes 5.5τ
q  12-bit resolution takes 8.3τ
q  16-bit resolution takes 11τ
Datel Data Acquisition and
Conversion Handbook

Nyquist–Shannon sampling theorem

n  A theorem, developed by Harry Nyquist, and


proven by Claude Shannon, which states that an
analog signal waveform may be uniquely
reconstructed, without error, from samples taken
at equal time intervals.

CSE466 16
Nyquist–Shannon sampling theorem

n  The sampling rate must be equal to, or


greater than, twice the highest frequency
component in the analog signal.

n  Stated differently:


n  The highest frequency which can be
accurately represented is one-half of the
sampling rate.

Nyquist Theorem and Aliasing

n  Nyquist Theorem:


We can digitally represent only frequencies up
to half the sampling rate.

q  Example:
CD: SR=44,100 Hz
Nyquist Frequency = SR/2 = 22,050 Hz

q  Example:
SR=22,050 Hz
Nyquist Frequency = SR/2 = 11,025 Hz

CSE466 17
Nyquist Theorem and Aliasing

n  Frequencies above Nyquist frequency "fold over" to


sound like lower frequencies.
q  This foldover is called aliasing.

n  Aliased frequency f in range [SR/2, SR] becomes f':


f' = |f – SR/2|

Nyquist Theorem and Aliasing

f' = |f - SR/2|

n  Example:
q  SR = 20,000 Hz
q  Nyquist Frequency = 10,000 Hz
q  f = 12,000 Hz --> f' = 8,000 Hz
q  f = 18,000 Hz --> f' = 2,000 Hz
q  f = 20,000 Hz --> f' = 0 Hz

CSE466 18
Nyquist Theorem and Aliasing
n  Graphical Example 1a:
q  SR = 20,000 Hz
q  Nyquist Frequency = 10,000 Hz
q  f = 2,500 Hz (no aliasing)

Nyquist Theorem and Aliasing


n  Graphical Example 1b:
q  SR = 20,000 Hz
q  Nyquist Frequency = 10,000 Hz
q  f = 5,000 Hz (no aliasing)

(left and right figures have same frequency, but have different
sampling points)

CSE466 19
Nyquist Theorem and Aliasing
n  Graphical Example 2:
q  SR = 20,000 Hz
q  Nyquist Frequency = 10,000 Hz
q  f = 10,000 Hz (no aliasing)

Nyquist Theorem and Aliasing


n  Graphical Example 2:
q  BUT, if sample points fall on zero-crossings the sound is
completely cancelled out

CSE466 20
Nyquist Theorem and Aliasing
n  Graphical Example 3:
q  SR = 20,000 Hz
q  Nyquist Frequency = 10,000 Hz
q  f = 12,500 Hz, f' = 7,500

Nyquist Theorem and Aliasing


n  Graphical Example 3:
q  Fitting the simplest sine wave to the sampled points gives an
aliased waveform (dotted line below):

CSE466 21
Method to reduce aliasing noise

Use low pass filter to remove high frequency


Input voltage = V
before sampling

output code = n
Low ADC 0110001
Pass Sampling 0100010
Filter: at 40KHz 0100100
fcorner=20KHz
0101011
:
e.g. Gain(dB)
0 :
Max freq
-3dB cut off :
=20KHz
Freq.

CSE466 22

You might also like