pylab_ml.smu.keithley.keithley2602.Keithley2602

class Keithley2602(addr=None, interface=None, backend=None, identify=True, instName=None)[source]

Bases: Keithley

Interface to the dual channel Power-Measuremet-Unit (SMU) Keithley2602.

Date:

June 16, 2026

Author:

Semi-ATE <info@Semi-ATE.org>

../_images/kethley2602.jpg

The Keithley2602 can source and sink power in all four voltage/current quadrants and measure voltage and current precisely on dual channels a & b.

__init__(addr=None, interface=None, backend=None, identify=True, instName=None)[source]

Connect and initialize Keithley2602 instrument.

Parameters:
  • addr (int) – Interface address

  • interface (Interface) – GPIB, USBSerial

  • backend (str) – VISA backend is either @ni’ for NI-Library or @py’ for pure python pyvisa-py backend. On default it uses @ni’ on win32 and @py’ on other platforms.

  • identify (bool) – If True, query the instrument ID and print it to the log.

  • instName (string) – Instance Name from parent.

Example: Initialization
>>> vdd = Keithley2602(addr=24)  # GPIB or USB address
>>>                              #  validate displayed message Id on device
>>> vdd.init()                   # connect and initialize instrument
Example: Voltage source
>>> vdd.i_clamp = 0.01           # current protection
>>> vdd.voltage = 3.3            # set output voltage
>>> i = vdd.current              # measure (supply) current
Example: Current source
>>> vdd.v_clamp = 5              # voltage protection
>>> vdd.current = 0.1            # set output current_range
>>> v = vdd.voltage              # measure voltage

Methods

__init__([addr, interface, backend, ...])

Connect and initialize Keithley2602 instrument.

channel([ch])

Set channel A or B.

clear()

Clear error status.

clearbuffer(ch)

Clear the instrument buffer.

close()

Close the connection and switch off all outputs.

com_recover([fix])

Detect & attempt to recover out of step communication (maybe after timeout).

error_list()

List of instrument errors.

find_names()

find_names() returns list of identifiers strings, lhs of = assignments

get_values([typ])

Transfer last requested measurement sweep results.

help()

Print the docstring of the instrument class.

identify([showInstName])

Identify message.

init([identify])

Connect to Keithley instrument and initialize.

local()

Switch back to local instrument control.

message([message])

Message display about Keithley instrument.

mfilter(input)

mqtt_add(client, instrument[, liste, qos])

Add the instrument to mqtt.

mqtt_disconnect()

Remove the instrument from mqtt.

off()

Deactivate output.

on()

Reactivate output.

publish(topic, value)

Publish topic as type='cmd' with payload=value.

publish_get(function_name, value)

Publish function_name as type='get' with paylad=value.

publish_set(function_name, value)

Publish function_name as type='set' with paylad=value.

reset()

Reset and switch beep off.

scriptin(msg)

A multiline LUA script needs to have -- comments correctly handled and newlines.

scripts()

Upload specific functionality : sweep DUT.

setup_inst()

Start setup instrument settings, called from class instruments.

stair_sweep(start, stop, dstep[, stime, ...])

Sweep V or I, measure v,i,r at time t with state s, change by dstep, steptime stime, wait for response.

Attributes

A

B

I_autorange

Autorange drive current on or off.

I_range

Set the current driver range (A).

V_autorange

Autorange drive voltage on or off.

V_range

Set the voltage driver range (V).

ch

Get or Set channel A or B.

command

current

Get or set output current.

i_autorange

Autorange current measurement on or off.

i_clamp

Set the current clamping (A), will adjust current measurement range.

i_range

Set the current measurement range (A).

id

Query IDN.

instName

Return with instname or instname[ch] if it has channels.

interchoices

measure

Get or set measure.

measurecnt

Set/get the number of measurement to be carried out in a loop.

mqtt_enable

mqtt_list

mqtt_status

Getter for the mqtt_status.

nplc

Set the conversion number of power line cycles accuracy, for all converters.

onoff

Set/get on state from output (True).

stair_slope

stair_slope to target or target, slope_time using previous stair_sweep() parameters.

stair_step

Set incremental ramp to target or (target,dstep) or (target,dstep,stime).

v_autorange

Autorange voltage measurement on or off.

v_clamp

Set the voltage clamping (V), will adjust voltage measurement range.

v_range

Set the voltage measurement range (V).

voltage

Get or set output voltage.

property I_autorange

Autorange drive current on or off.

property I_range

Set the current driver range (A).

property V_autorange

Autorange drive voltage on or off.

property V_range

Set the voltage driver range (V).

property ch

Get or Set channel A or B.

channel(ch='A')[source]

Set channel A or B.

clear()

Clear error status.

clearbuffer(ch)[source]

Clear the instrument buffer.

close()[source]

Close the connection and switch off all outputs.

com_recover(fix=False)[source]

Detect & attempt to recover out of step communication (maybe after timeout). Can lose coherency between read request and data, usually because of Timeout. This routine can diagnose such loss of coherency and attempt to fix it, when fix=True.

Parameters:

fix (bool) – If True, the method will attempt to recover from out-of-step communication by consuming unexpected responses until it regains coherency. If False, it will only detect and report the issue without attempting recovery.

Returns:

True if communication is coherent (i.e., the response matches the expected value), False if it is not coherent. If fix is True, it will return True after attempting recovery, even if it had to consume unexpected responses to regain coherency.

Return type:

bool

property current

Get or set output current. If the current is set the output is switched on immediately.

Returns:

value(float)

Return type:

output current (in A).

error_list()[source]

List of instrument errors.

find_names()

find_names() returns list of identifiers strings, lhs of = assignments

Returns:

obj_names – List of identifier strings

Return type:

list of str

get_values(typ='')[source]

Transfer last requested measurement sweep results. Get response of previous stair_sweep(), choosing result rows from previous request typ.

Parameters:

typ (str) – String with “vir” flags (VOLTAGE,CURRENT,RESISTANCE) defining the measurements to be returned. For example, “v” for voltage, “i” for current, “r” for resistance, “vi” for voltage and current, etc.

Returns:

Numpy array of measured values corresponding to the “vir” flags in typ, with shape (len(typ), number of steps). For example, if typ is “vi”, the returned array will have two rows: the first row for voltage measurements and the second row for current measurements, with columns corresponding to each step in the previous stair_sweep().

Return type:

np.array

help()

Print the docstring of the instrument class.

property i_autorange

Autorange current measurement on or off.

property i_clamp

Set the current clamping (A), will adjust current measurement range.

property i_range

Set the current measurement range (A).

property id

Query IDN.

identify(showInstName=False)

Identify message.

init(identify=False)

Connect to Keithley instrument and initialize.

Parameters:

identify (bool) – If True, query the instrument ID and print it to the log.

property instName

Return with instname or instname[ch] if it has channels.

json = <module 'json' from '/home/runner/miniconda3/envs/test/lib/python3.9/json/__init__.py'>
local()

Switch back to local instrument control.

property measure

Get or set measure. Where the measurements are defined by “vir” flags (VOLTAGE,CURRENT,RESISTANCE)

eg. “v” for voltage, “i” for current, “r” for resistance, “vi” for voltage and current, etc.

Parameters:

typ (str) –

String with “vir” flags (VOLTAGE,CURRENT,RESISTANCE) defining the measurements to be made.

For example, “v” for voltage, “i” for current, “r” for resistance, “vi” for voltage and current, etc.

Returns:

List of measured values corresponding to the “vir” flags.

Return type:

list

property measurecnt

Set/get the number of measurement to be carried out in a loop.

TODO: this function is not running yet, it is only a dummy

if the result == None than this function not implemented. The return value for the measurement is calculated togetheer with the mfilter setting.

message(message=None)[source]

Message display about Keithley instrument. Instrument message (“string”) or ()

If message is None, the display is cleared, otherwise the message is shown on the display.

Parameters:

message (str or None) – Message to be displayed on the instrument. If None, the display is cleared.

mqtt_add(client, instrument, liste='#', qos=0)

Add the instrument to mqtt. Calling from base_instrument, after the instrument (device) has been create. Normally you have not to use this function, only base_instrument use it.

Parameters:
  • client (mqtt_init) – The MQTT client instance to which the instrument should be added.

  • instrument (object) – The instrument to be added to the MQTT client.

  • liste (list or str) – A list of attributes for which MQTT messages should be sent. If set to “#”, all attributes will be included (default: “#”).

  • qos (int) – The Quality of Service level for MQTT messages (default: 0).

Return type:

None

mqtt_disconnect()

Remove the instrument from mqtt. Calling from base_instrument, if the instrument are closing. Normally you have not to use this function, only base_instrument use it.

property mqtt_status

Getter for the mqtt_status.

property nplc

Set the conversion number of power line cycles accuracy, for all converters.

For a plc of 0.1, conversion rate is 0.1/50s = 2ms. Accuracy max 25, min 0.001.

off()[source]

Deactivate output.

on()[source]

Reactivate output.

property onoff

Set/get on state from output (True).

publish(topic, value)

Publish topic as type=’cmd’ with payload=value.

Parameters:
  • topic (str) – The name of the topic to publish.

  • value (any) – The value to be published.

Return type:

None

publish_get(function_name, value)

Publish function_name as type=’get’ with paylad=value.

Parameters:
  • function_name (str) – The name of the function to be published as a ‘get’ command.

  • value (any) – The value to be published as the payload of the ‘get’ command.

Return type:

None

publish_set(function_name, value)

Publish function_name as type=’set’ with paylad=value.

Parameters:
  • function_name (str) – The name of the function to be published as a ‘set’ command.

  • value (any) – The value to be published as the payload of the ‘set’ command.

Return type:

None

reset()[source]

Reset and switch beep off.

scriptin(msg)[source]

A multiline LUA script needs to have – comments correctly handled and newlines.

Parameters:

msg (str) – Multiline LUA script as a string, where – comments are correctly handled and newlines are preserved.

Returns:

A formatted multiline LUA script string that can be sent to the instrument, with – comments handled and newlines preserved.

Return type:

str

scripts()[source]

Upload specific functionality : sweep DUT.

setup_inst()[source]

Start setup instrument settings, called from class instruments.

property stair_slope

stair_slope to target or target, slope_time using previous stair_sweep() parameters.

property stair_step

Set incremental ramp to target or (target,dstep) or (target,dstep,stime).

Step_stair to target or target,dstep or target,dstep,stime, using previous stair_sweep() parameters.

stair_sweep(start, stop, dstep, stime=0, typ='V', stair='Lin', wait=False)[source]

Sweep V or I, measure v,i,r at time t with state s, change by dstep, steptime stime, wait for response. If dstep is None then stime is slopetime (>1ms) & nplc is min : 0.01.

Parameters:
  • start (Start value in volts or amps, None implies incremental)

  • stop (Stop value in volts or amps)

  • dstep (Delta amplitude for Lin, Points to interpolate for Log, stime is slope time for None (>1ms))

  • stime (Delay between steps or slope time if dstep == None)

  • typ ('Vvirts-', 'Ivirts-' = Voltage / Current sourced, '-' changes direction,) – volts, amps, ohms, timestamp, status are sensed

  • stair (('Lin','Log) = linear or log source)

Return type:

None

property v_autorange

Autorange voltage measurement on or off.

property v_clamp

Set the voltage clamping (V), will adjust voltage measurement range.

property v_range

Set the voltage measurement range (V).

property voltage

Get or set output voltage.

If the voltage is set the output is switched on immediately.

Returns:

value(float)

Return type:

output voltage (in V).