ECM3165- Digital Signal Processing - TMA
Note: This assignment carries 10% of the module mark.
Completed work should be handed in using the ELE2 system by the deadlines stated there.
Information on downloading and installing Matlab on your own PC/Mac can be found at
https://www.exeter.ac.uk/departments/it/new/softwarecatalogue/#a8
Note: You must write your Matlab routines as m-files (script. files), rather than input lines individually via the Matlab command window. Using m-files enables you to alter, correct and modify routines more easily and efficiently than if you were to use command line entry.
You must follow the coding suggestions given here (DO NOT use code generated by AI)
You must include comment statements in your m-files too.
Include a copy your m-files as an appendix to your report.
In this TMA we investigate tone generation using marginally-stable IIR digital filters, and the use of such techniques for the generation of DTMF signals as used with touch-tone keypads.
2.1 Tone generation using marginally-stable digital filters (60 marks)
(a) The aim of a tone generator is to produce a sinewave type signal. A digital (discrete-time) sinewave, let’s call it s(n), can be described as
s(n) = sin(Ω0n) = sin(w0nTs)
where the symbols have their usual meaning.
If we assume that the signal s(n) is to be generated by a DTLTI system (i.e. it will be the output from the DTLTI system), then the impulse response of this system is simply equal to s(n), i.e.
ℎ(n) = sin(Ω0n)
Now that we know h(n) for the DTLTI tone generator, we can find its transfer function using the z-transform, since H(z) = ZT{h(n)}, where ZT{} represents the z-transform. operation.
We can show that H(z) for the above tone generator can be written as
Draw, in block diagram form, a DTLTI system to implement this transfer function H(z) and write down the numerical value for the system’s multiplier coefficients, assuming Ω0 = π/4. (15 marks)
(b) The next step is to implement the filter from part (a) using the filter function in Matlab, to then input into that filter an impulse signal, and, finally, to plot the resulting output of the filter (the output should of course be the tone signal!).
The filter function is described in Matlab as follows (found by typing ‘help filter’ in the command window)
filter - 1-D digital filter
This MATLAB function filters the input data x using a rational transfer
function defined by the numerator and denominator coefficients b and a.
y = filter(b,a,x)
The b and a coefficients should be those you found in part (a) above (but – remember Matlab needs an extra ‘zeroth-order’ a coefficient that is always set to 1).
To form. the impulse signal that we are going to use for the input to this filter, we need to generate a signal that has one sample value equal to 1, and all other samples values equal to zero. Let’s assume a sampling frequency of 10 kHz and use the value for the tone frequency from part (a) above, i.e. Ω0 = π/4 (or f0 = Ω0fS/(2π)).
We can now set up the impulse signal in Matlab using the following code:
fs=10000; omega_o = pi/4; fo=omega_o*fs/(2*pi); % set sampling and tone frequency
t=0:1/fs:1; % set suitable time range (here up to max of 1 second)
x=zeros(1,length(t)); % create an input signal of all zeros
x(1)=1; % set first value of input signal equal to 1, to generate an impulse
Once you have set up the input (impulse) signal to your filter as above, find and plot the filter output signal using Matlab’s filter function appropriately. Your output should be a sinusoidal tone with a frequency equal to f0 (or 1250 Hz). If it isn’t, you have done something wrong! (Note that you may have to adjust the time range over which you plot your signal to see the sinewave properly).
Next, confirm that your output signal is a 1250 Hz tone by finding (and plotting) its amplitude spectrum using Matlab’s fft routine. Make sure you normalise the amplitude spectrum properly
Finally, in this section, plot the pole-zero diagram for the tone generator system.
You should plot the pole-zero diagram using the fvtool command, as shown below:
fvtool(b, a, 'polezero'); %find and plot the poles and zeros of a DTLTI system defined by coeffs b and a
Comment on the position of the poles for this tone generator system, and the resulting stability, or otherwise, of this particular DTLTI system. (45 marks)
2.2 DTMF Tone generation (40 marks)
Tone generation similar to that used above finds practical application in dual-tone multifrequency signal (DTMF) generation used for touch-tone keypads on telephones, mobile phones etc.
The standard DTMF system is shown Figure 1 below.
When the number 5 is pressed, for example, a dual-frequency tone consisting of 770 Hz and 1336 Hz is generated (and used by the telephone switching system to identify which number to call/record).
In the second part of this TMA your task is to write a Matlab script. (m-file) that can, in response to a user input of a number from 1 to 9, generate the correct DTMF tones. Use the same sampling frequency as in 2.1 part (c) above (i.e. 10 kHz)
You must use the method of tone generation developed in part 2.1 above (i.e. use digital filters of the type in 2.1 but with appropriate coefficient values, to generate the tones).
Note that you can input a number and assign it to a variable in Matlab using something along the following lines:
number = input(‘input a keypad number 1 to 9‘); % prompts user to input a number 0 to 9
Figure 1: Tone generation in the DTMF keypad system
You should verify that your program is working by carrying out the following:
Selecting a keypad number to input to your generator program (a single number will suffice)
Generating the required DTMF tone and plotting its waveform. (i.e. time-domain plot of the DTMF tone generated)
Calculating and plotting the amplitude spectrum of the DTMF tone, and confirming that it contains the required frequencies
Reminder, you only have to demonstrate the above for a single pressed number, not all of them!
The part below, on listening to the tones you generate, is NOT ASSESSED – it is only there for you to look at if you so wish.
If you wish to listen to the tones you generate (they should sound the same as those generated by your mobile phone), you can convert a signal to an audio output in Matlab using the sound command, as described below (but note that generating sounds is just for fun – not an assessed part of this TMA)
sound(Y,FS) sends the signal in vector Y (with sample frequency
FS) out to the speaker on platforms that support sound. Values in
Y are assumed to be in the range -1.0 <= y <= 1.0. Values outside
that range are clipped.
sound(Y) plays the sound at the default sample rate of 8192 Hz.
Example:
load handel
sound(y,Fs)
You should hear a snippet of Handel's Hallelujah Chorus. (40 marks)
Your Report
You should write a formal report covering all of your findings from the above investigation.
Reports must be word-processed not handwritten (though you can include handwritten equations).
Be concise, though not at the expense of omitting important information/results.
Plots generated in Matlab should be exported to a suitable file format and pasted into you report where appropriate (screenshots/photos acceptable if of suitable quality).
Remember that all graphs should always have axes appropriately numbered and labelled - otherwise they are effectively meaningless!
All figures (i.e. graphs etc.) should also have a figure number, and all figures should be referred to somewhere in the text (a basic report writing 'norm').
The report should include all the results requested in the script, an appropriate level of discussion and an answer to any questions posed in the script.
You must include your Matlab m-files (script. files) as an appendix to your report.