Keithley driver

Core driver with the low level functions.

exception keithley_driver.KeithleyIOError

Bases: Exception

Raised when no Keithley instrument is connected.

exception keithley_driver.KeithleyError

Bases: Exception

Raised for error messages from the Keithley itself.

class keithley_driver.Keithley2600Base(visa_address: str, visa_library: str = '@py', raise_keithley_errors: bool = False, **kwargs)

Bases: keithley_driver.KeithleyClass

Keithley2600 driver

Keithley driver for base functionality. It replicates the functionality and syntax from the Keithley TSP commands, as provided by the Lua scripting language. Attributes are created on-demand if they correspond to Keithley TSP commands.

Parameters
  • visa_address – Visa address of the instrument.

  • visa_library – Path to visa library. Defaults to “@py” for pyvisa-py but another IVI library may be appropriate (NI-VISA, Keysight VISA, R&S VISA, tekVISA etc.). If an empty string is given, an IVI library will be used if installed and pyvisa-py otherwise.

  • raise_keithley_errors – If True, all Keithley errors will be raised as Python errors instead of being ignored. This causes significant communication overhead because the Keithley’s error queue is read after each command. Defaults to False.

  • kwargs – Keyword arguments passed on to the visa connection, for instance baude-rate or timeout. If not given, reasonable defaults will be used.

Variables
  • connection – Attribute holding a reference to the actual connection.

  • connectedTrue if connected to an instrument, False otherwise.

  • busyTrue if a measurement is running, False otherwise.

  • CHUNK_SIZE – Maximum length of lists which can be sent to the Keithley. Longer lists will be transferred in chunks.

Note

See the Keithley 2600 reference manual for all available commands and arguments. A dictionary of available commands will be loaded on access from the Keithley at runtime, if connected.

Examples
>>> keithley = Keithley2600Base('TCPIP0::192.168.2.121::INSTR')
>>> keithley.smua.measure.v()  # measures voltage at smuA
>>> keithley.smua.source.levelv = -40  # applies -40V to smuA
connect(**kwargs) → bool

Connects to Keithley.

Parameters

kwargs – Keyword arguments for Visa connection.

Returns

Whether the connection succeeded.

disconnect() → None

Disconnects from Keithley.

class keithley_driver.Keithley2600(visa_address: str, visa_library: str = '@py', raise_keithley_errors: bool = False, **kwargs)

Bases: keithley_driver.Keithley2600Base

Keithley2600 driver with high level functionality

Keithley driver with access to base functions and higher level functions such as IV measurements, transfer and output curves, etc. Inherits from Keithley2600Base. Base commands replicate the functionality and syntax of Keithley TSP functions.

Parameters
  • visa_address – Visa address of the instrument.

  • visa_library – Path to visa library. Defaults to “@py” for pyvisa-py but another IVI library may be appropriate (NI-VISA, Keysight VISA, R&S VISA, tekVISA etc.). If an empty string is given, an IVI library will be used if installed and pyvisa-py otherwise.

  • raise_keithley_errors – If True, all Keithley errors will be raised as Python errors instead of being ignored. This causes significant communication overhead because the Keithley’s error queue is read after each command. Defaults to False.

  • kwargs – Keyword arguments passed on to the visa connection, for instance baude-rate or timeout. If not given, reasonable defaults will be used.

Variables
  • connection – Attribute holding a reference to the actual connection.

  • connectedTrue if connected to an instrument, False otherwise.

  • busy (bool) – True if a measurement is running, False otherwise.

Examples

Base commands from Keithley TSP:

>>> k = Keithley2600('TCPIP0::192.168.2.121::INSTR')
>>> volts = k.smua.measure.v()  # measures and returns the smuA voltage
>>> k.smua.source.levelv = -40  # sets source level of smuA
>>> k.smua.nvbuffer1.clear()  # clears nvbuffer1 of smuA

New mid-level commands:

>>> data = k.read_buffer(k.smua.nvbuffer1)
>>> errs = k.read_error_queue()
>>> k.set_integration_time(k.smua, 0.001) # in sec
>>> k.apply_voltage(k.smua, -60) # applies -60V to smuA
>>> k.apply_current(k.smub, 0.1) # sources 0.1A from smuB
>>> k.ramp_to_voltage(k.smua, 10, delay=0.1, step_size=1)
>>> # voltage sweeps, single and dual SMU
>>> k.voltage_sweep_single_smu(smu=k.smua, smu_sweeplist=range(0, 61),
...                         t_int=0.1, delay=-1, pulsed=False)
>>> k.voltage_sweep_dual_smu(smu1=k.smua, smu2=k.smub,
...                       smu1_sweeplist=range(0, 61),
...                       smu2_sweeplist=range(0, 61),
...                       t_int=0.1, delay=-1, pulsed=False)

New high-level commands:

>>> data1 = k.output_measurement(...) # records output curve
>>> data2 = k.transfer_measurement(...) # records transfer curve
apply_current(smu: keithley_driver.KeithleyClass, curr: float) → None

Turns on the specified SMU and sources a current.

Parameters
  • smu – A keithley smu instance.

  • curr – Current to apply in Ampere.

apply_voltage(smu: keithley_driver.KeithleyClass, voltage: float) → None

Turns on the specified SMU and applies a voltage.

Parameters
  • smu – A keithley smu instance.

  • voltage – Voltage to apply in Volts.

property busy

True if a measurement is running, False otherwise.

measure_current(smu: keithley_driver.KeithleyClass) → float

Measures a current at the specified SMU.

Parameters

smu – A keithley smu instance.

Returns

Measured current in Ampere.

measure_voltage(smu: keithley_driver.KeithleyClass) → float

Measures a voltage at the specified SMU.

Parameters

smu – A keithley smu instance.

Returns

Measured voltage in Volts.

output_measurement(smu_gate: keithley_driver.KeithleyClass, smu_drain: keithley_driver.KeithleyClass, vd_start: float, vd_stop: float, vd_step: float, vg_list: Sequence[float], t_int: float, delay: float, pulsed: bool) → keithley2600.result_table.FETResultTable

Records an output curve with forward and reverse sweeps and returns the results in a sweep_data.TransistorSweepData instance.

Parameters
  • smu_gate – Keithley smu attached to gate electrode.

  • smu_drain – Keithley smu attached to drain electrode.

  • vd_start (float) – Start voltage of output sweep in Volt.

  • vd_stop (float) – End voltage of output sweep in Volt.

  • vd_step (float) – Voltage step size for output sweep in Volt.

  • vg_list – List of gate voltage steps in Volt. Can be a numpy array, list, tuple, range / xrange.

  • t_int (float) – Integration time per data point. Must be between 0.001 to 25 times the power line frequency (50Hz or 60Hz).

  • delay (float) – Settling delay before each measurement. A value of -1 automatically starts a measurement once the current is stable.

  • pulsed (bool) – Select pulsed or continuous sweep. In a pulsed sweep, the voltage is always reset to zero between data points.

Returns

Output curve data.

play_chord(notes: Tuple[str, ...] = ('C6', 'E6', 'G6'), durations: Union[float, Iterable[float]] = 0.3) → None

Plays a chord on the Keithley.

Parameters
  • notes – List of notes in scientific pitch notation, for instance ['F4', 'Ab4', 'C4'] for a f-minor chord in the 4th octave. Defaults to c-major in the 6th octave.

  • durations – List of durations for each note in sec. If a single float is given, all notes will have the same duration. Defaults to 0.3 sec.

ramp_to_voltage(smu: keithley_driver.KeithleyClass, target_volt: float, delay: float = 0.1, step_size: float = 1) → None

Ramps up the voltage of the specified SMU.

Parameters
  • smu – A keithley smu instance.

  • target_volt – Target voltage in Volts.

  • step_size – Size of the voltage steps in Volts.

  • delay – Delay between steps in sec.

static read_buffer(buffer: keithley_driver.KeithleyClass) → List[float]

Reads buffer values and returns them as a list. This can be done more quickly by calling buffer.readings but such a call may fail due to I/O limitations of the keithley if the returned list is too long.

Parameters

buffer – A keithley buffer instance.

Returns

A list with buffer readings.

read_error_queue() → List[Tuple[Union[float, str, bool, None, keithley_driver._LuaFunction, keithley_driver._LuaTable], ...]]

Returns all entries from the Keithley error queue and clears the queue.

Returns

List of errors from the Keithley error queue. Each entry is a tuple (error_code, message, severity, error_node). If the queue is empty, an empty list is returned.

send_trigger() → None

Manually sends a trigger signal to the Keithley. This can be used for instance to start a pre-programmed sweep.

set_integration_time(smu: keithley_driver.KeithleyClass, t_int: float) → None

Sets the integration time of SMU for measurements in sec.

Parameters
  • smu – A keithley smu instance.

  • t_int – Integration time in sec. Value must be between 1/1000 and 25 power line cycles (50Hz or 60 Hz).

Raises

ValueError for too short or too long integration times.

transfer_measurement(smu_gate: keithley_driver.KeithleyClass, smu_drain: keithley_driver.KeithleyClass, vg_start: float, vg_stop: float, vg_step: float, vd_list: Sequence[float], t_int: float, delay: float, pulsed: bool) → keithley2600.result_table.FETResultTable

Records a transfer curve with forward and reverse sweeps and returns the results in a sweep_data.TransistorSweepData instance.

Parameters
  • smu_gate – Keithley smu attached to gate electrode.

  • smu_drain – Keithley smu attached to drain electrode.

  • vg_start – Start voltage of transfer sweep in Volt.

  • vg_stop – End voltage of transfer sweep in Volt.

  • vg_step – Voltage step size for transfer sweep in Volt.

  • vd_list – List of drain voltage steps in Volt. Can be a numpy array, list, tuple, range / xrange. Optionally, you can also pass the string "trailing" for the drain voltage to always follow the gate voltage. This ensures that the FET is always at the edge of “saturation”.

  • t_int – Integration time per data point. Must be between 0.001 to 25 times the power line frequency (50Hz or 60Hz).

  • delay – Settling delay before each measurement. A value of -1 automatically starts a measurement once the current is stable.

  • pulsed (bool) – Select pulsed or continuous sweep. In a pulsed sweep, the voltage is always reset to zero between data points.

Returns

Transfer curve data.

voltage_sweep_dual_smu(smu1: keithley_driver.KeithleyClass, smu2: keithley_driver.KeithleyClass, smu1_sweeplist: Sequence[float], smu2_sweeplist: Sequence[float], t_int: float, delay: float, pulsed: bool) → Tuple[List[float], List[float], List[float], List[float]]

Sweeps voltages at two SMUs. Measures and returns current and voltage during sweep.

Parameters
  • smu1 – 1st keithley smu instance to be swept.

  • smu2 – 2nd keithley smu instance to be swept.

  • smu1_sweeplist – Voltages to sweep at smu1 (can be a numpy array, list, tuple or any other iterable with numbers).

  • smu2_sweeplist – Voltages to sweep at smu2 (can be a numpy array, list, tuple or any other iterable with numbers).

  • t_int – Integration time per data point. Must be between 0.001 to 25 times the power line frequency (50Hz or 60Hz).

  • delay – Settling delay before each measurement. A value of -1 automatically starts a measurement once the current is stable.

  • pulsed – Select pulsed or continuous sweep. In a pulsed sweep, the voltage is always reset to zero between data points.

Returns

Lists of voltages and currents measured during the sweep (in Volt and Ampere, respectively): (v_smu1, i_smu1, v_smu2, i_smu2).

voltage_sweep_single_smu(smu: keithley_driver.KeithleyClass, smu_sweeplist: Sequence[float], t_int: float, delay: float, pulsed: bool) → Tuple[List[float], List[float]]

Sweeps the voltage through the specified list of steps at the given SMU. Measures and returns the current and voltage during the sweep.

Parameters
  • smu – A keithley smu instance.

  • smu_sweeplist – Voltages to sweep through (can be a numpy array, list, tuple or any other iterable of numbers).

  • t_int – Integration time per data point. Must be between 0.001 to 25 times the power line frequency (50Hz or 60Hz).

  • delay – Settling delay before each measurement. A value of -1 automatically starts a measurement once the current is stable.

  • pulsed – Select pulsed or continuous sweep. In a pulsed sweep, the voltage is always reset to zero between data points.

Returns

Lists of voltages and currents measured during the sweep (in Volt and Ampere, respectively): (v_smu, i_smu).