DTMF decoder library

The code could be modified to handle six inputs but it would slow down the sampling rate quite substantially which would change the characteristics of the detection.
A better way to handle the audio sampling is to use a timer interrupt and do the detection on-the-fly but in either case you would probably need a faster processor to handle six channels.

Pete

I have an issue with the detection of the DTMF tones. When I try with audio archives through my computer, I have no problem, but when I connect my phone, nothing is detected. I don´t know why.

What I have in mind is to connect one phone to my arduino board, with voicemail active, then if there is an incoming call, the voice mail pick up the call and because of this is allowed to dial the tones. For example 001 wich turns on the heating.

But without detection through my mobile I am blocked, what can I do?

Thanks for your help in advanced

bowline77:
I have an issue with the detection of the DTMF tones. When I try with audio archives through my computer, I have no problem, but when I connect my phone, nothing is detected. I don´t know why.

What I have in mind is to connect one phone to my arduino board, with voicemail active, then if there is an incoming call, the voice mail pick up the call and because of this is allowed to dial the tones. For example 001 wich turns on the heating.

But without detection through my mobile I am blocked, what can I do?

Thanks for your help in advanced

You would probably have to show us how you are attempting to connect to your telephone line. Actually most countries/telephone companies have laws and rules about how equipment can be wired to the local subscribers loop, as it's a balance line and you are not free to ground either the tip or ring wire. Normally equipment manufactures use approved chips/modules/components to do such electrical interfacing to the line called DAA modules. These usually involve a 600 ohm 1:1 transformer as well as ring detection/protection components. Keep in mind that the ring voltage when your phone rings is a 90 VAC 20Hz signal that can easily blow up components wired directly to the phone pair.

So I would suggest you do a little goggling for telephone interfacing circuits to see what you should be using.

Lefty

I have used El_supremo offered drawing and I connected a mobile phone with the audio jack so I don´t have the issue of a landline connetion (this is another point that I want to check out)

Thaks for your help

audio_1.gif

corolla9:
hi i have an update its working.
is there a way that can i decode 6 inputs in parallel?

el_supremo:
The code could be modified to handle six inputs but it would slow down the sampling rate quite substantially which would change the characteristics of the detection.
A better way to handle the audio sampling is to use a timer interrupt and do the detection on-the-fly but in either case you would probably need a faster processor to handle six channels.

Pete

Parallax Propeller could decode to 7 parallel channels with little external circuitry & leaving one of the COG's for serial back to an arduino.. A propeller chip (P8X32A) has 32 I/O, fully digital, analog input can be accomplished via sigma-delta conversion. There are actually 8 separate MCU's called cog's inside of one chip, this is how the propeller can do real-time parallel processing

There is an IC part# MT8870. It is a DTMF decoder that will provide a Data Valid signal and 4 bit binary output. all it requires is about 100 MV of clean audio, 5 V and a 3.58 MHz color burst crystal.
Here is a link from "Futurlec"that " appears to do a great deal.. and cheaper too @$12.98..

MT8870 DTMF Receiver Mini Board.

Bob

i did buy 6 of these chips $6 ea. haven't tried them yet but im sure they will work fine.

Hi,
I'm trying to use el_supremo's DTMF library. No matter what I do, I can't get a reading/signal from it.
I am wiring up the handset output of my telephone with this schematic:

Taken from: https://coolarduino.files.wordpress.com/2011/02/dc_bias11.png
I know this circuit is working because other libraries that do different things correctly analyze the audio.

Is there something I need to change? I would prefer not to by a DTMF Decoder.

Which other libraries, what do they do?

Pete

This is a basic speech recognition software: GitHub - arjo129/uSpeech: Speech recognition toolkit for the arduino. It worked great.
This gave a response, but because it can only detect one tone at once, it didn't work: GitHub - jacobrosenthal/Goertzel: Arduino Library implementation of the Goertzel algorithm

Hello,

Works very well for me to display the code on the computer.

For cons, I can not seem to use a DTMF to turn an LED on output.

How to make the LED lights up when you press the button 5.

thank you

Post your code (using code tags).

Pete

Thank you for the reply,

I took your code and have just added this:

if(thischar == 5) {
digitalWrite(led, HIGH);
}

I know (thischar == 5) is not fair. But I do not know what to put.

with this code

if(thischar) {
digitalWrite(led, HIGH);
}

The LED lights up, but with all the DTMF.

Code complet:

//DTMF Remote 
//Led pin 13
//Audio IN A0


#include <DTMF.h>

int sensorPin = A0;
int led = 13;
float n=128.0;

// sampling rate in Hz
float sampling_rate=8926.0;

// Instantiate the dtmf library with the number of samples to be taken
// and the sampling rate.
DTMF dtmf = DTMF(n,sampling_rate);

void setup(){
  pinMode(led, OUTPUT);     
  Serial.begin(115200);

}

int nochar_count = 0;
float d_mags[8];



void loop()
{
  char thischar;
  

  /* while(1) */

  dtmf.sample(sensorPin);
  dtmf.detect(d_mags,506);
  thischar = dtmf.button(d_mags,1800.);

// Led ON receive DTMF "5"
//??? no (thischar) fonction
  if(thischar == 5) {
digitalWrite(led, HIGH);
}

  if(thischar) {
    Serial.print(thischar);
    nochar_count = 0;
    // Print the magnitudes for debugging
//#define DEBUG_PRINT
#ifdef DEBUG_PRINT
    for(int i = 0;i < 8;i++) {
      Serial.print("  ");
      Serial.print(d_mags[i]);
    }
    Serial.println("");
#endif
  } else {
    // print a newline 
    if(++nochar_count == 50)Serial.println("");
    // don't let it wrap around
    if(nochar_count > 30000)nochar_count = 51;
  }
}

I started, but you've probably noticed ...

thank you very much

The code returns the detected button as a character so you need to use:

if(thischar == '5') {
  digitalWrite(led, HIGH);
}

This allows it to also return the symbols such as '*', '#' and, if you have the full 16 button pad, 'A', 'B' etc.

Pete

The simplest things are the most obvious.

Thank you, now it works fine.

FYI, perfect decoding at a speed of 50ms, but only with the wiring you suggested.

thank you very much for the help and the job.

HB3YWU / Mike

DTMF.cpp gets compile errors for me. I use the current version of the 'arduino' package from the Fedora 'updates' repository on Fedora 20. Perhaps something has changed in the avr-gcc compiler. I get error message:
unable to find a register to spill in class 'POINTER_REGS'
The line causing the error is:
dtmf_mag = sqrt(Q1Q1 + Q2Q2 - coeffQ1_Q2);
I fixed the problem by splitting up this expression into 3 lines:
float tmp;

tmp = Q1*Q1 + Q2Q2;
tmp = tmp - coeff*Q1Q2;

dtmf_mag = sqrt(tmp);
Griff_

Pete, it is possible that your library can decode CTCSS tone? this guy make something that : Private Site
but this radio can't read DTMF tone or i made a mistake ?

The library is specifically designed to decode the 8 DTMF tones. Decoding CTCSS tones is much more difficult because in some cases they are less than 3Hz apart whereas the DTMF tones are at least 70Hz apart.
If you were aiming to decode only a few of the tones and could choose a few that were much further apart, it can be done, but trying to decode all of them is probably impossible on an Arduino without external hardware.

Pete

When I try to compile the example dtmf_test I get the following and some more error-messages:

C:\Users\Peter\Documents\Arduino\libraries\DTMF\DTMF.cpp: In member function 'void DTMF::detect(float*, int)':

C:\Users\Peter\Documents\Arduino\libraries\DTMF\DTMF.cpp:179:1: error: unable to find a register to spill in class 'POINTER_REGS'

Arduino: 1.6.1 (Windows 7), Platine: "Arduino Uno"

Has anyone an idea how to fix this?

The code compiles with Arduino version 1.0.6 but it appears that there is a bug of some sort in the compiler in versions 1.6.0 and 1.6.1 - probably related to the -Os flag.
I have a workaround. Replace the entire DTMF:detect function in the DTMF.cpp library file with this:

// return the magnitudes of the 8 DTMF frequencies
void DTMF::detect(float dtmf_mag[],int adc_centre)
{
  int index;
  float d_tmp;

  /* Process the samples. */
  for (index = 0; index < N; index++)
  {
    ProcessSample(testData[index],adc_centre);
  }
  // Calculate the magnitude of each tone.
  for(int i=0;i < 8;i++) {
// El_Supremo 150318 the compilers in Arduino verisons 1.6.0 and 1.6.1
// generated "unable to find a register to spill" error in the original statement
// here. Breaking it into pieces worked around the problem.
//     dtmf_mag[i] = sqrt(Q1[i]*Q1[i] + Q2[i]*Q2[i] - coeff[i]*Q1[i]*Q2[i]);

  	// This is the equivalent of sqrt(real*real + imag*imag)
  	d_tmp = Q1[i]*Q1[i];
  	d_tmp += Q2[i]*Q2[i];
  	d_tmp -= coeff[i]*Q1[i]*Q2[i];

    dtmf_mag[i] = sqrt(d_tmp);
  }
  ResetDTMF();
}

I didn't notice/remember the report of the same problem in message #24 by griff2a until after I'd found a fix. My first attempt at splitting up the statement was similar to his but it didn't help so I had to split it even further.

Let me know if this works for you. I will update the link to the library.

Pete