The Goertzel Algorithm
I have a hobby project that I have been working on
and I need a very reliable method of tone detection.
I thought of FFT but that is pretty intense for a uC to
do well. I have heard that the goertzel algorithm is
a leaner way to do tone detection. Has anyone here
written code for the Prop that does this and have you
also built the hardware that allows you to feed the audio
signal properly into the Prop for detection? If so I'd love
to see the hardware and code.
I'm using those cheap little SMD xtal oscillators as transmitters
at various frequencies but mostly at 50 and 66Mhz. They work
really well and I get great range but I need to make an adapter
that plugs into the audio out on a pro receiver and will display
received decoded tone data on a small LCD. The Prop seems
just perfect for this task. It would be nice if a single cog could do
the detection of the tone using a simple hardware interface while
other cogs decode the data and handle display. I hope someone
has already done some of this as that would really make this easier for me :-)
The receivers have very narrow filters installed so I can dial down
to a very narrow bandwidth and limit noise.
The oscillators are really very nice for data transmission. the xtals
are build into the tiny SMD devices. This page has 30 pages of links
to China ebay sellers offering these types of device.
http://www.sportslinkup.com/shop/0-Crystal-oscillator-1-LOWEST.html
The devices that transmit the data are extremely simple containing
only a battery, Tiny85 along with a few parts and one of the SMD oscillators.
and I need a very reliable method of tone detection.
I thought of FFT but that is pretty intense for a uC to
do well. I have heard that the goertzel algorithm is
a leaner way to do tone detection. Has anyone here
written code for the Prop that does this and have you
also built the hardware that allows you to feed the audio
signal properly into the Prop for detection? If so I'd love
to see the hardware and code.
I'm using those cheap little SMD xtal oscillators as transmitters
at various frequencies but mostly at 50 and 66Mhz. They work
really well and I get great range but I need to make an adapter
that plugs into the audio out on a pro receiver and will display
received decoded tone data on a small LCD. The Prop seems
just perfect for this task. It would be nice if a single cog could do
the detection of the tone using a simple hardware interface while
other cogs decode the data and handle display. I hope someone
has already done some of this as that would really make this easier for me :-)
The receivers have very narrow filters installed so I can dial down
to a very narrow bandwidth and limit noise.
The oscillators are really very nice for data transmission. the xtals
are build into the tiny SMD devices. This page has 30 pages of links
to China ebay sellers offering these types of device.
http://www.sportslinkup.com/shop/0-Crystal-oscillator-1-LOWEST.html
The devices that transmit the data are extremely simple containing
only a battery, Tiny85 along with a few parts and one of the SMD oscillators.
Comments
Microchip has a Goertzel library for the dsPIC:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en536955
It's written in assembler. The demo application is written in C for a dsPIC33FJ256GP710, and uses a SiLab chip interfaced to the dsPIC. It built OK with the dsPIC compiler.
It might be possible to convert the dsPIC assembler to PASM, but I'm not sure of the legality of doing it. Anyway, there is a good description of the algorithm in the manual, which should help if someone wants to do it from scratch.
I've got an audio processor board I designed which uses a dsPIC and Si3000 codec, I could try the code on that.
For a few more years it could be useful to decode DTFM tones.
Holly you don't need complicated Goertzel, just simple triple length decoding.
http://www.romanblack.com/DTMF/DTMF_alg.htm
I looks like the main requirement is that you must sample the signal at exactly 4 times the frequency you are wanting to detect.
After that it is some very basic math (just a subtraction and a running sum if I remember correctly).
Bean
I wrote a speech recognizer that includes a Goertzel object. You can access it here:
Here's a better link that includes some DTMF stuff:
-Phil
There was a Goertzel app note on the SX processor issued by Scenix/Ubicom written by a chap named Fogelclauw (sp?) when they were still active with that chip years ago. I messed with that a bunch and got it working nicely, and should be able to get it easily ported to the Prop. It uses the standard SigmaDelta A/D conversion for sampling the signal, and should be a breeze for the Prop. I'll see if I can find my code...... soooooo many years ago!
Cheers,
Peter (pjv)
Lots of good information and links.
@Bean, I will try to get hold of that issue of Circuit Cellar.
@Tonyp, That's a very interesting link!
@Leon, I will look at that asm code and see if I can make sense of it :-)
The tone I will be looking for will be known in advance.
Actually I can just pick any tone I like since just changing frequency slightly
will shift the tone the receiver outputs. Anything from say 500-800hz will be
good. I will have an LED that blinks on when the correct tone is being detected.
It's possible to modulate an audio tone using the little oscillators but you can
detect the simple carrier from a much greater distance than a modulated carrier.
Hey, it just occurred to me that you could use a similar project to tune musical
instruments :-)
I think that the hardest part for me will be the hardware adapter circuit to connect
the audio to the uC. I'm pretty sure I will figure out the software OK.