Pages: 1 [2]   Go Down
Author Topic: DTMF decoder library  (Read 16004 times)
0 Members and 1 Guest are viewing this topic.
Livermore, CA
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Tickling critical mass.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Electronics Engineering student - "E=MC^(OMG x WTF?!)"
Professional Auto Collision/Custom tech

Offline Offline
Newbie
*
Karma: 0
Posts: 48
Arduino is awesome
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

An Arduino is not a toy; it's a hobby.

Offline Offline
Edison Member
*
Karma: 31
Posts: 1417
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Which other libraries, what do they do?

Pete
Logged

Where are the Nick Gammons of yesteryear?

Offline Offline
Newbie
*
Karma: 0
Posts: 48
Arduino is awesome
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a basic speech recognition software: https://github.com/arjo129/uSpeech. It worked great.
This gave a response, but because it can only detect one tone at once, it didn't work: https://github.com/jacobrosenthal/Goertzel
Logged

An Arduino is not a toy; it's a hobby.

Avenches Suisse
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

HB3YWU/Mike

Offline Offline
Edison Member
*
Karma: 31
Posts: 1417
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Post your code (using code tags).

Pete
Logged

Where are the Nick Gammons of yesteryear?

Avenches Suisse
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the reply,

I took your code and have just added this:

Code:
if(thischar == 5) {
digitalWrite(led, HIGH);
}
I know (thischar == 5) is not fair. But I do not know what to put.

with this code
Code:
if(thischar) {
digitalWrite(led, HIGH);
}
The LED lights up, but with all the DTMF.

Code complet:
Code:
//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

« Last Edit: October 14, 2013, 12:22:47 pm by hb3ywu » Logged

HB3YWU/Mike

Offline Offline
Edison Member
*
Karma: 31
Posts: 1417
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code returns the detected button as a character so you need to use:
Code:
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
Logged

Where are the Nick Gammons of yesteryear?

Avenches Suisse
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

HB3YWU/Mike

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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(Q1*Q1 + Q2*Q2 - coeff*Q1*Q2);
I fixed the problem by splitting up this expression into 3 lines:
    float tmp;
     tmp = Q1*Q1 + Q2*Q2;
     tmp = tmp - coeff*Q1*Q2;
     dtmf_mag = sqrt(tmp);

Griff

Logged

Pages: 1 [2]   Go Up
Jump to: