Signals Labs

12
  1 DEPARTMENT OF COMPUTER SYSTEMS ENGINEERING CSE-309: Communication Systems Session: Fall 2010 Signals Laboratory Assignments Dr. Haseeb Zafar [email protected]  

Transcript of Signals Labs

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 1/12

 

1

DEPARTMENT OFCOMPUTER SYSTEMS

ENGINEERING 

CSE-309: Communication Systems

Session: Fall 2010

Signals Laboratory Assignments

Dr. Haseeb Zafar [email protected] 

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 2/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 2 of 12 

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 andsquare-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 adetailed logbook of your work. This should include important Matlab commands used,sketches of signals in the time and frequency domains, observations of results and anyinterpretation or conclusion(s) that occur to you. Printing out your results and code listingsare 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 descriptionof the work you have completed, the results you have obtained and the conclusions youhave drawn. Your logbook may be examined as part of the assessment process.

Experimental Set-Up

 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 SignalAssignment 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)

Matlab andData Acquisition Toolbox

Agilent 33220AFunction Generator

Agilent DSO3102ADigital Storage Oscilloscope

 

Computer

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 3/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 3 of 12 

Assignment 1: Sampling a Music Signal

Objective:

In this assignment you will investigate the effects of reducing the sampling frequency for amusic 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 thelocal 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 Handel’s MessiahFs=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 onthe 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 commandthen search for it using the ‘help’ facility in Matlab.)

(c) Plot the time-domain waveform labelling both axes (including units) and giving theplot an informative title. (Labelling of axes and incorporating an informative plottitle is mandatory for all plots made during all these assignments.) 

(d) Plot the amplitude spectrum on both linear and decibel (dB) scales using Matlab’s‘fft’ function. (In the latter case normalise the peak value of the spectrum to 0 dB.)Note the signal’s 10 dB and 30 dB bandwidths.

If you are having difficulty calculating the spectrum, use the following code:

%Calulate power spectrumx=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)

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 4/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 4 of 12 

len=length(y);new_len=round(len/fact);for i=1:new_len

x(i)=y(fact*(i-1)+1);endsub=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-domaininterpretation of what is happening. 

  In your opinion what minimum sampling frequency results in (a) an intelligiblereproduction of the music and (b) an acceptable reproduction of music?

  What sampling frequency is used for commercial CD recordings?

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 5/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 5 of 12 

Assignment 2: Sampling a Speech Signal

Objective:

In this assignment you will investigate the effects of reducing the sampling frequency for aspeech 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 >>loadspeech_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 tomake a recording of your voice – a short phrase such as “I think signal theory is a veryinteresting topic” should be used.

(a) Playback the file and listen to the recorded speech. Note the sampling frequencyand 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 aspossible) 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 speechsample 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 the10 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 justdegraded 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 speechsignal?

(f) What sampling frequency is used in digital mobile telephone applications?

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 6/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 6 of 12 

Assignment 3: Sampling a Sinusoidal Signal

Objective:

In this assignment you will investigate the effects of reducing the sampling frequency for asinusoidal signal.

Methodology:

This assignment should help to explain the results you obtained in the previous twoassignments.

(a) Use the function generator to generate and display a 1-kHz sinewave (i.e. a singletone).

[Turn on the waveform generator. It will probably set itself to 1.000 000 0 kHz. If itdoesn’t press the Freq/Period button until Freq is highlighted. Then press 1 on thenumerical input keypad followed by the kHz button.

Turn on the digital storage oscilloscope (DSO). Connect the Output of the functiongenerator 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 maybe turned off. Look for the words Output Off being displayed in the top right-handcorner 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 Auto-scale button on the DSO again. You should now see the 1 kHz waveform on theDSO 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 isdisplayed. (You may need to press it up to three times.) You will notice that the soft-key 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 upother options including Scale. The Scale soft-key toggles between VRMS anddBVRMS. The former displays RMS voltage against frequency and the latter displays20 log10(VRMS) against frequency. VRMS is recommended. Note that vertical andhorizontal scales for both time domain and frequency domain plots are given on thedisplay. 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 frequencydomain moves to the right. Continue until the spectral line is approximately in themiddle of the displayed frequency axis. What sampling frequency is now beingused?

(d) Now slowly increase the frequency of the sinewave (selecting Freq on the functiongenerator and the second decimal place of the displayed frequency with the

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 7/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 7 of 12 

right/left cursor keys) using the variable knob. Record what effect this has in thefrequency-domain. Continue until the tone appears at the extreme right of thefrequency domain display. What is the new frequency of the sinewave?

(e) Continue increasing the frequency of the sinewave watching the displayedwaveform in both time domain and frequency domains. (Don’t alter the DSO time-base even though the spectral line has disappeared off the high frequency end –but keep watching!) Keep increasing the signal frequency until the time-domainwaveform looks simple again (i.e. like a recognisable sinewave).

  Make a note of the apparent frequency of the signal as displayed in thefrequency domain. [To make an automatic frequency measurement press the(oval) Measure button, followed by the Time soft-key, followed by the Freq soft-key.]

  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 functiongenerator.

  Make a note of the sampling frequency as displayed in the bottom right-handcorner 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 samplingprocess, as witnessed above, the bandwidth of the analogue signal must be limitedbefore sampling in order to prevent aliasing. This is accomplished by using a low-pass (or anti-aliasing) filter. Discuss with illustrations how this helps.

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 8/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 8 of 12 

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 Handel’s MessiahFs=8000; % Sampling frequency (Hz)set(ao, ‘SampleRate’, Fs);nbits=16; % Number of bitsq=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, ensurethe sampling frequency is sufficiently high so that any distortion effects will be due solely toquantisation.

Now:

(a) Note the number of bits used in quantisation and comment on the acceptabilityof 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) acceptablereproduction 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= )/(log20 10 n sσ  σ   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-fitstraight line relationship between SNR and the number of bits.

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 9/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 9 of 12 

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 thiscase, 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 speechquality acceptable?

(b) Note the number of bits used in the quantisation and, using Matlab, plot the time-domain 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 andfind the best straight-line fit. Does this relationship differ from the plot obtained for the music signal?

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 10/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 10 of 12 

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 samplingfrequency 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 quantisedsinewave 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 bitsper sample. Does this relationship differ from the plots obtained for the music signaland speech signal?

(e) Compare the SQNR characteristic obtained for a sinewave with that theoreticallyexpected.

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 andmention some of its advantages and disadvantages. To find which ADC type youhave been allocated count the number of letters in your family name, divide thisnumber by four and note the remainder. The Roman numeral in the list (I, ii, iii, iv) isthe remainder plus one.

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 11/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 11 of 12 

Assignment 7: Fourier Series

Objective:

In this assignment you will analyse periodic signals in the frequency domain to obtain thecorresponding 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-domainwaveform then press the Math button etc to display its spectrum. Sketch the timewaveform and spectrum using both VRMS and dBVRMS amplitude scales.

(b) Slow down the time-base of the DSO so that the fundamental component appearsapproximately in the centre of the frequency axis. What sampling frequency is beingused?

(c) Now increase the (fundamental) frequency of the square-wave to 5 kHz (in smallsteps 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 square-wave frequency. Explain your observations.

(d) From basic Fourier series theory, analyse square waves with the abovecharacteristics, and compare the theoretical results with those you obtained byexperiment. Comment on any discrepancies between theory and experiment.

5/12/2018 Signals Labs - slidepdf.com

http://slidepdf.com/reader/full/signals-labs 12/12

 

CSE-309: Communication Systems

Signals Laboratory Assignments Page 12 of 12 

Report 

You are required to submit a report of these laboratory assignments. Your logbookrecord of your experimental work should therefore contain sufficient detail to serve asthe basis for this report. When you save graphical or other output to your personalaccount space on the server you should record in your logbook what the output is andprecisely 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 samplingfrequency used in commercial CD technology) can be answered outside the laboratoryperiods and factual material of this nature, not directly related to your experimentalwork, 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 toinclude every graph that you plot in the course of the lab or every line of Matlab codethat 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. (Theassignment 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 beannounced in the class.