Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions src/qcodes/instrument_drivers/Keithley/_Keithley_2600.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import qcodes.validators as vals
from qcodes.extensions.infer import infer_channel
from qcodes.instrument import (
Instrument,
InstrumentChannel,
VisaInstrument,
VisaInstrumentKWArgs,
Expand Down Expand Up @@ -412,7 +411,7 @@ def get_raw(self) -> npt.NDArray:
return self.instrument._execute_lua(script, config.total_points)


class TimeTrace(ParameterWithSetpoints):
class TimeTrace(ParameterWithSetpoints[npt.NDArray, "Keithley2600Channel"]):
"""
A parameter class that holds the data corresponding to the time dependence of
current and voltage.
Expand Down Expand Up @@ -503,7 +502,7 @@ def get_raw(self) -> npt.NDArray:
return data


class TimeAxis(Parameter):
class TimeAxis(Parameter[npt.NDArray, "Keithley2600Channel"]):
"""
A simple :class:`.Parameter` that holds all the times (relative to the
measurement start) at which the points of the time trace were acquired.
Expand Down Expand Up @@ -640,13 +639,13 @@ def get_raw(self) -> ParamRawDataType:
return value


class Keithley2600Channel(InstrumentChannel):
class Keithley2600Channel(InstrumentChannel["Keithley2600"]):
"""
Class to hold the two Keithley channels, i.e.
SMUA and SMUB.
"""

def __init__(self, parent: Instrument, name: str, channel: str) -> None:
def __init__(self, parent: Keithley2600, name: str, channel: str) -> None:
"""
Args:
parent: The Instrument instance to which the channel is
Expand All @@ -665,8 +664,8 @@ def __init__(self, parent: Instrument, name: str, channel: str) -> None:
self._extra_visa_timeout = 5000
self._measurement_duration_factor = 2 # Ensures that we are always above
# the expected time.
vranges = self._parent._vranges
iranges = self._parent._iranges
vranges = self.parent._vranges
iranges = self.parent._iranges
vlimit_minmax = self.parent._vlimit_minmax
ilimit_minmax = self.parent._ilimit_minmax

Expand Down Expand Up @@ -1093,14 +1092,19 @@ def setup_fastsweep(
inner_start = float(inner_setpoints[0])
inner_stop = float(inner_setpoints[-1])
inner_param = cast("Parameter", inner.param)
inner_channel = infer_channel(inner_param).channel
inner_channel = infer_channel(inner_param)
if not isinstance(inner_channel, Keithley2600Channel):
raise ValueError(
"Inner sweep parameter must belong to a Keithley2600Channel."
)
inner_channel_name = inner_channel.channel

channel_to_measure = inner_channel
channel_to_measure = inner_channel_name

if not measure_inner_channel:
channels = ["smua", "smub"]
channel_to_measure = next(
channel for channel in channels if channel != inner_channel
channel for channel in channels if channel != inner_channel_name
)

# Build the configuration
Expand All @@ -1112,7 +1116,7 @@ def setup_fastsweep(
inner_param_name=inner_param.label,
inner_param_unit=inner_param.unit,
inner_param_full_name=inner_param.full_name,
inner_channel=inner_channel,
inner_channel=inner_channel_name,
mode=mode,
measurement_channel=channel_to_measure,
)
Expand All @@ -1123,7 +1127,12 @@ def setup_fastsweep(
outer_start = float(outer_setpoints[0])
outer_stop = float(outer_setpoints[-1])
outer_param = cast("Parameter", outer.param)
outer_channel = infer_channel(outer_param).channel
outer_channel = infer_channel(outer_param)
if not isinstance(outer_channel, Keithley2600Channel):
raise ValueError(
"Outer sweep parameter must belong to a Keithley2600Channel."
)
outer_channel_name = outer_channel.channel

config.outer_start = outer_start
config.outer_stop = outer_stop
Expand All @@ -1132,19 +1141,15 @@ def setup_fastsweep(
config.outer_param_name = outer_param.label
config.outer_param_unit = outer_param.unit
config.outer_param_full_name = outer_param.full_name
config.outer_channel = outer_channel

# Get the inner channel object where fastsweep should be called from
# (measurement happens on the inner channel)
inner_channel_obj: Keithley2600Channel = getattr(
self.root_instrument, inner_channel
)
config.outer_channel = outer_channel_name

# fastsweep should be called from inner channel object where
# measurement happens.
# Store configuration on the inner channel - users call fastsweep there
inner_channel_obj._fastsweep_config = config
inner_channel._fastsweep_config = config

# Update fastsweep parameter metadata on the inner channel
inner_channel_obj.fastsweep._update_metadata(config)
inner_channel.fastsweep._update_metadata(config)

def _execute_lua(self, _script: list[str], steps: int) -> npt.NDArray:
"""
Expand All @@ -1165,7 +1170,7 @@ def _execute_lua(self, _script: list[str], steps: int) -> npt.NDArray:
estimated_measurement_duration + _time_trace_extra_visa_timeout
)

self.write(self.root_instrument._scriptwrapper(program=_script, debug=True))
self.write(self.parent._scriptwrapper(program=_script, debug=True))

# now poll all the data
# The problem is that a '\n' character might by chance be present in
Expand All @@ -1174,9 +1179,9 @@ def _execute_lua(self, _script: list[str], steps: int) -> npt.NDArray:
received = 0
data = b""
# we must wait for the script to execute
with self.root_instrument.timeout.set_to(new_visa_timeout):
with self.parent.timeout.set_to(new_visa_timeout):
while received < fullsize:
data_temp = self.root_instrument.visa_handle.read_raw()
data_temp = self.parent.visa_handle.read_raw()
received += len(data_temp)
data += data_temp

Expand Down
Loading