introduction to digital data acquisition

22
CSE/EE 474 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 2 CSE/EE474

Upload: others

Post on 06-Dec-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Digital Data Acquisition

CSE/EE 474 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

2 CSE/EE474

Page 2: Introduction to Digital Data Acquisition

CSE/EE 474 2

A little background

n  For periodic waveforms, the duration of the waveform before it repeats is called the period of the waveform

3 CSE/EE474

Frequency

n  the rate at which a regular vibration pattern repeats itself (frequency = 1/period)

4 CSE/EE474

Page 3: Introduction to Digital Data Acquisition

CSE/EE 474 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.

5 CSE/EE474

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

6 CSE/EE474

Page 4: Introduction to Digital Data Acquisition

CSE/EE 474 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 7 CSE/EE474

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

8 CSE/EE474

Page 5: Introduction to Digital Data Acquisition

CSE/EE 474 5

Sampling Rate

n  Higher sampling rates allow the waveform to be more accurately represented

9 CSE/EE474

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

10 CSE/EE474

Page 6: Introduction to Digital Data Acquisition

CSE/EE 474 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

11 CSE/EE474

•  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

12 CSE/EE474

Page 7: Introduction to Digital Data Acquisition

CSE/EE 474 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

13 CSE/EE474

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

14 CSE/EE474

Page 8: Introduction to Digital Data Acquisition

CSE/EE 474 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

15 CSE/EE474

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?

16 CSE/EE474

Page 9: Introduction to Digital Data Acquisition

CSE/EE 474 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

17 CSE/EE474

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

18 CSE/EE474

Page 10: Introduction to Digital Data Acquisition

CSE/EE 474 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

q  http://www.analog.com/media/en/training-seminars/tutorials/MT-001.pdf

FSR2n Q

12

19 CSE/EE474

• N-bit converter: δ =VFSR2N

Quantization noise

20 CSE/EE474

Page 11: Introduction to Digital Data Acquisition

CSE/EE 474 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

21 CSE/EE474

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

22 CSE/EE474

Page 12: Introduction to Digital Data Acquisition

CSE/EE 474 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

23 CSE/EE474

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

24 CSE/EE474

Page 13: Introduction to Digital Data Acquisition

CSE/EE 474 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

25 CSE/EE474

Example: Flash A/D

n  Advantages q  Ultra-fast

n  Disadvantages q  High power q  Low resolution q  Metastability

n  Sample/hold improves performance

26 CSE/EE474

Page 14: Introduction to Digital Data Acquisition

CSE/EE 474 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

27 CSE/EE474

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

28 CSE/EE474

Page 15: Introduction to Digital Data Acquisition

CSE/EE 474 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

29 CSE/EE474

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

30 CSE/EE474

Page 16: Introduction to Digital Data Acquisition

CSE/EE 474 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

31 CSE/EE474

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

32 CSE/EE474

Page 17: Introduction to Digital Data Acquisition

CSE/EE 474 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

33 CSE/EE474

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

34 CSE/EE474

Page 18: Introduction to Digital Data Acquisition

CSE/EE 474 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|

35 CSE/EE474

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

36 CSE/EE474

Page 19: Introduction to Digital Data Acquisition

CSE/EE 474 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)

37 CSE/EE474

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) 38 CSE/EE474

Page 20: Introduction to Digital Data Acquisition

CSE/EE 474 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)

39 CSE/EE474

Nyquist Theorem and Aliasing

n  Graphical Example 2: q  BUT, if sample points fall on zero-crossings the sound is

completely cancelled out

40 CSE/EE474

Page 21: Introduction to Digital Data Acquisition

CSE/EE 474 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

41 CSE/EE474

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

42 CSE/EE474

Page 22: Introduction to Digital Data Acquisition

CSE/EE 474 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

43 CSE/EE474