Vous êtes sur la page 1sur 2

Lab 3: DTMF modulator/demodulator, non-real time, in C

During this lab you will implement a DTMF modulator and demodulator. In a first
stage, your programs will compile and run on a desktop PC.
1. Implement a sinusoidal tone generator. To generate a continuous-time sinusoid
of amplitude A and frequency f0 (Hz), we need to generate a discrete-time sinus
oid,
y[n] = A sin( (2*pi*f0/fs) n ),
where fs is the sampling frequency in Hz (8000 in our case).
This sinusoid can be generated using the sin() function in the C math library, b
ut this would run slow because the sin() function is implemented using a Taylor
approximation, requiring a lot of computations.
Instead, we will compute the sinusoid samples using a digital oscillator, which
is an IIR digital filter with no input (x[n]=0) and with an output described by
the difference equation
y[n] = a1*y[n-1] - y[n-2]
where
a1 = 2*cos(2*pi*f0/fs),
y[0] = 0, and
y[-1] = -A*sin(2*pi*f0/fs)
Implement the sinusoidal generator with an amplitude of 10,000, and a frequency
of 1000 Hz. Write the output samples to a file, load that file in Matlab and lis
ten to your output to verify that you have a sinusoidal tone.
Use "float" for the current and previous output samples, and convert to 16-bit s
igned integer just before sending the sample to the output.
2. Read the attached handout on DTMF modulation. Implement a DTMF modulator by g
enerating two sinusoids of amplitude 5000 and adding them together. You will hav
e to store previous values (y[n-1], y[n-2]) separately for the two sinusoids. Ch
oose any key you wish. Listen to the output.
3. Modify the code to generate a sequence of DTMF tones as follows:
- 0.5 seconds for '8'
- 0.1 seconds pause
- 0.5 seconds for '6'
- 0.1 seconds pause
- ... and so on for the rest of the number 867-5309.
Verify by playing the output in Matlab.
4. Implement a DTMF demodulator. Your demodulator will perform the following loo
p:
repeat
read 0.1 seconds worth of samples
decode the audio into a phone key
print the key
until (no more inputs available)
Decoding the tones is conceptually easy if we are willing to implement a spectru
m analyzer. However, this would be computationally intensive. Instead, we will u
se a batch of Goertzel filters.
Read the following introductory material about Goertzel filters. http://eetimes.
com/design/embedded/4024443/The-Goertzel-Algorithm
http://en.wikipedia.org/wiki/Goertzel_algorithm

(The Wikipedia article even has code!)


5. Use your modulator to create a file containing the audio signal, then run you
r demodulator program to decode it. Hint: to debug your programs, you may want t
o consider looking at the spectrum of the audio signal in Matlab. Plot the abs(f
ft()) of the various segments of the audio and verify that the peaks are at the
correct locations.
Lab report due date: March 7th in the lab. Turn in a cover sheet and the code yo
u wrote for parts 3 and 4. One report per team of 3 students. You will have to d
emo step 5 of this lab, so please do come to the March 7th lab.

Vous aimerez peut-être aussi