1

I have an old land line phone that I want to connect to my Arduino. Then I would like to write a program that can decipher the touch-tone button presses (which are a combination of two tones) so that the Arduino can react to specific key presses and numeric sequences. My final goal is to make the Arduino play specific messages when the user enters in codes. I am really not sure even where to begin.

Thanks for the hardwares fixes for this problem, but if possible, I am looking for a softwares solution.

This will be used to make a telephone (with an attached Arduino) that will play a series of conversations when specific codes are dialed.

  • 2
    possible duplicate of Connecting an Arduino to a telephone line? – Greg Hewgill Jun 18 '15 at 2:18
  • Which connection are you trying to make? Are you trying to connect the arduino to a telephone line. Or simply connect the arduino to the "sound output" of a cellphone? – Paul Jun 18 '15 at 8:09
  • @GregHewgill - not, not a duplicate. The question is really very different - this is not about electrical connection but about detecting combinations of two tones. – Chris Stratton Jun 28 '15 at 0:54
  • @ChrisStratton: Yes, that's also asked in the linked question. Perhaps the linked question is too broad. – Greg Hewgill Jun 28 '15 at 1:01
  • cough cough ever tried googling? forum.arduino.cc/index.php?topic=121540.0 – TheDoctor Jul 12 '15 at 23:30
3

As John Taylor said, DTMF is not a single tone but two tones transmitted simultaneously, which select the digit from a two-dimensional grid. (Dual tone multi-frequency). This allow 16 possible combinations from only 8 distinct tones.

There are chips available specifically for the task of decoding DTMF, but it's always nice to try and find a one-chip solution.

There are two solutions that I can think of:

  • ArduinoFFT - a Fourier transform is an operation that splits a time-based signal into its frequency components. If you control the ADC directly instead of via the Arduino library, it is easily fast enough to sample a DTMF signal. Once you've done the FFT you just need to find the peaks in the output, which will tell you the tones that are present.
  • If you put the signal through the analog comparator and count the rate of zero-crossings (use an interrupt with a routine that increments a number, you may miss some if you just poll the pin), the rate of crossings should be unique for each tone combination. Counting for e.g. 10 ms and looking up the closest match from a table you've pre-measured should give reliable decoding, and is a slightly less brute-force approach than an FFT.

That said, you won't be able to beat a dedicated chip (although I personally think this way is much more fun.)

Happy hacking!

3

It is possible to decode DTMF tones with only a few common external components. The trick is to turn the analog audio into a digital signal, and then check the timing between the leading and trailing edges in order to figure out which tone is present.

First, create a 1.1V bias using a voltage divider. This bias will connect to both a capacitor that is coupling the audio, as well as one of the analog inputs. Note that phone lines have high voltages on them at times, and you must have both isolation and voltage clamping in place before connecting a device to one.

Second, enable the analog comparator in the MCU. See the "Analog Comparator" section of the MCU datasheet for details. Configure the non-inverting input to connect to the internal bandgap reference, the inverting input to connect to the analog input chosen earlier, and the output to connect to the input capture facility.

Third, configure the input capture facility in the MCU. See the "16-bit Timer/Counter1 with PWM" section of the datasheet, with particular emphasis on the "Input Capture Unit" subsection. Note that there is no way to trigger the input capture on "any" edge, therefore you will need to either flip the capture edge select bit each time, or you will need to detect the tone from only one set of edges. Also note that you will need to use the overflow interrupt to increment your explicit "high bytes" counter in case the edges to be detected appear on opposite sides of the overflow.

Now that all that is done, all that remains is to compare the timing detected by the input capture with your internal table of timings and select the appropriate tone from that. But that's the easy part.

  • seeedstudio.com/depot/… As an expansion to this answer: There are a lot of arduino shields made for this purpose. You should check on the search query: "Arduino DTMF shield". Most of them work by inputting a 3.5mm jack. This would be easier as a phone line, as those can vary in voltage etc. – Paul Jun 18 '15 at 8:11
  • Alas, you are handwaving away what is by far the most difficult part - simply digitizing, and timing zero crossing intervals will not be an easy way to detect the combination of two simultaneous tones which may (at least by the time they get to you) be of different amplitudes. – Chris Stratton Jun 28 '15 at 0:57
2

DTMF is actually two non-harmonically related frequencies transmitted at the same time as opposed to a single frequency tone that can be measured with the above process, hence Dual-Tone-Multi-Frequency:

DTMF Frequency to Code table

You can use the Rohm BU8872 series devices which decodes the 4 x 4 multi tone combinations directly into a 4 bit digital result per the grid above. This also works the same way in the Mitel MT8870 series devices (I think they were bought by Microsemi). These have digital filtering which pick out the two signals and some devices can even do single tone detection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.