# Signal to Noise Ratio and You, Part 2

In Part 1, we discussed ways to get better measurements by improving the signal to noise ratio (SNR), and saw that although it was often a win to measure more slowly and use lowpass filters, going too far actually makes things worse, because of the way noise concentrates at low frequency.  Here we introduce a more sophisticated approach that generally works better: the lock-in amplifier.

We were considering a typical baseband signal, one that goes from near DC to some much higher frequency.  Audio is a typical example, with a bandwidth usually quoted as 20 Hz to 20 kHz.  To escape the low frequency noise, we need to move our signal up in frequency, out of baseband.  In lock-in detection we make the signal periodic in time at some carrier frequency fc chosen to be several times higher than the required bandwidth. This is generally pretty easy to do, as we'll see, and doing so ensures that none of the signal we care about remains near DC.  Our noise rejection filter now needs to be a narrow bandpass centered at fc,  so as to reject both low-and high-frequency noise.  We'll also need some means of measuring the amplitude and phase of the AC signal.  That's more complicated, of course, but with this setup we can narrow the bandwidth as much as we like and still get the full SNR improvement.  A lock-in amplifier is a device for making such narrow-band AC measurements conveniently.  It's basically a radio that measures the phase and amplitude of its input, so that we recover a lowpass-filtered version of the baseband modulation signal that we care about, with no 1/f noise pollution to worry about.   At this point we need to geek out a little bit and talk about modulation, which is what we mean by moving the signal away from baseband.

An AC signal that passes through a narrowish filter can be looked at as a sine wave with some amplitude and phase: g(t) = A cos(2π f t + φ), where the signal information is contained in slowish variations of A and φ, the amplitude and phase (the modulation). This is familiar from broadcast radio: you can send music and speech program material over the air by encoding it as amplitude modulation (AM) or frequency modulation (FM).  AM changes the heights of the peaks of the sinusoidal carrier wave in response to the audio signal (A varies), while FM changes the position of the peaks in time (φ varies). FM maps the baseband signal s(t) onto the instantaneous frequency, so dφ/dt is proportional to s(t).  In phase modulation (PM), which is less common in radios but more useful in measurements, the signal maps directly: φ is proportional to s(t).  The two are collectively known as angle modulation.

All types of modulation widen the carrier spectrum, forming sidebands above and below fc that carry the signal information. It's generally preferable to talk about AM and PM, especially in discussions of noise, because in PM a flat baseband spectrum produces flat sidebands, whereas in FM it doesn't.  That makes PM much easier to think about.

A  carrier with both AM and PM can be written as g(t) = A(t) cos( 2π fc t + φ(t) ), where  A and φ are slowly varying compared with fc.  From trigonometry, we know that

cos(a+b) = cos a cos b - sin a sin b, or in this case, cos( 2π fc t + φ ) = cos( 2π fc t ) cos φ - sin( 2π fc t  ) sin φ  (PM)

Thus by measuring the amplitudes of the sine and cosine components of the signal, we can recover its phase. Rearranging the same trigonometric identity shows us how to do this:

cos a cos b = ( cos(a-b) + cos(a+b) ) / 2  and

sin a sin b = ( cos(a-b) - cos(a+b) ) / 2.

Thus if we multiply our signal by local oscillator (LO) signals sin(2π fc t ) and cos(2πfc t ), we get

I = A cos φ cos(2π fc t)  cos(2π fc t ) = A cos φ  [cos(0) + cos(4π fc t )], which is I = A cos φ + (a signal near 2fc ), and

Q = A sin φ sin(2πfc t ) sin(2πfc t ) = A sin φ cos(0) cos(4πfc t ), which is Q = A sin φ + (another signal near 2fc ).

Lowpass filtering gets rid of the 2fc components of I and Q and rejects noise exactly as our narrow bandpass filter would, with the same tradeoff of bandwidth vs. measurement speed but without the excess low-frequency noise. Baseband signals I and Q are the so-called in-phase and quadrature phase signals,. (You can think of "quadrature" as referring to the signal shifted a quarter cycle, though it actually comes from an old term for integration: sin x is the integral of cos x.) (The LO is the same signal we'll use to modulate the measurement (using e.g. an optical chopper or something more intelligent), so there's no problem there.)

Thus the procedure of multiplying by the sine and cosine phases of the carrier converts the modulated carrier into a pair of baseband signals containing both the amplitude and phase information. Because of the lowpass filtering, the exact waveform of the modulated wave (sine, square, or something else) doesn't matter much--only sinusoidal components sufficiently close to fc contribute. This property of sines and cosines is called orthogonality. Very often only one of the two is of interest, usually I, but one can also recover A and φ easily:

A= √( I 2 + Q 2 ) and φ = tan-1(Q / I ).

(One has to worry about a few other things when computing φ, such as which quadrant it's in, whether you're dividing by zero, and whether it needs unwrapping to avoid ambiguities of multiples of 2π.) The multiplications also of course produce the cross terms, proportional to

cos(2πfc t ) sin(2πfc t ) = 1/2 sin(4π fc t ),

but these have no baseband component and so get filtered out as well, showing that the sine and cosine components are orthogonal even though their frequencies are the same.

The sine and cosine LO signals can be derived from a reference frequency that you supply, or generated internally. Generally this reference is the same source used to generate the AC modulation of the measured signal, but it'll still work even if the two are different (the frequency error will show up as a ramp in φ(t), of course).

So that's the general principle of how lock-in amplifiers can improve our SNR by narrowing the measurement bandwidth while avoiding the low-frequency noise.  In Part 3 we'll look at how that's done, in both analog and digital lock-in amplifiers.