Chapter 4 Instrument

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Analog-to-Digital and Digital-to-Analog

Conversion
• Sampling of analog signals

• Quantization and coding

1
What is ADC
• An electronic integrated circuit which transforms a signal from analog (continuous)
to digital (discrete) form.
• Analog signals are directly measurable quantities.
• Digital signals only have two states. For digital procesor, we refer to binary states,
0 and 1.
Why ADC is needed
• Microprocessors can only perform complex processing on digitized signals.
• When signals are in digital form they are less susceptible to the deleterious
effects of additive noise.
• ADC Provides a link between the analog world of transducers and the digital
world of signal processing and data handling.
2
Data Convertor Basics
• Real world signals are analog (temp, pressure, position, sound, light, speed, etc):
• Continuous time and continuous amplitude

• DSP can only process:


• Discrete time and discrete amplitude

• Digital data conversion system requires ADC and DAC.

Because ADC is commonly


needed, most modern
microcontrollers has
an in-built ADC unit.

3
AD Conversion Process
There are two related steps in A-to-D conversion:
Sampling and holding:
The analogue signal is extracted, usually at regularly spaced time
instants. Quantization creates a series of digital values
The samples have real values. to represent the original analog signal
Quantization and Encoding:
The samples are quantized to discrete levels.
Each sample is represented as a digital value.

Tawetu A. McENG 6113 4


ADC Process
Consider an analog signals that can represent any
natural phenomena temp, pressure, position,
Sampling & Hold
sound, light, speed,…
• Measuring analog signals
at uniform time intervals Continuous Signal
• Ideally twice as fast as what
we are sampling

• Digital system works with


discrete states
• Taking samples from each
location t

• Reflects sampled and hold


signal
• Digital approximation
5
ADC Process

Sampling & Hold

• Measuring analog signals at


uniform time intervals
• Ideally twice as fast as what we
are sampling

• Digital system works with


discrete states
• Taking samples from each
location t

• Reflects sampled and hold


signal
• Digital approximation
6
ADC Process

Sampling & Hold

• Measuring analog signals at


uniform time intervals
• Ideally twice as fast as what we
are sampling
• Digital system works with discrete
states
• Taking a sample from each
location
t

• Reflects sampled and


hold signal
• Digital approximation
7
ADC Process

Sampling & Hold

• Measuring analog signals at


uniform time intervals
• Ideally twice as fast as what we
are sampling
• Digital system works with discrete
states
• Taking samples from each
location
t
• Reflects sampled and hold signal
• Digital approximation Sample and hold: The output only changes at
periodic instants of time. The independent
variable now takes values in a discrete set
8
Quantization & Coding
Quantizing: Partitioning
Quantization error
the reference signal • Use original analog
range into a number of signal
discrete quanta, then • Apply 2 bit coding
matching the input signal
to the correct quantum.

• Encoding: Assigning a • Use original analog


unique digital code to signal
each quantum, then
• Apply 3 bit coding
allocating the digital code
to the input signal.

Better representation of input information with additional bits 9


Sampling
Sampling is the process of recording an analog signal at regular discrete moments o
time.
• The time interval between samples is called the sampling interval Ts=1/fs.

• The number of samples per second is sampling rate or sampling frequency fs

• There are 3 sampling methods:


• Ideal - an impulse at each sampling instant

• Natural - a pulse of short width with varying amplitude

• Flattop - sample and hold, like natural but with single amplitude value

4.10
Three different sampling methods
If a sinusoidal signal is sampled with a high sampling rate, the original signal can be
recovered exactly by connecting the samples together in a smooth way (called ideal low
pass filtering). In contrast, if a sinusoidal signal is sampled with a low sampling rate, the
samples may be too infrequent to recover the original signal.
The question that arises is: for which values of sampling rate fs can we sample and then
perfectly recover a sinusoidal signal v(t) = cos(2πft)?

fs > fNyquist = 2fmax

The Nyquist-Shannon Sampling Theorem states that the sampling rate for exact recovery of a
signal composed of a sum of sinusoids must be larger than twice the maximum frequency of the
signal. This rate is called the Nyquist sampling rate fNyquist.

 Sampling rate less than Nyquist rate results in original signal is not recovered known
as aliasing phenomena 12
For an intuitive example of the Nyquist theorem, let us sample a simple sine
wave at three sampling rates: fs = 4f (2 times the Nyquist rate), fs = 2f (Nyquist
rate),and fs = f (one-half the Nyquist rate).

Figure : shows the sampling and the subsequent recovery of the signal.
From the figure it can be seen that sampling at the Nyquist rate can create
a good approximation of the original sine wave (part a). Oversampling in
part b can also create the same approximation, but it is redundant and
unnecessary. Sampling below the Nyquist rate (part c) does not produce a
signal that looks like the original sine wave.
Ex 1. In this example, v(t)=cos(2πft) is sampled with
sampling interval Ts=T/3 to produce the following v[n].

v[n] = cos(2πfnTs) by substituting t=nTs


= cos(2πfnT/3) since Ts=T/3
= cos(2πn/3) since T=1/f
This expression for v[n] evaluates to the
sample values as shown below.
The samples are shown
as the sequence
v[n] indexed by integer
values of n.

Ex 2: Given the signal v(t) = 7 + 5cos(2π440t) + 3sin(2π880t)  the sampling rate fs > fNyquist= 2(880)=1760 Hz.

Ex 3: Given the signal v(t) = 5 sin(2π50t) is sampled at fs = 40 Hz, what signal can be recovered after sampled?

Solution: v[n] = 5 sin(2πn 50/40) = 5 sin(2πn(1.25)) = 5 sin (2πn(1 + 0.25)) = 5 sin (2πn(0.25)) = 5 sin (0.5πn)
Recovering signal: vr(t) = 5 sin (0.5π 40t) = 5 sin (2π 10t)
15
Quantization & Coding
Quantizing: Partitioning
Quantization error
the reference signal • Use original analog
range into a number of signal
discrete quanta, then • Apply 2 bit coding
matching the input signal
to the correct quantum.

• Encoding: Assigning a • Use original analog


unique digital code to signal
each quantum, then
• Apply 3 bit coding
allocating the digital code
to the input signal.

Better representation of input information with additional bits 16


Quantization
• Sampling results in a series of pulses of varying amplitude values ranging
between two limits: a min and a max.
• The amplitude values are infinite between the two limits.
• We need to map the infinite amplitude values onto a finite set of known values.
• This is achieved by dividing the distance between min and max into M levels,
each of height  (zone width).
 = (max - min)/M , M=2N , N is number of bits
Quantization Levels
The midpoint of each zone is assigned a value from 0 to M-1 (resulting in M values)

Each sample falling in a zone is then approximated to the value of the midpoint
4.17
Quantization Zones
• Assume we have a voltage signal with amplitutes Vmin=-20V and Vmax=+20V.
We want to use L=8 quantization levels.
Zone width = (20 - -20)/8 = 5
The 8 zones are: -20 to -15, -15 to -10, -10 to -5, -5 to 0, 0 to +5, +5 to +10, +10 to +15,
+15 to +20
The midpoints are: -17.5, -12.5, -7.5, -2.5, 2.5, 7.5, 12.5, 17.5
Quantization Error
• When a signal is quantized, we introduce an error
• The difference between actual and coded value (midpoint) is referred to as the
quantization error.
• The more zones, the smaller  which results in smaller errors.
• BUT, the more zones the more bits required to encode the samples -> higher bit rate
Encoding
Encoding is assigning Codes to Zones
• Each zone is then assigned a binary code.
• The number of bits required to encode the zones, or the number of
bits per sample as it is commonly referred to, is obtained as follows:
nb = log2 M
• Given our example, nb = 3
• The 8 zone (or level) codes are therefore: 000, 001, 010, 011, 100, 101,
110, and 111
• Assigning codes to zones:
• 000 will refer to zone -20 to -15
• 001 to zone -15 to -10, etc.
4.19
Quantization and encoding of a sampled signal
A/D Conversion A/D & D/A Conversion

• Anti-alias filter is used to avoid any aliasing phenomena.


• The digital data is processed by
D/A Conversion a microprocessor and output
to a DAC.
• DAC is usually operated at the
same rate fS as the ADC
• The resulting staircase-like
signal is finally passed through
Tawetu A. McENG 6113
a smoothing filter to ease
21
the
effects of quantization noise.
Improve the accuracy in ADC
• Increase the sampling rate which increases the maximum frequency that can be
measured.
• Increase the resolution which improves the accuracy in measuring the amplitude
of the analog signal.

22
ADC : Parameters
Number of bits N: The higher is the number of bits, the more precise is the digital
output.

Quantisation error Eq: The average difference between the analogue input and the
quantized value. The quantization error of an ideal ADC is half of the step size.

Sample time Tsample: sampling shoud be done according Nyquist theorem

Conversion time Tconv: Time taken to convert the voltage on the sampling capacitor to a
digital output.

Resolution: r smallest analog change resulting from changing one bit

23
Resolution
Let n = 2 Vmax 3=11

r
M= 2n – 1
3=11
3 steps on the digital scale 2=10
d0 = 0 = 0b00
dVmax = 3 = 0b11 2=10

M = 2n 1=01
1=01

4 steps on the digital scale


d0 = 0 = 0b00
0V 0=00 0=00
dVmax - r = 3 = 0b11 (no dVmax )

You might also like