# Most efficient way to find single dominant frequency (without amplitude) in analog signal

I want to construct a reference locked sine oscillator. The multibit sine wave is calculated using DDS. The multibit reference signal is typically not sinusoidal, can have offset and substantial noise, but is expected to contain one dominant frequency.

If this dominant frequency is nearly known, a standard PLL approach will work to keep track of the dominant frequency in the reference signal.

However, I now suppose this cannot work to acquire initial reference lock if the dominant frequency is far away from the oscillator frequency. In this case, the PLL gets stuck on a locally dominant frequency.

What is the common approach to resolve this ? Calculating an DFT seems like overkill, since it produces a lot of unnecessary information. A recursive 4 sample Zoom FFT looks a bit more efficient. But maybe there is a way that directly modifies the PLL filter to capture further off frequencies ?

Please let me know if I missed crucial info.

One approach is to use a phase/frequency detector as the circuit determining error and to ensure that the initial loop bandwidth is wide enough to “see” both the weaker signal that would otherwise be a false acquisition as well as the strongest signal desired. The loop will lock onto the strongest signal within the loop bandwidth as long as it is 6 dB above the total power of the other tones (a phase vector diagram illustrates well the need for 6 dB margin as anything less causes abrupt 0/180 degree changes In phase such that a phase lock loop can’t converge to zero error). Once locked, the bandwidth can then be tightened for better SNR performance on the locked signal. This approach also leads to much faster acquisition time in general and is often referred to as “gear-shifting”.

If the signals are much wider than the acquisition bandwidth then more elaborate search and assessment methods are needed prior to setting the center frequency for acquisition. A separate frequency lock loop with wider bandwidth can be employed or other techniques that sweep over the entire bandwidth and access signal strength (such as the FFT or if processing time is available and resources scarce a linear frequency ramp can be employed). Note that the FFT approach can be significantly simplified since the number of bins (samples) needed in the FFT computation only need to be enough to ensure one bin for each step size equal to the loop acquisition bandwidth or less (so if the entire bandwidth of interest is ten times the loop bandwidth in its widest setting for acquisition or a real signal, then a 20 point FFT could be used to determine the location of the strongest bin).

• thanks for the comment. I will get back when I have had time to implement and check it. The gear shift approach to PLL sure sounds close to what I have in mind. – tobalt Feb 11 at 13:36
• Yes that is very typical practice in both analog and all digital PLL approaches; given you already have a PLL implementation. Marcus’ answer is also very good for the more generalized problem of finding the strongest signal. Here you are letting the PLL find the strongest signal and just need to down select first. Good luck and let us know how it works out. Prefiltering of everything else out of band is also recommended if not already done. – Dan Boschen Feb 11 at 13:45
• I have played a bit adaptive gains for the oscillator frequency and phase adjustments and it works pretty good. However, when the reference is a square wave with non-50:50 duty cycle, and I begin somewhere,e.g. in between the 2nd and 3rd harmonic of the fundamental, then it basically always gets stuck on a harmonic. I reckon this is inevitable with the PLL approach due to the high harmonic power (THD more than -6dbC). Could you please provide a ressource where this is explained ? I couldnt fully understand that part of your answer. – tobalt Feb 15 at 7:54
• @tobalt I will update my answer to further detail that - a picture is worth a thousand words. – Dan Boschen Feb 15 at 16:10

The multibit reference signal is typically not sinusoidal, can have offset and substantial noise, but is expected to contain one dominant frequency.

Against offset, you'd practically always start your processing with a high-pass filter.

If you know your dominant frequency to be sufficiently less than Nyquist, a fixed low-pass filter would also be a cheap way to increase your SNR before even doing anything complicated.

What you're looking for is the answer to the question

What's $$f_d$$ of the dominant frequency in the signal?

and that's a parametric estimation problem. So, I'd recommend using a parametric estimator.

I'm going to go ahead and recommend something that will seem quite like overkill (due to the scary complex algorithms mentioned therein), but it's really quite straightforward in the sizes of problem you deal with.

Do ROOT-MUSIC with a signal subspace size of $$m=2$$ and a noise subspace size of $$n-m=1$$ or $$2$$.

ROOT-MUSIC roughly works like the following:

1. You estimate a autocovariance matrix (and that you do by taking a vector $$X$$ of $$n$$ samples, and multiplying it with its transpose conjugate, so that you get a $$n\times n$$ matrix $$\hat R_{XX}$$. You typically accumulate and average a few of these to get an averaged $$\bar R_{XX}$$. Not that $$n$$ is "really small".
2. you do an Eigenvalue Decomposition. Because $$\bar R_{XX}$$ is real and symmetrical by construction, that becomes really trivial.
3. You take the two largest Eigenvalues (of your 3 to 5 eigenvalues...), and the matching eigenvector. These column vector $$S$$ spans your signal space! Yay! (Pick two, because your sine is real, and that means it's composed of two inherently linked complex sinusoids of $$\pm f_d$$).
4. You, however, consider the other eigenvectors. These span the noise space matrix $$G$$ (which has dimension 1 or 2 , depending on your choice of $$n-m$$), and by how eigenvalue decompositions of hermitian matrices like $$\bar R_{XX}$$ happen, that space is orthogonal to the signal space. If you calculated the "pure" sinusoid of the right frequencies $$f_d$$, their projection into the noise space would be zero. You exploit that. Let $$z=e^{j2\pi ft}$$, and define $$a=\left[ z^{-0}, z^{-1}\right]$$. Then, finding the zeros ("roots") of $$a^* GG^* a$$ (which is a very boring 1st or second degree polynomial) gives you your frequencies.
• Thanks for the unconventional method. I will need some time to think it through and implement it. I will get back eventually with results :) At the very least I will learn a lot. – tobalt Feb 11 at 13:38
• I tried to read up a bit on this topic, but from first glance it appears very computationally intense compared to adaptive PLL. Is that correct or did I misunderstand some part. E.g. for n=3 your step number (1.) would encompass already 9 MULs per sample just to compute R_XX. I realize some of these are just squares, but still. Compare this to two MULs (in-phase and quadrature) per sample for the PLL. Another story might be finding far-off reference frequencies. Is this MUSIC generally cheaper than say an 8 sample FFT ? – tobalt Feb 15 at 8:02
• @tobalt First of all, your PLL needs more MULs per sample, unless you don't have a loop filter (and that would be bad). Aside from that, you're comparing the PLL, which doesn't look at the whole spectrum, but only at the "surroundings" of where it currently is in phase, to a method that can find an arbitrary dominant frequency, so I'm not sure this comparison is overly fair! But you've noticed that yourself. Often, in highly energy-optimized systems, this is the point where people just switch between different methods after detecting they might be in a situation where the current method fails. – Marcus Müller Feb 15 at 9:36
• @tobalt re: FFT vs MUSIC: no, the FFT will probably be lower in CPU consumption, but an N-Point FFT gives you Nyquist/N in frequency resolution. ROOT-MUSIC gives you the exact frequency (of course, estimator variance due to noisy signal still applies). – Marcus Müller Feb 15 at 9:39
• for the "loop filter" part I can get away using only power-of-two coefficients to make a cheapo IIR, so I need only shifts and ADDs. This is for an FPGA, so saving actual MULs is a good. The same could be true for the calculations in MUSIC, but I didn't experiment with it. PLL and MUSIC sure have very different pros/cons. Why I considered the cheap 8 sample FFT, is to get me close to where the PLL can lock after doing it 2-3 times recursively to zoom in on the dominant bin. I will still study and understand MUSIC better, but for the present application, the PLL seems to serve me well. – tobalt Feb 15 at 9:50