2 - Signal Sampling and Quantization
2 - Signal Sampling and Quantization
and Quantization
11-Oct-24 1
Overview
• Digital Signal Processing System
• Analog to Digital Conversion
• Nyquist–Shannon Sampling Theorem
• Aliasing
• Sampling Effect in Time Domain
• Sampling Effect in Frequency Domain
• Anti Aliasing Filter
• Under-sampling
• Sampling of Band Limited Signals
• Over-sampling
• Digital to Analog Conversion
11-Oct-24 2
Analog vs. Digital Signal Processing
Analog Analog
input output
Signal x(t) Signal y(t)
A/D Digital D/A
converter Signal Processor converter
11-Oct-24 3
Typical Digital Signal Processing System
11-Oct-24 4
Analog to Digital Conversion
A/D conversion can be viewed as a three-step process
11-Oct-24 5
Analog to Digital Conversion
11-Oct-24 6
Analog to Digital Conversion
Sample & Hold (Sampler)
11-Oct-24 7
Analog to Digital Conversion
Sample & Hold (Sampler)
11-Oct-24 8
Analog to Digital Conversion
Sample & Hold (Sampler)
11-Oct-24 9
Analog to Digital Conversion
Sample & Hold (Sampler)
11-Oct-24 10
Analog to Digital Conversion
Sample & Hold (Sampler)
11-Oct-24 11
Analog to Digital Conversion
Sample & Hold (Sampler)
11-Oct-24 12
Analog to Digital Conversion
Sample & Hold (Sampler)
11-Oct-24 13
Analog to Digital Conversion
Sample & Hold (Sampler)
Figure below shows an analog (continuous-time) signal (solid
line) defined at every point over the time axis (horizontal line)
and amplitude axis (vertical line).
Hence, the analog signal contains an infinite number of points.
11-Oct-24 14
Analog to Digital Conversion
Sample & Hold (Sampler)
• Each sample maintains its voltage level during the sampling
interval ࢀ to give the ADC enough time to convert it.
• This process is called sample and hold.
11-Oct-24 15
Nyquist–Shannon Sampling Theorem
The sampling theorem guarantees that an analogue signal
can be perfectly recovered as long as the sampling rate is at
least twice as large as the highest-frequency component of
the analogue signal to be sampled.
11-Oct-24 16
Nyquist–Shannon Sampling Theorem
11-Oct-24 17
Nyquist–Shannon Sampling Theorem
Examples
11-Oct-24 18
Nyquist–Shannon Sampling Theorem
Example: For the following analog signal, find the Nyquist sampling rate,
also determine the digital signal frequency and the digital signal
11-Oct-24 19
Nyquist–Shannon Sampling Theorem
Example: Find the sampling frequency of the following signal.
11-Oct-24 20
Nyquist–Shannon Sampling Theorem
Exercise
11-Oct-24 21
11-Oct-24 22
Aliasing
Generally, people notice when the frame-rate is less than the refresh rate of the
display.
11-Oct-24 23
Aliasing
• When the minimum sampling rate is not respected,
distortion called aliasing occurs.
• The low pass filter, called the anti-aliasing filter, removes all
frequencies above half the selected sampling rate.
11-Oct-24 24
Aliasing
• Figure illustrates sampling a 40 Hz sinusoid
• The sampling interval between sample points is T = 0.01
second, and the sampling rate is thus fs = 100 Hz.
• The sampling theorem condition is satisfied
11-Oct-24 25
Aliasing
• Figure illustrates sampling a 90 Hz sinusoid
• The sampling interval between sample points is T = 0.01
second, and the sampling rate is thus fs = 100 Hz.
• The sampling theorem condition is not satisfied
11-Oct-24 26
Aliasing
11-Oct-24 27
Sampling Effect in Time Domain
11-Oct-24 28
Time & Frequency Domains
• There are two complementary signal descriptions.
• Signals seen as projected onto time or frequency domains.
11-Oct-24 29
Time & Frequency Domains
11-Oct-24 30
Frequency Range of Analog & Digital Signals
11-Oct-24 31
Sampling theorem in the frequency domain
In practice this can help us to:
11-Oct-24 32
Sampling theorem in the frequency domain
11-Oct-24 33
Sampling theorem in the frequency domain
Fourier series
Fourier Transform
Original spectrum
11-Oct-24 34
Sampling theorem in the frequency domain
11-Oct-24 35
(reconstruction)
݂ ݏ− ܤ > ܤ
ࢌ࢙ >
11-Oct-24 36
If applying a lowpass reconstruction filter to obtain exact reconstruction of the
original signal spectrum, the following condition must be satisfied:
11-Oct-24 37
Review of Fourier series and FT
11-Oct-24 38
Example:
11-Oct-24 39
The spectrum of original frequency:
b- After the analog signal is sampled at the rate of 8000 Hz, the sampled signal
spectrum and its replicas centered at the frequencies ±kfs, each with the scaled
amplitude being 2.5/T
The two-sided
amplitude
spectrum for
the sinusoid
11-Oct-24 41
11-Oct-24 42
11-Oct-24 43
Practical consideration for signal sampling
Design of the Anti-Aliasing Filter
• Anti-aliasing filters are analog filters.
• They process the signal before it is sampled.
• In most cases, they are also low-pass filters unless band-
pass sampling techniques are used.
11-Oct-24 44
Design of the Anti-Aliasing Filter
The shape of each replica in the sampled signal spectrum is the same as that of
the anti-aliasing filter magnitude frequency response.
11-Oct-24 45
Example: Butterworth Filter
• The Butterworth magnitude frequency response with an order of n is given by:
• For a second-order Butterworth lowpass filter with the unit gain, the transfer
function and its magnitude frequency response are given by:
11-Oct-24 46
Second-order unit-gain Sallen-Key lowpass filter
11-Oct-24 47
i1
Vo
i=0
i i2 Vo = +
ܸ − ܸ
݅=
Assume the ܴଵ
voltage at ܸ − ܸ
this node is V ݅ଵ =
ܼଶ
ܸ − ܸ ܸ ܸ ܴଶ + ܼଵ
݅ଶ = = = ≫≫ ܸ = ܸ
ܴଶ ܴଶ + ܼଵ ܼଵ ܼଵ
= +
ࢂ − ࢂ ࢂ − ࢂ ࢂ − ࢂ
ࢆࢉ = = +
࢙ ࡾ ࡾ ࢆࢉ
11-Oct-24 50
Assuming a sampling rate of 16,000 Hz is used, and the anti-aliasing filter is a
second-order Butterworth lowpass filter with a cutoff frequency of 3.4 kHz:
11-Oct-24 51
Given the DSP system with a sampling rate of 40,000 Hz is used, the antialiasing filter is the
Butterworth lowpass filter with a cutoff frequency 8 kHz, and the percentage of aliasing level
at the cutoff frequency is required to be less than 1%, determine the order of the anti-aliasing
lowpass filter
11-Oct-24 52
11-Oct-24 53
Signal Reconstruction
Review : A block diagram for a DSP system
11-Oct-24 54
Zero-order Hold Circuit (ZOH)
11-Oct-24 55
Practical consideration of signal reconstruction
Hold transfer function
Frequency Response
11-Oct-24 56
Sample-and-hold lowpass filtering effect
11-Oct-24 57
• The magnitude frequency response acts like lowpass filtering and shapes the
sampled signal spectrum of Ys(f ). This shaping effect distorts the sampled signal
spectrum Ys(f ) in the desired frequency band.
• The spectral images are attenuated due to the lowpass effect of sin(x)/x. This
sample-and-hold effect can help us design the anti-image filter.
• Since the magnitude frequency response of the sampled signal using an ideal
sampler is T|Ys(f )|, therefore, the spectral distortion at the recovery stage can
be derived as
11-Oct-24 58
11-Oct-24 59
Example:
11-Oct-24 60
11-Oct-24 61
11-Oct-24 62
Under Sampling
• If the sampling rate is lower than the required Nyquist rate,
that is fS < 2W, it is called under sampling.
11-Oct-24 63
Sampling of Band Limited Signals
Signals whose frequencies are restricted to a narrow band of
high frequencies can be sampled at a rate similar to twice the
Bandwidth (BW) instead of twice the maximum frequency.
Fs ≥ BW
11-Oct-24 64
Sampling of Band Limited Signals
• While this under-sampling is normally avoided, it can be
exploited.
• For example, in the case of band limited signals all of the
important signal characteristics can be deduced from the
copy of the spectrum that appears in the baseband through
sampling.
• Depending on the relationship between the signal
frequencies and the sampling rate, spectral inversion may
cause the shape of the spectrum in the baseband to be
inverted from the true spectrum of the signal.
11-Oct-24 65
Sampling of Band Limited Signals
11-Oct-24 66
Over Sampling
11-Oct-24 67
Over Sampling
• In the example below, 2x oversampling means that a low order analog
filter is adequate to keep important signal information intact after
sampling.
• After sampling, higher order digital filter can be used to extract the
information.
11-Oct-24 68
Over Sampling
• The ideal filter has a flat pass-band and the cut-off is very
sharp, since the cut-off frequency of this filter is half of that
of the sampling frequency, the resulting replicated spectrum
of the sampled signal do not overlap each other. Thus no
aliasing occurs.
• Practical low-pass filters cannot achieve the ideal
characteristics.
• Firstly, this would mean that we have to sample the filtered
signals at a rate that is higher than the Nyquist rate to
compensate for the transition band of the filter
11-Oct-24 69
Spectra of Sampled signals
11-Oct-24 70
Sampling Low Pass Signals
11-Oct-24 71
Exercise
Exercise-1: If the 20 kHz signal is under-sampled at 30 kHz, find the
aliased frequency of the signal.
11-Oct-24 72
Exercise
Exercise-4: Humans can hear sounds at frequencies between 0 and 20
kHz. What minimum sampling rate should be chosen to permit perfect
recovery from samples?
11-Oct-24 73
11-Oct-24 74
Analog to Digital Conversion (ADC)
11-Oct-24 75
Analog to Digital Conversion
There are several ways to implement ADC. The most common ones are
Successive
Feature Flash ADC Sigma-Delta ADC
Approximation ADC
Converts analog input into digital
Converts analog input into digital
output by using a comparator array Iteratively approximates the input
output by oversampling and
Operating Principle that directly compares the input voltage by successively narrowing
using a feedback loop to
voltage with multiple reference down the possible output values.
continuously adjust the output.
voltages simultaneously.
Relatively slow due to
Very fast, usually in the range of 1 Moderate speed, suitable for a oversampling and filtering,
Conversion Speed
to 10 nanoseconds. wide range of applications. typically measured in
milliseconds.
High resolution, typically ranging High resolution, commonly Extremely high resolution, often
Resolution
from 8 to 16 bits. ranging from 8 to 24 bits. exceeding 24 bits.
High accuracy, as all reference High accuracy, with each bit
Excellent accuracy due to
Accuracy voltages are compared to the input decision based on the previous
oversampling and noise shaping.
simultaneously. bit's result.
High complexity, requiring a large Moderate complexity, requiring a Moderate complexity but
Complexity number of comparators and digital-to-analog converter (DAC) requires digital filtering and a
precise voltage references. and a comparator for each bit. high-precision analog front end.
Typically, higher power
Moderate power consumption, as
consumption due to the Lower power consumption
Power Consumption it operates in a sequential
simultaneous comparison of many compared to other ADC types.
manner.
reference voltages.
Commonly used in applications
Used in applications where speed
Versatile and suitable for general- that prioritize high-resolution
and high resolution are crucial,
purpose applications, including measurements and can tolerate
Applications such as high-speed
microcontrollers and data slower sampling rates, such as
communications, radar, and high-
acquisition systems. precision sensors and audio
end instrumentation.
equipment.
11-Oct-24 76
2-bit Flash ADC
Assume input voltage = 3 V
11-Oct-24 77
Analog to Digital Conversion
11-Oct-24 78
Analog to Digital Conversion
• The quantization step size or the ADC resolution (Δ): is the distance between
two successive quantization levels, (it is also defined as Vmin (minimum
detectable voltage) or the LSB value of the ADC)
Full scale
ࢄࢇ࢞ − ࢄ analogue range
∆=
• Xmax and Xmin are the maximum value and minimum values, respectively,
of the analog input signal X , and m is the number of bits used by the
converter.
11-Oct-24 79
Example:
If a 3-bit ADC channel accepts analog input ranging from 0 to 5V, determine the following:
Solution
a)
b)
c)
d)
11-Oct-24 80
Quantization Error
11-Oct-24 81
Quantization Error
• The quantization error is calculated as the difference between the quantized
level and the true sample level.
• Most quantization errors are bounded in size to half a quantization step (Δ).
Example: Determine the quantization error when the analog input is 3.2V
Solution
11-Oct-24 82
Analog to Digital Conversion
• Let's consider the signal which is to be quantized.
In the figure, we can see that there is a difference between the original signal (Blue
Line) and the quantized signal (Red Lines). This is the error produced while
quantization
11-Oct-24 83
Analog to Digital Conversion
Quantization error can be reduced, however, if the number of quantization levels is
increased as illustrated in the figure
11-Oct-24 84
Analog to Digital Conversion
11-Oct-24 85
Three-bit A/D Conversion
11-Oct-24 86
Dynamic Range
• Quantization errors can be determined by the quantization step.
• Quantization errors can be reduced by increasing the number of bits
used to represent each sample.
• Unfortunately, these errors can not be entirely eliminated, and their
combined effect is called quantization noise.
ࢄࢇ࢞ ି ࢄ
ࡰ࢟ࢇࢉ ࡾࢇࢍࢋ = ࢍ = 20log (2m) = 6.02 x m dB
∆
11-Oct-24 87
Signal-to-Quantization-Noise Ratio
Assuming that eq is a uniformly distributed random variable which has a range within
a quantized interval Δ and has the following probability density function, f(eq)
11-Oct-24 88
Signal-to-Quantization-Noise Ratio
The ratio of signal power to quantization noise power (SNR) due to quantization
can be expressed as
11-Oct-24 89
Example:
11-Oct-24 90
Digital-to-Analog (D/A) Conversion
Block Diagram of D/A Conversion
11-Oct-24 91
Digital-to-Analog (D/A) Conversion
• Once digital signal processing is complete, digital-to-analog
(D/A) conversion must occur.
• This process begins by converting each digital code into an
analog voltage that is proportional in size to the number
represented by the code.
• This voltage is held steady through zero order hold until the
next code is available, one sampling interval later.
11-Oct-24 92
Digital-to-Analog (D/A) Conversion
• In the frequency domain, the high frequency elements
present in the zero-order hold signal appear as images,
copies of the original signal spectrum situated around
integer multiples of the sampling frequency.
11-Oct-24 93
Digital-to-Analog (D/A) Conversion
Three bit D/A Conversion
11-Oct-24 94
Summary
11-Oct-24 95
Summary
11-Oct-24 96