Shop OBEX P1 Docs P2 Docs Learn Events
Goertzel mode? Where to find information? — Parallax Forums

Goertzel mode? Where to find information?

This mode sounds interesting and if possible I'd like to use it on a Prop2 for single-tone detection. Where can I find info about what this mode does and how to use it? Code examples would help. Not much found on the forums or the Parallax site. Thanks. --Jon

Comments

  • Christof Eb.Christof Eb. Posts: 1,087
    edited 2023-03-05 09:15

    Hi,
    yes the documentation of Goertzel mode is scarce.
    Most important source is the description in the https://docs.google.com/document/d/1gn6oaT5Ib7CytvlZHacmrSbVBJsD9t_-kmvjd7nUR6o/edit?usp=sharing&_ga=2.259515978.1520442725.1678003785-804092565.1605948706

    Hardware Manual is void for streamer.

    I got help here: https://forums.parallax.com/discussion/174898/goertzel-for-object-detection#latest Especially post #9.

    Have you found https://forums.parallax.com/discussion/174955/p2-taqoz-2-8-dac-comparator-and-goertzel-touch-sense-and-reflex-sensor-with-modulated-light#latest ?

    All in all I got it working after some hard time. And learned upsides and downsides.

    • You will need to dedicate a cog for this, because there is no double buffering. The cog has to wait for results and read them instantly, if not they will be overwritten at the next sample.
    • It does block the streamer and you can only detect one frequency and one signal at a time per cog.
    • I do not completely understand this, but as the sin table has a resolution of max 8bits and a limited length, the resolution of the result must be limited too.
    • It is fast
      So as you will need one cog for it anyways, you might consider to use "real" Goertzel algorithm in software, if your sample frequency is not too high. You can then filter for several frequencies in parallel. In my audio analyser project https://forums.parallax.com/discussion/173880/picture-of-sound-parallax-propeller-p2-as-a-tool-to-analyse-a-guitar-effect-pedal-or-an-amp#latest I used the method to capture a buffer first and then analyse it with software Goertzel. Somewhat straight forward.
      The hardware "Goertzel mode" ( as far as I understand it has nothing to do with Goertzel algorithm but is rather a IQ mixer ) seems to be really useful only, if you have to deal with one rather high frequency.
      Regards Christof
  • Thanks for your help, Christoph. I got the assembly-language Goertzel program to run properly a few minutes for sinc1. I'll try sinc2 in a while. The problems were of my own making--I forgot that I needed to sweep the signal (frequency-modulate it) around the 1 MHz signal I used for tests. After I set up a Wavetek Model 148A signal generator, I got the results I expected for the Goertzel transform! Here's an image of the results.

    Now I need to determine how well the Goertzel transform works on a Prop-2 when I sample audio signals. I'll need to look closely at the sampling rates and cog clock frequencies.

    A final point. The Goertzel code includes the instruction asmclk, but I could not find any reference to it in any of the Propeller docs.

    All the best. Jon

  • Christof Eb.Christof Eb. Posts: 1,087
    edited 2023-03-06 06:44

    Hi,
    There is no picture and no code, so it is difficult for me to follow your post.
    Christof

    Edit: Found the usage of "asmclk" in the example in the P2 doc V35. I assume it is a macro for hubset somehow. I would suggest, to open a new thread for this question.

    Regarding exact frequencies: In my audio analyser project I learned, that if you want to detect a frequency, it was necessary to add/average at least 3 adjacent frequency bands, because the frequency might just lie in between two bin centers. Perhaps use lower sample rate and analyse shorter bursts to broaden bandwidth.

  • @JonTitus said:
    This mode sounds interesting and if possible I'd like to use it on a Prop2 for single-tone detection. Where can I find info about what this mode does and how to use it? Code examples would help. Not much found on the forums or the Parallax site. Thanks. --Jon

    The Goertzel mode of the P2 streamer is IMHO ideally suited for applications like capacitive or inductive sensors and de-modulation of an RF signal in the MHz range. Phase or time-of-flight measurements are also possible (ping sensors). For audio applications where discrete frequencies have to be extracted from a broader spectrum, I think a traditional FFT would be better.

    What exactly do you mean with "single-tone detection". You have to trigger to some sort of dial-tone?

  • evanhevanh Posts: 15,126
    edited 2023-03-06 10:44

    ASMCLK is indeed a macro for effecting of _clkmode from an assembled pure Pasm program. This functionality is automatic and hidden with a compiled Spin program.

    With _clkmode being built from _clkfreq, _xtlfreq and _xinfreq


  • There is a nice video that explain the goertzel filter.
    It has nothing to do with the P2 cordic goertzel,but it is a good basic.

  • **1. ** Thanks, folks. There's a good discussion of the Goertzel transform in the book, "Understanding Digital Signal Processing (2 ed.)" by Richard G. Lyons. pages 528 and 529. There's one copy (used) for under $10 on Abebooks.com! It's an excellent book if you want to learn about DSP.

    2. The links below show my Goertzel results for a signal swept (frequency modulated) from about 950 kHz to about 1050 kHz (1.05 MHz) with a sine wave of amplitude 0 to 3 V.

    (https://forums.parallax.com/uploads/editor/g8/0n2p2418i5fw.jpg "")

    **3. ** evanh noted, "ASMCLK is indeed a macro for effecting of _clkmode from an assembled pure Pasm program." Where are the macros described? I couldn't find them in any Prop2 documentation.

    **4. ** Does anyone know where to find the code format for the CORDIC operations? The Prop2 docs list them and describe what they do, but nothing found in a search for the arguments required and how the results get returned. Not a high priority but I'd like to knwo.

    Again, thanks for your help. --Jon

  • evanhevanh Posts: 15,126
    edited 2023-03-13 00:19

    There is one paragraph on ASMCLK in the Spin2 docs. With a note saying it's now a redundant feature - as of September 2022.

    EDIT: Not too sure if Flexspin followed suit though.

  • evanhevanh Posts: 15,126
    edited 2023-03-13 00:43

    The "Silicon" doc briefly covers the Cordic ops - https://www.parallax.com/propeller-2/documentation/ Ignore the PDFs at that link, they're still a work in progress. The three main docs to read there is:
    Silicon doc - https://docs.google.com/document/d/1gn6oaT5Ib7CytvlZHacmrSbVBJsD9t_-kmvjd7nUR6o/edit
    Spin2 doc - https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit
    Instruction spreadsheet - https://docs.google.com/spreadsheets/d/1_vJk-Ad569UMwgXTKTdfJkHYHpc1rZwxB-DcIiAZNdk/edit

    There is also a bunch of examples in the Pnut zip file - https://forums.parallax.com/discussion/171196/a/p1

    It is all very terse still. I guess, with so much packed in the Prop2, the docs are a lot of work to flesh out

Sign In or Register to comment.