Usage Examples

Simple Measurement

This examples shows a simple measurement script, using a Stanford Research Systems LockIn amplifier and is discussed in more detail in the Quickstart section.

#!/usr/bin/env python
import time

from slave.srs import SR830
from slave.transport import Visa

lockin = SR830(Visa('GPIB::08'))
lockin.frequency = 22.08
lockin.amplitude = 5.0
lockin.reserve = 'high'
for i in range(60):
    print lockin.x

Magnetotransport Measurement

In this example, we assume a sample with standard four terminal wiring is placed inside a Quantum Desing PPMS. We’re using our own Lock-In amplifier to measure the resistance as a function of temperature.

"""This example shows a measurement routine for a custom magnetotransport setup
in the [P]hysical [P]roperties [M]easurement [S]ystem PPMS Model 6000.

import datetime

import visa

from slave.quantum_design import PPMS
from slave.sr830 import SR830
from slave.transport import Visa # pyvisa wrapper
from slave.misc import Measurement

# Connect to the lockin amplifier and the ppms
lockin = SR830(Visa('GPIB::10'))
ppms = PPMS(Visa('GPIB::15'))

    # Configure the lockin amplifier
    lockin.frequency = 22.08  # Use a detection frequency of 22.08 Hz
    lockin.amplitude = 5.0    # and an amplitude of 5 V.
    lockin.reserve = 'low'
    lockin.time_constant = 3

    # Set the ppms temperature to 10 K, cooling with a rate of 20 K per min.
    ppms.set_temperature(10, 20, wait_for_stability=True)
    # Now sweep slowly to avoid temperature instabilities.
    ppms.set_temperature(1.2, 0.5, wait_for_stability=True)
    # Set a magnetic field of 1 T at a rate of 150 mT per second and set the magnet
    # in persistent mode.
    # Note: The PPMS uses Oersted instead of Tesla. 1 Oe = 0.1 mT.
    ppms.set_field(10000, 150, mode='persistent', wait_for_stability=True)

    # Set the appropriate gain. (We're assuming the measured voltage decreases
    # with increasing temperature.

    # Define the measurement parameters
    parameters = [
        lambda:, # Get timestamp
        lambda: lockin.x,
        lambda: lockin.y,
        lambda: ppms.temperature,
    # Finally start the measurement, using the Measurement helper class as a
    # context manager (This automatically closes the measurement file).
    with Measurement('1.2K-300K_1T.dat', measure=parameters) as measurement:
        ppms.scan_temperature(measurement, 300, 0.5)
except Exception, e:
    # Catch possible errors and print a message.
    print 'An error occured:', e
    # Finally put the ppms in standby mode.

Differential Conductance

In this example we’re showing how to use the Keithley K6221 currentsource and K2182 nanovoltmeter combo to perform a differential conductance measurement.

"""This example shows a differential conductance measurement.

In this example we're showing how to use the Keithley :class:`~.K6221`
currentsource and :class:`~.K2182` nanovoltmeter combo to perform a differential
conductance measurement.

# To use the ethernet connection instead of the GPIB interface import Socket
# instead of Visa
from slave.transport import Visa
# We don't need to import the nanovoltmeter driver, the K6221 does this for us.
from slave.keithley import K6221

current_source = K6221(Visa('GPIB::22'))
# Note: The nanovoltmeter has to be connected to the K6221 with the serial and
# trigger link cable.
nanovolt_meter = current_source.system.communicate.serial.k2182

# Now configure the nanovoltmeter.
nanovolt_meter.sense.auto_range = True
nanovolt_meter.sense.nplc = 1

# Then configure the current source
current_source.source.differential_conductance.start = 0     # start at 0 A
current_source.source.differential_conductance.step = 1e-6   # 10 uA steps
current_source.source.differential_conductance.stop = 50e-6  # stop at 50 uA = 20e-6 # 20 uA delta
current_source.source.differential_conductance.delay = 1e-3  # 1 ms delay
current_source.source.differential_conductance.compliance_abort = True
current_source.trace.points = 6

# Finally we read back the measurements
data =[:]