Shop OBEX P1 Docs P2 Docs Learn Events
The Goertzel Algorithm — Parallax Forums

The Goertzel Algorithm

HollyMinkowskiHollyMinkowski Posts: 1,398
edited 2011-06-20 13:35 in General Discussion
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.

images?q=tbn:ANd9GcRN3cW0cQomkDeJhX6ZYQhr8I59V4vU9xOQAQvyMjPA16NEB4Z_0A

Comments

  • kwinnkwinn Posts: 8,697
    edited 2011-06-20 04:56
    Not sure if this helps but there is this bell 202 modem object "http://obex.parallax.com/objects/421/"
  • LeonLeon Posts: 7,620
    edited 2011-06-20 05:08
    Goertzel is actually a stripped-down FFT for detecting frequencies that are known in advance.

    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.
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-06-20 06:59
    Though analog phone service is slowly going away, good riddance.

    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
  • BeanBean Posts: 8,129
    edited 2011-06-20 07:07
    Holly if you have access...Circuit Celler magazine #182 Sept 2005 pg 22-28 is a really good article about the Goertzel algorithm.

    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
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-06-20 08:30
    Holly,

    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
  • pjvpjv Posts: 1,903
    edited 2011-06-20 10:39
    Holly;

    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)
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2011-06-20 13:35
    Thanks guys :-)

    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.
Sign In or Register to comment.