# Difference between a digital lock-in amplifier and a FFT when extracting phase of a signal?

I am trying to measure the relative phase of a sine wave fixed at a particular frequency in a noisy environment. My initial approach is to simply collect $N$ samples, take an FFT, and then just extract the phase at the operating frequency (which I know apriori).

When reading about methods to extract signals from noisy environments, I came across the lock-in amplifier. However, I am confused about whether I should have any reason to expect it to perform better than the FFT (ignoring run time, just looking at ability to extract my phase).

Specifically, imagine that I implement the lock-in amplifier digitally. I would then numerically calculate the following two integrals (source):

\begin{align} X_{LI} &= \frac{1}{T}\int\limits^{T}_{0} U_{\rm in}(s) \cos(2\pi f s) \,ds\\ Y_{LI} &= \frac{1}{T}\int\limits^{T}_{0} U_{\rm in}(s) \sin(2\pi f s) \,ds \end{align}

and then I would get my phase using:

$$\theta_{LI} = \tan^{-1}\left(\frac{Y_{LI}}{X_{LI}}\right)$$

However, if I were to use an FFT, the FFT would evaluate

\begin{align} X_{FFT}(f) + iY_{FFT}(f) &= \int\limits_0^T U_{\rm in}(s)e^{-2\pi i s f}\,ds\\ &=\int\limits_0^T U_{\rm in}(s)\cos(2\pi f s)\,ds + i \int\limits_0^T U_{\rm in}(s)\sin(2\pi f s)\,ds \end{align}

Which seems to imply that just as with the lock-in amplifier, I would get

\begin{align} X_{FFT} &= \int^{T}_{0} U_{\rm in}(s) \cos(2\pi f s)\,ds = \frac{1}{T}X_{LI}\\ Y_{FFT} &= \int^{T}_{0} U_{\rm in}(s) \sin(2\pi f s)\,ds = \frac{1}{T}Y_{LI}\\ \theta_{FFT} &= \tan^{-1}\left(\frac{Y_{FFT}}{X_{FFT}}\right) = \tan^{-1}\left(\frac{Y_{LI}}{X_{LI}}\right) = \theta_{LI} \end{align}

• So does this mean that I would always get the same result whether I use a digital lock-in amplifier, or a digital FFT on the same data set?
• What is the benefit of using a lock-in amplifier?
• Is there no advantage to the lock-in amp in my application?
• What is then an example of an application that the lock-in amplifier is best suited for?

Is there a difference between the FFT and a lock-in amp?

Yes, two of them:

1. The FFT assumes the signal at its input to be periodic.

• What this means about your FFT integrals is that they are missing a phase variable (let's call it $\phi_r$) which will be random because it depends on the ratio of your signals period (or its frequency), the window of the FFT and the initial phase that the FFT will "catch" the signal on the first frame (and any subsequent phase changes whether desired or not). By the way, Frequency is integrated Phase.
• Consequently, your $\theta_{LI}$ will depend on that $\phi_r$ (which is all over the place).
• Intuitively now, the FFT assumes the signal to be periodic. That is, it repeats in the same way both to the left and to the right of the observation window. This is "alright" if the window happens to be an integer multiple of the signal's period but this is extremely unlikely because of noise and possible changes in the phase of the signal. It will therefore sound like a whistle with regular "pops" because of the discontinuities and at each "pop" the phase estimation will be disturbed. There are workarounds to this (and this one) and this brings us to the second difference.
2. There is a concept in the FFT called Spectral Resolution.

• Spectral resolution relates the physical frequencies (in Hz) with each of the distinct harmonics that the discrete FT evaluates its integrals at. Therefore, you would have to accurately calculate the length of the window of the FFT with respect to the sampling frequency and the frequency of the input signal so that it lands exactly on one of the bins. And after doing this of course, it would seem a waste to be evaluating the FT for all harmonics when all you are interested in is just one of them.

Having said this, let's try to tackle the rest of the questions:

So does this mean that I would always get the same result whether I use a digital lock-in amplifier, or a digital FFT on the same data set?

Provided that the above details are taken care of, the result will be almost identical. I say almost because there is another consequence from #1 above that is not exactly obvious. Even if you were to use overlap-add or overlap-save, you would still have no control over the initial phase at which the FFT would "catch" the incoming signal. And once the FFT "starts", it's own local oscillators are not going to adapt to the incoming signal. Therefore, both techniques would provide information about phase but the FFT's estimate would suffer by a systematic error proportional to the initial phase of the incoming signal. The lock-in amp takes care of this with its Phase-Locked-Loop (PLL). For (much) more information, please see this link.

What is the benefit of using a lock-in amplifier?

Should be becoming clearer by now. A lock-in amp can return amplitude, power and phase information at one specific frequency with the accuracy of its estimate depending on the clarity of the reference signal (the local oscillator).

Is there no advantage to the lock-in amp in my application?

On the contrary, there is a massive advantage. And this advantage is coming from the use of the PLL. The PLL is an automatic control system that adjusts the frequency (and therefore phase) of a local oscillator to match the frequency and phase of the incoming signal. It therefore can "adjust its frame of reference" and it returns much more accurate phase information.

What is then an example of an application that the lock-in amplifier is best suited for?