KEITHLEY2612 module

Created on Fri Dec 10 08:39:48 2021

@author: Martin.Mihaylov

class Instruments_Libraries.KEITHLEY2612.KEITHLEY2612(resource_str)[source]

Bases: object

This class is using pyvisa. Please install PyVisa before you use it.

Parameters:

resource_str (str)

Close()[source]
ask_AutoCurrentRange(channel)[source]

This attribute contains the state of (smuX.source.autorangeY) the source autorange current control. You might want to keep it on auto i.e. 1 or “ON”!

Parameters:

channel (str) – Select channel A or B

Return type:

int

ask_AutoCurrentRangeMeasure(channel)[source]

This attribute contains the smuX.measure.autorangeY current setting. You might want to keep it on auto i.e. 1 or “ON”!

Parameters:

channel (str) – Select channel A or B

Return type:

int

ask_AutoVoltageRange(channel)[source]

This attribute contains the state of (smuX.source.autorangeY) the source autorange voltage control. You might want to keep it on auto i.e. 1 or “ON”!

Parameters:

channel (str) – Select channel A or B

Return type:

int

ask_AutoVoltageRangeMeasure(channel)[source]

This attribute contains the smuX.measure.autorangeY voltage setting. You might want to keep it on auto i.e. 1 or “ON”!

Parameters:

channel (str) – Select channel A or B

Return type:

int

ask_Current(channel)[source]

Performs one current measurements and returns the value.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_CurrentLimit(channel)[source]

This attribute contains the source current limit.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_CurrentRange(channel)[source]

This attribute contains the source current range.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_CurrentRangeMeasure(channel)[source]

This attribute contains the smuX.measure.rangeY current setting. Look up the datasheet!

If the source function is the same as the measurement function (for example, sourcing voltage and measuring voltage), the measurement range is locked to be the same as the source range. However, the setting for the measure range is retained. If the source function is changed (for example, from sourcing voltage to sourcing current), the retained measurement range will be used.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_CurrentSetting(channel)[source]

This attribute contains the source current setting.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_LimitReached(channel)[source]

This attribute contains the state of source compliance. A configured limit has been reached. (voltage, current, or power limit)

Parameters:

channel (str) – Select channel A or B This output indicates that a configured limit has been reached. (voltage, current, or power limit)

Return type:

bool

ask_OutputSourceFunction(channel)[source]

This attribute contains the source output function. Returns: 1 = voltage, 0 = current

Parameters:

channel (str) – Select channel A or B

Returns:

1 = voltage, 0 = current

Return type:

int

ask_Power(channel)[source]

This function performs one power measurements and returns the value.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_Resistance(channel)[source]

This function performs one resistance measurements and returns the value.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_Voltage(channel)[source]

This function performs one voltage measurements and returns the value.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_VoltageLimit(channel)[source]

This attribute contains the source voltage limit.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_VoltageRange(channel)[source]

This attribute contains the source voltage range.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_VoltageRangeMeasure(channel)[source]

This attribute contains the smuX.measure.rangeY voltage setting. Look up the datasheet!

If the source function is the same as the measurement function (for example, sourcing voltage and measuring voltage), the measurement range is locked to be the same as the source range. However, the setting for the measure range is retained. If the source function is changed (for example, from sourcing voltage to sourcing current), the retained measurement range will be used.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_VoltageSetting(channel)[source]

This attribute contains the source voltage setting.

Parameters:

channel (str) – Select channel A or B

Return type:

float

ask_readBuffer(channel, start, stop)[source]

TODO: This function should be checked. Also is doesn’t return anything at the moment. Print the source function used for ‘start’ - ‘stop’ readings stored in source-measure unit (SMU) channel A, buffer 1.

Parameters:
  • channel (str) – Select channel A or B

  • start (int) – select start value

  • stop (int) – select stop value

clear()[source]
clear_error_queue()[source]
define_lua_script(lua_script=None)[source]

Define a Lua script to be loaded into the instrument.

Parameters:

lua_script (str, optional) – The Lua script to define. If not provided, an example script will be loaded.

Raises:

ValueError – If the script is invalid.

Return type:

None

delete_lua_script(script_name)[source]

Delete a Lua script from the instrument. TODO: check if it works

Parameters:

script_name (str) – The name of the script to delete.

Raises:

ValueError – If the script name is not found in the dict_of_lua_scripts.

execute_lua_script(script_name)[source]

Execute a Lua script on the instrument.

Parameters:

script_name (str) – The name of the script to execute.

Raises:

ValueError – If the script name is not found in the dict_of_lua_scripts.

Return type:

None

getIdn()[source]
Returns:

Instrument identification

Return type:

str

get_Data(channel=None)[source]

Get voltage and current measurements.

Parameters:

channel (str) – Select channel A or B If no channel is selected, all channels are measured.

Returns:

OutPut – Return a dictionary with the measured voltage and current.

Return type:

dict

query(message)[source]
read()[source]
read_Measurement(channel, type)[source]

This function performs one measurements and returns the value.

Parameters:
  • channel (str) – Select channel A or B

  • type (str) – Select measurement type: ‘volt’, ‘amp’, ‘ohm’, or ‘watt’.

Return type:

float

read_after_lua_script(print_output=False)[source]

Reads output from the instrument after executing a Lua script.

Parameters:

print_output (bool, optional) – If True, prints the output to the console. The default is False.

Returns:

  • list[str] – A list of strings representing the output lines.

  • str – A string containing all the output lines separated by newlines.

Return type:

tuple[list[str], str]

read_lua_kv_table(lua_table_name)[source]

Reads an associative (key-value) Lua table from the Keithley 2612. Returns a Python dict mapping str→(float or str).

read_lua_table(lua_table_name)[source]

Reads an array-like Lua table from the Keithley 2612 using one-line queries.

Parameters:

lua_table_name (str) – Name of the Lua table (must already exist in instrument memory).

Returns:

A list of floats representing the table contents.

Return type:

list

reset()[source]
reset_channel(channel)[source]

Reset channel to default settings.

Parameters:

channel (str) – Select channel A or B

Return type:

None

set_AutoCurrentRange(channel, state)[source]

This attribute contains the state of the source autorange control (on/off).

Parameters:
  • channel (str) – Select channel A or B

  • state (str) – ON/OFF current source automatic range

Return type:

None

set_AutoVoltageRange(channel, state)[source]

This attribute contains the state of the source autorange control (on/off).

Parameters:
  • channel (str) – Select channel A or B

  • state (str) – ON/OFF voltage source automatic range

Return type:

None

set_ChannelDisplay(channel=None)[source]

Set which channel(s) to display.

Parameters:

channel (str | None) – Select channel A or B. If None, displays SMU A and SMU B.

Return type:

None

set_Current(channel, current)[source]

This attribute sets the source level current.

Parameters:
  • channel (str) – Select Channel A or B

  • current (int/float) – Set Current on channels A and B

Return type:

None

set_CurrentLimit(channel, limit)[source]

Sets current source compliance. Use to limit the current output when in the voltage source mode. This attribute should be set in the test sequence before turning the source on.

Parameters:
  • channel (str) – Select Channel A or B

  • value (int/float) – Sets the current limit of channel X to A. Using a limit value of 0 will result in a “Parameter Too Small” error message (error 1102)

  • limit (int | float)

Return type:

None

set_CurrentRange(channel, value)[source]
This attribute contains the positive full-scale value

of the source range for current

Parameters:
  • channel (str) – Select Channel A or B

  • value (int/float) – Set current source current range

Return type:

None

set_CurrentRangeMeasure(channel, value)[source]

This attribute contains the positive full-scale value of the measure range for current. Look up the datasheet! -> smuX.measure.rangeY. You might want to keep it on auto!

If the source function is the same as the measurement function (for example, sourcing voltage and measuring voltage), the measurement range is locked to be the same as the source range. However, the setting for the measure range is retained. If the source function is changed (for example, from sourcing voltage to sourcing current), the retained measurement range will be used.

Parameters:
  • channel (str) – Select Channel A or B

  • value (int/float) – Set current measure range

Return type:

None

set_DisplayMeasurementFunction(channel, measurement_type)[source]

This attribute specifies the type of measurement being displayed.

Parameters:
  • channel (str) – Select channel A or B

  • measurement_type (str) – Selects the displayed measurement function: volt, amp, ohm, or watt. SMU A and SMU B can be set for different measurement functions!

Return type:

None

set_MeasOutput(channel, state)[source]

Alias for set_SourceOutput().

Parameters:
  • channel (str)

  • state (int | str | bool)

Return type:

None

set_MeasurementRange(channel, measurement_type, range_value)[source]

This attribute contains the positive full-scale value of the measure range for voltage orcurrent. Look up the datasheet! -> smuX.measure.rangeY. You might want to keep it on auto! Same as set_CurrentRangeMeasure and set_VoltageRangeMeasure.

If the source function is the same as the measurement function (for example, sourcing voltage and measuring voltage), the measurement range is locked to be the same as the source range. However, the setting for the measure range is retained. If the source function is changed (for example, from sourcing voltage to sourcing current), the retained measurement range will be used.

Parameters:
  • channel (str) – Select channel A or B

  • measurement_type (str) – Selects the measurement function: ‘volt’ or ‘amp’.

  • range_value (int/float) – Set to the maximum expected voltage or current to be measured.

Return type:

None

set_Out(channel, state)[source]

Alias for set_SourceOutput().

Parameters:
  • channel (str)

  • state (int | str | bool)

Return type:

None

set_OutputSourceFunction(channel, function)[source]

This attribute sets the source function (V source or I source).

Parameters:
  • channel (str) – Select channel A or B

  • function (str) – The source function. Set to one of the following values: function = ‘volt’ Selects voltage source function function = ‘amp’ Selects current source function

Return type:

None

set_PulseMeasured(channel, value, ton, toff)[source]

TODO: function should be checked

Parameters:
  • channel (str) – Select channel A or B

  • value (int/float or list with curly braces for example {1,2,3....}.)

  • ton (int/float) – X ms pulse on

  • toff (int/float) – X ms pulse off

Return type:

None

set_SourceOutput(channel, state)[source]

This attribute sets source output state (on or off)

Parameters:
  • channel (str) – Select channel A or B

  • state (str) – Set source output (channel A/B) ON or OFF

Return type:

None

set_Voltage(channel, voltage, highVoltage=False)[source]

This attribute sets the source level voltage.

Parameters:
  • channel (str) – Select Channel A or B

  • voltage (int/float) – Set voltage on channels A and B

  • highVoltage (bool)

Return type:

None

set_VoltageLimit(channel, limit, highVoltage=False)[source]

Sets voltage source compliance. Use to limit the voltage output when in the current source mode. This attribute should be set in the test sequence before turning the source on.

Parameters:
  • channel (str) – Select Channel A or B

  • value (int/float) – Sets the voltage limit of channel X to V. Using a limit value of 0 will result in a “Parameter Too Small” error message (error 1102)

  • limit (int | float)

  • highVoltage (bool)

Return type:

None

set_VoltageRange(channel, value)[source]
This attribute contains the positive full-scale value

of the source range for voltage.

Parameters:
  • channel (str) – Select Channel A or B

  • value (int/float) – Set voltage source voltage range

Return type:

None

set_VoltageRangeMeasure(channel, value)[source]

This attribute contains the positive full-scale value of the measure range for voltage. Look up the datasheet! -> smuX.measure.rangeY. You might want to keep it on auto!

If the source function is the same as the measurement function (for example, sourcing voltage and measuring voltage), the measurement range is locked to be the same as the source range. However, the setting for the measure range is retained. If the source function is changed (for example, from sourcing voltage to sourcing current), the retained measurement range will be used.

Parameters:
  • channel (str) – Select Channel A or B

  • value (int/float) – Set measure voltage range

Return type:

None

set_offmode(channel, mode)[source]

This attribute sets the source output-off mode

Parameters:
  • channel (str) – Channel A or B

  • mode (int or str) – 0 or NORMAL: Configures the source function according to smuX.source.offfunc attribute 1 or ZERO: Configures source to output 0 V 2 or HIGH_Z: Opens the output relay when the output is turned off

Return type:

None

setup_current_source(channel, current, voltage_limit)[source]

Convenience method to setup current source with voltage limit

Parameters:
  • channel (str)

  • current (float)

  • voltage_limit (float)

Return type:

None

setup_voltage_source(channel, voltage, current_limit)[source]

Convenience method to setup voltage source with current limit

Parameters:
  • channel (str)

  • voltage (float)

  • current_limit (float)

Return type:

None

validate_lua_script(lua_script)[source]

Validates a Keithley 2612 Lua script to ensure: - It starts with ‘loadscript <name>’ - It ends with ‘endscript’ - A script name is provided

Parameters:

lua_script (str) – The Lua script to validate.

Returns:

  • script_name (str) – The name of the script.

  • lua_script (str) – The validated Lua script.

Raises:

ValueError – If the script is invalid.

Return type:

tuple[str, str]

write(message)[source]