semi_cr.core.lab.drivers.keithley package

Drivers for Keithley source-measure units.

class semi_cr.core.lab.drivers.keithley.Keithley2636b(*, resource_manager: Any | None = None, timeout_ms: int = 10000)[source]

Bases: object

Control both SMU channels on a Keithley 2636B over VISA/TSP.

Source and measurement methods configure the selected channel but do not silently change its output state, except set_output and source_off.

Create a driver and its VISA resource manager.

Parameters:
  • resource_manager – Optional PyVISA-compatible manager, useful when the caller shares a manager or supplies a test double.

  • timeout_ms – Read/write timeout in milliseconds for the VISA session.

Raises:

ValueError – If timeout_ms is not a positive integer.

DEFAULT_TIMEOUT_MS = 10000
CHANNELS = frozenset({'a', 'b'})
FILTER_TYPES = frozenset({'FILTER_MEDIAN', 'FILTER_MOVING_AVG', 'FILTER_REPEAT_AVG'})
MIN_NPLC = 0.001
MAX_NPLC = 25.0
MIN_FILTER_COUNT = 1
MAX_FILTER_COUNT = 100
property connected: bool

Return whether a live VISA session is open.

connect(address: str) → bool[source]

Open a VISA resource and verify that it identifies as a 2636B.

Parameters:

address – VISA resource name, for example TCPIP0::192.168.0.2::INSTR.

Returns:

True after the instrument identity has been verified.

Raises:

KeithleyConnectionError – If the resource cannot be opened, queried, or does not identify as a Keithley 2636B.

disconnect() → bool[source]

Close the current VISA session and any resource manager owned here.

Returns:

True when the session and owned resource manager are closed.

Raises:

KeithleyDisconnectionError – If a session or owned manager fails to close.

check_connection() → bool[source]

Query *IDN? and return whether this session reaches a 2636B.

Raises:

KeithleyConnectionError – If there is no open session or the query fails.

get_IDN() → str[source]

Return the instrument’s raw *IDN? response.

set_source(channel: str, source: str, level: float, compliance: float | None = None) → None[source]

Set voltage or current source mode, level, and optional compliance.

The channel output is not enabled by this method. When compliance is omitted, the instrument’s existing limit for the selected source mode is read and written back unchanged.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • source – Source mode, “voltage” or “current”.

  • level – Source level in volts or amperes, according to source.

  • compliance – Optional positive current limit in voltage mode or voltage limit in current mode.

Raises:
set_compliance(channel: str, compliance: float) → None[source]

Set the active mode’s current or voltage compliance limit.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • compliance – Positive limit in amperes for voltage mode or volts for current mode.

Raises:
set_filter(channel: str, filter_type: str) → None[source]

Set the digital measurement filter algorithm for one channel.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • filter_type – One of FILTER_REPEAT_AVG, FILTER_MOVING_AVG, or FILTER_MEDIAN.

Raises:
set_nplc(channel: str, nplc: float) → None[source]

Set the measurement integration time in power-line cycles.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • nplc – Integration time from 0.001 through 25 power-line cycles.

Raises:
set_settling_time(channel: str, time: float) → None[source]

Set the source delay in seconds; use -1 for automatic delay.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • time – Non-negative delay in seconds, or -1 for range-dependent delay.

Raises:
get_source(channel: str) → dict[str, str | float][source]

Read source mode and active source level from one channel.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

A dictionary with source (“voltage” or “current”) and level.

Raises:
get_compliance(channel: str) → float[source]

Read the compliance limit for the channel’s active source mode.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

Current limit in amperes for voltage mode, or voltage limit in volts for current mode.

get_filter(channel: str) → str[source]

Read the configured digital measurement filter type.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

The filter constant name.

Raises:

KeithleyMeasurementError – If the instrument returns an unknown filter.

get_nplc(channel: str) → float[source]

Read the measurement integration time in power-line cycles.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

The configured NPLC value.

get_settling_time(channel: str) → float[source]

Read source delay in seconds, returning -1 for automatic delay.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

The configured delay in seconds or -1.0 when delay is automatic.

measure_resistance(channel: str) → float[source]

Take and return one resistance reading without changing output state.

measure_voltage(channel: str) → float[source]

Take and return one voltage reading without changing output state.

measure_current(channel: str) → float[source]

Take and return one current reading without changing output state.

measure_power(channel: str) → float[source]

Take and return one power reading without changing output state.

set_output(channel: str, enabled: bool) → bool[source]

Set and verify whether one channel’s source output is enabled.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • enabled – True to enable output, False to disable it.

Returns:

The output state read back from the instrument.

get_output_enabled(channel: str) → bool[source]

Read and decode the source output state for one channel.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

Whether the channel output is enabled.

Raises:

KeithleyMeasurementError – If the instrument returns an unknown state.

source_off() → None[source]

Disable and verify both SMU outputs.

set_measure(channel: str, *, nplc: float, filter_enabled: bool, filter_type: str, filter_count: int, voltage_range: float | None = None, current_range: float | None = None) → None[source]

Configure integration time, digital filtering, and autorange/ranges.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • nplc – Measurement integration time, from 0.001 to 25 PLC.

  • filter_enabled – Whether to enable the selected digital filter.

  • filter_type – Supported Keithley filter constant.

  • filter_count – Filter count from 1 to 100.

  • voltage_range – Fixed voltage measurement range; None enables autorange.

  • current_range – Fixed current measurement range; None enables autorange.

Raises:
exception semi_cr.core.lab.drivers.keithley.KeithleyConnectionError[source]

Bases: KeithleyError

Raised when the VISA session is unavailable or communication fails.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception semi_cr.core.lab.drivers.keithley.KeithleyDisconnectionError[source]

Bases: KeithleyConnectionError

Raised when the VISA resource manager or session cannot be closed.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception semi_cr.core.lab.drivers.keithley.KeithleyError[source]

Bases: RuntimeError

Base error raised by the Keithley 2636B driver.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception semi_cr.core.lab.drivers.keithley.KeithleyMeasurementError[source]

Bases: KeithleyError

Raised when a response from the instrument cannot be interpreted.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

Subpackages

Submodules

semi_cr.core.lab.drivers.keithley.keithley_2636b module

PyVISA driver for the two-channel Keithley 2636B SourceMeter.

class semi_cr.core.lab.drivers.keithley.keithley_2636b.Keithley2636b(*, resource_manager: Any | None = None, timeout_ms: int = 10000)[source]

Bases: object

Control both SMU channels on a Keithley 2636B over VISA/TSP.

Source and measurement methods configure the selected channel but do not silently change its output state, except set_output and source_off.

Create a driver and its VISA resource manager.

Parameters:
  • resource_manager – Optional PyVISA-compatible manager, useful when the caller shares a manager or supplies a test double.

  • timeout_ms – Read/write timeout in milliseconds for the VISA session.

Raises:

ValueError – If timeout_ms is not a positive integer.

DEFAULT_TIMEOUT_MS = 10000
CHANNELS = frozenset({'a', 'b'})
FILTER_TYPES = frozenset({'FILTER_MEDIAN', 'FILTER_MOVING_AVG', 'FILTER_REPEAT_AVG'})
MIN_NPLC = 0.001
MAX_NPLC = 25.0
MIN_FILTER_COUNT = 1
MAX_FILTER_COUNT = 100
device: Any | None
property connected: bool

Return whether a live VISA session is open.

connect(address: str) → bool[source]

Open a VISA resource and verify that it identifies as a 2636B.

Parameters:

address – VISA resource name, for example TCPIP0::192.168.0.2::INSTR.

Returns:

True after the instrument identity has been verified.

Raises:

KeithleyConnectionError – If the resource cannot be opened, queried, or does not identify as a Keithley 2636B.

disconnect() → bool[source]

Close the current VISA session and any resource manager owned here.

Returns:

True when the session and owned resource manager are closed.

Raises:

KeithleyDisconnectionError – If a session or owned manager fails to close.

check_connection() → bool[source]

Query *IDN? and return whether this session reaches a 2636B.

Raises:

KeithleyConnectionError – If there is no open session or the query fails.

get_IDN() → str[source]

Return the instrument’s raw *IDN? response.

set_source(channel: str, source: str, level: float, compliance: float | None = None) → None[source]

Set voltage or current source mode, level, and optional compliance.

The channel output is not enabled by this method. When compliance is omitted, the instrument’s existing limit for the selected source mode is read and written back unchanged.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • source – Source mode, “voltage” or “current”.

  • level – Source level in volts or amperes, according to source.

  • compliance – Optional positive current limit in voltage mode or voltage limit in current mode.

Raises:
set_compliance(channel: str, compliance: float) → None[source]

Set the active mode’s current or voltage compliance limit.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • compliance – Positive limit in amperes for voltage mode or volts for current mode.

Raises:
set_filter(channel: str, filter_type: str) → None[source]

Set the digital measurement filter algorithm for one channel.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • filter_type – One of FILTER_REPEAT_AVG, FILTER_MOVING_AVG, or FILTER_MEDIAN.

Raises:
set_nplc(channel: str, nplc: float) → None[source]

Set the measurement integration time in power-line cycles.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • nplc – Integration time from 0.001 through 25 power-line cycles.

Raises:
set_settling_time(channel: str, time: float) → None[source]

Set the source delay in seconds; use -1 for automatic delay.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • time – Non-negative delay in seconds, or -1 for range-dependent delay.

Raises:
get_source(channel: str) → dict[str, str | float][source]

Read source mode and active source level from one channel.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

A dictionary with source (“voltage” or “current”) and level.

Raises:
get_compliance(channel: str) → float[source]

Read the compliance limit for the channel’s active source mode.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

Current limit in amperes for voltage mode, or voltage limit in volts for current mode.

get_filter(channel: str) → str[source]

Read the configured digital measurement filter type.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

The filter constant name.

Raises:

KeithleyMeasurementError – If the instrument returns an unknown filter.

get_nplc(channel: str) → float[source]

Read the measurement integration time in power-line cycles.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

The configured NPLC value.

get_settling_time(channel: str) → float[source]

Read source delay in seconds, returning -1 for automatic delay.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

The configured delay in seconds or -1.0 when delay is automatic.

measure_resistance(channel: str) → float[source]

Take and return one resistance reading without changing output state.

measure_voltage(channel: str) → float[source]

Take and return one voltage reading without changing output state.

measure_current(channel: str) → float[source]

Take and return one current reading without changing output state.

measure_power(channel: str) → float[source]

Take and return one power reading without changing output state.

set_output(channel: str, enabled: bool) → bool[source]

Set and verify whether one channel’s source output is enabled.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • enabled – True to enable output, False to disable it.

Returns:

The output state read back from the instrument.

get_output_enabled(channel: str) → bool[source]

Read and decode the source output state for one channel.

Parameters:

channel – SMU channel, “a” or “b” (case-insensitive).

Returns:

Whether the channel output is enabled.

Raises:

KeithleyMeasurementError – If the instrument returns an unknown state.

source_off() → None[source]

Disable and verify both SMU outputs.

set_measure(channel: str, *, nplc: float, filter_enabled: bool, filter_type: str, filter_count: int, voltage_range: float | None = None, current_range: float | None = None) → None[source]

Configure integration time, digital filtering, and autorange/ranges.

Parameters:
  • channel – SMU channel, “a” or “b” (case-insensitive).

  • nplc – Measurement integration time, from 0.001 to 25 PLC.

  • filter_enabled – Whether to enable the selected digital filter.

  • filter_type – Supported Keithley filter constant.

  • filter_count – Filter count from 1 to 100.

  • voltage_range – Fixed voltage measurement range; None enables autorange.

  • current_range – Fixed current measurement range; None enables autorange.

Raises:
exception semi_cr.core.lab.drivers.keithley.keithley_2636b.KeithleyConnectionError[source]

Bases: KeithleyError

Raised when the VISA session is unavailable or communication fails.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception semi_cr.core.lab.drivers.keithley.keithley_2636b.KeithleyDisconnectionError[source]

Bases: KeithleyConnectionError

Raised when the VISA resource manager or session cannot be closed.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception semi_cr.core.lab.drivers.keithley.keithley_2636b.KeithleyError[source]

Bases: RuntimeError

Base error raised by the Keithley 2636B driver.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception semi_cr.core.lab.drivers.keithley.keithley_2636b.KeithleyMeasurementError[source]

Bases: KeithleyError

Raised when a response from the instrument cannot be interpreted.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.