ECE 4760: Laboratory 2
You will construct a standard Dual Tone Multi-Frequency (DTMF) generator like those used on any tonch-tone or cell phone. 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 contorlled DAC.
The analog signal will
be DTMF sine wave bursts generated using Direct Digital Synthesis
(DDS) technique. An example on the DAC page (PWM example 3) shows how you might implement
a DDS, but remeber that you are not using PWM output, so you will have to merge this example with the SPI DAC example below. 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 simulaneous DDS units and sum them. The sine wave table will need to be scaled to prevent overflow.
The SPI DAC you will use is the MCP4822. The connection and setup is described on Tahmid's blog
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
- 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
- handles erase/start commands
- waits for 30 mSec.
- DDS parameter Thread
- 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 appropriate tones are played.
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 100 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.
- Frequency accuracy should be +/-1%. Duration accuracy should be +/-3
mSec. 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. 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.
- 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.
- 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
September 11, 2015