The basic Goertzel transform, which has been around since 1958, was derived from the discrete Fourier transform (DFT). It’s an extremely efficient method of detecting a single frequency component in a block of input data. Figure 1 depicts the signal flow for the basic Goertzel algorithm as each sample is processed.

Figure 1 may be written as Equation 1. y_{0} is the current processed output. x_{0} is the current ADC sample. y_{1} is the previously processed output, and y_{2} is the next previously processed output. m is the frequency domain bin number. N is the sample block size. Input samples are processed on a sample-by-sample basis. Processing continues over a block of input data of the length N. After a block of data has been processed, magnitude and phase information for the signal of interest is contained in the y_{1} and y_{2} variables.

One of the advantages of the Goertzel transform is that the magnitude (and phase) computation needs to be performed only at the end of a block of data. After a block of data has passed through Equation 1, the relative magnitude may be determined by computing the sum of the squares of the real and imaginary components.

The real component (RC) is described as Equation 2. The imaginary component is calculated with Equation 3. The squared magnitude is computed with Equation 4.

For tone detection only, phase information may be ignored. It’s sufficient to compute the square of the magnitude to determine the relative power of a signal.—Eric Kiser, “Digital Decoding Simplified,” *Circuit Cellar* 182, 2005. The issue is available in the CC Webshop.

If possible, design the system so that m/n = 1/2.

Then the cosine term is equal to 0 and the sine term equal to 1.

No math. Simple calcs. At least until the final eval.

Even then you can approximate the RMS value rather than doing the squaring and (not always needed) square rooting. That approximation is left as an exercise.

Gary

It seems that the ability to ‘tune’ the Goertzel filter center frequency is still not widely known. Normally, the variable m is calculated as

m = (f/fs) * N,

where f is the desired center frequency, fs is the sampling frequency, and N is the number of samples. Then m is taken as the nearest integer to the calculated value. Thus the center frequency of the resulting filter is usually not exactly at the desired frequency.

However, if you simply use the actual calculated value (not the integer) and therefore use m/M = f/fs in the Goertzel formulas, the resulting filter is spot on the desired frequency. Why settle for less? And it is actually easier.

Also, remember that the value of N is not constrained (even for the DFT) like it is for the FFT. The value mainly determines the effective bandwidth which is usually not very sensitive to a few points +/- in N.