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

ECE 164 Module 1 - Pulse Code Modulation

Introduction

The activities this week will give you an overview of how analog to digital conversion and digital to analog conversion
plays a large role in communication systems. There are different methods of converting an analog signal to a digital
signal and the implementation depends on the type of signal and the efficiency of conversion. Generally, there is a
tradeoff between how many bytes are used to represent an analog signal and how much computing power is needed
to process that data. Pulse Code Modulation (PCM) is the most basic conversion technique that gives a good
balance on simplicity of implementation and the number of bytes needed to recreate the original analog signal.

Objectives

1. Create and execute a Simulink block diagram simulation.

2. Explain the process of analog-to-digital conversion and digital-to-analog conversion.

3. Implement the different stages of analog-to-digital conversion (and digital-to-analog conversion) in simulation.

4. Determine the conditions to satisfy Nyquist’s sampling criterion.

Pulse Code Modulation

Most signals in the physical world are analog in nature, i.e. they are continuous-valued and they occur in continuous
time. In a lot of applications, these analog signals need to be converted to digital signals in order to be processed
by electronic devices and software. Often there is also a need to convert these digital signals to analog form, such
as audio.

In this exercise, we will be examining the processes of converting an analog signal to a digital signal and vice versa,
by simulating Pulse Code Modulation.

Analog-to-digital converters and digital-to-analog converters serve as the interface between the analog domain and
the digital domain. Pulse Code Modulation (PCM) is one method to convert an analog signal to a digital signal
(see Delta Modulation and Differential PCM). It is a three-step process consisting of sampling, quantizing, and
encoding. It is NOT a modulation technique since it does not vary a signal’s parameter based on an input (message)
signal, rather, it outputs bits which are processed by the digital signal processor. It is widely used in digital audio
applications such as compact discs (CD), telephones, and audio in computers.

If you have audio files in your PC, you can examine its quality using parameters on how its original analog signal
is converted to digital, namely, number of bits and sampling time. For example, most music files stored in PCs use
16 bits with a 44.1 kHz sampling rate. Generally, more bits or larger sampling rate ensures higher audio quality
as they can more accurately represent the original audio signal. Although it is at an expense of a larger
storage size and larger processor memory used.

Figure 1 shows the block diagram of the PCM process. The sampling block discretizes the input analog signal in
time, the quantization block discretizes in amplitude, and the encoding block converts the quantized discrete-time
sequence into bits. For a PCM communication system, the bits are transmitted via a channel. For a computer,
the bits are stored in memory. The message can be any analog signal ranging from speech, music, picture, etc.

1
Message Sampling Quantization Encoding Bits

Figure 1: PCM Transmitter Block Diagram

Inverse Lowpass Approximation


Bits Decoding
Quantization Filter of Message

Figure 2: PCM Receiver Block Diagram

The recovery of the original signal is also composed of three steps, namely, decoding, inverse quantization, and
reconstruction, as shown in Figure 2. Decoding is the opposite of encoding in which decoding involves converting
a sequence of bits into discrete signal levels. Reconstruction involves using a low-pass filter to remove the aliases of
the sampled signal output from the decoder block. It can be thought of as the opposite of sampling where a discrete-
time signal is converted into a continuous-time signal. Note that the reconstructed signal is an approximation of
the original message. Due to the quantization of the signal in the transmitter block, some information is lost in
the process.

In this simulation exercise, you will be tasked to convert a sine wave into a series of bits and then attempt to
reconstruct it.

Learning Activities

Preliminaries

Simulink is an extension of MATLAB that will be used that offers modelling, simulation, and analysis of embedded
systems. Everything is implemented through a graphical user interface environment containing a comprehensive
library of blocks for design and simulation.

Simulink will be used in the first three modules of ECE 164. For an introduction (or review) of Simulink:

1. Go through the Simulink video lecture uploaded in UVLE.

2. Finish the tutorial exercise on Simulink.

Activity 1: Sampling

In sampling, we convert a continuous-time analog signal into a discrete-time signal by taking samples of the signal
at certain instants. When these samples are taken at regular intervals, sampling is characterized as being periodic.

The sampling frequency is the rate at which samples are taken from the analog signal. The inverse of this quantity
is the sampling interval, which is the time period in between two successive samples. To successfully reconstruct
a sampled signal into the original signal, the sampling frequency used must be greater than twice the highest
frequency contained in the signal. This frequency is also referred to as the Nyquist frequency.

2
1. We will implement sampling by using the Sample and Hold block in Simulink. This block takes two inputs:
the In port and the Trigger port.

2. For the In signal port, connect a 20 kHz Sine wave block. This will be the example of the message we will
be sampling. What is the appropriate frequency to sample this 20 kHz sinusoid?
Note: Make sure to check the output of the Sine wave block. If it is not as expected, you may try the
following: (1) Under Modeling > Model Settings, temporarily set the Solver Selection type to Fixed-step, or
(2) Use a very small sample time such as 1e-7 to approximate a continuous sinusoid.

3. For the Trigger port, connect a Discrete Pulse Generator. This block will generate the signal that will
trigger when the message sample will be sampled. Change the period so that it corresponds to an appropriate
sampling rate, based on the Sampling Theorem. What is the effect of sampling at rates higher or lower than
the Nyquist frequency?
Note: If you used a nonzero sample time in Task 2, make sure to set the sample time of the Discrete Pulse
Generator similarly.

4. Examine the output of the Sample and Hold block. At this point, can the process be easily inverted and the
original signal be reconstructed, without error?

5. Try changing the input signal by changing the frequency or combining signals with different frequencies. You
may even wish to upload your own signals and test sampling at different frequencies.

Activity 2: Quantization

The signal after sampling is in discrete-time, but the value is still considered to be continuous-valued. In order to
realize a fully digital signal, a transformation into discrete values must be performed.

In quantization, the continuous range of values is mapped into a finite set of discrete values. As there are an
infinite number of values that are represented by each discrete value, it will be more difficult to determine which
is the original value if we attempted to reverse the process. Thus, a quantization error has been introduced in the
process.

1. We will use the Uniform Encoder block to perform quantization on our sampled signal. Change the
properties of this block to have a peak of 1, number of bits to 32, and output type to Signed Integer.

2. Connect the sampled signal to the Uniform Encoder block. The output of this block is the quantized signal.

Activity 3: Encoding

After the quantization process, the signal is already digital, i.e. discrete-valued and in discrete-time. However,
there are a number of applications which will need these quantized values to be further converted into binary digits.
Encoding is the process of assigning these quantized values into binary numbers.

1. We will use the Integer to Bit Converter block to implement encoding on our quantized signal. Set the
Number of Bits per Integer to the same value that you used in the quantizer block and the input values
should be Signed.

2. Connect the quantized signal to the Integer to Bit Converter block.

3
Activity 4: Signal Reconstruction

To reconstruct the analog signal, we reverse the analog-to-digital conversion process by using the inverse of the
blocks we previously used.

1. We will use the Bit to Integer Converter, Uniform Decoder, and Analog Filter Design to conduct
our digital-to-analog conversion process. Make sure to use matching parameters for these blocks as to the
ones you used in the analog-to-digital process. Examine the output. Was the analog signal successfully
reconstructed?
Note: If you used a nonzero sample time in Activity 1, you may also use the Lowpass Filter block.

2. Try varying the number of bits of the quantizer to 4, 8 and 16. What are the effects on the recovered signal?
How would you describe the quality of the signal? What are the cost implications of using a higher number of
bits?

The final model is illustrated below.

Figure 3: PCM Simulation Model

Activity 5: UVLe Quiz

Submit brief answers for the questions below in the corresponding UVLe quiz for this module.

1. (60 points) Discuss the practical considerations that an engineer must consider in performing analog-to-digital
conversion. Include the following in your discussion:

• Sampling frequency

4
• Number of bits used
• Cost

2. (25 points) In this exercise, we used uniform quantization, wherein the step size is equal across the whole range
of quantization. In some applications, however, it can be more appropriate to use non-uniform quantization,
wherein variable step size is used. Describe instances where this method is more appropriate. Include the
following in your discussion:

• Discuss why smaller step sizes are more desirable at certain ranges.
• Identify companding algorithms and typical applications.

3. (15 points) Cite some instances wherein we can have a lower sampling rate of the PCM while maintaining
the intelligibility of the reconstructed signal.

References

• Simulink Documentation

• Documentation for the Signal Processing toolbox and the Communications toolbox

• EEE 157 Week 8 materials on the Transition from Digital to Analog, and the corresponding video lectures:

– Introduction
– Sampling
– Quantization
– Encoding
– PCM Implementation in Simulink

• Digital Signal Processing: Principles, Algorithms and Applications, by J. G. Proakis and D. G. Manolakis

• Communication Systems, by S. Haykin and M. Moher

• Introduction to Analog and Digital Communications, by S. Haykin and M. Moher

You might also like