EE 451 - LAB 9

DTMF Detector

Part 2: Determining which DTMF Signal is Present

Finish the DTMF project by adding the code to determine which DTMF signal is present. If a valid DTMF tone is present put out a four-bit number on bits 3-0 of Port B indicating which of the 16 keys was pressed, and put out a one on bit 4 of Port B to indicate a DTMF signal is present. If a signal other than a DTMF tone is present (at least one detector output asserted, but the detection outputs do not match any DTMF pattern) put out a one on bit 5 of Port B. If none of the detectors are asserted all bits of Port B should be low.

There are many ways you can do this. Here are a couple of suggestions.

  1. Allocate eight storage locations for results for each of the eight frequencies. If a frequency is present, put a 1 in the corresponding storage location. If the frequency is not present, put a 0 in the corresponding location. Add locations 0, 1, 2, and 3. Add locations 4, 5, 6, and 7. If a DTMF signal is present, the first sum should be 1, and the second sum should be 1. (A sum of 0 means no frequency in the group of four was present; a sum greater that 1 means that more than one frequency in the group of four was present).

    If a valid DTMF frequency is present, check to see which one it is. In C this might look like:

        if ((sum1 == 1) && (sum2 == 1))
        {
            if ((result[0]==1) && (result[4]==1)) key = 0x10;        //"1"
            else if ((result[0]==1) && (result[5]==1)) key = 0x11;   //"2"
            else if ((result[0]==1) && (result[6]==1)) key = 0x12;   //"3"
            else if ((result[0]==1) && (result[7]==1)) key = 0x13;   //"A"
            else if ((result[1]==1) && (result[4]==1)) key = 0x14;   //"4"
            else if ((result[1]==1) && (result[5]==1)) key = 0x15;   //"5"
            else if ((result[1]==1) && (result[6]==1)) key = 0x16;   //"6"
            else if ((result[1]==1) && (result[7]==1)) key = 0x17;   //"B"
            else if ((result[2]==1) && (result[4]==1)) key = 0x18;   //"7"
            else if ((result[2]==1) && (result[5]==1)) key = 0x19;   //"8"
            else if ((result[2]==1) && (result[6]==1)) key = 0x1a;   //"9"
            else if ((result[2]==1) && (result[7]==1)) key = 0x1b;   //"C"
            else if ((result[3]==1) && (result[4]==1)) key = 0x1c;   //"*"
            else if ((result[3]==1) && (result[5]==1)) key = 0x1d;   //"0"
            else if ((result[3]==1) && (result[6]==1)) key = 0x1e;   //"#"
            else if ((result[3]==1) && (result[7]==1)) key = 0x1f;   //"D"
        }
        else if ((sum1 == 0) && (sum2 == 0)) key = 0;  // No frequency
        else key = 0x20;                               // Frequency, not valid DTMF
    

  2. Start with a variable result = 0. As you go through the frequencies, shift result one to the left, and put a 1 on the end. If the frequency is not present, shift result one to the left put do not put a 1 on the end:

        result = result << 1;
        if (a > thresh) result = result | 1;
    

    If a valid DTMF code is present, result should match one of sixteen possible values. If it doesn't match any of those sixteen values, then a valid DTMF code was not present:

        if (result == 0x88) key = 0x10;        //"1"
        else if (result == 0x84) key = 0x10;   //"2"
        else if (result == 0x82) key = 0x11;   //"3"
        else if (result == 0x81) key = 0x12;   //"A"
        else if (result == 0x48) key = 0x13;   //"4"
        else if (result == 0x44) key = 0x14;   //"5"
        else if (result == 0x42) key = 0x15;   //"6"
        else if (result == 0x41) key = 0x16;   //"B"
        else if (result == 0x28) key = 0x17;   //"7"
        else if (result == 0x24) key = 0x18;   //"8"
        else if (result == 0x22) key = 0x19;   //"9"
        else if (result == 0x21) key = 0x1a;   //"C"
        else if (result == 0x18) key = 0x1b;   //"*"
        else if (result == 0x14) key = 0x1c;   //"0"
        else if (result == 0x12) key = 0x1d;   //"#"
        else if (result == 0x11) key = 0x1e;   //"D"
        else if (result > 0)     key = 0x20;   //At least one freq, but no DTMF
        else if (result == 0)    key = 0;   //no frequency present
    

Once your program is written, use one 56002 board running the program from Lab 4 to generate a DTMF signal. Use another board to decode the signal. Verify that the detector works for a few different inputs.



Bill Rison
2000-10-27