DTMF Touch Tone Decoder Using Microchip PIC Microprocessor using PIC12F683

Summary of DTMF Touch Tone Decoder Using Microchip PIC Microprocessor using PIC12F683


This project uses a Microchip PIC12F683 microcontroller to detect DTMF (touch-tone) sequences using the Goertzel algorithm. The PIC samples audio via its ADC at four times each target frequency, runs the algorithm for all eight DTMF frequencies with 120 samples each, and compares magnitudes to thresholds. If a programmed DTMF string is detected, the PIC outputs a high signal to control external circuitry. HEX and source files are provided, and a simple circuit with level shifting and 5V regulation is required.

Parts used in the DTMF Touch Tone Decoder Using Microchip PIC Microprocessor:

  • Microchip PIC12F683 microcontroller
  • Power supply regulated to +5V (e.g., LM7805 regulator circuit)
  • Audio input coupling components and input level shifting components (as shown in the schematic)
  • Discrete passive components from the schematic (resistors, capacitors)
  • Programmer for PIC microcontrollers (to load the provided HEX file)
  • DTMF tone source (telephone or other DTMF tone generator)
  • Miscellaneous wiring, connectors, and PCB or prototyping board

DTMF Touch Tone Decoder Using Microchip PIC Microprocessor

This project contains the details of using a Microchip PIC12F683 8 bit microprocessor to detect DTMF tones. The completed program allows the processor to be programmed with a string of DTMF tones to detect. If the programmed string is detected in the audio applied the audio input, the output will turn on (go high), and can be used to control other circuitry of the users design.

UPDATE! 11/2/2010:
Due to requests for the source code, I have attached it. I have created a new step (Step 9) containing the *.asm file, along with some important notes.

UPDATE! 10/12/2010:
The HEX file for progdramming that I originally attached to this instructable had a bug that prevented successful programing of the tone sequence, unless the microprocessor was in serial output mode while in programming mode. The HEX file attached now works properly. Sorry for any inconveniene caused for those who may have tried the original code.

I have included the *.hex file needed to program the microprocessor, 12F683_DTMF_DECODE_01A.HEX. You will need a programmer for PIC microprocessors. I have seen instructions on this site for building your own, but I cannot speak for any of them. The programmer I use came from a company called Micro Engineer Labs, Inc at www.melabs.com.

The only other parts needed are the electronic components, as shown in the schematic in step 3, Circuit Details. Digikey (www.digikey.com) is an excellent source for electronic components .

A telephone or other means of generating DTMF tones is also needed for programming the microprocessor with the the sequence of tones you want to detect. This is described in more detail in step 4.

Touch Tone Decoder

Quick DTMF Overview

There are a total of 8 tones used to represent DTMF or “touch tone” numbers. The tones are in two groups of four, often referred to as the low and high tones. A number is represented by an audio waveform consisting of the sum of one of the low tones and one of the high tones. This can easily be visualized in a matrix format, as shown in the figure. Note that the DTMF system actually allows a total of 16 different tone pairs. The A, B, C, and D tones shown on the right hand column of the keypad in the figure are not included on a normal telephone, but they are often included on two way radios that have a DTMF keypad. They are sometimes used by two way radios for business or ham radio. The software for the project will also detect these additional 4 tone pairs.

Signal Processing Algorithm Description

The PIC 12F683 microprocessors built in A/D converter is used to sample an input audio waveform. The samples are analyzed using the Goertzel algorithm to detect whether any of the 8 tones are present.

The Goertzel algorithm is a signal processing algorithm which is used for detecting a single frequency. It acts as a very narrow bandpass filter.  It produces a very sharp response to frequencies within the pass band, and a much lower response for frequencies outside the pass band.

In my implementation of the algorithm, the samples are taken at a rate of 4 times the frequency to be detected. Using a sample rate of 4 times the target frequency makes coefficients used in the algorithm be equal to 1 or 0. This eliminates the need to perform complicated and time consuming multiplication on an 8 bit micro.  I haven’t included all the mathematical details of the algorithm here, but  a Google search will produce articles on the topic if you are interested in learning more about the algorithm itself.

Due to the restriction that the sampling rate must be 4 times the target frequency, the sample rate required will be different for each of the 8 tones that are used for DTMF. So, the algorithm must be run once for each of the 8 frequencies . This means that a separate set of samples must be taken for each frequency of interest, as each frequency will be tested at a different sample rate.

The sharpness of the filter response versus frequency is proportional to the number of samples taken. The response of the algorithm must be sharp enough that it responds to the target frequency, but does not respond to any of the other 7 frequencies. A value of 120 samples was found to produce a reasonably narrow response in experimentation. There is of course a tradeoff between number of samples and the execution time. In order to detect short tones, the execution time should be as short as possible. But, to make a narrow response the number of samples must be larger, resulting in a longer execution time. The number of samples becomes the limiting factor in how short of a tone can be detected.

Once the algorithm has processed 120 samples, it outputs a value. The magnitude of this value is proportional to the amplitude of the frequency of interest. This resulting value is compared against a threshold to determine if target frequency is present.
Once the algorithm has been run for all 8 frequencies, the microprocessor performs logic on the results to determine if a valid DTMF pair is present. A valid DTMF pair is considered to be present only if 1 row freq and 1 col freq is detected. Other combinations are regarded as invalid.

The graph shows the actual response measured using this algorithm running on a PIC 12F683.  The graph shows the frequency response of all 8 times the algorithm is run.  The x axis is frequency, in Hz.  The vertical axis is the value output by the algorithm.  The input was a 1V sine wave, swept from 600Hz to 1800Hz.  Note that the width of the response is wider for the higher frequency filters.  This is due to the fact that the width of the response is proportional to the sample rate, divided by the number of samples taken.  In this implementation of the algorithm, the sample rate is always four times the target frequency, to simply and speed up the math.  However, the same number of samples is used for each of the 8 target frequencies.  The to make the width of the response the same for each would require using the same sample frequency for each, which would involve more time consuming mathematics, or it would require that the number of samples taken at the higher frequencies be greater, which would lengthen the execution time.  If you were using a microprocessor with real DSP functionality, the extra math could be performed very fast and so it would be something that you would most likely include.

Despite the differences in the width of the response, the operation has been very robust at detecting tones, even in the presence of significant noise.

Circuit Details

The schematic for the circuit is shown below.  The connection labeled +5V must connect to a regulated 5V power supply, such as the output of LM7805  5 volt regulator circuit.
Schematic Touch Tone Decoder
The A/D converter measures voltages between 0V and 5V. The audio input will be a signal that swings above and below 0 volts, so its waveform will have positive and negative portions. In order to sample the input audio waveform with the A/D converter, the input signal needs to be shifted.

Quick Solutions to Questions related to the DTMF Touch Tone Decoder Using Microchip PIC Microprocessor:

  • What microcontroller is used in this DTMF decoder?
    The project uses a Microchip PIC12F683 microcontroller.
  • How are DTMF tones detected by the PIC?
    The PIC samples audio with its ADC and runs the Goertzel algorithm for each of the eight DTMF frequencies to detect tone magnitudes.
  • What sample rate is used for detecting each frequency?
    Samples are taken at a rate of four times the target frequency for each frequency tested.
  • How many samples are used for each Goertzel run?
    The implementation uses 120 samples for each frequency.
  • What indicates a valid DTMF digit was detected?
    A valid DTMF pair is detected only when one row frequency and one column frequency are both found.
  • What does the PIC do when the programmed DTMF string is detected?
    The output goes high (turns on) and can be used to control other circuitry.
  • Is source code or HEX provided for programming the PIC?
    Yes, both the HEX file and the source *.asm file are provided with notes.
  • What power supply voltage is required?
    The circuit requires a regulated +5V supply.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter