ECE 4760: Laboratory 2
DTMF generator with speech feedback.
You will construct a standard Dual Tone Multi-Frequency (DTMF) generator like those used on any tonch-tone or cell phone. As you press the buttons, the system will speak the digits. The system will record up to 12 digits, then play them back to simulate redial. To do this you will have to use Direct Digital Synthesis sampling at a fairly high rate to a DAC, then to speakers.
You will use a keypad to make a DTMF dialer with audio output to a speaker. Analog output will be through a SPI controlled DAC.
The analog signal will
be DTMF sine wave bursts generated using Direct Digital Synthesis
(DDS) technique one one channel of the DAC and speech on the other channel. An example on the DSP page (example 1 or 2) shows how you might implement
a DDS, with the SPI DAC. Your DDS unit must resolve 256 table entries. For this lab, you will need to modulate the amplitude, and you will need to run two simultaneous DDS units and sum them. The sine wave table will need to be scaled to prevent overflow.
There are two ways of doing the speech feedback. Choose one:
- Compress 8:1 using spectral sampling. The speech signal is sampled at 8 KHz and will require several DDS units.
Use the scheme described on the DSP page, but use between 10 and 20 sinewaves to reconstruct, log-distributed between 340 and 3400 Hz.
The resulting voice is somewhat robotic and sing-song.
- Compress 2:1 by dropping bits. The 16 kHz sampled speech signal is truncated to 4 bits and packed into byte format.
The C program you write will play the samples back through the external DAC, not through the Vref DAC.
You will need to parse the speech signal into individual digits, probably by reading it in Matlab, plotting it, and noting the position of the silences.
See the Vref DAC page.
- The SPI DAC you will use is the MCP4822. The connection and setup is described on the SPI page
and a code example here
- You will need to get user input from a keypad as explained on the TFT/keypad page.
- Possible pin assignments for keypad, DAC and keypad
- TFT uses
pins 4,5,6, 22 and 25 (RB0, RB1, RB2, MOSI1, SCLK1)
SCK1: connected to RB14 on the PIC
MOSI (SDO1): PPS output group 2 connected to RB11 on the PIC
CS: connected to RB1 on the PIC
SDCS: left unconnected as I'm not using the microSD card for this
RST: connected to RB2 on the PIC
D/C: connected to RB0 on the PIC
VIN: connected to 3.3V supply
GND: connected to gnd
- DAC SPI channel 2 uses
SDO2 (MOSI) is in PPS output group 2, could be connected to RB5 which is
pin 14, but remember to set
#pragma config JTAGEN = OFF, DEBUG = OFF
CS (chip select) connected to RB4,
pin 11, but remember to set
#pragma config JTAGEN = OFF, DEBUG = OFF
- Keypad -- need 7 i/o lines (see schematic above)
A0 to A3 and B7 to B9
In this lab and every lab, make sure you are running Protothreads 1_2_1.
I suggest organizing the code as:
- Protothreads maintains the ISR-driven millisceond-scale timing.
- Timer ISR running at the DDS sample rate to update the DDS and the DAC.
- Main sets up peripherials and protothreads then just schedules tasks, round-robin.
- Keypad Thread
- scans the keypad
- runs the debounce state machine (state machine pseudocode for ONE buttton)
- places valid keypresses into a digit buffer and triggers speech production
- handles erase/start commands
- waits for 30 mSec.
- sets the DDS parameters for two sine waves (if any) which are playing.
- Starts/stops the play back
- Write a Protothreads C program which implements a DTMF generator with the following
- The keypad will be used to enter up to 12 digit telephone numbers. As each digit is pressed, the digit will be spoken.
You must debounce the keypad.
- Pressing the
* button erases the entire stored phone number.
- When the
# button is pressed, the DTMF signal for each entered digit is produced for at least 65 millseconds to simulate dialing of the digits.
There should be at least 65 millseconds of silence between each digit.
- Each tone burst should ramp up to full amplitude over a time of about 5 milliseconds and ramp down again in about the same amount of time. Ramping the amplitude will decrease the broad band Fourier components which tend to add an annoying click to the sounds. The ramp need not be linear, but could be.
Example matlab code.
- Frequency accuracy should be +/-1.5% (as per DTMF spec) Generate sinewaves using DDS. The sinewaves should be built from
8-bit samples (taken from a 256 entry table).
- Implement a test mode in which each of 7 DTMF frequencies can be individually measured for frequency accuracy.
Holding down the
* button (or another button you place on the white board, or any other scheme you want to use),
while pressing the buttons 1 through 7 should produce one of seven sine waves for as long as you hold the buttons.
You will need to display the FFT of the 7 frequencies to show that all spurous frequencies are lower than -20 db from main tones.
A table of DTMF frequencies:
- Connect the circuit to a speaker audio input (green phone plug) and listen
the output. This will aid in debugging and is required for the demo.
- Demo this program to a staff member. Show that all specifications are met
by verifying frequencies with an oscilloscope.
- At no time during the demo should you need to press RESET.
- Your written lab report should include the sections mentioned in the policy page, and :
- How you generated the freqencies (DDS resolution, etc) and an measurement
of how accurate they are.
- Oscilloscope capture of typical waveforms.
- Oscilloscope capture of FFT to show that harmonic distortion meets the DTMF spec
- How you generated the various time intervals required by this project.
- A diagram of the state machine you used to debounce. One of the TAs (Shiva) recommends drawing FSM with fizzim.
- Other design aspects of the assignment, such as the conversion from
user input frequency in Hz to DDS increment.
- A heavily commented listing of your code.
Copyright Cornell University
October 6, 2016