SRS module
This module contains drivers for Stanford Research Systems devices. Currently, this includes the SR830 and SR850 lock-in amplifier models.
The SR8x0 class contains common API elements, while the SR830 and SR850 classes implement device-specific functions.
- class SRS.SR830(rm, address)[source]
Bases:
SR8x0Driver class for SR830 and SR830M devices. Supports both GPIB and serial connections. For the latter, the device must be set to RS-323 mode at 19200 baud.
- Parameters:
rm (pyvisa.ResourceManager) – Pass a pyvisa ResourceManager object to use for opening the device.
address (str) – VISA address of the SR830 device.
- getBinNum()[source]
Read number of points stored in acquisition buffer.
- Returns:
num – Number of elements in buffer.
- Return type:
int
- property inputMode
Gets or sets the input mode of the device. Possible values:
Value
Description
0
A (voltage)
1
A-B (differential voltage)
2
I (1 MΩ)
3
I (100 MΩ)
- Type:
int
- multiRead(ch1=None, ch2=None, t=1, srate=None, wait=False)[source]
Capture the given data on each channel for an amount of time and return the results.
- Parameters:
ch1 (str, optional) – Value to capture on channel 1. Possible values: “X”, “R”, “XNOISE”, “AUX1”, “AUX2”. Use None to disable this channel. The default is None.
ch2 (str, optional) – Value to capture on channel 1. Possible values: “Y”, “THETA”, “YNOISE”, “AUX3”, “AUX4”. Use None to disable this channel. The default is None.
t (float, optional) – Acqusition time in seconds. The default is 1.
srate (float, optional) – Sampling rate in Hz. If set to None, the highest available sampling rate is selected for the current time constant. The default is None.
wait (bool, optiona) – Whether to wait for all planned points to arrive. If True, it will extent the desired time if there are not enough points in the buffer. If False, will return all points gathered up until the desired timer is up. The default is False.
- Returns:
ch1 (list(float)) – List of floats containing the data from channel 1. None if acquisition is disabled for this channel.
ch2 (list(float)) – List of floats containing the data from channel 2. None if acquisition is disabled for this channel.
- readBuffer(buffer, start, length)[source]
Read a buffer from the device.
- Parameters:
i (int) – Buffer number. Must be one 1 or 2.
start (int) – Starting index. Elements are indexed from 0.
length (int) – Number of elements to read starting from index.
- Returns:
result – Buffer contents as a list of floats.
- Return type:
list(float)
- property reserve
Gets or sets reserve mode. 0 is high reserve, 1 is normal and 2 is low noise.
- Type:
int
- setDisplay(disp, target, ratio=0)[source]
Sets a specified display on the lock-in to a given value. Required for automated data collection.
- Parameters:
disp (int)
target (str) – Select value to be displayed. Possible values for display 1: “X”, “R”, “XNOISE”, “AUX1”, “AUX2”. Possible values for display 2: “Y”, “THETA”, “YNOISE”, “AUX3”, “AUX4”.
ratio (int, optional) – Display ratio. 0 is none, 1 is AUX1, 2 is AUX2. The default is 0.
- Returns:
success – True on success, False on failure.
- Return type:
bool
- snapshot(*args)[source]
Reads out at most 6 values simultaneously.
- Parameters:
*args (str) – At most 6 str arguments, each representing a measured quantitiy. See SR830._snapDict for valid options. Notable examples include ‘X’, ‘Y’, ‘R’ and ‘THETA’.
- Returns:
result – List of up to 6 values, corresponding to the passed arguments. None if a failure has occured.
- Return type:
list(float)
- property source
Gets or sets which frequency source is used. True is internal, False is external.
- Type:
bool
- class SRS.SR850(rm, address)[source]
Bases:
SR8x0- Parameters:
rm (pyvisa.ResourceManager) – Pass a pyvisa ResourceManager object to use for opening the device.
address (str) – VISA address of the SR850 device.
- getTraceLength(i)[source]
Get the length of a trace.
- Parameters:
i (int,) – Trace number. Must be in 1-4.
- Returns:
num – Number of values in the selected trace
- Return type:
int
- getTraceSource(i)[source]
Get trace definition.
- Parameters:
i (int) – Trace number. Must be in 1-4.
- Returns:
source – A list of 3 int values representing the source values. See SR850._traceDict for a conversion table.
- Return type:
list(int):
- property inputMode
Gets or sets the input mode of the device. Possible values:
Value
Description
0
A (voltage)
1
A-B (differential voltage)
2
I (1 MΩ)
3
I (100 MΩ)
- Type:
int
- multiRead(tr1=None, tr2=None, tr3=None, tr4=None, t=1.0, srate=None, wait=False)[source]
Record a trace on up to 4 channels at a time.
- Parameters:
tr1 (str, optional) – Trace definition. If None, do not record anything on trace 1. For valid options, see the keys of SR850._traceDict. Notable examples include ‘X’, ‘Y’, ‘R’ and ‘THETA’.
tr2 (str, optional) – Trace definition. Same as tr1, but for channel 2.
tr3 (str, optional) – Trace definition. Same as tr1, but for channel 3.
tr4 (str, optional) – Trace definition. Same as tr1, but for channel 4.
t (float, default: 1.0) – Total acquisition time in seconds.
srate (float, optional) – Acquisition sample rate. If none, the highest meaningful sample rate will be used for the given time constant. If the given value is too fast for the time constant, it will be clamped.
wait (bool, default: False) – Whether to account for communication overhead when calculating wait time. When False, a few samples might be missing, especially at high sampling rates.
- Returns:
results – A list of results. The list contains 4 elements, corresponding to traces 1-4.and Each element is itself a list of floats, containing the trace data. If a given trace is disabled, its value will be None.
- Return type:
list(list(float))
- readTrace(i, start, length)[source]
Read a trace from the device.
- Parameters:
i (int) – Trace number. Must be one of 1, 2, 3 or 4.
start (int) – Starting index. Elements are indexed from 0
length (int) – Number of elements to read starting from index.
- Returns:
result – Resulting trace as a list of floats.
- Return type:
list(float)
- property reserve
Gets or sets reserve mode. 0 is minimum reserve, 5 is maximum.
- Type:
int
- setTraceSource(i, target, multiply=0, divide=0, store=True)[source]
Sets the trace source.
- Parameters:
i (int) – Trace number. Must be in 1-4.
target (int or str) – Value to be measured. If str, it will be decoded to the device’s option index using SR850._traceDict. Notable examples include ‘X’, ‘Y’, ‘R’ and ‘THETA’.
multiply (int or str, default: 0) – Value to divide the target with. Works the same as target. The default value of 0 corresponds to unity (‘1’), so no multiplication will be performed.
divide (int or str, default: 0) – Value to divide the target with. Works the same as target. The default value of 0 corresponds to unity (‘1’), so no division will be performed.
- snapshot(*params)[source]
Emulates the snapshot function of the SR830. Does not actually guarantee that the samples are taken at the same time. If syncronization is required, use multiRead.
- Parameters:
*args (str) – Multiple str arguments, each representing a measured quantitiy. See SR850._snapDict for valid options. Notable examples include ‘X’, ‘Y’, ‘R’, ‘THETA’ and ‘REF’.
- Returns:
result – List of floats, corresponding to the passed arguments. None if a failure has occured.
- Return type:
list(float)
- property source
Gets or sets the reference frequency source. 0 is internal, 1 is internal sweep and 2 is external.
- Type:
int
- class SRS.SR8x0[source]
Bases:
object- property DC
Gets or sets DC coupling. True is DC, False is AC.
- Type:
bool
- enableTrigger(state=True)[source]
Enable back panel trigger for automatic acquisition
- Parameters:
state (bool) – Whether or not back panel triggering is enabled.
- property freq
Get or set the oscillator frequency in Hz
- Type:
float
- getFreq()[source]
Get the internal oscillator frequency.
- Returns:
freq – LO frequency.
- Return type:
float
- getSamplerate()[source]
Query the device for the currently set sampling rate.
- Returns:
i (int) – Index of frequency setting
f (float) – Sampling frequency in Hz.
- getSensitivity()[source]
Get the sensitivity of the device.
- Returns:
index (int) – Index of sensitvity setting. Negative values indicate current mode.
sens (float) – Achieved sensitivity in volts or amperes.
- getTau()[source]
Query the device for the currently set time constant.
- Returns:
i (int) – Index of time constant setting.
t (float) – Time constant in seconds.
- property grounding
Gets or sets grounded coupling. True is grounded, False is floating.
- Type:
bool
- property notchFilter
Gets or sets noth filter. 0 is neither, 1 is line, 2 is 2line, 3 is both.
- Type:
int
- property phase
Get or set the oscillator phase in degrees
- Type:
float
- queryASCIIFloat(cmd)[source]
Query a list of float values from the device. Parse the response as ASCII floats.
- Parameters:
cmd (str) – Command to send to the device.
- Returns:
response – A set of floating point values returned by the instrument.
- Return type:
list(float)
- queryBinary(cmd)[source]
Query a list of binary values from the device.
- Parameters:
cmd (str) – Command to send to the device.
- Returns:
response – A set of raw bytes returned by the instrument.
- Return type:
bytes
- queryBinaryFloat(cmd)[source]
Query a list of float values from the device. Parse the response as binary floats.
- Parameters:
cmd (str) – Command to send to the device.
- Returns:
response – A set of floating point values returned by the instrument.
- Return type:
list(float)
- property sampleRate
Gets or sets the sample rate in Hz.
- Type:
float
- setFreq(freq)[source]
Set the internal oscillator frequency.
- Parameters:
freq (float) – Target frequency.
- Returns:
success – True if successful.
- Return type:
bool
- setSampleRate(target=None)[source]
Sets a specified sample rate for automatic acquisition.
- Parameters:
target (None, str or int) – Target sample rate. If None, set highest rate that is meaninful with the current time constant. If str, try to parse it based on the translation table (see SR8x0M._srateDF). If int, set it directly (see translation table or instrument manual).
- Return type:
Achieved sample rate in Hz (float). Trigger mode corresponds to 0, while -1 indicates a failure.
- setSensitivity(target, setMode=True)[source]
Sets a specified sensitivity.
- Parameters:
target (str or int) – If str, try to parse it based on the translation table (see SR830M._sensDF). If int, set it directly (see translation table or instrument manual). Negative values indicate current measurement mode.
setMode (Bool, default: True) – Whether to automatically set the input mode. Defaults to A in voltage mode and I (100 MΩ) in current mode. Set to False for more granular control.
- Returns:
sens (float) – Achieved sensitivity (float). -1 indicates an error.
current (Bool) – Voltage (False) or current (True) mode
- setSensitivityA(target, **kwargs)[source]
Sets the sensitivity in amperes.
- Parameters:
target (float) – Target sensitivity in A.
setMode (Bool, default: True) – Whether to automatically set the input mode to current. Defaults to 100 MΩ mode if True.
- Returns:
sens (float) – Achieved sensitivity in volts or amperes. -1 indicates an error.
current (Bool) – Voltage (False) or current (True) mode.
- setSensitivityV(target, **kwargs)[source]
Sets the sensitivity in volts.
- Parameters:
target (float) – Target sensitivity in V.
setMode (Bool, default: True) – Whether to automatically set the input mode to voltage. Defaults to A mode if True.
- Returns:
sens (float) – Achieved sensitivity in volts or amperes. -1 indicates an error.
current (Bool) – Voltage (False) or current (True) mode.
- setTau(target)[source]
Sets a specified time constant.
- Parameters:
target (str or int) – If str, try to parse it based on the translation table (see SR8x0M._srateDF). If int, set it directly (see translation table or instrument manual).
- Return type:
Achieved time constant (float). -1 indicates an error.
- property slope
Gets or sets the low pass filter slope. Possible values:
Value
Slope
0
6 dB/oct
1
12 dB/oct
2
18 dB/oct
3
24 dB/oct
- Type:
int
- property tau
Get or set the time constant in seconds
- Type:
float