# Lock-in Amplifier & Square Wave: How to Get DC-term?

• Niles
In summary: Thanks for your input!In summary, the lock-in amplifier works by decomposing the input signal into its harmonics and then locking in the reference to get a DC-term containing the incident amplitude. The integration is usually done with a low-pass filter to get the projection of the input signal onto the reference.
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?

Niles.

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

f95toli said:
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
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.

Niles.

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.

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?Niles.

Last edited:
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.

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.

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.

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 into a frequency, and of phase sensitive detection, extends to even lower frequencies as well.

## 1. What is a lock-in amplifier?

A lock-in amplifier is an electronic device used to measure and amplify a small AC signal that is buried in noise. It consists of a mixer, low-pass filter, and amplifier, and is used in a wide range of scientific and engineering applications.

## 2. How does a lock-in amplifier work?

A lock-in amplifier works by multiplying the input signal with a reference signal, which is typically a square wave. The result is a DC signal that contains only the information at the same frequency as the reference signal. This DC signal is then passed through a low-pass filter to remove any remaining noise.

## 3. What is the purpose of using a square wave in a lock-in amplifier?

The square wave is used as the reference signal in a lock-in amplifier because it is a periodic signal with a well-defined frequency and phase. This allows the lock-in amplifier to extract the signal of interest from the noise and amplify it, while rejecting all other noise signals that do not match the reference frequency and phase.

## 4. How do I get the DC-term from a lock-in amplifier?

The DC-term is the amplified output from the lock-in amplifier, which contains the information at the reference frequency and phase. It can be obtained by connecting a voltmeter or oscilloscope to the output of the lock-in amplifier.

## 5. What are the applications of a lock-in amplifier?

Lock-in amplifiers are commonly used in scientific research, particularly in fields such as physics, chemistry, and biology. They are used to measure weak signals in the presence of noise, making them useful for studying phenomena such as magnetic fields, atomic and molecular spectroscopy, and biological signals. They are also used in engineering applications, such as signal processing and communication systems.

• Electrical Engineering
Replies
5
Views
594
• Electrical Engineering
Replies
10
Views
929
• Electrical Engineering
Replies
10
Views
2K
• Electrical Engineering
Replies
3
Views
3K
• Electrical Engineering
Replies
6
Views
3K
• Electrical Engineering
Replies
2
Views
4K
• Electrical Engineering
Replies
28
Views
4K
• Electrical Engineering
Replies
3
Views
5K
• Electrical Engineering
Replies
4
Views
4K
• Electrical Engineering
Replies
15
Views
2K