KEITHLEY2612 module
Created on Fri Dec 10 08:39:48 2021
@author: Martin.Mihaylov @author: Maxim Weizel
- class Instruments_Libraries.KEITHLEY2612.KEITHLEY2612(resource_str, visa_library='@py', **kwargs)[source]
Bases:
BaseInstrumentDriver for Keithley 2612 SourceMeter using BaseInstrument.
- Parameters:
resource_str (str)
visa_library (str)
- define_lua_script(lua_script=None)[source]
Load a Lua script into the instrument.
- Parameters:
lua_script (str | None, optional) – The Lua script to load. If None, loads a default ‘Hello World’ script.
- Return type:
None
- delete_lua_script(script_name)[source]
Delete a Lua script from the instrument and local cache.
- Parameters:
script_name (str) – Name of the script to delete.
- Return type:
None
- execute_lua_script(script_name)[source]
Execute a previously loaded Lua script.
- Parameters:
script_name (str) – Name of the script to execute.
- Raises:
ValueError – If script is not found in local cache.
- Return type:
None
- format_scientific(value, precision=4)[source]
Format number in scientific notation consistently.
- Parameters:
value (int | float) – The value to format.
precision (int, optional) – Number of decimal places. Default is 4.
- Return type:
str
- get_auto_current_range(channel)[source]
Get source auto current range status (1 if enabled, 0 if disabled). You might want to keep it on auto i.e. 1 or “ON”!
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
int
- get_auto_current_range_measure(channel)[source]
Get measurement auto current range status (1 if enabled, 0 if disabled). You might want to keep it on auto i.e. 1 or “ON”!
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
int
- get_auto_voltage_range(channel)[source]
Get source auto voltage range status (1 if enabled, 0 if disabled). You might want to keep it on auto i.e. 1 or “ON”!
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
int
- get_auto_voltage_range_measure(channel)[source]
Get measurement auto voltage range status (1 if enabled, 0 if disabled). You might want to keep it on auto i.e. 1 or “ON”!
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
int
- get_current_limit(channel)[source]
Get source current limit.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- get_current_range(channel)[source]
Get source current range.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- get_current_range_measure(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) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- get_current_setting(channel)[source]
Get source current setting.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- get_data(channel=None)[source]
Get voltage and current measurements. Returns dictionary containing ‘voltage_V’, ‘current_A’, and ‘channel(s)’.
- Parameters:
channel (str, optional) – Channel to measure (‘a’ or ‘b’). If None, measures both.
- Return type:
dict
- get_limit_reached(channel)[source]
Check if source compliance limit has been reached.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
bool
- get_output_source_function(channel)[source]
Get source output function (1 if voltage, 0 if current).
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
int
- get_read_buffer(channel, start, stop)[source]
TODO: This function should be checked. Also is doesn’t return anything at the moment.
- Parameters:
channel (str)
start (int)
stop (int)
- Return type:
None
- get_voltage_limit(channel)[source]
Get source voltage limit.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- get_voltage_range(channel)[source]
Get source voltage range.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- get_voltage_range_measure(channel)[source]
Get measurement voltage range.
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) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- get_voltage_setting(channel)[source]
Get source voltage setting.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- measure_current(channel)[source]
Measure current on the specified channel.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- measure_power(channel)[source]
Measure power on the specified channel.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- measure_resistance(channel)[source]
Measure resistance on the specified channel.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- measure_voltage(channel)[source]
Measure voltage on the specified channel.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Return type:
float
- read_after_lua_script(print_output=False)[source]
Read output from the instrument after script execution.
- Parameters:
print_output (bool, optional) – If True, logs the output. Default is False.
- Returns:
(list_of_lines, full_output_string).
- Return type:
tuple[list[str], str]
- read_lua_table(lua_table_name)[source]
Read a Lua table from the instrument as a list of floats.
- Parameters:
lua_table_name (str) – Name of the table to read.
- Returns:
List of values in the table.
- Return type:
list[float]
- read_measurement(channel, type_)[source]
Perform a measurement of the specified type.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
type (str) – Type of measurement (e.g., ‘voltage’, ‘current’, ‘power’, ‘resistance’).
type_ (str)
- Return type:
float
- reset_channel(channel)[source]
Reset channel to default settings.
- Parameters:
channel (str) – Select channel A or B
- Return type:
None
- set_auto_current_range(channel, state)[source]
Set source autorange current control.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
state (int | str | bool) – Status (e.g., ‘ON’ or ‘OFF’).
- Return type:
None
- set_auto_voltage_range(channel, state)[source]
Set source autorange voltage control.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
state (int | str | bool) – Status (e.g., ‘ON’ or ‘OFF’).
- Return type:
None
- set_channel_display(channel=None)[source]
Set which channel(s) to display.
- Parameters:
channel (str, optional) – Channel to display (‘a’ or ‘b’). If None, displays both.
- Return type:
None
- set_current(channel, current)[source]
Set source current level.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
current (int | float) – Current to set in Amperes.
- Raises:
ValueError – If current is out of range.
- Return type:
None
- set_current_limit(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) – Channel identifier (‘a’ or ‘b’).
limit (int | float) – Current limit in Amperes.
- Raises:
ValueError – If limit is out of range.
- Return type:
None
- set_current_range(channel, value)[source]
Set source current range.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
value (int | float) – Current range in Amperes.
- Return type:
None
- set_current_range_measure(channel, value)[source]
Set measure current range.
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) – Channel identifier (‘a’ or ‘b’).
value (int | float) – Range in Amperes.
- Return type:
None
- set_display_measurement_function(channel, measurement_type)[source]
Set displayed measurement function.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
measurement_type (str) – Measurement type (‘v’, ‘i’, ‘r’, ‘p’, etc.).
- Return type:
None
- set_meas_output(channel, state)
Set source output state (on or off).
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
state (int | str | bool) – Output state (e.g., ‘ON’, ‘OFF’, 1, 0, True, False).
- Return type:
None
- set_measurement_range(channel, measurement_type, range_value)[source]
Set measurement range for voltage or current.
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) – Channel identifier (‘a’ or ‘b’).
measurement_type (str) – Type (‘volt’, ‘voltage’, ‘amp’, ‘current’).
range_value (int | float) – Range value.
- Return type:
None
- set_offmode(channel, mode)[source]
Set source output-off mode.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
mode (str | int) – Off mode (‘normal’/0, ‘zero’/1, ‘high_z’/2).
- Return type:
None
- set_out(channel, state)
Set source output state (on or off).
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
state (int | str | bool) – Output state (e.g., ‘ON’, ‘OFF’, 1, 0, True, False).
- Return type:
None
- set_output(channel, state)[source]
Set source output state (on or off).
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
state (int | str | bool) – Output state (e.g., ‘ON’, ‘OFF’, 1, 0, True, False).
- Return type:
None
- set_output_source_function(channel, function)[source]
Set source function (V or I).
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
function (str) – Source function (‘volt’, ‘voltage’, ‘amp’, ‘current’).
- Return type:
None
- set_pulse_measured(channel, value, ton, toff)[source]
Configure pulse measurement (TODO: Verify function).
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
value (Any) – Pulse value.
ton (int | float) – On time.
toff (int | float) – Off time.
- Return type:
None
- set_source_output(channel, state)
Set source output state (on or off).
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
state (int | str | bool) – Output state (e.g., ‘ON’, ‘OFF’, 1, 0, True, False).
- Return type:
None
- set_voltage(channel, voltage, high_voltage=False)[source]
Set source voltage level.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
voltage (int | float) – Voltage to set in Volts.
high_voltage (bool, optional) – Enable high voltage range (>10V). Default is False.
- Raises:
ValueError – If voltage is out of range.
- Return type:
None
- set_voltage_limit(channel, limit, high_voltage=False)[source]
Set voltage source compliance.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
limit (int | float) – Voltage limit in Volts.
high_voltage (bool, optional) – Enable high voltage range (>10V). Default is False.
- Raises:
ValueError – If limit is out of range.
- Return type:
None
- set_voltage_range(channel, value)[source]
Set source voltage range.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
value (int | float) – Voltage range in Volts.
- Return type:
None
- set_voltage_range_measure(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) – Channel identifier (‘a’ or ‘b’).
value (int | float) – Range in Volts.
- Return type:
None
- setup_current_source(channel, current, voltage_limit)[source]
Setup current source with voltage limit.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
current (float) – Current level in Amperes.
voltage_limit (float) – Voltage compliance in Volts.
- Return type:
None
- setup_voltage_source(channel, voltage, current_limit)[source]
Setup voltage source with current limit.
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
voltage (float) – Voltage level in Volts.
current_limit (float) – Current compliance in Amperes.
- Return type:
None
- validate_channel(channel)[source]
Validate and normalize channel input. Returns the normalized channel string (‘a’ or ‘b’).
- Parameters:
channel (str) – Channel identifier (‘a’ or ‘b’).
- Returns:
Normalized channel string (‘a’ or ‘b’).
- Return type:
str
- Raises:
ValueError – If the channel is invalid.
- 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 content.
- Returns:
(script_name, cleaned_script_content).
- Return type:
tuple[str, str]
- Raises:
ValueError – If script format is invalid (missing loadscript/endscript).
- validate_state(state, output=False)[source]
Validate and normalize state input.
- Parameters:
state (int | str | bool) – State to validate (e.g., ‘ON’, ‘OFF’, 1, 0, True, False).
output (bool, optional) – If True, allows ‘HIGH_Z’ state. Default is False.
- Returns:
Normalized state string (e.g., ‘ON’, ‘OFF’, ‘HIGH_Z’).
- Return type:
str