devctrl.devices.lock_in.impl.sr830.SR830#

class SR830(instr, check_front_switch=True)[source]#

Bases: LockInAmp

Wrapper class for the SR830 controlled via pyvisa

Methods

add_device

Manually add a specific device.

allow_only_dummy_devices

auto_gain

buffer_get_data

Retrieve data from the buffer

buffer_get_data_2

DEPRECATED Get the data from the buffer.

buffer_get_max_size

Get the maximum buffer size for storing samples

buffer_get_n_points

Query the number of points in the buffer :return:

buffer_is_done

Check if the target number of points are in the buffer

buffer_setup

Configure buffer settings for data acquisition

buffer_setup_2

Prepare the device for a buffer (curve) measurement

buffer_start_fill

Start a buffer measurement that was previously configured with buffer_setup()

buffer_stop_fill

Stop the current buffer measurement

check_overloads

Check if bits 0,1,2 in the LIA status register are set.

connect

connect_device

This function should be overridden by device implementations only, and is not intended to be used directly.

connect_dummy

Connect an instance of the device's dummy implementation

decrease_full_scale_sensitivity_volt

Decreases the full-scale sensitivity (output signal range) :return: The new full-scale sensitivity

decrease_time_constant_s

Decreases the time constant :return: The new time constant

get_base_classes

Return a flat dictionary of all base classes below this class :param recurse: If True, recursively search for base classes :return: dict of {class name: class}

get_device_name

get_device_type_name

get_filter_slope

get_frequency_Hz

get_next_valid_sample_rate_Hz

Get the highest valid sample rate not exceeding the target

get_reference_trigger

get_reserve

get_sensitivity_volt

get_status

Query the status of the device and return a string describing errors.

get_sync_filter

get_time_constant_s

get_wait_time_s

Calculate wait time to reach 99% of final value

increase_full_scale_sensitivity_volt

Increases the full-scale sensitivity (output signal range) :return: The new full-scale sensitivity

increase_time_constant_s

Increases the time constant :return: The new time constant

is_connected

Query whether the device is (still) connected

list_devices

Get a list of all devices for this type.

query

read_get_wait_time_s

Get the wait time required to reach 99% of the final value

read_value

Read a single value from the lock-in amplifier

reset

run

Run SCPI code on the device by writing it

run_and_check

Run a command and check for errors

set_filter_slope

set_frequency_Hz

set_reference

set_reference_trigger

set_reserve

set_sensitivity_volt

set_sync_filter

set_time_constant_s

snap

Acquire a snapshot of multiple instrument values

start_check_overloads

Clear the LIA status byte by reading it

try_recover_from_communication_error

Try to get into a normal state by flushing the output queue and reading the instrument status

Attributes

ADC

BUFFER_MAX_LENGTH

CH1

CH2

OFLT

OUTP

SRAT

VALID_FILTER_SLOPE

VALID_REFERENCE

VALID_REFERENCE_TRIGGER

VALID_RESERVE

VALID_SENSITIVITY_VOLT

VALID_SYNC_FILTER

classmethod add_device(connect_info)#

Manually add a specific device. The device will show up when list_devices() is called for the device type. Call this from the device class implementation, e.g. use ModelXYZ9000.add_device(‘GPIB:1234:5678’) to add a specific device with a fixed GPIB address. This is useful when automatic discovery is undesired/impossible, either because it is not implemented or it disturbs other devices which can’t handle a identification request. :param cls: The device implementation class :param connect_info: A string argument that is passed to the connect() method of the device implementation, when the device is being connected.

buffer_get_data(start=0, n_points: int | None = None)[source]#

Retrieve data from the buffer

Parameters:
  • start – Starting index for data retrieval

  • n_points – Number of points to retrieve. None for all available points

Returns:

NumPy array of shape [Q, N] where Q is number of quantities (same order as configured in ``what```parameter in buffer_setup() and N is number of points

buffer_get_data_2(CH1=True, CH2=True, start=0, n_points: int | None = None)[source]#

DEPRECATED Get the data from the buffer. :return: np.ndarray | tuple[np.ndarray, np.ndarray]

buffer_get_max_size(n_values: int) int[source]#

Get the maximum buffer size for storing samples

Parameters:

n_values – Number of values stored per sample

Returns:

Maximum number of samples the buffer can hold

buffer_get_n_points(dont_log=True) int[source]#

Query the number of points in the buffer :return:

buffer_is_done() bool[source]#

Check if the target number of points are in the buffer

buffer_setup(what=['R', 'theta'], length=None, sample_rate_Hz=512)[source]#

Configure buffer settings for data acquisition

Parameters:
  • what – List of quantities to measure (e.g., [‘R’, ‘theta’])

  • length – Number of samples to acquire.

  • sample_rate_Hz – Sample rate in Hz

buffer_setup_2(CH1='R', CH2='theta', length=None, sample_rate_Hz=512)[source]#

Prepare the device for a buffer (curve) measurement

Parameters:
  • CH1 – Source of channel 1: X, R, X Noise, Aux In 1, Aux In 2 or None to use the current source

  • CH2 – Source of channel 2: Y, theta, Y Noise, Aux In 3, Aux In 4 or None to use the current source

  • length – Number of values to store in the buffer, or None to use the maximum number of values

  • sample_rate_Hz – Sample rate in Hz or “Trigger”, see SR830 Manual

buffer_start_fill()[source]#

Start a buffer measurement that was previously configured with buffer_setup()

buffer_stop_fill()[source]#

Stop the current buffer measurement

check_overloads() str[source]#

Check if bits 0,1,2 in the LIA status register are set.

You should clear the register using “start_check_overloads()” when your measurement starts. :return: String describing which kind of overload occurred, or empty string if none occured

classmethod connect(device_type_name: str, device_name: str | None, **kwargs) Device#
Parameters:
  • device_type_name – The name of the device class

  • device_name – The name of the device class

classmethod connect_device(device_name)[source]#

This function should be overridden by device implementations only, and is not intended to be used directly. Instead, use list_devices() to get a list of devices, and pass the selected device type and name to connect() :param device_name: The name of the device class

classmethod connect_dummy(**kwargs) Device#

Connect an instance of the device’s dummy implementation

decrease_full_scale_sensitivity_volt() float[source]#

Decreases the full-scale sensitivity (output signal range) :return: The new full-scale sensitivity

decrease_time_constant_s() float[source]#

Decreases the time constant :return: The new time constant

classmethod get_base_classes(recurse=True) dict[str, type[Device]]#

Return a flat dictionary of all base classes below this class :param recurse: If True, recursively search for base classes :return: dict of {class name: class}

classmethod get_device_name() str#
Returns:

The specific type name of the device, e.g., SR830 or Keithly2600

classmethod get_device_type_name() str#
Returns:

The general type name of the device, e.g., Lock-In Amplifier or Voltmeter

get_next_valid_sample_rate_Hz(target_sample_rate_Hz: int | float) int | float[source]#

Get the highest valid sample rate not exceeding the target

Parameters:

target_sample_rate_Hz – Desired sample rate in Hz

Returns:

The highest valid sample rate ≤ target_sample_rate_Hz

get_status() str#

Query the status of the device and return a string describing errors. If everything is ok, empty string must be returned :return: String of device status

classmethod get_wait_time_s(time_const: float, filter_slope: int)#

Calculate wait time to reach 99% of final value

This method implements the SR830 filter slope timing rules. Subclasses with different filter slopes must override this method.

Parameters:
  • time_const – Time constant in seconds

  • filter_slope – Filter slope in dB/octave (6, 12, 18, or 24)

Returns:

Wait time in seconds

Raises:

ValueError – If filter_slope is invalid

increase_full_scale_sensitivity_volt() float[source]#

Increases the full-scale sensitivity (output signal range) :return: The new full-scale sensitivity

increase_time_constant_s() float[source]#

Increases the time constant :return: The new time constant

is_connected() bool[source]#

Query whether the device is (still) connected

classmethod list_devices() list[tuple[str, str]]#

Get a list of all devices for this type. The list made up of: - Manually added devices - Available devices (those returned by _enumerate_devices) - A dummy device (if a dummy implementation exists) - List of all devices of child classes

Returns:

list of available devices

read_get_wait_time_s(time_const: float | None = None, filter_slope: int | None = None)#

Get the wait time required to reach 99% of the final value

Uses the rule of thumb from SR830 manual to wait 5 time constants (page 6-35) depending on the filter slope. See SR830 Manual 3-21.

Parameters:
  • time_const – Time constant in seconds. If None, read from device

  • filter_slope – Filter slope in dB/octave. If None, read from device

Returns:

Wait time in seconds to reach 99% of final value

read_value(which: str, dont_log=True)[source]#

Read a single value from the lock-in amplifier

Parameters:

which – Which value to read. Must be one of ‘X’, ‘Y’, ‘R’, ‘theta’

Returns:

The requested value

run(code, split=True)[source]#

Run SCPI code on the device by writing it

Empty lines, leading whitespaces and lines starting with ‘ or # are ignored.

Parameters:
  • code – SCPI commands to execute

  • split – If True, split commands by newline and execute separately

run_and_check(cmd)[source]#

Run a command and check for errors

Executes a command on the device and checks the standard event status byte for execution errors or illegal commands. Raises RuntimeError if errors are detected.

Parameters:

cmd – SCPI command to execute

Raises:
  • RuntimeError – If execution error or illegal command detected

  • pyvisa.VisaIOError – If VISA communication fails

snap(what='3,4,5,7')[source]#

Acquire a snapshot of multiple instrument values

Takes a single measurement of the specified quantities and returns them as a list.

Parameters:

what – Comma-separated list of value indices to measure (1-11). Default: “3,4,5,7”

Returns:

List of measured values in the order requested

start_check_overloads()[source]#

Clear the LIA status byte by reading it

try_recover_from_communication_error(original_error)[source]#

Try to get into a normal state by flushing the output queue and reading the instrument status