# Basic Goertzel (EE Tip #120)

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: The signal flow of the basic Goertzel transform produces an output (y0) for each sample processed. The output is a combination of the current ADC sample added to the product of the previous output (y1) multiplied by a constant minus the previous output (y2). After a block of samples has been processed, the sum of the squares of y1 and y2 are computed to determine the relative amplitude of a particular frequency.

Figure 1 may be written as Equation 1. y0 is the current processed output. x0 is the current ADC sample. y1 is the previously processed output, and y2 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 y1 and y2 variables.

Equations 1 – 4

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.

This entry was posted in EE Tips and tagged , , by Circuit Cellar Staff.

Circuit Cellar's editorial team comprises professional engineers, technical editors, and digital media specialists. You can reach the Editorial Department at editorial@circuitcellar.com, @circuitcellar, and facebook.com/circuitcellar

## 2 thoughts on “Basic Goertzel (EE Tip #120)”

1. 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

2. 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.