# DSP 7265 Lock-in Amplifier

class pymeasure.instruments.signalrecovery.DSP7265(adapter, name='Signal Recovery DSP 7265', **kwargs)

  Bases: `DSPBase`

  Represents the Signal Recovery DSP 7265 lock-in amplifier.

  Class inherits commands from the DSPBase parent class and utilizes dynamic properties for various properties and includes additional functionality.

      lockin7265 = DSP7265("GPIB0::12::INSTR")
      lockin7265.imode = "voltage mode"       # Set to measure voltages
      lockin7265.reference = "internal"       # Use internal oscillator
      lockin7265.fet = 1                      # Use FET pre-amp
      lockin7265.shield = 0                   # Ground shields
      lockin7265.coupling = 0                 # AC input coupling
      lockin7265.time_constant = 0.10         # Filter time set to 100 ms
      lockin7265.sensitivity = 2E-3           # Sensitivity set to 2 mV
      lockin7265.frequency = 100              # Set oscillator frequency to 100 Hz
      lockin7265.voltage = 1                  # Set oscillator amplitude to 1 V
      lockin7265.gain = 20                    # Set AC gain to 20 dB
      print(lockin7265.x)                     # Measure X channel voltage
      lockin7265.shutdown()                   # Instrument shutdown

  property adc1

    Measure the voltage of the ADC1 input on the rear panel.

    Returned value is a floating point number in volts.

  property adc2

    Measure the voltage of the ADC2 input on the rear panel.

    Returned value is a floating point number in volts.

  property adc3

    Measure the ADC3 input voltage.

  property adc3_time

    Control the ADC3 sample time in seconds.

  property auto_gain

    Control lock-in amplifier for automatic AC gain.

  auto_phase()

    Adjusts the reference absolute phase to maximize the X channel output and minimize the Y channel output signals.

  auto_sensitivity()

    Adjusts the full-scale sensitivity so signal’s magnitude lies between 30 - 90 % of full-scale.

  buffer_to_float(buffer_data, sensitivity=None, sensitivity2=None, raise_error=True)

    Converts fixed-point buffer data to floating point data.

    The provided data is converted as much as possible, but there are some requirements to the data if all provided columns are to be converted; if a key in the provided data cannot be converted it will be omitted in the returned data or an exception will be raised, depending on the value of raise_error.

    The requirements for converting the data are as follows:

    - Converting X, Y, magnitude and noise requires sensitivity data, which can either be part of the provided data or can be provided via the sensitivity argument

    - The same holds for X2, Y2 and magnitude2 with sensitivity2.

    - Converting the frequency requires both ‘frequency part 1’ and ‘frequency part 2’.

    Parameters:

      - buffer_data (dict) – The data to be converted. Must be in the format as returned by the get_buffer method: a dict of numpy arrays.

      - sensitivity – If provided, the sensitivity used to convert X, Y, magnitude and noise. Can be provided as a float or as an array that matches the length of elements in buffer_data. If both a sensitivity is provided and present in the buffer_data, the provided value is used for the conversion, but the sensitivity in the buffer_data is stored in the returned dict.

      - sensitivity2 – Same as the first sensitivity argument, but for X2, Y2, magnitude2 and noise2.

      - raise_error (bool) – Determines whether an exception is raised in case not all keys provided in buffer_data can be converted. If False, the columns that cannot be converted are omitted in the returned dict.

    Returns:

      Floating-point buffer data

    Return type:

      dict

  check_errors()

    Read all errors from the instrument and log them.

    Returns:

      List of error entries.

  check_get_errors()

    Check for errors after having gotten a property and log them.

    Called if `check_get_errors=True` is set for that property.

    If you override this method, you may choose to raise an Exception for certain errors.

    Returns:

      List of error entries.

  check_set_errors()

    Check for errors after having set a property and log them.

    Called if `check_set_errors=True` is set for that property.

    If you override this method, you may choose to raise an Exception for certain errors.

    Returns:

      List of error entries.

  clear()

    Clears the instrument status byte

  property complete

    Get the synchronization bit.

    This property allows synchronization between a controller and a device. The Operation Complete query places an ASCII character 1 into the device’s Output Queue when all pending selected device operations have been finished.

  property coupling

    Control the input coupling mode.

    Valid values are 0 for AC coupling mode or 1 for DC coupling mode.

  property curve_buffer_bits

    Control which data outputs are stored in the curve buffer.

    Valid values are values are integers between 1 and 65,535 (or 2,097,151 in dual reference mode). (dynamic)

  property curve_buffer_interval

    Control the time interval between the collection of successive points in the curve buffer.

    Valid values to the time interval are integers in ms with a resolution of 5 ms; input values are rounded up to a multiple of 5. Valid values are values between 0 and 1,000,000,000 (corresponding to 12 days). The interval may be set to 0, which sets the rate of data storage to the curve buffer to 1.25 ms/point (800 Hz). However this only allows storage of the X and Y channel outputs. There is no need to issue a CBD 3 command to set this up since it happens automatically when acquisition starts.

  property curve_buffer_length

    Control the length of the curve buffer.

    Valid values are integers between 1 and 32,768, but the actual maximum amount of points is determined by the amount of curves that are stored, as set via the curve_buffer_bits property (32,768 / n).

  property curve_buffer_status

    Measure the status of the curve buffer acquisition.

    Command returns four values: First value - Curve Acquisition Status: Number with 5 possibilities: 0: no activity 1: acquisition via TD command running 2: acquisition by a TDC command running 5: acquisition via TD command halted 6: acquisition bia TDC command halted Second value - Number of Sweeps Acquired: Number of sweeps already acquired. Third value - Status Byte: Decimal representation of the status byte (the same response as the ST command Fourth value - Number of Points Acquired: Number of points acquired in the curve buffer.

  property dac1

    Control the voltage of the DAC1 output on the rear panel.

    Valid values are floating point numbers between -12 to 12 V.

  property dac2

    Control the voltage of the DAC2 output on the rear panel.

    Valid values are floating point numbers between -12 to 12 V.

  property dac3

    Control the voltage of the DAC3 output on the rear panel.

    Valid values are floating point numbers between -12 to 12 V.

  property dac4

    Control the voltage of the DAC4 output on the rear panel.

    Valid values are floating point numbers between -12 to 12 V.

  property fet

    Control the voltage preamplifier transistor type.

    Valid values are 0 for bipolar or 1 for FET.

  property frequency

    Control the oscillator frequency.

    Valid values are floating point numbers representing the frequency in Hz. (dynamic)

  property gain

    Control the AC gain of signal channel amplifier.

  get_buffer(quantity=None, convert_to_float=True, wait_for_buffer=True)

    Retrieves the buffer after it has been filled. The data retrieved from the lock-in is in a fixed-point format, which requires translation before it can be interpreted as meaningful data. When convert_to_float is True the conversion is performed (if possible) before returning the data.

    Parameters:

      - quantity (str) – If provided, names the quantity that is to be retrieved from the curve buffer; can be any of: ‘x’, ‘y’, ‘magnitude’, ‘phase’, ‘sensitivity’, ‘adc1’, ‘adc2’, ‘adc3’, ‘dac1’, ‘dac2’, ‘noise’, ‘ratio’, ‘log ratio’, ‘event’, ‘frequency part 1’ and ‘frequency part 2’; for both dual modes, additional options are: ‘x2’, ‘y2’, ‘magnitude2’, ‘phase2’, ‘sensitivity2’. If no quantity is provided, all available data is retrieved.

      - convert_to_float (bool) – Bool that determines whether to convert the fixed-point buffer-data to meaningful floating point values via the buffer_to_float method. If True, this method tries to convert all the available data to meaningful values; if this is not possible, an exception will be raised. If False, this conversion is not performed and the raw buffer-data is returned.

      - wait_for_buffer (bool) – Bool that determines whether to wait for the data acquisition to finished if this method is called before the acquisition is finished. If True, the method waits until the buffer is filled before continuing; if False, the method raises an exception if the acquisition is not finished when the method is called.

  property harmonic

    Control the reference harmonic mode.

    Valid values are integers. (dynamic)

  property id

    Measure the model number of the instrument.

    Returned value is an integer.

  property imode

    Control the lock-in amplifier to detect a voltage or current signal.

    Valid values are `voltage mode, ``current mode`, or `low noise current mode`.

  init_curve_buffer()

    Initializes the curve storage memory and status variables. All record of previously taken curves is removed.

  property log_ratio

    Measure the log (base 10) of the ratio between the X channel and ADC1.

    Returned value is a unitless floating point number equivalent to the mathematical expression log(X/ADC1).

  property mag

    Measure the magnitude of the signal.

    Returned value is a floating point number in volts.

  property next_error

    Get the next error of the instrument (tuple of code and message).

  property options

    Get the device options installed.

  property phase

    Measure the signal’s absolute phase angle.

    Returned value is a floating point number in degrees.

  property ratio

    Measure the ratio between the X channel and ADC1.

    Returned value is a unitless floating point number equivalent to the mathematical expression X/ADC1.

  read(**kwargs)

    Read the response and remove extra unicode character from instrument readings.

  read_binary_values(**kwargs)

    Read binary values from the device.

  read_bytes(count, **kwargs)

    Read a certain number of bytes from the instrument.

    Parameters:

      - count (int) – Number of bytes to read. A value of -1 indicates to read the whole read buffer.

      - kwargs – Keyword arguments for the adapter.

    Returns bytes:

      Bytes response of the instrument (including termination).

  property reference

    Control the oscillator reference input mode.

    Valid values are `internal`, `external rear` or `external front`.

  property reference_phase

    Control the reference absolute phase angle.

    Valid values are floating point numbers between 0 - 360 degrees.

  reset()

    Resets the instrument.

  property sensitivity

    Control the signal’s measurement sensitivity range.

    When in voltage measurement mode, valid values are discrete values from 2 nV to 1 V. When in current measurement mode, valid values are discrete values from 2 fA to 1 µA (for normal current mode) or up to 10 nA (for low noise current mode).

  setChannelAMode()

    Sets lock-in amplifier to measure a voltage signal only from the A input connector.

  setDifferentialMode(lineFiltering=True)

    Sets lock-in amplifier to differential mode, measuring A-B.

  set_buffer(points, quantities=None, interval=0.01)

    Prepares the curve buffer for a measurement.

    Parameters:

      - points (int) – Number of points to be recorded in the curve buffer

      - quantities (list) – List containing the quantities (strings) that are to be recorded in the curve buffer, can be any of: ‘x’, ‘y’, ‘magnitude’, ‘phase’, ‘sensitivity’, ‘adc1’, ‘adc2’, ‘adc3’, ‘dac1’, ‘dac2’, ‘noise’, ‘ratio’, ‘log ratio’, ‘event’, ‘frequency’ (or ‘frequency part 1’ and ‘frequency part 2’); for both dual modes, additional options are: ‘x2’, ‘y2’, ‘magnitude2’, ‘phase2’, ‘sensitivity2’. Default is ‘x’ and ‘y’.

      - interval (float) – The interval between two subsequent points stored in the curve buffer in s. Default is 10 ms.

  set_voltage_mode()

    Sets lock-in amplifier to measure a voltage signal.

  property shield

    Control the input connector shield state.

    Valid values are 0 to have shields grounded or 1 to have the shields floating (i.e., connected to ground via a 1 kOhm resistor).

  shutdown()

    Safely shutdown the lock-in amplifier.

    Sets oscillator amplitude to 0 V and AC gain to 0 dB.

  property slope

    Control the low-pass filter roll-off.

    Valid values are the integers 6, 12, 18, or 24, which represents the slope of the low-pass filter in dB/octave.

  start_buffer()

    Initiates data acquisition. Acquisition starts at the current position in the curve buffer and continues at the rate set by the STR command until the buffer is full.

  property status

    Get the status byte and Master Summary Status bit.

  property time_constant

    Control the filter time constant.

    Valid values are a strict set of time constants from 10 us to 50,000 s. Returned values are floating point numbers in seconds.

  property voltage

    Control the oscillator amplitude.

    Valid values are floating point numbers between 0 to 5 V.

  wait_for(query_delay=None)

    Wait for some time. Used by ‘ask’ to wait before reading.

    Parameters:

      query_delay – Delay between writing and reading in seconds. None is default delay.

  wait_for_buffer(timeout=None, delay=0.1)

    Method that waits until the curve buffer is filled

  write(command, **kwargs)

    Write a string command to the instrument appending write_termination.

    Parameters:

      - command – command string to be sent to the instrument

      - kwargs – Keyword arguments for the adapter.

  write_binary_values(command, values, *args, **kwargs)

    Write binary values to the device.

    Parameters:

      - command – Command to send.

      - values – The values to transmit.

      - **kwargs (*args,) – Further arguments to hand to the Adapter.

  write_bytes(content, **kwargs)

    Write the bytes content to the instrument.

  property x

    Measure the output signal’s X channel.

    Returned value is a floating point number in volts.

  property xy

    Measure both the X and Y channels.

    Returned values are floating point numbers in volts.

  property y

    Measure the output signal’s Y channel.

    Returned value is a floating point number in volts.