Keithley driver¶
Core driver with the low level functions.
-
exception
keithley_driver.
KeithleyIOError
[source]¶ Bases:
Exception
Raised when no Keithley instrument is connected.
-
exception
keithley_driver.
KeithleyError
[source]¶ Bases:
Exception
Raised for error messages from the Keithley itself.
-
class
keithley_driver.
Keithley2600Base
(visa_address, visa_library='@py', raise_keithley_errors=False, **kwargs)[source]¶ Bases:
keithley_driver.MagicClass
Keithley2600 driver
Keithley driver for base functionality. It replicates the functionality and syntax from the Keithley TSP commands, which have a syntax similar to python. Attributes are created on-access if they correspond to Keithley TSP type commands.
Parameters: - visa_address (str) – Visa address of the instrument.
- visa_library (str) – PyVisa backend specification. Defaults to “@py” for pyvisa-py but NI-VISA may be appropriate, depending on the interface type.
- raise_keithley_errors (bool) – 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 toFalse
. - 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.
- connected (bool) –
True
if connected to an instrument,False
otherwise. - busy (bool) –
True
if a measurement is running,False
otherwise. - TO_TSP_LIST (list) – List of python types which will be converted to
Keithley TSP lists by this driver and can be used as inputs. Currently,
those are
list
,numpy.ndarray
,tuple
,set
andrange
(xrange
in Python 2). - CHUNK_SIZE (int) – 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. Almost all Keithley TSP commands can be used with this driver. Not supported are:
lan.trigger[N].connected
: conflicts with the connected attributeio.output()
: conflicts withsmuX.source.output
- All Keithley IV sweep commands. We implement our own in
Keithley2600
.
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
-
class
keithley_driver.
Keithley2600
(visa_address, visa_library='@py', raise_keithley_errors=False, **kwargs)[source]¶ 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 (str) – Visa address of the instrument.
- visa_library (str) – PyVisa backend specification. Defaults to “@py” for pyvisa-py but NI-VISA may be appropriate, depending on the interface type.
- raise_keithley_errors (bool) – 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 toFalse
. - kwargs – Keyword arguments passed on to the visa connection, for instance baude-rate or timeout. If not given, reasonable defaults will be used.
Variables: 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.readBuffer(k.smua.nvbuffer1) >>> errs = k.readErrorQueue() >>> k.setIntegrationTime(k.smua, 0.001) # in sec
>>> k.applyVoltage(k.smua, -60) # applies -60V to smuA >>> k.applyCurrent(k.smub, 0.1) # sources 0.1A from smuB >>> k.rampToVoltage(k.smua, 10, delay=0.1, step_size=1)
>>> # voltage sweeps, single and dual SMU >>> k.voltageSweepSingleSMU(smu=k.smua, smu_sweeplist=range(0, 61), ... t_int=0.1, delay=-1, pulsed=False) >>> k.voltageSweepDualSMU(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.outputMeasurement(...) # records output curve >>> data2 = k.transferMeasurement(...) # records transfer curve
-
readErrorQueue
()[source]¶ 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.Return type: list
-
static
readBuffer
(buffer)[source]¶ 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. Return type: list
-
setIntegrationTime
(smu, t_int)[source]¶ Sets the integration time of SMU for measurements in sec.
Parameters: - smu – A keithley smu instance.
- t_int (float) – 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.
-
applyVoltage
(smu, voltage)[source]¶ Turns on the specified SMU and applies a voltage.
Parameters: - smu – A keithley smu instance.
- voltage (float) – Voltage to apply in Volts.
-
applyCurrent
(smu, curr)[source]¶ Turns on the specified SMU and sources a current.
Parameters: - smu – A keithley smu instance.
- curr (float) – Current to apply in Ampere.
-
measureVoltage
(smu)[source]¶ Measures a voltage at the specified SMU.
Parameters: smu – A keithley smu instance. Returns: Measured voltage in Volts. Return type: float
-
measureCurrent
(smu)[source]¶ Measures a current at the specified SMU.
Parameters: smu – A keithley smu instance. Returns: Measured current in Ampere. Return type: float
-
rampToVoltage
(smu, target_volt, delay=0.1, step_size=1)[source]¶ Ramps up the voltage of the specified SMU. Beeps when done.
Parameters:
-
voltageSweepSingleSMU
(smu, smu_sweeplist, t_int, delay, pulsed)[source]¶ 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 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: Lists of voltages and currents measured during the sweep (in Volt and Ampere, respectively):
(v_smu, i_smu)
.Return type:
-
voltageSweepDualSMU
(smu1, smu2, smu1_sweeplist, smu2_sweeplist, t_int, delay, pulsed)[source]¶ 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 range / xrange). - smu2_sweeplist – Voltages to sweep at
smu2
(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: Lists of voltages and currents measured during the sweep (in Volt and Ampere, respectively):
(v_smu1, i_smu1, v_smu2, i_smu2)
.Return type:
-
transferMeasurement
(smu_gate, smu_drain, vg_start, vg_stop, vg_step, vd_list, t_int, delay, pulsed)[source]¶ 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 (float) – Start voltage of transfer sweep in Volt.
- vg_stop (float) – End voltage of transfer sweep in Volt.
- vg_step (float) – 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.
- 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: Transfer curve data.
Return type: sweep_data.TransistorSweepData
-
outputMeasurement
(smu_gate, smu_drain, vd_start, vd_stop, vd_step, vg_list, t_int, delay, pulsed)[source]¶ 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.
Return type: sweep_data.TransistorSweepData
-
playChord
(notes=('C6', 'E6', 'G6'), durations=0.3)[source]¶ Plays a chord on the Keithley.
Parameters: - notes (list) – 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 (float or list) – 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.
- notes (list) – List of notes in scientific pitch notation, for
instance