Lecture 2
Lecture 2
LIU Liang
Assistant Professor
Department of Electronic and Information Engineering
The Hong Kong Polytechnic University
0
Lecture 1 Review
q Shannon capacity shows the maximum rates for reliable communication over a channel
q In modern communication systems, digital communication techniques are used to
approach Shannon capacity
1
Analog and Digital Signals
q Analog signal: continuous signals varying over time
Ø Consisting of an infinite number of samples
Ø Each sample is continuously valued
q Digital signal
Ø Consisting of a finite number of samples (via sampling)
Ø Each sample is discretely valued (via quantization)
2
Analog-to-Digital (A/D) Conversion at Transmitter
3
Digital-to-Analog (D/A) Conversion at Receiver
4
Advantages of Digital Communication
5
6
Harry Nyquist
Continuous-Time Discrete-Time
7
Sampling Process
8
Sampling Methods
In this course,
we usually
assume ideal
sampling
Sampling at 2 Hz
Sampling at 1.5 Hz
Sampling at 2 Hz
Sampling at 1.5 Hz
?
Frequency of the signal: 1 Hz
11
Nyquist Sampling Rate
q The minimum sampling rate 2𝑊 Hz is called the Nyquist sampling rate
q Intuition: Signals containing high-frequency components change quickly with
time, thus requiring more frequent samples in the time domain
Time
domain:
Frequency
domain:
𝑓 𝑓
𝑊! 𝑊"
12
How to Understand Nyquist Sampling Theory
q It is easier to understand Nyquist Sampling Theory in the frequency domain
q Fourier Transform: from time domain to frequency domain
0
-W W
0 -fs 0
-fs -W W fs -W W fs
-fs-W -fs+W fs-W fs+W -fs-W -fs+W fs-W fs+W
13
Aliasing Effect
6
5
4
3
2
1
0
14
Recovery of Continuous Signal from Samples
q If sampling rate is above 2W Hz, the continuous signal can be recovered as follows
Ø Using samples to construct
0
-fs -W W fs
0 0
-fs -fs/2 -W W fs/2 fs -W W
15
Example of De-Sampling
q Input signal:
Ø Sampling rate:
Ø Four samples:
q De-sampling
Ø Step 1:
17
Some Practical Issues
q In practice, it is difficult to design a low-pass filter with sharp cut-off
0
-W W fs 2fs
q If the sampling rate is much higher than the Nyquist sampling rate, the filter to
recover the signal can have a gentler slope in the cut-off region, making it easier to
implement in practice
0
-W W fs 2fs
q In practice, the sampling rate is higher than the Nyquist sampling rate
18
Examples
q For telephone voice signals, the maximum frequency is 3.4 kHz
Ø The Nyquist rate is 6.8 kHz
Ø A minimum sampling rate of 6.8 kHz is needed
Ø The sampling rate is set as 8 kHz, which is an international standard to process
voice signals
q For music signals in Compact Disk (CD), the maximum frequency is 20 kHz
Ø The Nyquist rate is 40 kHz
Ø The sampling frequency adopted to sample music thus must be greater than or
equal to 40 kHz
Ø The signal is originally sampled at a rate of 44.1 kHz, and then oversampled by 4
times to make the sampling rate 176.4 kHz
19
20
Quantization
q Objective: Transforms a continuous-amplitude signal into a discrete-amplitude
signal, where the discrete amplitudes are only taken from a finite set
q Divide the range of real values into N disjoint subsets
, each called a quantization region and corresponds
to a value (also called the quantization level).
q The quantizer output for any input amplitude is if or
q Quantization function Q(.):
21
An Example
q One quantization design with N=8 quantization levels
Ø Quantization region:
Ø Quantization level:
output
22
Quantization Error
q Quantization error:
Ø True value: output
Ø Quantized value:
q Average distortion (mean-squared error)
ℛ! ℛ" ℛ# ℛ$
input
ℛ% ℛ& ℛ' ℛ(
24
Uniform Quantization
q Quantization error/noise for uniform quantization
Quantized waveform
0.5
0.3
0.1
-0.1
-0.3
25
Uniform Quantization
26
Uniform Quantization
q Example:
Ø Range of the input samples:
Ø Number of quantization levels:
Ø Length of each quantization region:
Ø Assuming quantization error uniformly distributed in
§ Distortion:
§ SQNR:
28
Non-Uniform Quantization
q In practice, the signal’s amplitude may not be evenly distributed. For example, for
speech waveform, there exists a higher probability for smaller amplitudes and a
lower probability for larger amplitudes
q This motivates us to design a quantizer with more quantization regions (smaller
step size) at lower amplitudes and fewer quantization regions (larger step size) at
larger amplitudes. This is called non-uniform quantization
0.6
0.4
0.2
-0.2
-0.4
29
Non-Uniform Quantization
q Method: First pass the samples through a nonlinear element that compresses the
large amplitudes (reduces the dynamic range of the signal), and then perform a
uniform quantization on the output
q At the receiving end, the inverse (expansion) of this nonlinear operation is
applied to obtain the sampled value.
q This technique is called companding (compressing-expanding)
q Two commonly adopted standards, namely A-law and µ-law, have been widely
used
30
A-Law
31
A-Law
the weaker signals are amplified by
larger factors while the stronger signals
q Compressor output versus input are amplified by smaller factors
32
µ-Law
ln(1 + µ vin )
vout = sgn(vin )
ln(1 + µ )
q The value µ controls the amount of compression and expansion.
q µ-law is used in North America to compress the dynamic range of telephone voice
for quantization. The standard pulse code modulation system in US and Canada
employs a compressor with µ=255 followed by a uniform quantizer with 8
bits/sample
33
µ-Law
34
Extension: Vector Quantization
35
36
Encoding
37
Natural Binary Coding (NBC)
q Assign values of 0 to N−1 to different quantization levels, starting from the lowest
level to the highest level. Then, assign the binary expression of the numbers 0 to N−1
to these levels
N=8 7 111
N=16
6 110
5 101
4 100
011 3
010 2
001 1
000 0
38
Gray Coding
q Assign the bit sequence such that adjacent quantization levels only differ in one bit
010
011
001
000
Ø In practice, the signal amplitude changes smoothly. When the quantized value
changes to the next level, it is practically appealing to change the code by one bit
39
An Example for A/D and D/A Conversion
q Sampling rate: 5 Hz
q Number of quantization bits per sample: 3
40
Sampling at Transmitter
100
101
111
110
010
011
001
000
100
101
111
110
010
011
001
000
100
101
111
110
010
011
001
000
44
Some Remarks
q Sampling does not lose any information as long as the sampling rate is equal to or
higher than the Nyquist sampling rate
q However, quantization error is inevitable, unless we use an infinite number of
quantization bits
Ø Rate-distortion trade-off
45
Summary of A/D and D/A Conversion
46
Homework 1
q Visit the website of this course on blackboard. On the left tool bar, click
“Assessment”. You will see one item called “Homework 1”
q Download “Instruction_of_Homework1.pdf”
q Design a program using Matlab or Pathon to perform A/D and D/A conversion
following the instruction in the above file
q If you meet any difficulty, please contact TA
Ø Wang Qipeng: [email protected]
q The deadline for Homework 1 is 11:59pm, January 31, 2023
Ø Click “Homework 1” in “Assessment”. Attach your code and report there, and
click “Submit”
47
How to Install Matlab
q If you have an available Matlab license, use it to install a full version of Matlab on
your PC
q Download a trial version of Matlab from the official website
https://au.mathworks.com/products/matlab.html using your PolyU email address.
This version can be used for 30 days
q Use the open-source version of Matlab, the GNU Octave, which can be
downloaded from https://octave.org/download.html. In Octave, you can write script
and run it in the same way as Matlab (except for some complicated Matlab packages
which are not needed in this assignment). Octave has both Windows and MAC OS
versions, and is easy to install
48