0% found this document useful (0 votes)
28 views8 pages

Lab 1

This document describes Experiment #1 on sampling and quantization. The experiment has two parts: 1. Creating a "half sample delay" by convolving an input signal with a designed sequence. This is simulated in MATLAB and then implemented in real-time using a DSP. 2. Observing the effects of reducing the number of bits per sample on a signal. As bit depth decreases, quantization noise increases and the reconstructed signal deteriorates compared to the original analog signal.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views8 pages

Lab 1

This document describes Experiment #1 on sampling and quantization. The experiment has two parts: 1. Creating a "half sample delay" by convolving an input signal with a designed sequence. This is simulated in MATLAB and then implemented in real-time using a DSP. 2. Observing the effects of reducing the number of bits per sample on a signal. As bit depth decreases, quantization noise increases and the reconstructed signal deteriorates compared to the original analog signal.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

ECE 431 c 2006 Bruno Korst-Fagundes, Wei Yu Fall 2006

Experiment # 1

Sampling and Quantization

3 3

2
2

1
1

0
−→ E000 −→ −1

−1 Input Output
−2
Signal Mask
−2
−3

−3 −4
2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9
−3 −3
x 10 x 10

1 Introduction and Purpose

In order for the engineer to manipulate an analog signal with the help of a microprocessor, the
signal must be converted into a digital form. This is the very first step to be performed, usually
by a hardware device called an A/D (analog-to-digital, or simply “a to d”) converter. The A/D
converter will take samples of the signal at regular intervals (a process called sampling) and assign
numbers to these samples (a process called quantization). After the signal is processed by the
microprocessor as programmed by the engineer, the resulting digital samples are sent to a D/A
converter to be recomposed into an analog (continuous) signal. The hardware utilized in this lab
will make use of a dedicated integrated circuit to do both A/D and D/A conversions (a CODEC),
and a dedicated signal processor (a “DSP”) will perform all necessary computation as specified in
the program you will run. The hardware utilized in this lab is comprised of a stereo (two channel)
codec operating at 48KHz sampling rate, with each two-channel sample represented in 32 bits (16
bits per channel). Remember these numbers throughout the experiment.

The purpose for this lab is to verify the validity of the theory behind sampling and quantization
seen in the classroom. This will be done in two main parts:

• First, you will create a “half sample delay” by means of a convolution between the input
analog signal and a sequence that you will calculate;

• Second, you will observe the effects of reducing the number of bits used per sample. As the
number of bits per sample decreases, noise increases and the resulting signal is a deteriorated
version of the original analog signal;

1
2 Background Reading and Preparation

It is fair to say that every textbook in digital signal processing starts by describing how an analog
signal is converted into a digital one prior to being processed. Sampling and quantization are
described in detail in many references. Therefore, rather than looking for a single reference for
background reading, you can refer to most of the textbooks cited in the bibliography presented at
the end of this outline. Sampling and quantization are also explained from the communications
perspective, under Pulse Code Modulation. For this experiment, you should review your notes
on convolution, aliasing and downsampling from introduction to signals and systems, and bitwise
operations from microprocessor theory. It will be very helpful to you reading the document titled
“On Instruments”, with specific guidelines relating to the instruments in the lab.

Before coming to the lab, complete the matlab part of the experiment. If the lab facilities in
GB150 are not in use by another course, you may also come by at any time during office hours to
practice. It is beneficial for you, even for your future professional practice, to become acquainted
with the tools and equipment in this lab.

3 Experiment

The experiment is divided into two main parts. As described above, on the first part you will
create a “half sample delay”. This will be done by convolving the input analog signal with a
sequence which you will calculate. This convolution operation will be first simulated in Matlab
then implemented in real-time. On the second part of the experiment, you will gradually remove
bits from incoming samples of the analog signal and observe the effect of quantization noise in
frequency domain.

All results are to be reported in the spaces provided in the answer booklet. The T.A.
will verify the experimental results you obtain by providing his/her signature.

3.1 Half-Sample Delay

In your previous course in signals and systems, you have been introduced to the convolution between
two sequences. In this part of the experiment you will design a sequence and will convolve it with a
sinusoid. In Matlab you can design your sequences to have defined lengths, whereas in a real-time
implementation your incoming signal comes from a signal generator. For all purposes, the signal
coming from the generator is infinite, for it lasts while the instrument is on.

3.1.1 Problem Statement

Suppose that you have the sampled version of a continuous-time signal x(t) (which is band-limited
and is assumed to satisfy the Nyquist criterion)

x[n] = x(nTs ) (1)

2
where the sampling frequency is 48kHz. Your goal is to find y[n], the half-sample delayed version
of x[n]:
y[n] = x((n − 1/2)Ts ) (2)
Since x(t) satisfies Nyquist, you could have reconstructed x(t) from x[n], then resampled it to get
y[n]. The point of this exercise is to find a digital way to accomplish the same thing.

In your lab preparation, design a digital filter h[n] so that

y[n] = x[n] ∗ h[n] (3)

Give a mathematical expression for h[n].

The h[n] you designed is of infinite length. In practical implementation, we need to limit it to a
finite duration. For the rest of the experiment, assume that the filter length is at most 32.

3.1.2 Simulation

Your task now is to create: a) a finite sequence of a sinusoid at frequency 2kHz, of length 100,
sampled at 48kHz; b) a 32 element sequence h1 [n] to generate a delay of 17 samples; and c) a 32
element sequence h2 [n] to generate a delay of 17-and-half samples (similar to the one you designed
above). Plot h1 [n] and h2 [n] and attach it to your answer booklet.

You will determine that the half-sample delay is taking place by comparing the results of two
convolutions: sinusoid convolved with 17-sample-delayed sequence; and sinusoid convolved with
17-and-half-sample-delayed sequence.

Answer the questions in the answer booklet.

3.1.3 Implementation

The convolution that you have just performed in Matlab is the simulation of what you will do in
real-time. In order for you to run this convolution in real-time, a skeleton program is given to you
(it is located at ECE431/Exp01/PartA Half Delay). Open Code Composer Studio (CCS2) and
open the project named Half delay.pjt. You will need to insert your two sequences on the two
“coefficient” files, written in C (look at the project tree on Code Composer Studio). Open the
files, then copy and paste your sequences from within Matlab. It may be a good idea to display
the transpose of you sequence on the Matlab active window and copy from there.

Having done all that, compile the project, load and run the executable program on the DSP
platform. For your convenience, go under the tab Option (top menu), Customize, then press on
the tab Program Load Options and select “Load Program After Build”. This will save you the
time to load the program every time you perform and incremental build after every modification
to the program. You need to press the “Run” button to get the DSP running.

Remember, the program deals with samples coming as one 32-bit word representing two channels
(from a stereo CODEC). Two convolutions will be performed (one for each channel) and two outputs
are generated. The outputs are combined into one word and sent back to the CODEC.

3
With the DSP running already, turn on your oscilloscope, your signal generator, and connect inputs
and outputs appropriately. Make sure the output button on the signal generator is pressed, or you
will not have a signal. Set your signal to a 3Vpp (peak-to-peak) sine at 1KHz. Display both outputs
on the scope. After you verify that it runs, modify the frequency to 20KHz. Leave the amplitude
unchanged.

When you are successful in observing the half-sample delay, ask the TA to sign off your experiment.
Answer additional questions in the answer booklet.

3.2 Less Bits, More Noise

You should expect that as you reduce the number of bits assigned per sample of the incoming
analog signal, you should have a gradually less accurate digital representation of your analog signal.
Consider the extreme case: you have one bit to represent samples of a sinusoid. Of course, with
only two values possible, one of them would be assigned to every sample in the positive cycle of the
sinusoid and the other would be assigned to every sample in the negative cycle. The result would
be a square wave with the same period as the original sinusoid. Now consider the frequency domain
view of this new signal sampled with only one bit per sample. You used to have one component
(ideally an impulse) in the frequency domain for the sinusoid, and after sampling it you have that
same component and all of its odd harmonics. This is not at all a faithful representation of the
analog signal. As you increase the number of bits, you decrease the amount of quantization noise,
achieving a gradually better representation of your signal.

A skeleton quantization program is given to you (it is located at ECE431/Exp01/PartB Quant).


Open Code Composer Studio and open the project named quant alias.pjt. Look briefly at the
code. You are to change the code to modify the number of bits used for each sample of the input
signal. The CODEC provides 15 bits plus a sign bit for each sample on each channel. You will
force the samples for one of the channels to be “quantized” by using only a reduced number of bits.

When you reduce the number of bits on the quantization, you increase the error introduced in the
process by reducing the number of quantization levels available. Should you modify the MSBs or
the LSBs to accomplish this?

The operation you will utilize to modify the word length of the incoming signal is known as “mask-
ing”, and you likely have already made use of it in a Microprocessors course. It consists of per-
forming a logical AND operation between the data word passed on to the DAC and a “mask” that
you select. Looking at your decimate.c program, you will notice that there are several masking
options for variable y. Use only one mask at a time, and comment out the others. You may change
the mask to answer the questions in the answer booklet. Do not forget to recompile and run the
program every time you make a change. You do not need to run Matlab to answer the questions
for this part.

Use an input signal of around 3.45Vpp and 100Hz to answer the questions below. The reason why
you are using 3.45Vpp is to utilize the full range of the CODEC. If you do not have the full range
of the signal going into the CODEC, you will not get the right results.

Answer the questions in the answer booklet.

4
ECE 431 c 2006 Bruno Korst-Fagundes, Wei Yu Fall 2006

Answer Booklet
Lab # 1 - Sampling and Quantization
• Name: Experiment Date:

• Student No.: Day of the week: Time:

• Name:

• Student No.: Grade: / 25

1 Half-Sample Delay

1. Suppose you have a sampled version of a bandlimited continuous-time signal and you would
like to delay it by half a sampling period. Design an infinite-length digital filter which, when
convolved with the sampled input, will provide such a delay. Give a mathematical expression
of h[n] as required in Section 3.1.1. Show the derivation. [4 pts]

5
2. Using Matlab, generate and plot finite-duration filters h1 [n] and h2 [n] as required in Section
3.1.2. Please attach your Matlab program segment and the plots. [2 pts]

3. Using Matlab, convolve the input (finite-duration sinusoid) with the half-sample delay se-
quence. Now convolve the same input with the simple delay sequence. Plot both results in the
same figure, and attach the Matlab plot. What is their time difference? Report the difference
below. Compare with the theoretical value. [2 pts]

4. You probably have noticed that the amplitude of one result is slightly different than the other.
(The difference is very small. You need to zoom in.) Why is there a difference? [2 pts]

5. When you have successfully implemented the half-sample delay in DSP hardware, please ask
the TA to check your oscilloscope outputs. If the outputs are correct, the TA will sign in the
space below. [2 pts]

6. Overlap the two outputs on your oscilloscope. Obtain a “zoomed” picture of the overlapped
signals. Plot the picture below. Use the cursors on the scope to measure the time difference
between the two signals. Would you measure the time difference at the peaks or at the zero-
crossings? What is the time difference? Does that correspond to what you expected? [2
pts]

6
7. Why did the signal on the oscilloscope attenuate as you increased the frequency? What happens
if you change the frequency to 25KHz? Why is this happening? Hint: the A/D and D/A
converters operate at 48KHz sampling rate. [2 pts]

2 Quantization

1. Implement a 3-bit quantizer using an appropriate mask. What should the mask be? How
many quantization levels are there? Explain what is the mask selecting. [2 pts]

2. Sketch original signal, the quantized signal, and the quantization error by using the Subtraction
function in Math mode on the oscilloscope. The quantization error is the difference between
the original signal and its quantized version. [2 pts]

7
3. Show your quantization error output on the oscilloscope to the TA, who will sign in the space
below. [2 pts]

4. Set the oscilloscope on Math - FFT mode. Change the mask to 8000. Run the program.
Draw an FFT of the quantized signal below. Explain what you see. How many bits does this
quantizer have? Where are the main harmonics located? [2 pts]

5. Compare qualitatively the quantization noise spectrum levels of a 1-bit quantizer, a 2-bit quan-
tizer and a 4-bit quantizer. Does the quantization noise level increase or decrease with more
bits? [1 pts]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy