Sie sind auf Seite 1von 12

1

DEPARTMENT OF COMPUTER SYSTEMS ENGINEERING

CSE-309: Communication Systems Session: Fall 2010 Signals Laboratory Assignments

Dr. Haseeb Zafar haseeb@nwfpuet.edu.pk

CSE-309: Communication Systems

Aims and Objectives


These laboratory assignments have been designed to allow you to investigate a variety of signals in the time and frequency domains, including speech, music, sine-waves and square-waves, and to illustrate the important concepts of sampling and quantisation.

Methodology, Logbooks and Assessment


Throughout the various procedures carried out in these assignments you must keep a detailed logbook of your work. This should include important Matlab commands used, sketches of signals in the time and frequency domains, observations of results and any interpretation or conclusion(s) that occur to you. Printing out your results and code listings are not, in themselves, sufficient. You should also store relevant information (e.g. *.m files) on some appropriate medium (e.g. memory pen etc) which you can then use during your next session. The assessment will be principally based on a report containing a description of the work you have completed, the results you have obtained and the conclusions you have drawn. Your logbook may be examined as part of the assessment process.

Experimental Set-Up

Agilent 33220A Function Generator

Agilent DSO3102A Digital Storage Oscilloscope

Matlab and Data Acquisition Toolbox

Computer

Note that you can obtain help for any function in Matlab with the help facility (try help help).

Laboratory Assignments
Assignment 1: Sampling a Music Signal Assignment 2: Sampling a Speech Signal Assignment 3: Sampling a Sinusoidal Signal (Optional) Assignment 4: Quantising a Music Signal Assignment 5: Quantising a Speech Signal Assignment 6: Quantising a Sinusoidal Signal Assignment 7: Fourier Series (Optional)

Signals Laboratory Assignments

Page 2 of 12

CSE-309: Communication Systems

Assignment 1: Sampling a Music Signal


Objective:
In this assignment you will investigate the effects of reducing the sampling frequency for a music file. In this, and the exercises that follow, it is recommended that you save your work (e.g. MATLAB files) to the memory pen. Please do not save your personal work to the local hard disc of the computer.

Methodology:
Invoke Matlab, create a new *.m file, and enter the following commands:
ao=analogoutput(winsound,0); addchannel(ao,[1 2]); load handel; % Music for Handels Messiah Fs=8000; % Sampling frequency (Hz) set(ao, SampleRate, Fs); data=[y y]; putdata(ao,data); start(ao);

Now: (a) Run this file and listen to the music. Note the sampling frequency and comment on the acceptability of the music quality. (b) Sound(y, Fs) is a simple Matlab command which will replace the above code. Try rerunning the file using this command. (If you need help using the command then search for it using the help facility in Matlab.) (c) Plot the time-domain waveform labelling both axes (including units) and giving the plot an informative title. (Labelling of axes and incorporating an informative plot title is mandatory for all plots made during all these assignments.) (d) Plot the amplitude spectrum on both linear and decibel (dB) scales using Matlabs fft function. (In the latter case normalise the peak value of the spectrum to 0 dB.) Note the signals 10 dB and 30 dB bandwidths. If you are having difficulty calculating the spectrum, use the following code:
%Calulate power spectrum x=fft(data); y=fftshift(x); power=(abs(y)).^2; %Establish frequency vector (for frequency axis) N=length(data); n=0:N-1; m=n-N/2; Ts=1/Fs; freq_resolution=1/(N*Ts); f=m*freq_resolution;

(e) The following function can be used investigate the effects of reducing the sampling frequency. Type in this code and save as an appropriate m-file (i.e. subsamp.m). Explain how it works. You should also annotate it with comments (using the % character):
function sub=subsamp(y,fact)

Signals Laboratory Assignments

Page 3 of 12

CSE-309: Communication Systems len=length(y); new_len=round(len/fact); for i=1:new_len x(i)=y(fact*(i-1)+1); end sub=x;

(f) The above function can now be used in the Matlab Command Window to reduce the sampling rate by a factor of 2 as follows:
>> >> >> >> >> load handel fact=2 x=subsamp(y,fact); sound(y,8000) sound(x,8000/fact)

Relate the new sampling frequency to the bandwidth of the music signal. (g) Repeat the above for decreasing sampling frequencies until the music becomes completely unintelligible. Give both a time-domain and frequency-domain interpretation of what is happening. In your opinion what minimum sampling frequency results in (a) an intelligible reproduction of the music and (b) an acceptable reproduction of music? What sampling frequency is used for commercial CD recordings?

Signals Laboratory Assignments

Page 4 of 12

CSE-309: Communication Systems

Assignment 2: Sampling a Speech Signal


Objective:
In this assignment you will investigate the effects of reducing the sampling frequency for a speech signal.

Methodology:
The Matlab command >>daqrecord(x) records x seconds of audio starting from the instant that <Enter> is executed. Type >>daqrecord(5)in the Matlab control window. After striking the key speak in to the microphone (which may be incorporated in the laptop). After the recording period is over the time series samples will appear in the control window. The samples are the elements of the vector ans. Create a new name (e.g. y) for the vector by typing, for example, >>y=ans. Save the samples to a file (called, for example, speech_samples) by typing >>save speech_samples y. This variable can then by recovered by typing >>load speech_samples. (Use the Matlab command >>daqschool to launch the data acquisition toolkit tutorial if you think it would be helpful to learn more about Matlab data acquisition.) Obtain a speech sample for analysis using Matlab and the Data Acquisition Toolkit to make a recording of your voice a short phrase such as I think signal theory is a very interesting topic should be used. (a) Playback the file and listen to the recorded speech. Note the sampling frequency and comment on the speech quality. [If the sound on playback is insufficiently loud (with both hardware and software laptop volume controls turned up as high as possible) then increase the magnitude of the speech samples using, for example: y=y*10; or some other appropriate factor in place of 10. Alternatively re-record your speech sample closer to the microphone and/or speaking more loudly. (b) Using Matlab, plot the time-domain waveform. (c) Using Matlab, plot the amplitude spectrum on both a linear and a dB scale. Note the 10 dB and 30 dB signal bandwidths. (d) Repeat the playback but with reduced values of the sampling frequency (in a similar manner to Assignment 1) until, in your opinion, the quality of speech has just degraded to below what you would consider (a) acceptable, and (b) intelligible. (e) How do these sampling frequencies relate to the 30 dB bandwidth of the speech signal? (f) What sampling frequency is used in digital mobile telephone applications?

Signals Laboratory Assignments

Page 5 of 12

CSE-309: Communication Systems

Assignment 3: Sampling a Sinusoidal Signal


Objective:
In this assignment you will investigate the effects of reducing the sampling frequency for a sinusoidal signal.

Methodology:
This assignment should help to explain the results you obtained in the previous two assignments. (a) Use the function generator to generate and display a 1-kHz sinewave (i.e. a single tone). [Turn on the waveform generator. It will probably set itself to 1.000 000 0 kHz. If it doesnt press the Freq/Period button until Freq is highlighted. Then press 1 on the numerical input keypad followed by the kHz button. Turn on the digital storage oscilloscope (DSO). Connect the Output of the function generator to Channel 1 of the Oscilloscope. Press the (white) Auto-scale button. If no signal is displayed on the DSO screen the output of the function generator may be turned off. Look for the words Output Off being displayed in the top right-hand corner of the function generator screen. If these words are present press the (oval) Output button on the function generator and then, if necessary, press the Autoscale button on the DSO again. You should now see the 1 kHz waveform on the DSO screen.] Sketch the sinusoidal signal. (b) Use the FFT facility to display the signal spectrum. [Press the Math button on the DSO. Press the top soft-key on the DSO until FFT is displayed. (You may need to press it up to three times.) You will notice that the softkey menu disappears after a few seconds. To bring it back press the (round) MENU ON/OFF button above the soft-key buttons. The bottom soft-key button brings up other options including Scale. The Scale soft-key toggles between VRMS and dBVRMS. The former displays RMS voltage against frequency and the latter displays 20 log10(VRMS) against frequency. VRMS is recommended. Note that vertical and horizontal scales for both time domain and frequency domain plots are given on the display. The third soft-button down toggles between different windowing function. Experiment with these to see the effect of different windows. The Hanning (i.e. raised cosine) window is recommended. The 4th key down is labelled display. Pressing this toggles between Full Screen and Split (Screen). Use of Split (Screen) is recommended.] Sketch the spectrum and note the sampling frequency (Sa/s = samples/s) which is displayed in the bottom right-hand corner of the DSO display. (c) Slow down the time-base (using top, left-hand knob) so that more cycles of the signal are displayed in the time domain and the spectral line in the frequency domain moves to the right. Continue until the spectral line is approximately in the middle of the displayed frequency axis. What sampling frequency is now being used? (d) Now slowly increase the frequency of the sinewave (selecting Freq on the function generator and the second decimal place of the displayed frequency with the

Signals Laboratory Assignments

Page 6 of 12

CSE-309: Communication Systems

right/left cursor keys) using the variable knob. Record what effect this has in the frequency-domain. Continue until the tone appears at the extreme right of the frequency domain display. What is the new frequency of the sinewave? (e) Continue increasing the frequency of the sinewave watching the displayed waveform in both time domain and frequency domains. (Dont alter the DSO timebase even though the spectral line has disappeared off the high frequency end but keep watching!) Keep increasing the signal frequency until the time-domain waveform looks simple again (i.e. like a recognisable sinewave). Make a note of the apparent frequency of the signal as displayed in the frequency domain. [To make an automatic frequency measurement press the (oval) Measure button, followed by the Time soft-key, followed by the Freq softkey.] Make a note of the apparent frequency of the sinewave as displayed in the time. [To make an automatic period measurement press the (oval) Measure button, followed by the Time soft-key, followed by the Period soft-key.] Make a note of the frequency of the signal as displayed by the function generator. Make a note of the sampling frequency as displayed in the bottom right-hand corner of the DSO display. From your knowledge of sampling theory reconcile the above observations. (f) To prevent distortion (or, in particular, aliasing) of a signal during the sampling process, as witnessed above, the bandwidth of the analogue signal must be limited before sampling in order to prevent aliasing. This is accomplished by using a lowpass (or anti-aliasing) filter. Discuss with illustrations how this helps.

Signals Laboratory Assignments

Page 7 of 12

CSE-309: Communication Systems

Assignment 4: Quantising Music Signal Samples


Objective:
In this assignment you will investigate the effects of reducing the number of bits per sample for a music file.

Methodology:
Invoke Matlab, create a new *.m file, and enter the following commands: ao=analogoutput(winsound,0); addchannel(ao,[1 2]); load handel; % Music for Handels Messiah Fs=8000; % Sampling frequency (Hz) set(ao, SampleRate, Fs); nbits=16; % Number of bits q=2^(-nbits+1); y=quant(y,q); data=[y y]; putdata(ao,data); start(ao); The above assumes the data has been scaled to the range [-1, 1]. In the following, ensure the sampling frequency is sufficiently high so that any distortion effects will be due solely to quantisation. Now: (a) Note the number of bits used in quantisation and comment on the acceptability of the music quality. (b) Using Matlab, plot the music sample waveform. (c) Repeat both (a) and (b) for reduced quantisation levels of 12, 10, 8, 6, 4, 2 and 1 bits. Note the minimum number of bits required in your opinion for (i) acceptable reproduction and (ii) intelligible reproduction. (d) What quantisation level is used for commercial CD recordings? (e) Using a Matlab.m-file, construct a plot of SNR vs. number of bits, where SNR= 20 log10 ( s / n ) dB and s and n are the standard deviations of the signal and noise, respectively. Note there is a std command within Matlab. Document the Matlab code that you use to obtain this plot. Find the best-fit straight line relationship between SNR and the number of bits.

Signals Laboratory Assignments

Page 8 of 12

CSE-309: Communication Systems

Assignment 5: Quantising Speech Signal Samples


Objective:
In this assignment you will investigate the effects, for speech, of reducing the number of bits per sample.

Methodology:
Following the same procedure as used in Assignment 2, obtain a speech sample. In this case, ensure that the sampling frequency is high enough not to introduce any distortion. Now: (a) Playback the file using Matlab and listen to the recorded speech. Is the speech quality acceptable? (b) Note the number of bits used in the quantisation and, using Matlab, plot the timedomain waveform. (c) Repeat (a) and (b) for reduced quantisation levels of 12, 10, 8, 6, 4, 2 and 1 bits. Note the minimum number of bits required in your opinion for (i) acceptable reproduction and (ii) intelligible reproduction. (d) How many quantisation bits are used in digital mobile telephones? (e) Obtain a plot of SQNR vs. number of quantisation bits for the speech sample and find the best straight-line fit. Does this relationship differ from the plot obtained for the music signal?

Signals Laboratory Assignments

Page 9 of 12

CSE-309: Communication Systems

Assignment 6: Quantising Sinusoidal Signal Samples


Objective:
In this assignment you will investigate the effects of reducing the number of bits per sample for a sinusoidal signal.

Methodology:
Using Matlab generate a 1-kHz sinewave with a duration of 5 seconds. Use a sampling frequency of 32 kHz. Now: (a) Playback the file using Matlab, noting the number of bits used in the quantisation. Comment on the quality of the resulting single tone. (b) Playback the file for reduced quantisation levels of 12, 10, 8, 6, 4, 2 and 1 bits. Explain the change of tone quality with increasingly harsh quantisation. (c) Plot three cycles comparing the original (unquantised) sinewave with the quantised sinewave and the quantisation noise for reduced quantisation levels of 12, 10, 8, 4, 2 and 1 bits. Why is unquantised in inverted commas in the last sentence? (d) Obtain a plot of signal-to-quantisation-ratio (SQNR) vs. number of bits per sample for the sinusoid and find the best straight-line fit between SNR and number of bits per sample. Does this relationship differ from the plots obtained for the music signal and speech signal? (e) Compare the SQNR characteristic obtained for a sinewave with that theoretically expected. Exercise (for completion outside the laboratory sessions and inclusion in your report) (f) You are required to describe the operation of one analogue-to-digital convertor (ADC) allocated to you from the following list: (i) parallel comparator or flash convertor, (ii) successive approximation convertor, (iii) dual slope convertor, (iv) sigma-delta convertor. You should describe the basic operation of the convertor and mention some of its advantages and disadvantages. To find which ADC type you have been allocated count the number of letters in your family name, divide this number by four and note the remainder. The Roman numeral in the list (I, ii, iii, iv) is the remainder plus one.

Signals Laboratory Assignments

Page 10 of 12

CSE-309: Communication Systems

Assignment 7: Fourier Series


Objective:
In this assignment you will analyse periodic signals in the frequency domain to obtain the corresponding Fourier series.

Methodology:
(a) Use the function generator to generate a 1 kHz (zero mean or DC) square-wave with an amplitude of 1 V. Press the Auto-scale button to display the time-domain waveform then press the Math button etc to display its spectrum. Sketch the time waveform and spectrum using both VRMS and dBVRMS amplitude scales. (b) Slow down the time-base of the DSO so that the fundamental component appears approximately in the centre of the frequency axis. What sampling frequency is being used? (c) Now increase the (fundamental) frequency of the square-wave to 5 kHz (in small steps of, say, 0.1 kHz). Describe, using example sketches if you wish, what happens to the spectrum as the frequency is increased. Take particular note of what happens when the sampling frequency is an integer multiple of the squarewave frequency. Explain your observations. (d) From basic Fourier series theory, analyse square waves with the above characteristics, and compare the theoretical results with those you obtained by experiment. Comment on any discrepancies between theory and experiment.

Signals Laboratory Assignments

Page 11 of 12

CSE-309: Communication Systems

Report
You are required to submit a report of these laboratory assignments. Your logbook record of your experimental work should therefore contain sufficient detail to serve as the basis for this report. When you save graphical or other output to your personal account space on the server you should record in your logbook what the output is and precisely where it is saved so you can recover it for pasting into your report. Many of the questions you are asked to answer in the exercises (e.g. the sampling frequency used in commercial CD technology) can be answered outside the laboratory periods and factual material of this nature, not directly related to your experimental work, does not need to be recorded in your logbook. Your report should not exceed 7 pages in a font size of 12-point. You must exercise judgement as to what goes into the report and what is left out. You do not need to include every graph that you plot in the course of the lab or every line of Matlab code that you have used. Include those graphs you believe illustrate some significant point. You may include the assignment instructions (this document) as an appendix of your report and refer to it rather than reproduce sections of it in your report. (The assignment instructions are, of course, not counted in the page limit.) Plots should be large enough such that their axis labels etc are legible but need be no larger than this. All figure should be numbered and have captions. The date of report submission will be announced in the class.

Signals Laboratory Assignments

Page 12 of 12

Das könnte Ihnen auch gefallen