1.2.1. Lock-in amplifiers: wanglib.instruments.lockins

Lock-in amplifiers are commonly used for sensitive detection of a modulated voltage signal. They enable us to measure both the amplitude and phase of a signal, which we can access in either the cartesian (X, Y) or polar (R, phase) basis.

This module provides interfaces to two brands of lock-in, using two corresponding classes.

Note

The methods implemented by these two classes are named the same, but don’t always behave the same way. For example, the EG&G 5110 returns a 2-tuple with unit when the ADC ports are queried, but the SRS 830 always returns a figure in volts.

Warning

I’m working toward parity between the return value formats of the two classes. This will make it easier to switch between lock-ins, but will break existing code!

class wanglib.instruments.lockins.egg5110(bus)

An EG&G model 5110 lock-in.

Typically controlled over GPIB, address 12. Instantiate like:

>>> li = egg5110(plx.instrument(12))

where plx is a prologix controller. pyVISA instruments should also work fine.

autophase()

Automatically adjust the reference phase to maximize the X signal and minimize Y.

get_ADC(n)

Read one of the four ADC ports. Return value in volts.

get_phase()

Get current value of the phase, in degrees.

get_r()

Get current value of R, in volts.

get_sensitivity(unit='V')

Get the current sensitivity, in Volts.

>>> li.get_sensitivity()
0.1

If the unit kwarg is specified, the value will be converted to the desired unit instead.

>>> li.get_sensitivity(unit='uV')
100000.

Using unit=True will return a value in a 2-tuple along with the most sensible unit (as a string).

>>> li.get_sensitivity(unit=True)
(100, 'mV')
get_timeconst()

Get the current time constant (as a 2-tuple).

get_x()

Get current value of X, in volts.

get_y()

Get current value of Y, in volts.

lights

Boolean. Turns the front panel lights on or off.

measure(command, unit='V')

Measure one of the usual voltage signals (X, Y, or MAG).

>>> li.measure('X')
0.0014

Results are given in volts. To specify a different unit, use the unit kwarg.

>>> li.measure('X', unit='mV')
1.4

To skip this conversion, and instead return the result as a fraction of the sensitivity (what the manual calls “percent of full-scale”), specify unit=None:

>>> li.measure('X', unit=None)
.14

You will need to multiply by the sensitivity (in this example, 10mV) to get a meaningful number. To perform this multiplication automatically, specify unit=True:

>>> li.measure('X', unit=True)
(1.4, 'mV')

This returns a 2-tuple containing the measurement and the unit string (“V”, “mV”, etc.),

Note

to provide an answer in real units, the EG&G 5110 needs to be queried for its sensitivity on every single measurement. This can slow things down. If you need to make measurements quickly, and are using a fixed sensitivity, specify unit=None for speed.

phase

Get current value of the phase, in degrees.

r

Get current value of R, in volts.

sensitivities = {0: (100, 'nV'), 1: (200, 'nV'), 2: (500, 'nV'), 3: (1, 'uV'), 4: (2, 'uV'), 5: (5, 'uV'), 6: (10, 'uV'), 7: (20, 'uV'), 8: (50, 'uV'), 9: (100, 'uV'), 10: (200, 'uV'), 11: (500, 'uV'), 12: (1, 'mV'), 13: (2, 'mV'), 14: (5, 'mV'), 15: (10, 'mV'), 16: (20, 'mV'), 17: (50, 'mV'), 18: (100, 'mV'), 19: (200, 'mV'), 20: (500, 'mV'), 21: (1, 'V')}
sensitivity

Get the current sensitivity, in Volts.

>>> li.get_sensitivity()
0.1

If the unit kwarg is specified, the value will be converted to the desired unit instead.

>>> li.get_sensitivity(unit='uV')
100000.

Using unit=True will return a value in a 2-tuple along with the most sensible unit (as a string).

>>> li.get_sensitivity(unit=True)
(100, 'mV')
set_sensitivity(code)

Set the current sensitivity (Using a code).

set_timeconst(code)

Set the current time constant (Using a code).

timeconst

Get the current time constant (as a 2-tuple).

timeconsts = {0: (0, 'MIN'), 1: (1, 'ms'), 2: (3, 'ms'), 3: (10, 'ms'), 4: (30, 'ms'), 5: (100, 'ms'), 6: (300, 'ms'), 7: (1, 's'), 8: (3, 's'), 9: (10, 's'), 10: (30, 's'), 11: (100, 's'), 12: (300, 's')}
x

Get current value of X, in volts.

y

Get current value of Y, in volts.

class wanglib.instruments.lockins.srs830(bus)

A Stanford Research Systems model SR830 DSP lock-in.

Typically controlled over GPIB, address 8. Instantiate like:

>>> li = srs830(plx.instrument(8))

where plx is a prologix controller. pyVISA instruments should also work fine.

ADC_cmd = 'OAUX?%d'
ADC_range = (1, 2, 3, 4)
DAC_range = (1, 2, 3, 4)
get_ADC(n)

read one of the ADC ports. Return value in volts.

get_DAC(n)

read one of the DAC ports. Return value in volts.

get_r()
get_x()
get_y()
measure(command)

Measure one of the usual signals (X, Y, or MAG).

Results are given in units of volts or degrees.

measurements = {'Y': 2, 'X': 1, 'R': 3, 'MAG': 3}
r
set_DAC(n, value)

set one of the DAC ports. Provide value in volts.

x
y