##### Personal tools
•
You are here: Home Upsampling/Downsampling and Discrete-time Modulation

# Upsampling/Downsampling and Discrete-time Modulation

## Objective

The objective of this lab is to deepen students understanding of principles of discrete-time modulation, demodulation, upsampling and down sampling.

## Upsampling and Downsampling

1. In this part of the lab, you will experiment with up and down sampling by a factor of 3.
2. First, download the file h.mat and type load h at the Matlab prompt.  This will load a variable h into the Matlab workspace.
3. Startup Simulink and build up and down sampling models.
4. Recall that down sampling requires two processing blocks: (1) modulation with a periodic impulse train {..., 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, ...} and (2) removing the zero samples.
5. An easy way to modulate by the {..., 1, 0, 0, 1, 0, 0, ...} sequence is to define the sequence in the Matlab workspace and then bring it into the model using a Signal From Workspace block. Here's some code to consider.
6. M=3; % Factor for up and down sampling
N = length(h);
p = zeros(N,1); % Define a vector of all zeros
p(1:M:N)=1; % Set every third sample to one

7. The Signal Operations Block Library in the DSP Blockset Library contains a Downsample block which removes zero samples.  It looks like this

8. Upsampling consists of two operations:  (1) inserting zeros and (2) low-pass filtering to remove images.
9. This Signal Operations Block Library in the DSP Blockset Library contains an Upsample block which inserts zeros.  It looks like this

10. You already know about designing low-pass filters using the Matlab remez function.
11. The following is an example Simulink model.  The upper branch does down sampling and the lower branch does up sampling.
12. Note:  In up and down sampling, be very careful to set the sample rates in each block.  When available, set the "Sample Time" in the filter blocks to -1.  Then the filters will "inherit" their sample times from the previous block.  Otherwise, you must set the sample times explicitly.

13. In this model, a few Signal To Workspace blocks have been added to capture various signals.
14. In the Simulation Parameters Dialog, set the Start time to 0 and the Stop time to N-1 where N is the length of the input signal h .  Also, in the Solver options category, set the Type to Fixed-step.
15. Run the simulation.
16. Compare the spectra and time-domain sequences of the three signals:  h, hpd, hdown.  Write an explanation of what you see.  Do the two processing blocks used for the down sampling function as expected?  Turn plots like the ones shown below with your write up.
17. Below are the spectra and time-domain sequences (first few samples only) computed using the Simulink model above.

18. Compare the spectra and time-domain sequences of the three signals:  h, hpu, hup.  Write an explanation of what you see.  Do the two processing blocks used for up sampling function as expected?  Turn plots like the ones shown below with your write up.
19. Explain how you designed the low-pass filter for upsampling.  What were the edges of the transition band?  What was the gain of the filter?
20. Below are the spectra and time-domain sequences (first few samples only) computed using the Simulink model above.

21. As shown above, the upsampled time-domain sequence passes through the samples of the original signals.  This is achieved using a gain of 3 in the low pass filter.  You can see the gain of three in the frequency domain.  Note that the low-pass filter will cause a delay in the upsampled signal reltive to the original signal.  In the figure above, the delay has been removed.

Discrete-time Modulation and Demodulation
1. Download the file y.wav .  Any multimedia equiped computer with standard software packages should be able to play this audio file.  Try it.  Do you recognize what the woman is reading?
2. You can read the wav data into Matlab by typing:

This loads three variables into you Matlab workspace:   y is the audio data, fs is the sample rate (11025 in this case), and nbits is the number of bits used to represent each sample in y .

4. The spectrum of y is as shown below.

5. As you can see, y contains significant frequency content all the way out to 0.5 (discrete-time frequency) which corresponds to 11025/2 Hz (continuous-time frequency) half the sample rate.
6. Build a Simulink model to amplitude modulate y on a co-sinusoidal carrier using a carrier frequency of 0.2 (discrete-time frequency) and then perform synchronous demodulation and downsampling to restore the spectrum to its original shape.
7. In order to avoid aliasing, y must be upsampled before modulating it.
8. Recall that in discrete-time, the constraint on the carrier frequency is

9. where these frequencies are discrete-time f requencies in units of rads.  If you would rather use units that are consistent with the way that we generate our plots, then divide the inequality above by a factor of (2 pi) leading to the following constraint on the carrier frequency.

10. Use an upsampling factor of 3.
11. What is the highest frequency (between -0.5 and 0.5) after upsampling by 3?
12. What is the highest frequency (between -0.5 and 0.5) in the modulated signal?
13. Will upsampling by 3 avoid aliasing in the modulated signal?
14. The two steps in synchronous demodulation are: (1) modulation (multiply) by the carrier and (2) low-pass filtering to remove the double frequency components.  What is the highest frequency after the modulation step but before low-pass filtering?  Does aliasing occur?
15. What are the transition bands edges and the gain of the low-pass filter that you used for demodulation?
16. Does the demodulated and downsampled signal sound the same as the original signal?  By the way, if you want to write a signal yr out to a wav file in order to listen to it, type the following at the Matlab prompt.
17. wavwrite(yr,fs,nbits,'yr.wav');

18. Turn in your answers to the questions above and figures like the ones below showing your model and the spectra.  An example of what the spectra look like at various points appears at the bottom of this page.
19. A Simulink Model of the complete system may look like this.

20. The spectra of several of the intermediate signals looks like this.

Copyright 2008, by the Contributing Authors. Cite/attribute Resource . admin. (2006, June 28). Upsampling/Downsampling and Discrete-time Modulation. Retrieved January 07, 2011, from Free Online Course Materials — USU OpenCourseWare Web site: http://ocw.usu.edu/Electrical_and_Computer_Engineering/Communication_Systems_I_1/lab4.html. This work is licensed under a Creative Commons License