# Lock-in amplifier

1. Mar 15, 2012

### Niles

Hi

Usually when a lock-in amplifier is introduced to students, it is done when the input signal is a harmonic function and the reference is one as well. This is a nice concept, and it is easy to see how a DC-term propotional to the (desired) incident amplitude can be obtained.

My question is, say my input signal is a square wave. Then I can decompose it into a Fourier series. I was wondering how to get a DC-term containing the incident amplitude out via phase sensitive detection in this case.

What I would say is that I can decompose the input signal and reference into their respective Fourier series. They will have the same harmonics. Then I would mix them, and this would give me a DC-component for each harmonic in the Fourier expansion. Is this the explanation?

Best,
Niles.

2. Mar 15, 2012

### f95toli

Is this a theoretical of practical question?
What will happen depends on what type of lock-in you are using.
E.g. RF lock-ins usually prefer a square-wave reference even if the input is sinusoidal.

I would suggest locking in the manuals for the Stanford Research SR830 and SR844 (I use both types), they both have pretty good explanation for how they work,

edit: the SR website www.thinksrs.com

3. Mar 15, 2012

### Niles

It is just a theoretical question. I haven't ever seen a lock-in amplifier in real life, I just come across them all the time in the litterature.

Best,
Niles.

4. Mar 15, 2012

Well I don't know how the lock in amplifier was introduced to you, but I find square waves much easier to understand.... Anyhow how the beast works:

The lock in reference output is any periodic function f(t) that fulfils:

$$\int_0^T f(t) dt = 0$$

Where T is the period. Let us assume that it is also normalized (otherwise we'd have to divide by some number)

$$\int_0^T f(t)^2 dt = 1$$

If we multiply the input with the reference and integrate we have a scalar product in the Hilbert space.

$$\left< f(t),g(t) \right> =\int_0^T f(t)g(t) dt$$

This is exactly what the lock in does. It gets the projection of the input signal onto the reference signal this way. The integration is usually done with a low pass filter, (this changes the measure of the integral a bit, but those are details...). You can get some phase sensitive detection if:

$$\left< f(t-T/4),g(t) \right> = 0$$

Which will give you two so called "quadrature components" of the reference signal or you manually adjust the phase shift (=time shift) until you get the maximum signal and see what the phase is.

For a square wave it is really easy. So the reference signal oscillates between say +1 and -1. If the input signal and the reference are in phase. The input signal changes sign at the same moment. So if you multiply the two numbers you always get the same positive value. If you integrate over it, then you get exactly the amplitude of the input signal. The phase detection is simply done by time shifting the reference. So there appear negative dips and the integral decreases until you are at T/4 when the negative dips and the positive ones cancel exactly and the integral is zero, if you shift further the signal becomes negative.

I do not know what the lock in manufacturers call phase, if the reference is not a sine wave. The "true phase" in my eyes would be the time shift of the input signal divided by the period times two pi, but I suppose it will usually be easier to use the arctan of the in-phase signal and the 90° shifted signal.

As you have probably noticed a phase shifted (=time shifted) signal will have different phase shifts on all the different frequency components so the Fourier transform dis not really useful for determining the phase.

5. Mar 18, 2012

### Niles

Thanks for taking the time to write that. The way I was introduced to it was by looking at a reference given by
$$V_{ref}\sin(\omega t+\Theta_{ref})$$
If the signal is varied harmonically with a frequency the same as the reference, then we get the amplitude of the signal out after mixing the terms and using a proper low-pass filter. So this explanation is pretty trivial. I am not sure where in this process the inner product is taken though.

I like yours a lot more, it is more detailed. However, I have to admit that I'm not 100% sure how the PSD works.

Do you have a reference for these things?

Best,
Niles.

Last edited: Mar 18, 2012
6. Mar 18, 2012

Sorry, but I don't have an English reference. Looking at the recommended manual is probably a pretty good idea.

The inner product is taken by the nonlinearity of the mixer if it is not done digitally.

If the input output relation is something like

$$V_\text{out} = \alpha_0 + \alpha_1 V_\text{in} +\alpha_2 V_\text{in}^2 + O(V_\text{in}^3)$$

Then the quadratic term will produce a multiplication.
$$V_\text{in} = V_\text{reference} + V_\text{signal}$$
$$V_\text{in}^2 = V_\text{reference}^2 + 2V_\text{signal}\cdot V_\text{reference} + V_\text{signal}^2$$

(You can see the mixed multiplication term in the middle)
Again. You can do the phase sensitive detection by changing the phase of your signal with a variable delay or an adjustable all pass filter, and adjust until you have the maximum signal.

The other way is to rewrite your signal
$$V_\text{ref} = \sin (\omega t + \Theta) = \cos(\Theta)\sin(\omega t) + \sin(\Theta)\cos(\omega t) =\beta_1\sin(\omega t) + \beta_2\cos(\omega t)$$

If you now find the two coefficients $$\beta_1,\beta_2$$ by projecting to the two quadrature components sin and cos. Then you can calculate the phase $$\Theta = \arctan \frac{\beta_2}{\beta_1}$$ With square waves you can do something similar, but in that case the result is not the phase, just something close to it.

7. Mar 18, 2012

### marcusl

Phase sensitive detection is often/usually done with devices that act like mixers, in the sense that they switch between states -1 and +1 rapidly when the reference voltage changes sign. Obviously a square wave reference r(t) commutates the switching elements; a sine wave reference is effectively converted to a square wave and also commutates the switch. The PSD output is then
$$y(t)=\int{x(t) \mathrm{\ signum}[r(t)] dt}$$
You can easily work out how both sine- and square-wave inputs x result, after low-pass filtration, in a DC output.

BTW, an RF mixer does the same. The sinusoidal local oscillator level is chosen to drive the mixer diodes rapidly into saturation, producing a "square wave" commutating action like the one described above.

8. Mar 19, 2012

### f95toli

There are -from a "practical" point of view- two ways to think about lock-ins; depending on the application.

*As a tunable band-pass filter, with the centre frequency given by the reference frequency and the BW by the time-constant/filter steepness.

*As a down-converting mixer with a tunable phase difference between the RF and the LO, and built in amplification both at the RF and IF stage (and the "distribution" of amplification set by the "dynamic reserve" button).

The latter way of thinking about is is quite useful if you are working at high frequencies (where a lock-in quite sometimes is used in place of an ordinary mixer), whereas the former is better for low frequencies/DC.

9. Mar 19, 2012

### marcusl

It is useful to point out that Robert Dicke's original lock-in, developed during World War II for microwave radiometry, operated at 30 Hz. The utility of locking in to a frequency, and of phase sensitive detection, extends to even lower frequencies as well.