introduction to digital data acquisition - courses.cs ... · introduction to digital data...

22
CSE466 1 Introduction to Digital Data Acquisition: Sampling Physical world is analog Digital systems need to Measure analog quantities Switch inputs, speech waveforms, etc Control analog systems Computer monitors, automotive engine control, etc Analog-to-digital: A/D converter (ADC) Example: CD recording Digital-to-analog: D/A converter (DAC) Example: CD playback

Upload: vanminh

Post on 20-Feb-2019

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 1

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

Page 2: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 2

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)

Page 3: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 3

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

Page 4: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 4

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

Page 5: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 5

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

Page 6: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 6

n  Converts analog voltages to binary integers.

ADC

Analog Voltage

Binary Integers (0s & 1s)

Sampling

-1.5

-1

-0.5

0

0.5

1

1.5

0 1 2 3 4 5 6 7 8 9

Vol

tage

Time

Analog-to-Digital Conversion

•  ADC calibration Calibration Curve ( 3 bit ADC)

0

1

2

3

7 6 5 4

0 0.5 1.0 1.5 2.0 2.5 3.0 3.5

Analog Voltage

Integer Code

Analog-to-Digital Conversion

Page 7: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 7

n  Input Range q  Unipolar: ( 0, VADCMAX )

q  Bipolar: ( -VADCMAX , +VADCMAX ) (Nominal Range)

q  Clipping: If |VIN| > |VADCMAX|, then |VOUT| = |VADCMAX|

time VADCMAX

-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:

QV VADC ADC

n=−−

MAX min

2 1

0123

7 6 5 4

0 0.5 1.0 1.5 2.0 2.5 3.0 3.5

Analog Voltage

Integer Code

0123

7 6 5 4

-2 -1.5 -1.0 -.5 0.0 0.5 1.0 1.5

Analog Voltage

Integer Code

Analog-to-Digital Conversion

Page 8: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 8

n  Voltage to Integer Code q  n bit ADC

Code Round=−⎡

⎣⎢

⎦⎥

V VQ

IN ADCmin

VADCmin VADCMAX

Q Voltage:

Code: 2n-1 0

VIN

-2n-1 2n-1-1 Positive Coding: Positive and Negative Coding:

Code Round=⎡

⎣⎢

⎦⎥

VQIN

Analog-to-Digital Conversion

n  Signals are analog by nature n  ADC necessary for DSP n  Digital signal processing

provides: q  Close to infinite SNR q  Low system cost q  Repetitive system

ADC DAC Analog signal

Processing

Digital signal processing

Analog signal

processing

Single chip

Analog input

Analog output

•  ADC bottle necks: •  Dynamic range •  Conversion speed •  Power consumption

Why A/D-conversion?

Page 9: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 9

Quantizer

Sample & hold

Time discreteAmplitude continuos

Time continuosAmplitude continuos

Time discreteAmplitude discrete

Samplingclock

[ ] ( )[ ] ( ) ( ) )n(e)n(e)n(e)n(e)n(qTsnvGnD

)n(qTsnvGnD

distortionjitternoiseoffsetINidealrealOUT

INidealidealOUT

+++++⋅⋅+⋅=

+⋅⋅=

ε1

( )tv A,IN[ ]nDOUT

Anti-aliasfilter

( )tvIN

INf

t

fINf

t

f

t

INf SF2/FS

STn ⋅

f

SF

A/D-converter basics

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

Page 10: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 10

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

n  Step size (Q):

n  RMS quantization error:

q  RMS value of triangle wave

FSR2n Q

12

• N-bit converter: δ =VFSR2N

Quantization noise

Page 11: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 11

n  Noise energy: n  SNR for ideal ADC:

222

)(

N

RMSinV⋅

=δ [ ]dB.N.SNR 761026 +×=

)log(20)(

)(

RMSQ

RMSin

VV

SNR =

•  Signal energy:

121 22/

2/

2)(

δδ

δ

δ=∫=

−QQRMSQ dVVV

)232log(20 ⋅= NSNR

Quantization noise

n  Noise energy: n  SNR for ideal ADC:

222

)(

N

RMSinV⋅

=δ [ ]dB.N.SNR 761026 +×=

)log(20)(

)(

RMSQ

RMSin

VV

SNR =

•  Signal energy:

121 22/

2/

2)(

δδ

δ

δ=∫=

−QQRMSQ dVVV

)232log(20 ⋅= NSNR

Quantization noise

Page 12: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 12

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

Page 13: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 13

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

Page 14: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 14

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

Page 15: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 15

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

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

✦  2fc is called the Nyquist rate

✦  Real life ➭  Sample at 2.5fc or faster ➭  Sample clock should not be coherent

with the input signal

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

Page 16: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 16

Sampling speed versus bit resolution

n  Hardware issues q  Sampling speed depends

on bit resolution n  Think time constants

n 

n  Examples: q  8-bit resolution takes 5.5τ q  12-bit resolution takes 8.3τ q  16-bit resolution takes 11τ

Settling errort

e− τ=

Datel Data Acquisition and Conversion Handbook

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.

Nyquist–Shannon sampling theorem

Page 17: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 17

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–Shannon sampling theorem

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

Page 18: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 18

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

Page 19: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 19

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)

Page 20: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 20

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

Page 21: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 21

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):

Page 22: Introduction to Digital Data Acquisition - courses.cs ... · Introduction to Digital Data Acquisition: Sampling Physical world is analog ! Digital systems need to ... Frequencies

CSE466 22

Method to reduce aliasing noise

ADC Sampling at 40KHz

output code = n 0110001 0100010 0100100 0101011 : : :

Input voltage = V

Low Pass

Filter: fcorner=20KHz

e.g. Max freq =20KHz

Use low pass filter to remove high frequency before sampling

Freq.

Gain(dB) 0 -3dB cut off