Offline
God Member
Karma: 11
Posts: 896
|
 |
« on: September 04, 2012, 08:19:22 pm » |
I have modified the Goertzel algorithm implementation here: https://github.com/jacobrosenthal/Goertzelso that it can be used to detect DTMF tones. The new version, like the original, is not interrupt driven. It is provided AS IS for you to play with. There are two sample audio files in the zip which, when the windows audio is turned up full, the sample code detects with no errors. There is also a circuit diagram of how I connected the audio from the computer's headphone output to the Arduino's analog Pin 0. Use at your own risk. Unzip the attached file into your libraries directory. Pete
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #1 on: September 05, 2012, 08:49:52 pm » |
So, I took a look and it works beautifully. Their are 2 things I have questions about though. The tone length is very strict. If the tone is too short it wont work and if it plays too long it will put print the number multiple times. Is their any chance you could make it modifiable? Also, the goertzel algorithm is supposed to compensate for magnitude on its own. Is there anyway to account for that?
Again, great job and thanks for your help!
Moose
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15293
Measurement changes behavior
|
 |
« Reply #2 on: September 05, 2012, 08:53:57 pm » |
So, I took a look and it works beautifully. Their are 2 things I have questions about though. The tone length is very strict. If the tone is too short it wont work and if it plays too long it will put print the number multiple times. Is their any chance you could make it modifiable? Also, the goertzel algorithm is supposed to compensate for magnitude on its own. Is there anyway to account for that?
Again, great job and thanks for your help!
Moose
I believe the official (original ATT specs?) DTMF specs for minimum recognition time (shortest tone period) for a valid digit is around 40 msec if I recall correctly. Decoding multiple repeated digits for a single tone of any length sounds like just a 'feature' of the library. 
|
|
|
|
« Last Edit: September 05, 2012, 08:55:58 pm by retrolefty »
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 11
Posts: 896
|
 |
« Reply #3 on: September 05, 2012, 09:37:17 pm » |
The tone length is very strict. If the tone is too short it wont work How short a tone are you trying? The dialabc example uses 50ms tones. The example code uses a sample length of 128 which means that a sample block is 14 milliseconds long. It should have 3 good blocks in one 50ms tone and might detect tones down to around 30ms - I haven't tried that. You could try making the sample length shorter (try 64) so that the algorithm samples the tone more times. If you do that, you'll have to reduce the threshold amplitude as well. and if it plays too long it will put print the number multiple times. When the code detects a tone it won't return it again until it sees something that is not a tone. If for any reason the amplitude drops a bit to just below the threshold it can think it has seen the end of the tone when there's actually still more to come. Try lowering the threshold amplitude just a bit. Is their any chance you could make it modifiable? Make what modifiable? Also, the goertzel algorithm is supposed to compensate for magnitude on its own. I saw one implementation which divided the resulting magnitude by the number of samples. I don't know if that's actually part of the Goertzel algorithm itself. I'll play with it in the next day or so. Again, great job and thanks for your help! You're welcome ;-) Pete
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 11
Posts: 896
|
 |
« Reply #4 on: September 06, 2012, 11:29:58 am » |
Also, the goertzel algorithm is supposed to compensate for magnitude on its own. This can be done without changing the library. The dtmf_test sketch originally had this code: dtmf.detect(d_mags,512);
thischar = dtmf.button(d_mags,1800); Change it to this: dtmf.detect(d_mags,512); for(int i = 0;i < 8;i++) { d_mags[i] /= n; } thischar = dtmf.button(d_mags,20.); The "for" loop normalizes the magnitudes. I determined the threshold value of 20 empirically but it works for values of n from 55 up to 160 when using either of the sample audio files. I prefer to leave this outside the library but if you want to build it in, in the method DTMF::detect change this statement: dtmf_mag[i] = sqrt(Q1[i]*Q1[i] + Q2[i]*Q2[i] - coeff[i]*Q1[i]*Q2[i]); to this: dtmf_mag[i] = sqrt(Q1[i]*Q1[i] + Q2[i]*Q2[i] - coeff[i]*Q1[i]*Q2[i])/N; Pete
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #5 on: January 14, 2013, 03:58:45 am » |
is there a way to make the link alive again?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 11
Posts: 896
|
 |
« Reply #6 on: January 14, 2013, 11:24:01 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #7 on: January 15, 2013, 05:18:52 am » |
Hi Pete
thanks for the new link, but i fail to understand how the code work . i dont have any expriance in arduino but i want to give it a shot....
as described i built the neccesery cirucit and connected it to my audio output of my pc. when i upload the code to my (MEGA2560) i dont see any feedback from the circuit exept from when i opening the serial monitor and the led on pin 13 go ON. i tried to open the serial monitor put it on 115200 baud and wait and see the detction working but its seems to do nothing.
how can i adavnce and make it work (sorry for my bad english) my audio output in full volume and my divider is on 512 please help.
|
|
|
|
« Last Edit: January 15, 2013, 06:10:25 am by corolla9 »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #8 on: January 15, 2013, 09:57:16 am » |
hi i have an update its working. is there a way that can i decode 6 inputs in parallel?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 11
Posts: 896
|
 |
« Reply #9 on: January 15, 2013, 11:03:41 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #10 on: January 25, 2013, 04:11:03 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15293
Measurement changes behavior
|
 |
« Reply #11 on: January 25, 2013, 08:49:37 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #12 on: January 28, 2013, 12:10:28 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Dublin, CA
Offline
Newbie
Karma: 0
Posts: 9
Tickling critical mass.
|
 |
« Reply #13 on: February 17, 2013, 12:21:21 pm » |
hi i have an update its working. is there a way that can i decode 6 inputs in parallel?
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
|
|
|
|
|
Logged
|
Electronics Engineering student - online (AEES) & (BEET) Professional Auto Collision/Custom tech
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2304
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #14 on: February 22, 2013, 10:03:20 pm » |
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.. http://www.futurlec.com/Mini_MT8870.shtml. Bob
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
|