| 1 |
# |
| 2 |
# This file is part of the PyMeasure package. |
| 3 |
# |
| 4 |
# Copyright (c) 2013-2024 PyMeasure Developers |
| 5 |
# |
| 6 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 |
# of this software and associated documentation files (the "Software"), to deal |
| 8 |
# in the Software without restriction, including without limitation the rights |
| 9 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 |
# copies of the Software, and to permit persons to whom the Software is |
| 11 |
# furnished to do so, subject to the following conditions: |
| 12 |
# |
| 13 |
# The above copyright notice and this permission notice shall be included in |
| 14 |
# all copies or substantial portions of the Software. |
| 15 |
# |
| 16 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 |
# THE SOFTWARE. |
| 23 |
# |
| 24 |
|
| 25 |
import logging |
| 26 |
import weakref |
| 27 |
import time |
| 28 |
import re |
| 29 |
import numpy as np |
| 30 |
import pandas as pd |
| 31 |
from enum import IntEnum |
| 32 |
from collections import Counter, namedtuple, OrderedDict |
| 33 |
from pymeasure.instruments.validators import (strict_discrete_set, |
| 34 |
strict_range, |
| 35 |
strict_discrete_range) |
| 36 |
from pymeasure.instruments import Instrument, SCPIUnknownMixin |
| 37 |
|
| 38 |
log = logging.getLogger(__name__) |
| 39 |
log.addHandler(logging.NullHandler()) |
| 40 |
|
| 41 |
###################################### |
| 42 |
# Agilent B1500 Mainframe |
| 43 |
###################################### |
| 44 |
|
| 45 |
|
| 46 |
class AgilentB1500(SCPIUnknownMixin, Instrument): |
| 47 |
""" Represents the Agilent B1500 Semiconductor Parameter Analyzer |
| 48 |
and provides a high-level interface for taking different kinds of |
| 49 |
measurements. |
| 50 |
""" |
| 51 |
|
| 52 |
def __init__(self, adapter, name="Agilent B1500 Semiconductor Parameter Analyzer", **kwargs): |
| 53 |
super().__init__( |
| 54 |
adapter, |
| 55 |
name, |
| 56 |
**kwargs |
| 57 |
) |
| 58 |
self._smu_names = {} |
| 59 |
self._smu_references = {} |
| 60 |
|
| 61 |
@property |
| 62 |
def smu_references(self): |
| 63 |
"""Returns all SMU instances. |
| 64 |
""" |
| 65 |
return self._smu_references.values() |
| 66 |
|
| 67 |
@property |
| 68 |
def smu_names(self): |
| 69 |
"""Returns all SMU names. |
| 70 |
""" |
| 71 |
return self._smu_names |
| 72 |
|
| 73 |
def query_learn(self, query_type): |
| 74 |
"""Queries settings from the instrument (``*LRN?``). |
| 75 |
Returns dict of settings. |
| 76 |
|
| 77 |
:param query_type: Query type (number according to manual) |
| 78 |
:type query_type: int or str |
| 79 |
""" |
| 80 |
return QueryLearn.query_learn(self.ask, query_type) |
| 81 |
|
| 82 |
def query_learn_header(self, query_type, **kwargs): |
| 83 |
"""Queries settings from the instrument (``*LRN?``). |
| 84 |
Returns dict of settings in human readable format for debugging |
| 85 |
or file headers. |
| 86 |
For optional arguments check the underlying definition of |
| 87 |
:meth:`QueryLearn.query_learn_header`. |
| 88 |
|
| 89 |
:param query_type: Query type (number according to manual) |
| 90 |
:type query_type: int or str |
| 91 |
""" |
| 92 |
return QueryLearn.query_learn_header( |
| 93 |
self.ask, query_type, self._smu_references, **kwargs) |
| 94 |
|
| 95 |
def reset(self): |
| 96 |
""" Resets the instrument to default settings (``*RST``) |
| 97 |
""" |
| 98 |
self.write("*RST") |
| 99 |
|
| 100 |
def query_modules(self): |
| 101 |
""" Queries module models from the instrument. |
| 102 |
Returns dictionary of channel and module type. |
| 103 |
|
| 104 |
:return: Channel:Module Type |
| 105 |
:rtype: dict |
| 106 |
""" |
| 107 |
modules = self.ask('UNT?') |
| 108 |
modules = modules.split(';') |
| 109 |
module_names = { |
| 110 |
'B1525A': 'SPGU', |
| 111 |
'B1517A': 'HRSMU', |
| 112 |
'B1511A': 'MPSMU', |
| 113 |
'B1511B': 'MPSMU', |
| 114 |
'B1510A': 'HPSMU', |
| 115 |
'B1514A': 'MCSMU', |
| 116 |
'B1520A': 'MFCMU' |
| 117 |
} |
| 118 |
out = {} |
| 119 |
for i, module in enumerate(modules): |
| 120 |
module = module.split(',') |
| 121 |
if not module[0] == '0': |
| 122 |
try: |
| 123 |
out[i + 1] = module_names[module[0]] |
| 124 |
# i+1: channels start at 1 not at 0 |
| 125 |
except Exception: |
| 126 |
raise NotImplementedError( |
| 127 |
f'Module {module[0]} is not implemented yet!') |
| 128 |
return out |
| 129 |
|
| 130 |
def initialize_smu(self, channel, smu_type, name): |
| 131 |
""" Initializes SMU instance by calling :class:`.SMU`. |
| 132 |
|
| 133 |
:param channel: SMU channel |
| 134 |
:type channel: int |
| 135 |
:param smu_type: SMU type, e.g. ``'HRSMU'`` |
| 136 |
:type smu_type: str |
| 137 |
:param name: SMU name for pymeasure (data output etc.) |
| 138 |
:type name: str |
| 139 |
:return: SMU instance |
| 140 |
:rtype: :class:`.SMU` |
| 141 |
""" |
| 142 |
if channel in ( |
| 143 |
list(range(101, 1101, 100)) |
| 144 |
+ list(range(102, 1102, 100))): |
| 145 |
channel = int(str(channel)[0:-2]) |
| 146 |
# subchannels not relevant for SMU/CMU |
| 147 |
channel = strict_discrete_set(channel, range(1, 11)) |
| 148 |
self._smu_names[channel] = name |
| 149 |
smu_reference = SMU(self, channel, smu_type, name) |
| 150 |
self._smu_references[channel] = smu_reference |
| 151 |
return smu_reference |
| 152 |
|
| 153 |
def initialize_all_smus(self): |
| 154 |
""" Initialize all SMUs by querying available modules and creating |
| 155 |
a SMU class instance for each. |
| 156 |
SMUs are accessible via attributes ``.smu1`` etc. |
| 157 |
""" |
| 158 |
modules = self.query_modules() |
| 159 |
i = 1 |
| 160 |
for channel, smu_type in modules.items(): |
| 161 |
if 'SMU' in smu_type: |
| 162 |
setattr(self, 'smu' + str(i), |
| 163 |
self.initialize_smu( |
| 164 |
channel, smu_type, 'SMU' + str(i))) |
| 165 |
i += 1 |
| 166 |
|
| 167 |
def pause(self, pause_seconds): |
| 168 |
""" Pauses Command Execution for given time in seconds (``PA``) |
| 169 |
|
| 170 |
:param pause_seconds: Seconds to pause |
| 171 |
:type pause_seconds: int |
| 172 |
""" |
| 173 |
self.write("PA %d" % pause_seconds) |
| 174 |
|
| 175 |
def abort(self): |
| 176 |
""" Aborts the present operation but channels may still output |
| 177 |
current/voltage (``AB``) |
| 178 |
""" |
| 179 |
self.write("AB") |
| 180 |
|
| 181 |
def force_gnd(self): |
| 182 |
""" Force 0V on all channels immediately. Current Settings can |
| 183 |
be restored with RZ. (``DZ``) |
| 184 |
""" |
| 185 |
self.write("DZ") |
| 186 |
|
| 187 |
def check_errors(self): |
| 188 |
""" Check for errors (``ERRX?``) |
| 189 |
""" |
| 190 |
error = self.ask("ERRX?") |
| 191 |
error = re.match( |
| 192 |
r'(?P<errorcode>[+-]?\d+(?:\.\d+)?),"(?P<errortext>[\w\s.]+)', |
| 193 |
error).groups() |
| 194 |
if int(error[0]) == 0: |
| 195 |
return |
| 196 |
else: |
| 197 |
raise OSError( |
| 198 |
f"Agilent B1500 Error {error[0]}: {error[1]}") |
| 199 |
|
| 200 |
def check_idle(self): |
| 201 |
""" Check if instrument is idle (``*OPC?``) |
| 202 |
""" |
| 203 |
self.ask("*OPC?") |
| 204 |
|
| 205 |
def clear_buffer(self): |
| 206 |
""" Clear output data buffer (``BC``) """ |
| 207 |
self.write("BC") |
| 208 |
|
| 209 |
def clear_timer(self): |
| 210 |
""" Clear timer count (``TSR``) """ |
| 211 |
self.write("TSR") |
| 212 |
|
| 213 |
def send_trigger(self): |
| 214 |
""" Send trigger to start measurement (except High Speed Spot) |
| 215 |
(``XE``)""" |
| 216 |
self.write("XE") |
| 217 |
|
| 218 |
@property |
| 219 |
def auto_calibration(self): |
| 220 |
""" Enable/Disable SMU auto-calibration every 30 minutes. (``CM``) |
| 221 |
|
| 222 |
:type: bool |
| 223 |
""" |
| 224 |
response = self.query_learn(31)['CM'] |
| 225 |
response = bool(int(response)) |
| 226 |
return response |
| 227 |
|
| 228 |
@auto_calibration.setter |
| 229 |
def auto_calibration(self, setting): |
| 230 |
setting = int(setting) |
| 231 |
self.write('CM %d' % setting) |
| 232 |
self.check_errors() |
| 233 |
|
| 234 |
###################################### |
| 235 |
# Data Formatting |
| 236 |
###################################### |
| 237 |
|
| 238 |
class _data_formatting_generic(): |
| 239 |
""" Format data output head of measurement value into user |
| 240 |
readable values |
| 241 |
|
| 242 |
:param str output_format_str: Format string of measurement value |
| 243 |
:param dict smu_names: Dictionary of channel and SMU name |
| 244 |
""" |
| 245 |
|
| 246 |
channels = {"A": 101, "B": 201, "C": 301, "D": 401, "E": 501, |
| 247 |
"F": 601, "G": 701, "H": 801, "I": 901, "J": 1001, |
| 248 |
"a": 102, "b": 202, "c": 302, "d": 402, "e": 502, |
| 249 |
"f": 602, "g": 702, "h": 802, "i": 902, "j": 1002, |
| 250 |
"V": "GNDU", "Z": "MISC"} |
| 251 |
status = { |
| 252 |
'W': 'First or intermediate sweep step data', |
| 253 |
'E': 'Last sweep step data', |
| 254 |
'T': 'Another channel reached its compliance setting.', |
| 255 |
'C': 'This channel reached its compliance setting', |
| 256 |
'V': ('Measurement data is over the measurement range/Sweep was ' |
| 257 |
'aborted by automatic stop function or power compliance. ' |
| 258 |
'D will be 199.999E+99 (no meaning).'), |
| 259 |
'X': ('One or more channels are oscillating. Or source output did ' |
| 260 |
'not settle before measurement.'), |
| 261 |
'F': 'SMU is in the force saturation condition.', |
| 262 |
'G': ('Linear/Binary search measurement: Target value was not ' |
| 263 |
'found within the search range. ' |
| 264 |
'Returns source output value. ' |
| 265 |
'Quasi-pulsed spot measurement: ' |
| 266 |
'The detection time was over the limit.'), |
| 267 |
'S': ('Linear/Binary search measurement: The search measurement ' |
| 268 |
'was stopped. Returns source output value. ' |
| 269 |
'Quasi-pulsed spot measurement: Output slew rate was too ' |
| 270 |
'slow to perform the settling detection. ' |
| 271 |
'Or quasi-pulsed source channel reached compliance before ' |
| 272 |
'the source output voltage changed 10V ' |
| 273 |
'from the start voltage.'), |
| 274 |
'U': 'CMU is in the NULL loop unbalance condition.', |
| 275 |
'D': 'CMU is in the IV amplifier saturation condition.' |
| 276 |
} |
| 277 |
smu_status = { |
| 278 |
1: 'A/D converter overflowed.', |
| 279 |
2: 'Oscillation of force or saturation current.', |
| 280 |
4: 'Another unit reached its compliance setting.', |
| 281 |
8: 'This unit reached its compliance setting.', |
| 282 |
16: 'Target value was not found within the search range.', |
| 283 |
32: 'Search measurement was automatically stopped.', |
| 284 |
64: 'Invalid data is returned. D is not used.', |
| 285 |
128: 'End of data' |
| 286 |
} |
| 287 |
cmu_status = { |
| 288 |
1: 'A/D converter overflowed.', |
| 289 |
2: 'CMU is in the NULL loop unbalance condition.', |
| 290 |
4: 'CMU is in the IV amplifier saturation condition.', |
| 291 |
64: 'Invalid data is returned. D is not used.', |
| 292 |
128: 'End of data' |
| 293 |
} |
| 294 |
data_names_int = {"Sampling index"} # convert to int instead of float |
| 295 |
|
| 296 |
def __init__(self, smu_names, output_format_str): |
| 297 |
""" Stores parameters of the chosen output format |
| 298 |
for later usage in reading and processing instrument data. |
| 299 |
|
| 300 |
Data Names: e.g. "Voltage (V)" or "Current Measurement (A)" |
| 301 |
""" |
| 302 |
sizes = {"FMT1": 16, "FMT11": 17, "FMT21": 19} |
| 303 |
try: |
| 304 |
self.size = sizes[output_format_str] |
| 305 |
except Exception: |
| 306 |
raise NotImplementedError( |
| 307 |
("Data Format {} is not " |
| 308 |
"implemented so far.").format(output_format_str)) |
| 309 |
self.format = output_format_str |
| 310 |
data_names_C = { |
| 311 |
"V": "Voltage (V)", |
| 312 |
"I": "Current (A)", |
| 313 |
"F": "Frequency (Hz)", |
| 314 |
} |
| 315 |
data_names_CG = { |
| 316 |
"Z": "Impedance (Ohm)", |
| 317 |
"Y": "Admittance (S)", |
| 318 |
"C": "Capacitance (F)", |
| 319 |
"L": "Inductance (H)", |
| 320 |
"R": "Phase (rad)", |
| 321 |
"P": "Phase (deg)", |
| 322 |
"D": "Dissipation factor", |
| 323 |
"Q": "Quality factor", |
| 324 |
"X": "Sampling index", |
| 325 |
"T": "Time (s)" |
| 326 |
} |
| 327 |
data_names_G = { |
| 328 |
"V": "Voltage Measurement (V)", |
| 329 |
"I": "Current Measurement (A)", |
| 330 |
"v": "Voltage Output (V)", |
| 331 |
"i": "Current Output (A)", |
| 332 |
"f": "Frequency (Hz)", |
| 333 |
"z": "invalid data" |
| 334 |
} |
| 335 |
if output_format_str in ['FMT1', 'FMT5', 'FMT11', 'FMT15']: |
| 336 |
self.data_names = {**data_names_C, **data_names_CG} |
| 337 |
elif output_format_str in ['FMT21', 'FMT25']: |
| 338 |
self.data_names = {**data_names_G, **data_names_CG} |
| 339 |
else: |
| 340 |
self.data_names = {} # no header |
| 341 |
self.smu_names = smu_names |
| 342 |
|
| 343 |
def check_status(self, status_string, name=False, cmu=False): |
| 344 |
"""Check returned status of instrument. If not null or end of |
| 345 |
data, message is written to log.info. |
| 346 |
|
| 347 |
:param status_string: Status string returned by the instrument |
| 348 |
when reading data. |
| 349 |
:type status_string: str |
| 350 |
:param cmu: Whether or not channel is CMU, defaults to False (SMU) |
| 351 |
:type cmu: bool, optional |
| 352 |
""" |
| 353 |
def log_failed(): |
| 354 |
log.info( |
| 355 |
('Agilent B1500: check_status not ' |
| 356 |
'possible for status {}').format(status_string)) |
| 357 |
|
| 358 |
if name is False: |
| 359 |
name = '' |
| 360 |
else: |
| 361 |
name = f' {name}' |
| 362 |
|
| 363 |
status = re.search( |
| 364 |
r'(?P<number>[0-9]*)(?P<letter>[ A-Z]*)', |
| 365 |
status_string) |
| 366 |
# depending on FMT, status may be a letter or up to 3 digits |
| 367 |
if len(status.group('number')) > 0: |
| 368 |
status = int(status.group('number')) |
| 369 |
if status in (0, 128): |
| 370 |
# 0: no error; 128: End of data |
| 371 |
return |
| 372 |
if cmu is True: |
| 373 |
status_dict = self.cmu_status |
| 374 |
else: |
| 375 |
status_dict = self.smu_status |
| 376 |
for index, digit in enumerate(bin(status)[2:]): |
| 377 |
# [2:] to chop off 0b |
| 378 |
if digit == '1': |
| 379 |
log.info('Agilent B1500{}: {}'.format( |
| 380 |
name, status_dict[2**index])) |
| 381 |
elif len(status.group('letter')) > 0: |
| 382 |
status = status.group('letter') |
| 383 |
status = status.strip() # remove whitespaces |
| 384 |
if status not in ['N', 'W', 'E']: |
| 385 |
try: |
| 386 |
status = self.status[status] |
| 387 |
log.info(f'Agilent B1500{name}: {status}') |
| 388 |
except KeyError: |
| 389 |
log_failed() |
| 390 |
else: |
| 391 |
log_failed() |
| 392 |
|
| 393 |
def format_channel_check_status(self, status_string, channel_string): |
| 394 |
"""Returns channel number for given channel letter. |
| 395 |
Checks for not null status of the channel and writes according |
| 396 |
message to log.info. |
| 397 |
|
| 398 |
:param status_string: Status string returned by the instrument |
| 399 |
when reading data. |
| 400 |
:type status_string: str |
| 401 |
:param channel_string: Channel string returned by the instrument |
| 402 |
:type channel_string: str |
| 403 |
:return: Channel name |
| 404 |
:rtype: str |
| 405 |
""" |
| 406 |
channel = self.channels[channel_string] |
| 407 |
if isinstance(channel, int): |
| 408 |
channel = int(str(channel)[0:-2]) |
| 409 |
# subchannels not relevant for SMU/CMU |
| 410 |
try: |
| 411 |
smu_name = self.smu_names[channel] |
| 412 |
if 'SMU' in smu_name: |
| 413 |
self.check_status(status_string, name=smu_name, cmu=False) |
| 414 |
if 'CMU' in smu_name: |
| 415 |
self.check_status(status_string, name=smu_name, cmu=True) |
| 416 |
return smu_name |
| 417 |
except KeyError: |
| 418 |
self.check_status(status_string) |
| 419 |
return channel |
| 420 |
|
| 421 |
class _data_formatting_FMT1(_data_formatting_generic): |
| 422 |
""" Data formatting for FMT1 format |
| 423 |
""" |
| 424 |
|
| 425 |
def __init__(self, smu_names={}, output_format_string="FMT1"): |
| 426 |
super().__init__(smu_names, output_format_string) |
| 427 |
|
| 428 |
def format_single(self, element): |
| 429 |
""" Format single measurement value |
| 430 |
|
| 431 |
:param element: Single measurement value read from the instrument |
| 432 |
:type element: str |
| 433 |
:return: Status, channel, data name, value |
| 434 |
:rtype: (str, str, str, float) |
| 435 |
""" |
| 436 |
status = element[0] # one character |
| 437 |
channel = element[1] |
| 438 |
data_name = element[2] |
| 439 |
data_name = self.data_names[data_name] |
| 440 |
if data_name in self.data_names_int: |
| 441 |
value = int(float(element[3:])) |
| 442 |
else: |
| 443 |
value = float(element[3:]) |
| 444 |
channel = self.format_channel_check_status(status, channel) |
| 445 |
|
| 446 |
return (status, channel, data_name, value) |
| 447 |
|
| 448 |
class _data_formatting_FMT11(_data_formatting_FMT1): |
| 449 |
""" Data formatting for FMT11 format (based on FMT1) |
| 450 |
""" |
| 451 |
|
| 452 |
def __init__(self, smu_names={}): |
| 453 |
super().__init__(smu_names, "FMT11") |
| 454 |
|
| 455 |
class _data_formatting_FMT21(_data_formatting_generic): |
| 456 |
""" Data formatting for FMT21 format |
| 457 |
""" |
| 458 |
|
| 459 |
def __init__(self, smu_names={}): |
| 460 |
super().__init__(smu_names, "FMT21") |
| 461 |
|
| 462 |
def format_single(self, element): |
| 463 |
""" Format single measurement value |
| 464 |
|
| 465 |
:param element: Single measurement value read from the instrument |
| 466 |
:type element: str |
| 467 |
:return: Status (three digits), channel, data name, value |
| 468 |
:rtype: (str, str, str, float) |
| 469 |
""" |
| 470 |
status = element[0:3] # three digits |
| 471 |
channel = element[3] |
| 472 |
data_name = element[4] |
| 473 |
data_name = self.data_names[data_name] |
| 474 |
if data_name in self.data_names_int: |
| 475 |
value = int(float(element[5:])) |
| 476 |
else: |
| 477 |
value = float(element[5:]) |
| 478 |
channel = self.format_channel_check_status(status, channel) |
| 479 |
|
| 480 |
return (status, channel, data_name, value) |
| 481 |
|
| 482 |
def _data_formatting(self, output_format_str, smu_names={}): |
| 483 |
""" Return data formatting class for given data format string |
| 484 |
|
| 485 |
:param output_format_str: Data output format, e.g. ``FMT21`` |
| 486 |
:type output_format_str: str |
| 487 |
:param smu_names: Dictionary of channels and SMU names, defaults to {} |
| 488 |
:type smu_names: dict, optional |
| 489 |
:return: Corresponding formatting class |
| 490 |
:rtype: class |
| 491 |
""" |
| 492 |
classes = { |
| 493 |
"FMT1": self._data_formatting_FMT1, |
| 494 |
"FMT11": self._data_formatting_FMT11, |
| 495 |
"FMT21": self._data_formatting_FMT21 |
| 496 |
} |
| 497 |
try: |
| 498 |
format_class = classes[output_format_str] |
| 499 |
except KeyError: |
| 500 |
log.error(( |
| 501 |
"Data Format {} is not implemented " |
| 502 |
"so far. Please set appropriate Data Format." |
| 503 |
).format(output_format_str)) |
| 504 |
return |
| 505 |
else: |
| 506 |
return format_class(smu_names=smu_names) |
| 507 |
|
| 508 |
def data_format(self, output_format, mode=0): |
| 509 |
""" Specifies data output format. Check Documentation for parameters. |
| 510 |
Should be called once per session to set the data format for |
| 511 |
interpreting the measurement values read from the instrument. |
| 512 |
(``FMT``) |
| 513 |
|
| 514 |
Currently implemented are format 1, 11, and 21. |
| 515 |
|
| 516 |
:param output_format: Output format string, e.g. ``FMT21`` |
| 517 |
:type output_format: str |
| 518 |
:param mode: Data output mode, defaults to 0 (only measurement |
| 519 |
data is returned) |
| 520 |
:type mode: int, optional |
| 521 |
""" |
| 522 |
# restrict to implemented formats |
| 523 |
output_format = strict_discrete_set( |
| 524 |
output_format, [1, 11, 21]) |
| 525 |
# possible: [1, 2, 3, 4, 5, 11, 12, 13, 14, 15, 21, 22, 25] |
| 526 |
mode = strict_range(mode, range(0, 11)) |
| 527 |
self.write("FMT %d, %d" % (output_format, mode)) |
| 528 |
self.check_errors() |
| 529 |
if self._smu_names == {}: |
| 530 |
print( |
| 531 |
'No SMU names available for formatting, ' |
| 532 |
'instead channel numbers will be used. ' |
| 533 |
'Call data_format after initializing all SMUs.' |
| 534 |
) |
| 535 |
log.info( |
| 536 |
'No SMU names available for formatting, ' |
| 537 |
'instead channel numbers will be used. ' |
| 538 |
'Call data_format after initializing all SMUs.' |
| 539 |
) |
| 540 |
self._data_format = self._data_formatting( |
| 541 |
"FMT%d" % output_format, self._smu_names) |
| 542 |
|
| 543 |
###################################### |
| 544 |
# Measurement Settings |
| 545 |
###################################### |
| 546 |
|
| 547 |
@property |
| 548 |
def parallel_meas(self): |
| 549 |
""" Enable/Disable parallel measurements. |
| 550 |
Effective for SMUs using HSADC and measurement modes 1,2,10,18. |
| 551 |
(``PAD``) |
| 552 |
|
| 553 |
:type: bool |
| 554 |
""" |
| 555 |
response = self.query_learn(110)['PAD'] |
| 556 |
response = bool(int(response)) |
| 557 |
return response |
| 558 |
|
| 559 |
@parallel_meas.setter |
| 560 |
def parallel_meas(self, setting): |
| 561 |
setting = int(setting) |
| 562 |
self.write('PAD %d' % setting) |
| 563 |
self.check_errors() |
| 564 |
|
| 565 |
def query_meas_settings(self): |
| 566 |
"""Read settings for ``TM``, ``AV``, ``CM``, ``FMT`` and ``MM`` |
| 567 |
commands (31) from the instrument. |
| 568 |
""" |
| 569 |
return self.query_learn_header(31) |
| 570 |
|
| 571 |
def query_meas_mode(self): |
| 572 |
"""Read settings for ``MM`` command (part of 31) from the instrument. |
| 573 |
""" |
| 574 |
return self.query_learn_header(31, single_command='MM') |
| 575 |
|
| 576 |
def meas_mode(self, mode, *args): |
| 577 |
""" Set Measurement mode of channels. Measurements will be taken in |
| 578 |
the same order as the SMU references are passed. (``MM``) |
| 579 |
|
| 580 |
:param mode: Measurement mode |
| 581 |
|
| 582 |
* Spot |
| 583 |
* Staircase Sweep |
| 584 |
* Sampling |
| 585 |
|
| 586 |
:type mode: :class:`.MeasMode` |
| 587 |
:param args: SMU references |
| 588 |
:type args: :class:`.SMU` |
| 589 |
""" |
| 590 |
mode = MeasMode.get(mode) |
| 591 |
cmd = "MM %d" % mode.value |
| 592 |
for smu in args: |
| 593 |
if isinstance(smu, SMU): |
| 594 |
cmd += ", %d" % smu.channel |
| 595 |
self.write(cmd) |
| 596 |
self.check_errors() |
| 597 |
|
| 598 |
# ADC Setup: AAD, AIT, AV, AZ |
| 599 |
|
| 600 |
def query_adc_setup(self): |
| 601 |
"""Read ADC settings (55, 56) from the instrument. |
| 602 |
""" |
| 603 |
return {**self.query_learn_header(55), **self.query_learn_header(56)} |
| 604 |
|
| 605 |
def adc_setup(self, adc_type, mode, N=''): |
| 606 |
""" Set up operation mode and parameters of ADC for each ADC type. |
| 607 |
(``AIT``) |
| 608 |
Defaults: |
| 609 |
|
| 610 |
- HSADC: Auto N=1, Manual N=1, PLC N=1, Time N=0.000002(s) |
| 611 |
- HRADC: Auto N=6, Manual N=3, PLC N=1 |
| 612 |
|
| 613 |
:param adc_type: ADC type |
| 614 |
:type adc_type: :class:`.ADCType` |
| 615 |
:param mode: ADC mode |
| 616 |
:type mode: :class:`.ADCMode` |
| 617 |
:param N: additional parameter, check documentation, defaults to ``''`` |
| 618 |
:type N: str, optional |
| 619 |
""" |
| 620 |
|
| 621 |
adc_type = ADCType.get(adc_type) |
| 622 |
mode = ADCMode.get(mode) |
| 623 |
if (adc_type == ADCType['HRADC']) and (mode == ADCMode['TIME']): |
| 624 |
raise ValueError("Time ADC mode is not available for HRADC") |
| 625 |
command = "AIT %d, %d" % (adc_type.value, mode.value) |
| 626 |
if not N == '': |
| 627 |
if mode == ADCMode['TIME']: |
| 628 |
command += (", %g" % N) |
| 629 |
else: |
| 630 |
command += (", %d" % N) |
| 631 |
self.write(command) |
| 632 |
self.check_errors() |
| 633 |
|
| 634 |
def adc_averaging(self, number, mode='Auto'): |
| 635 |
""" Set number of averaging samples of the HSADC. (``AV``) |
| 636 |
|
| 637 |
Defaults: N=1, Auto |
| 638 |
|
| 639 |
:param number: Number of averages |
| 640 |
:type number: int |
| 641 |
:param mode: Mode (``'Auto','Manual'``), defaults to 'Auto' |
| 642 |
:type mode: :class:`.AutoManual`, optional |
| 643 |
""" |
| 644 |
if number > 0: |
| 645 |
number = strict_range(number, range(1, 1024)) |
| 646 |
mode = AutoManual.get(mode).value |
| 647 |
self.write("AV %d, %d" % (number, mode)) |
| 648 |
else: |
| 649 |
number = strict_range(number, range(-1, -101, -1)) |
| 650 |
self.write("AV %d" % number) |
| 651 |
self.check_errors() |
| 652 |
|
| 653 |
@property |
| 654 |
def adc_auto_zero(self): |
| 655 |
""" Enable/Disable ADC zero function. Halves the |
| 656 |
integration time, if off. (``AZ``) |
| 657 |
|
| 658 |
:type: bool |
| 659 |
""" |
| 660 |
response = self.query_learn(56)['AZ'] |
| 661 |
response = bool(int(response)) |
| 662 |
return response |
| 663 |
|
| 664 |
@adc_auto_zero.setter |
| 665 |
def adc_auto_zero(self, setting): |
| 666 |
setting = int(setting) |
| 667 |
self.write('AZ %d' % setting) |
| 668 |
self.check_errors() |
| 669 |
|
| 670 |
@property |
| 671 |
def time_stamp(self): |
| 672 |
""" Enable/Disable Time Stamp function. (``TSC``) |
| 673 |
|
| 674 |
:type: bool |
| 675 |
""" |
| 676 |
response = self.query_learn(60)['TSC'] |
| 677 |
response = bool(int(response)) |
| 678 |
return response |
| 679 |
|
| 680 |
@time_stamp.setter |
| 681 |
def time_stamp(self, setting): |
| 682 |
setting = int(setting) |
| 683 |
self.write('TSC %d' % setting) |
| 684 |
self.check_errors() |
| 685 |
|
| 686 |
def query_time_stamp_setting(self): |
| 687 |
"""Read time stamp settings (60) from the instrument. |
| 688 |
""" |
| 689 |
return self.query_learn_header(60) |
| 690 |
|
| 691 |
def wait_time(self, wait_type, N, offset=0): |
| 692 |
"""Configure wait time. (``WAT``) |
| 693 |
|
| 694 |
:param wait_type: Wait time type |
| 695 |
:type wait_type: :class:`.WaitTimeType` |
| 696 |
:param N: Coefficient for initial wait time, default: 1 |
| 697 |
:type N: float |
| 698 |
:param offset: Offset for wait time, defaults to 0 |
| 699 |
:type offset: int, optional |
| 700 |
""" |
| 701 |
wait_type = WaitTimeType.get(wait_type).value |
| 702 |
self.write('WAT %d, %g, %d' % (wait_type, N, offset)) |
| 703 |
self.check_errors() |
| 704 |
|
| 705 |
###################################### |
| 706 |
# Sweep Setup |
| 707 |
###################################### |
| 708 |
|
| 709 |
def query_staircase_sweep_settings(self): |
| 710 |
"""Reads Staircase Sweep Measurement settings (33) |
| 711 |
from the instrument. |
| 712 |
""" |
| 713 |
return self.query_learn_header(33) |
| 714 |
|
| 715 |
def sweep_timing(self, hold, delay, step_delay=0, step_trigger_delay=0, |
| 716 |
measurement_trigger_delay=0): |
| 717 |
""" Sets Hold Time, Delay Time and Step Delay Time for |
| 718 |
staircase or multi channel sweep measurement. (``WT``) |
| 719 |
If not set, all parameters are 0. |
| 720 |
|
| 721 |
:param hold: Hold time |
| 722 |
:type hold: float |
| 723 |
:param delay: Delay time |
| 724 |
:type delay: float |
| 725 |
:param step_delay: Step delay time, defaults to 0 |
| 726 |
:type step_delay: float, optional |
| 727 |
:param step_trigger_delay: Trigger delay time, defaults to 0 |
| 728 |
:type step_trigger_delay: float, optional |
| 729 |
:param measurement_trigger_delay: Measurement trigger delay time, |
| 730 |
defaults to 0 |
| 731 |
:type measurement_trigger_delay: float, optional |
| 732 |
""" |
| 733 |
hold = strict_discrete_range(hold, (0, 655.35), 0.01) |
| 734 |
delay = strict_discrete_range(delay, (0, 65.535), 0.0001) |
| 735 |
step_delay = strict_discrete_range(step_delay, (0, 1), 0.0001) |
| 736 |
step_trigger_delay = strict_discrete_range( |
| 737 |
step_trigger_delay, (0, delay), 0.0001) |
| 738 |
measurement_trigger_delay = strict_discrete_range( |
| 739 |
measurement_trigger_delay, (0, 65.535), 0.0001) |
| 740 |
self.write("WT %g, %g, %g, %g, %g" % |
| 741 |
(hold, delay, step_delay, step_trigger_delay, |
| 742 |
measurement_trigger_delay)) |
| 743 |
self.check_errors() |
| 744 |
|
| 745 |
def sweep_auto_abort(self, abort, post='START'): |
| 746 |
""" Enables/Disables the automatic abort function. |
| 747 |
Also sets the post measurement condition. (``WM``) |
| 748 |
|
| 749 |
:param abort: Enable/Disable automatic abort |
| 750 |
:type abort: bool |
| 751 |
:param post: Output after measurement, defaults to 'Start' |
| 752 |
:type post: :class:`.StaircaseSweepPostOutput`, optional |
| 753 |
""" |
| 754 |
abort_values = {True: 2, False: 1} |
| 755 |
abort = strict_discrete_set(abort, abort_values) |
| 756 |
abort = abort_values[abort] |
| 757 |
post = StaircaseSweepPostOutput.get(post) |
| 758 |
self.write("WM %d, %d" % (abort, post.value)) |
| 759 |
self.check_errors() |
| 760 |
|
| 761 |
###################################### |
| 762 |
# Sampling Setup |
| 763 |
###################################### |
| 764 |
|
| 765 |
def query_sampling_settings(self): |
| 766 |
"""Reads Sampling Measurement settings (47) from the instrument. |
| 767 |
""" |
| 768 |
return self.query_learn_header(47) |
| 769 |
|
| 770 |
@property |
| 771 |
def sampling_mode(self): |
| 772 |
""" Set linear or logarithmic sampling mode. (``ML``) |
| 773 |
|
| 774 |
:type: :class:`.SamplingMode` |
| 775 |
""" |
| 776 |
response = self.query_learn(47) |
| 777 |
response = response['ML'] |
| 778 |
return SamplingMode(response) |
| 779 |
|
| 780 |
@sampling_mode.setter |
| 781 |
def sampling_mode(self, mode): |
| 782 |
mode = SamplingMode.get(mode).value |
| 783 |
self.write("ML %d" % mode) |
| 784 |
self.check_errors() |
| 785 |
|
| 786 |
def sampling_timing(self, hold_bias, interval, number, hold_base=0): |
| 787 |
""" Sets Timing Parameters for the Sampling Measurement (``MT``) |
| 788 |
|
| 789 |
:param hold_bias: Bias hold time |
| 790 |
:type hold_bias: float |
| 791 |
:param interval: Sampling interval |
| 792 |
:type interval: float |
| 793 |
:param number: Number of Samples |
| 794 |
:type number: int |
| 795 |
:param hold_base: Base hold time, defaults to 0 |
| 796 |
:type hold_base: float, optional |
| 797 |
""" |
| 798 |
n_channels = self.query_meas_settings()['Measurement Channels'] |
| 799 |
n_channels = len(n_channels.split(', ')) |
| 800 |
if interval >= 0.002: |
| 801 |
hold_bias = strict_discrete_range(hold_bias, (0, 655.35), 0.01) |
| 802 |
interval = strict_discrete_range(interval, (0, 65.535), 0.001) |
| 803 |
else: |
| 804 |
try: |
| 805 |
hold_bias = strict_discrete_range( |
| 806 |
hold_bias, (-0.09, -0.0001), 0.0001) |
| 807 |
except ValueError as error1: |
| 808 |
try: |
| 809 |
hold_bias = strict_discrete_range( |
| 810 |
hold_bias, (0, 655.35), 0.01) |
| 811 |
except ValueError as error2: |
| 812 |
raise ValueError( |
| 813 |
'Bias hold time does not match either ' |
| 814 |
+ 'of the two possible specifications: ' |
| 815 |
+ f'{error1} {error2}') |
| 816 |
if interval >= 0.0001 + 0.00002 * (n_channels - 1): |
| 817 |
interval = strict_discrete_range(interval, |
| 818 |
(0, 0.00199), 0.00001) |
| 819 |
else: |
| 820 |
raise ValueError( |
| 821 |
f'Sampling interval {interval} is too short.') |
| 822 |
number = strict_discrete_range(number, (0, int(100001 / n_channels)), 1) |
| 823 |
# ToDo: different restrictions apply for logarithmic sampling! |
| 824 |
hold_base = strict_discrete_range(hold_base, (0, 655.35), 0.01) |
| 825 |
|
| 826 |
self.write("MT %g, %g, %d, %g" % |
| 827 |
(hold_bias, interval, number, hold_base)) |
| 828 |
self.check_errors() |
| 829 |
|
| 830 |
def sampling_auto_abort(self, abort, post='Bias'): |
| 831 |
""" Enables/Disables the automatic abort function. |
| 832 |
Also sets the post measurement condition. (``MSC``) |
| 833 |
|
| 834 |
:param abort: Enable/Disable automatic abort |
| 835 |
:type abort: bool |
| 836 |
:param post: Output after measurement, defaults to 'Bias' |
| 837 |
:type post: :class:`.SamplingPostOutput`, optional |
| 838 |
""" |
| 839 |
abort_values = {True: 2, False: 1} |
| 840 |
abort = strict_discrete_set(abort, abort_values) |
| 841 |
abort = abort_values[abort] |
| 842 |
post = SamplingPostOutput.get(post).value |
| 843 |
self.write("MSC %d, %d" % (abort, post)) |
| 844 |
self.check_errors() |
| 845 |
|
| 846 |
###################################### |
| 847 |
# Read out of data |
| 848 |
###################################### |
| 849 |
|
| 850 |
def read_data(self, number_of_points): |
| 851 |
""" Reads all data from buffer and returns Pandas DataFrame. |
| 852 |
Specify number of measurement points for correct splitting of |
| 853 |
the data list. |
| 854 |
|
| 855 |
:param number_of_points: Number of measurement points |
| 856 |
:type number_of_points: int |
| 857 |
:return: Measurement Data |
| 858 |
:rtype: pd.DataFrame |
| 859 |
""" |
| 860 |
data = self.read() |
| 861 |
data = data.split(',') |
| 862 |
data = np.array(data) |
| 863 |
data = np.split(data, number_of_points) |
| 864 |
data = pd.DataFrame(data=data) |
| 865 |
data = data.applymap(self._data_format.format_single) |
| 866 |
heads = data.iloc[[0]].applymap(lambda x: ' '.join(x[1:3])) |
| 867 |
# channel & data_type |
| 868 |
heads = heads.to_numpy().tolist() # 2D List |
| 869 |
heads = heads[0] # first row |
| 870 |
data = data.applymap(lambda x: x[3]) |
| 871 |
data.columns = heads |
| 872 |
return data |
| 873 |
|
| 874 |
def read_channels(self, nchannels): |
| 875 |
""" Reads data for 1 measurement point from the buffer. Specify number |
| 876 |
of measurement channels + sweep sources (depending on data |
| 877 |
output setting). |
| 878 |
|
| 879 |
:param nchannels: Number of channels which return data |
| 880 |
:type nchannels: int |
| 881 |
:return: Measurement data |
| 882 |
:rtype: tuple |
| 883 |
""" |
| 884 |
data = self.read_bytes(self._data_format.size * nchannels) |
| 885 |
data = data.decode("ASCII") |
| 886 |
data = data.rstrip('\r,') |
| 887 |
# ',' if more data in buffer, '\r' if last data point |
| 888 |
data = data.split(',') |
| 889 |
data = map(self._data_format.format_single, data) |
| 890 |
data = tuple(data) |
| 891 |
return data |
| 892 |
|
| 893 |
###################################### |
| 894 |
# Queries on all SMUs |
| 895 |
###################################### |
| 896 |
|
| 897 |
def query_series_resistor(self): |
| 898 |
"""Read series resistor status (53) for all SMUs.""" |
| 899 |
return self.query_learn_header(53) |
| 900 |
|
| 901 |
def query_meas_range_current_auto(self): |
| 902 |
"""Read auto ranging mode status (54) for all SMUs.""" |
| 903 |
return self.query_learn_header(54) |
| 904 |
|
| 905 |
def query_meas_op_mode(self): |
| 906 |
"""Read SMU measurement operation mode (46) for all SMUs.""" |
| 907 |
return self.query_learn_header(46) |
| 908 |
|
| 909 |
def query_meas_ranges(self): |
| 910 |
"""Read measruement ranging status (32) for all SMUs.""" |
| 911 |
return self.query_learn_header(32) |
| 912 |
|
| 913 |
###################################### |
| 914 |
# SMU Setup |
| 915 |
###################################### |
| 916 |
|
| 917 |
|
| 918 |
class SMU(): |
| 919 |
""" Provides specific methods for the SMUs of the Agilent B1500 mainframe |
| 920 |
|
| 921 |
:param parent: Instance of the B1500 mainframe class |
| 922 |
:type parent: :class:`.AgilentB1500` |
| 923 |
:param int channel: Channel number of the SMU |
| 924 |
:param str smu_type: Type of the SMU |
| 925 |
:param str name: Name of the SMU |
| 926 |
""" |
| 927 |
|
| 928 |
def __init__(self, parent, channel, smu_type, name, **kwargs): |
| 929 |
# to allow garbage collection for cyclic references |
| 930 |
self._b1500 = weakref.proxy(parent) |
| 931 |
channel = strict_discrete_set(channel, range(1, 11)) |
| 932 |
self.channel = channel |
| 933 |
smu_type = strict_discrete_set( |
| 934 |
smu_type, |
| 935 |
['HRSMU', 'MPSMU', 'HPSMU', 'MCSMU', 'HCSMU', |
| 936 |
'DHCSMU', 'HVSMU', 'UHCU', 'HVMCU', 'UHVU']) |
| 937 |
self.voltage_ranging = SMUVoltageRanging(smu_type) |
| 938 |
self.current_ranging = SMUCurrentRanging(smu_type) |
| 939 |
self.name = name |
| 940 |
|
| 941 |
########################################## |
| 942 |
# Wrappers of B1500 communication methods |
| 943 |
########################################## |
| 944 |
def write(self, string): |
| 945 |
"""Wraps :meth:`.Instrument.write` method of B1500. |
| 946 |
""" |
| 947 |
self._b1500.write(string) |
| 948 |
|
| 949 |
def ask(self, string): |
| 950 |
"""Wraps :meth:`~.Instrument.ask` method of B1500. |
| 951 |
""" |
| 952 |
return self._b1500.ask(string) |
| 953 |
|
| 954 |
def query_learn(self, query_type, command): |
| 955 |
"""Wraps :meth:`~.AgilentB1500.query_learn` method of B1500. |
| 956 |
""" |
| 957 |
response = self._b1500.query_learn(query_type) |
| 958 |
# query_learn returns settings of all smus |
| 959 |
# pick setting for this smu only |
| 960 |
response = response[command + str(self.channel)] |
| 961 |
return response |
| 962 |
|
| 963 |
def check_errors(self): |
| 964 |
"""Wraps :meth:`~.AgilentB1500.check_errors` method of B1500. |
| 965 |
""" |
| 966 |
return self._b1500.check_errors() |
| 967 |
########################################## |
| 968 |
|
| 969 |
def _query_status_raw(self): |
| 970 |
return self._b1500.query_learn(str(self.channel)) |
| 971 |
|
| 972 |
@property |
| 973 |
def status(self): |
| 974 |
"""Query status of the SMU.""" |
| 975 |
return self._b1500.query_learn_header(str(self.channel)) |
| 976 |
|
| 977 |
def enable(self): |
| 978 |
""" Enable Source/Measurement Channel (``CN``)""" |
| 979 |
self.write("CN %d" % self.channel) |
| 980 |
|
| 981 |
def disable(self): |
| 982 |
""" Disable Source/Measurement Channel (``CL``)""" |
| 983 |
self.write("CL %d" % self.channel) |
| 984 |
|
| 985 |
def force_gnd(self): |
| 986 |
""" Force 0V immediately. Current Settings can be restored with |
| 987 |
``RZ`` (not implemented). (``DZ``)""" |
| 988 |
self.write("DZ %d" % self.channel) |
| 989 |
|
| 990 |
@property |
| 991 |
def filter(self): |
| 992 |
""" Enables/Disables SMU Filter. (``FL``) |
| 993 |
|
| 994 |
:type: bool |
| 995 |
""" |
| 996 |
# different than other SMU specific settings (grouped by setting) |
| 997 |
# read via raw command |
| 998 |
response = self._b1500.query_learn(30) |
| 999 |
if 'FL' in response.keys(): |
| 1000 |
# only present if filters of all channels are off |
| 1001 |
return False |
| 1002 |
else: |
| 1003 |
if str(self.channel) in response['FL0']: |
| 1004 |
return False |
| 1005 |
elif str(self.channel) in response['FL1']: |
| 1006 |
return True |
| 1007 |
else: |
| 1008 |
raise NotImplementedError('Filter Value cannot be read!') |
| 1009 |
|
| 1010 |
@filter.setter |
| 1011 |
def filter(self, setting): |
| 1012 |
setting = strict_discrete_set(int(setting), (0, 1)) |
| 1013 |
self.write("FL %d, %d" % (setting, self.channel)) |
| 1014 |
self.check_errors() |
| 1015 |
|
| 1016 |
@property |
| 1017 |
def series_resistor(self): |
| 1018 |
""" Enables/Disables 1MOhm series resistor. (``SSR``) |
| 1019 |
|
| 1020 |
:type: bool |
| 1021 |
""" |
| 1022 |
response = self.query_learn(53, 'SSR') |
| 1023 |
response = bool(int(response)) |
| 1024 |
return response |
| 1025 |
|
| 1026 |
@series_resistor.setter |
| 1027 |
def series_resistor(self, setting): |
| 1028 |
setting = strict_discrete_set(int(setting), (0, 1)) |
| 1029 |
self.write("SSR %d, %d" % (self.channel, setting)) |
| 1030 |
self.check_errors() |
| 1031 |
|
| 1032 |
@property |
| 1033 |
def meas_op_mode(self): |
| 1034 |
""" Set SMU measurement operation mode. (``CMM``) |
| 1035 |
|
| 1036 |
:type: :class:`.MeasOpMode` |
| 1037 |
""" |
| 1038 |
response = self.query_learn(46, 'CMM') |
| 1039 |
response = int(response) |
| 1040 |
return MeasOpMode(response) |
| 1041 |
|
| 1042 |
@meas_op_mode.setter |
| 1043 |
def meas_op_mode(self, op_mode): |
| 1044 |
op_mode = MeasOpMode.get(op_mode) |
| 1045 |
self.write("CMM %d, %d" % (self.channel, op_mode.value)) |
| 1046 |
self.check_errors() |
| 1047 |
|
| 1048 |
@property |
| 1049 |
def adc_type(self): |
| 1050 |
"""ADC type of individual measurement channel. (``AAD``) |
| 1051 |
|
| 1052 |
:type: :class:`.ADCType` |
| 1053 |
""" |
| 1054 |
response = self.query_learn(55, 'AAD') |
| 1055 |
response = int(response) |
| 1056 |
return ADCType(response) |
| 1057 |
|
| 1058 |
@adc_type.setter |
| 1059 |
def adc_type(self, adc_type): |
| 1060 |
adc_type = ADCType.get(adc_type) |
| 1061 |
self.write("AAD %d, %d" % (self.channel, adc_type.value)) |
| 1062 |
self.check_errors() |
| 1063 |
|
| 1064 |
###################################### |
| 1065 |
# Force Constant Output |
| 1066 |
###################################### |
| 1067 |
def force(self, source_type, source_range, output, comp='', |
| 1068 |
comp_polarity='', comp_range=''): |
| 1069 |
""" Applies DC Current or Voltage from SMU immediately. |
| 1070 |
(``DI``, ``DV``) |
| 1071 |
|
| 1072 |
:param source_type: Source type (``'Voltage','Current'``) |
| 1073 |
:type source_type: str |
| 1074 |
:param source_range: Output range index or name |
| 1075 |
:type source_range: int or str |
| 1076 |
:param output: Source output value in A or V |
| 1077 |
:type output: float |
| 1078 |
:param comp: Compliance value, defaults to previous setting |
| 1079 |
:type comp: float, optional |
| 1080 |
:param comp_polarity: Compliance polairty, defaults to auto |
| 1081 |
:type comp_polarity: :class:`.CompliancePolarity` |
| 1082 |
:param comp_range: Compliance ranging type, defaults to auto |
| 1083 |
:type comp_range: int or str, optional |
| 1084 |
""" |
| 1085 |
if source_type.upper() == "VOLTAGE": |
| 1086 |
cmd = "DV" |
| 1087 |
source_range = self.voltage_ranging.output(source_range).index |
| 1088 |
if not comp_range == '': |
| 1089 |
comp_range = self.current_ranging.meas(comp_range).index |
| 1090 |
elif source_type.upper() == "CURRENT": |
| 1091 |
cmd = "DI" |
| 1092 |
source_range = self.current_ranging.output(source_range).index |
| 1093 |
if not comp_range == '': |
| 1094 |
comp_range = self.voltage_ranging.meas(comp_range).index |
| 1095 |
else: |
| 1096 |
raise ValueError("Source Type must be Current or Voltage.") |
| 1097 |
cmd += " %d, %d, %g" % (self.channel, source_range, output) |
| 1098 |
if not comp == '': |
| 1099 |
cmd += ", %g" % comp |
| 1100 |
if not comp_polarity == '': |
| 1101 |
comp_polarity = CompliancePolarity.get(comp_polarity).value |
| 1102 |
cmd += ", %d" % comp_polarity |
| 1103 |
if not comp_range == '': |
| 1104 |
cmd += ", %d" % comp_range |
| 1105 |
self.write(cmd) |
| 1106 |
self.check_errors() |
| 1107 |
|
| 1108 |
def ramp_source(self, source_type, source_range, target_output, comp='', |
| 1109 |
comp_polarity='', comp_range='', |
| 1110 |
stepsize=0.001, pause=20e-3): |
| 1111 |
""" Ramps to a target output from the set value with a given |
| 1112 |
step size, each separated by a pause. |
| 1113 |
|
| 1114 |
:param source_type: Source type (``'Voltage'`` or ``'Current'``) |
| 1115 |
:type source_type: str |
| 1116 |
:param target_output: Target output voltage or current |
| 1117 |
:type: target_output: float |
| 1118 |
:param irange: Output range index |
| 1119 |
:type irange: int |
| 1120 |
:param comp: Compliance, defaults to previous setting |
| 1121 |
:type comp: float, optional |
| 1122 |
:param comp_polarity: Compliance polairty, defaults to auto |
| 1123 |
:type comp_polarity: :class:`.CompliancePolarity` |
| 1124 |
:param comp_range: Compliance ranging type, defaults to auto |
| 1125 |
:type comp_range: int or str, optional |
| 1126 |
:param stepsize: Maximum size of steps |
| 1127 |
:param pause: Duration in seconds to wait between steps |
| 1128 |
""" |
| 1129 |
if source_type.upper() == "VOLTAGE": |
| 1130 |
source_type = 'VOLTAGE' |
| 1131 |
cmd = 'DV%d' % self.channel |
| 1132 |
source_range = self.voltage_ranging.output(source_range).index |
| 1133 |
unit = 'V' |
| 1134 |
if not comp_range == '': |
| 1135 |
comp_range = self.current_ranging.meas(comp_range).index |
| 1136 |
elif source_type.upper() == "CURRENT": |
| 1137 |
source_type = 'CURRENT' |
| 1138 |
cmd = 'DI%d' % self.channel |
| 1139 |
source_range = self.current_ranging.output(source_range).index |
| 1140 |
unit = 'A' |
| 1141 |
if not comp_range == '': |
| 1142 |
comp_range = self.voltage_ranging.meas(comp_range).index |
| 1143 |
else: |
| 1144 |
raise ValueError("Source Type must be Current or Voltage.") |
| 1145 |
|
| 1146 |
status = self._query_status_raw() |
| 1147 |
if 'CL' in status: # SMU is OFF |
| 1148 |
start = 0 |
| 1149 |
elif cmd in status: |
| 1150 |
start = float(status[cmd][1]) # current output value |
| 1151 |
else: |
| 1152 |
log.info( |
| 1153 |
("{} in different state. " |
| 1154 |
"Changing to {} Source.").format(self.name, source_type)) |
| 1155 |
start = 0 |
| 1156 |
|
| 1157 |
# calculate number of points based on maximum stepsize |
| 1158 |
nop = np.ceil(abs((target_output - start) / stepsize)) |
| 1159 |
nop = int(nop) |
| 1160 |
log.info("{0} ramping from {1}{2} to {3}{2} in {4} steps".format( |
| 1161 |
self.name, start, unit, target_output, nop |
| 1162 |
)) |
| 1163 |
outputs = np.linspace(start, target_output, nop, endpoint=False) |
| 1164 |
|
| 1165 |
for output in outputs: |
| 1166 |
# loop is only executed if target_output != start |
| 1167 |
self.force( |
| 1168 |
source_type, source_range, output, |
| 1169 |
comp, comp_polarity, comp_range) |
| 1170 |
time.sleep(pause) |
| 1171 |
# call force even if start==target_output |
| 1172 |
# to set compliance |
| 1173 |
self.force( |
| 1174 |
source_type, source_range, target_output, |
| 1175 |
comp, comp_polarity, comp_range) |
| 1176 |
|
| 1177 |
###################################### |
| 1178 |
# Measurement Range |
| 1179 |
# implemented: RI, RV |
| 1180 |
# not implemented: RC, TI, TTI, TV, TTV, TIV, TTIV, TC, TTC |
| 1181 |
###################################### |
| 1182 |
|
| 1183 |
@property |
| 1184 |
def meas_range_current(self): |
| 1185 |
""" Current measurement range index. (``RI``) |
| 1186 |
|
| 1187 |
Possible settings depend on SMU type, e.g. ``0`` for Auto Ranging: |
| 1188 |
:class:`.SMUCurrentRanging` |
| 1189 |
""" |
| 1190 |
response = self.query_learn(32, 'RI') |
| 1191 |
response = self.current_ranging.meas(response) |
| 1192 |
return response |
| 1193 |
|
| 1194 |
@meas_range_current.setter |
| 1195 |
def meas_range_current(self, meas_range): |
| 1196 |
meas_range_index = self.current_ranging.meas(meas_range).index |
| 1197 |
self.write("RI %d, %d" % (self.channel, meas_range_index)) |
| 1198 |
self.check_errors() |
| 1199 |
|
| 1200 |
@property |
| 1201 |
def meas_range_voltage(self): |
| 1202 |
""" Voltage measurement range index. (``RV``) |
| 1203 |
|
| 1204 |
Possible settings depend on SMU type, e.g. ``0`` for Auto Ranging: |
| 1205 |
:class:`.SMUVoltageRanging` |
| 1206 |
""" |
| 1207 |
response = self.query_learn(32, 'RV') |
| 1208 |
response = self.voltage_ranging.meas(response) |
| 1209 |
return response |
| 1210 |
|
| 1211 |
@meas_range_voltage.setter |
| 1212 |
def meas_range_voltage(self, meas_range): |
| 1213 |
meas_range_index = self.voltage_ranging.meas(meas_range).index |
| 1214 |
self.write("RV %d, %d" % (self.channel, meas_range_index)) |
| 1215 |
self.check_errors() |
| 1216 |
|
| 1217 |
def meas_range_current_auto(self, mode, rate=50): |
| 1218 |
""" Specifies the auto range operation. Check Documentation. (``RM``) |
| 1219 |
|
| 1220 |
:param mode: Range changing operation mode |
| 1221 |
:type mode: int |
| 1222 |
:param rate: Parameter used to calculate the *current* value, |
| 1223 |
defaults to 50 |
| 1224 |
:type rate: int, optional |
| 1225 |
""" |
| 1226 |
mode = strict_range(mode, range(1, 4)) |
| 1227 |
if mode == 1: |
| 1228 |
self.write("RM %d, %d" % (self.channel, mode)) |
| 1229 |
else: |
| 1230 |
self.write("RM %d, %d, %d" % (self.channel, mode, rate)) |
| 1231 |
self.write |
| 1232 |
|
| 1233 |
###################################### |
| 1234 |
# Staircase Sweep Measurement: (WT, WM -> Instrument) |
| 1235 |
# implemented: |
| 1236 |
# WV, WI, |
| 1237 |
# WSI, WSV (synchronous output) |
| 1238 |
# not implemented: BSSI, BSSV, LSSI, LSSV |
| 1239 |
###################################### |
| 1240 |
|
| 1241 |
def staircase_sweep_source(self, source_type, mode, source_range, |
| 1242 |
start, stop, steps, comp, Pcomp=''): |
| 1243 |
""" Specifies Staircase Sweep Source (Current or Voltage) and |
| 1244 |
its parameters. (``WV`` or ``WI``) |
| 1245 |
|
| 1246 |
:param source_type: Source type (``'Voltage','Current'``) |
| 1247 |
:type source_type: str |
| 1248 |
:param mode: Sweep mode |
| 1249 |
:type mode: :class:`.SweepMode` |
| 1250 |
:param source_range: Source range index |
| 1251 |
:type source_range: int |
| 1252 |
:param start: Sweep start value |
| 1253 |
:type start: float |
| 1254 |
:param stop: Sweep stop value |
| 1255 |
:type stop: float |
| 1256 |
:param steps: Number of sweep steps |
| 1257 |
:type steps: int |
| 1258 |
:param comp: Compliance value |
| 1259 |
:type comp: float |
| 1260 |
:param Pcomp: Power compliance, defaults to not set |
| 1261 |
:type Pcomp: float, optional |
| 1262 |
""" |
| 1263 |
if source_type.upper() == "VOLTAGE": |
| 1264 |
cmd = "WV" |
| 1265 |
source_range = self.voltage_ranging.output(source_range).index |
| 1266 |
elif source_type.upper() == "CURRENT": |
| 1267 |
cmd = "WI" |
| 1268 |
source_range = self.current_ranging.output(source_range).index |
| 1269 |
else: |
| 1270 |
raise ValueError("Source Type must be Current or Voltage.") |
| 1271 |
mode = SweepMode.get(mode).value |
| 1272 |
if mode in [2, 4]: |
| 1273 |
if start >= 0 and stop >= 0: |
| 1274 |
pass |
| 1275 |
elif start <= 0 and stop <= 0: |
| 1276 |
pass |
| 1277 |
else: |
| 1278 |
raise ValueError( |
| 1279 |
"For Log Sweep Start and Stop Values must " |
| 1280 |
"have the same polarity." |
| 1281 |
) |
| 1282 |
steps = strict_range(steps, range(1, 10002)) |
| 1283 |
# check on comp value not yet implemented |
| 1284 |
cmd += ("%d, %d, %d, %g, %g, %g, %g" % |
| 1285 |
(self.channel, mode, source_range, start, stop, steps, comp)) |
| 1286 |
if not Pcomp == '': |
| 1287 |
cmd += ", %g" % Pcomp |
| 1288 |
self.write(cmd) |
| 1289 |
self.check_errors() |
| 1290 |
|
| 1291 |
# Synchronous Output: WSI, WSV, BSSI, BSSV, LSSI, LSSV |
| 1292 |
|
| 1293 |
def synchronous_sweep_source(self, source_type, source_range, |
| 1294 |
start, stop, comp, Pcomp=''): |
| 1295 |
""" Specifies Synchronous Staircase Sweep Source (Current or Voltage) |
| 1296 |
and its parameters. (``WSV`` or ``WSI``) |
| 1297 |
|
| 1298 |
:param source_type: Source type (``'Voltage','Current'``) |
| 1299 |
:type source_type: str |
| 1300 |
:param source_range: Source range index |
| 1301 |
:type source_range: int |
| 1302 |
:param start: Sweep start value |
| 1303 |
:type start: float |
| 1304 |
:param stop: Sweep stop value |
| 1305 |
:type stop: float |
| 1306 |
:param comp: Compliance value |
| 1307 |
:type comp: float |
| 1308 |
:param Pcomp: Power compliance, defaults to not set |
| 1309 |
:type Pcomp: float, optional |
| 1310 |
""" |
| 1311 |
if source_type.upper() == "VOLTAGE": |
| 1312 |
cmd = "WSV" |
| 1313 |
source_range = self.voltage_ranging.output(source_range).index |
| 1314 |
elif source_type.upper() == "CURRENT": |
| 1315 |
cmd = "WSI" |
| 1316 |
source_range = self.current_ranging.output(source_range).index |
| 1317 |
else: |
| 1318 |
raise ValueError("Source Type must be Current or Voltage.") |
| 1319 |
# check on comp value not yet implemented |
| 1320 |
cmd += ("%d, %d, %g, %g, %g" % |
| 1321 |
(self.channel, source_range, start, stop, comp)) |
| 1322 |
if not Pcomp == '': |
| 1323 |
cmd += ", %g" % Pcomp |
| 1324 |
self.write(cmd) |
| 1325 |
self.check_errors() |
| 1326 |
|
| 1327 |
###################################### |
| 1328 |
# Sampling Measurements: (ML, MT -> Instrument) |
| 1329 |
# implemented: MV, MI |
| 1330 |
# not implemented: MSP, MCC, MSC |
| 1331 |
###################################### |
| 1332 |
|
| 1333 |
def sampling_source(self, source_type, source_range, base, bias, comp): |
| 1334 |
""" Sets DC Source (Current or Voltage) for sampling measurement. |
| 1335 |
DV/DI commands on the same channel overwrite this setting. |
| 1336 |
(``MV`` or ``MI``) |
| 1337 |
|
| 1338 |
:param source_type: Source type (``'Voltage','Current'``) |
| 1339 |
:type source_type: str |
| 1340 |
:param source_range: Source range index |
| 1341 |
:type source_range: int |
| 1342 |
:param base: Base voltage/current |
| 1343 |
:type base: float |
| 1344 |
:param bias: Bias voltage/current |
| 1345 |
:type bias: float |
| 1346 |
:param comp: Compliance value |
| 1347 |
:type comp: float |
| 1348 |
""" |
| 1349 |
if source_type.upper() == "VOLTAGE": |
| 1350 |
cmd = "MV" |
| 1351 |
source_range = self.voltage_ranging.output(source_range).index |
| 1352 |
elif source_type.upper() == "CURRENT": |
| 1353 |
cmd = "MI" |
| 1354 |
source_range = self.current_ranging.output(source_range).index |
| 1355 |
else: |
| 1356 |
raise ValueError("Source Type must be Current or Voltage.") |
| 1357 |
# check on comp value not yet implemented |
| 1358 |
cmd += ("%d, %d, %g, %g, %g" % |
| 1359 |
(self.channel, source_range, base, bias, comp)) |
| 1360 |
self.write(cmd) |
| 1361 |
self.check_errors() |
| 1362 |
|
| 1363 |
############################################################################### |
| 1364 |
# Additional Classes / Constants |
| 1365 |
############################################################################### |
| 1366 |
|
| 1367 |
|
| 1368 |
class Ranging(): |
| 1369 |
"""Possible Settings for SMU Current/Voltage Output/Measurement ranges. |
| 1370 |
Transformation of available Voltage/Current Range Names to Index and back. |
| 1371 |
|
| 1372 |
:param supported_ranges: Ranges which are supported (list of range indizes) |
| 1373 |
:type supported_ranges: list |
| 1374 |
:param ranges: All range names ``{Name: Indizes}`` |
| 1375 |
:type ranges: dict |
| 1376 |
:param fixed_ranges: add fixed ranges (negative indizes); defaults to False |
| 1377 |
:type inverse_ranges: bool, optional |
| 1378 |
|
| 1379 |
.. automethod:: __call__ |
| 1380 |
""" |
| 1381 |
|
| 1382 |
_Range = namedtuple('Range', 'name index') |
| 1383 |
|
| 1384 |
def __init__(self, supported_ranges, ranges, fixed_ranges=False): |
| 1385 |
if fixed_ranges: |
| 1386 |
# add negative indizes for measurement ranges (fixed ranging) |
| 1387 |
supported_ranges += [-i for i in supported_ranges] |
| 1388 |
# remove duplicates (0) |
| 1389 |
supported_ranges = list(dict.fromkeys(supported_ranges)) |
| 1390 |
|
| 1391 |
# create dictionary {Index: Range Name} |
| 1392 |
# distinguish between limited and fixed ranging |
| 1393 |
# omitting 'limited auto ranging'/'range fixed' |
| 1394 |
# defaults to 'limited auto ranging' |
| 1395 |
inverse_ranges = {0: 'Auto Ranging'} |
| 1396 |
for key, value in ranges.items(): |
| 1397 |
if isinstance(value, tuple): |
| 1398 |
for v in value: |
| 1399 |
inverse_ranges[v] = (key + ' limited auto ranging', key) |
| 1400 |
inverse_ranges[-v] = (key + ' range fixed') |
| 1401 |
else: |
| 1402 |
inverse_ranges[value] = (key + ' limited auto ranging', key) |
| 1403 |
inverse_ranges[-value] = (key + ' range fixed') |
| 1404 |
|
| 1405 |
ranges = {} |
| 1406 |
indizes = {} |
| 1407 |
# only take ranges supported by SMU |
| 1408 |
for i in supported_ranges: |
| 1409 |
name = inverse_ranges[i] |
| 1410 |
# check if multiple names exist for index i |
| 1411 |
if isinstance(name, tuple): |
| 1412 |
ranges[i] = name[0] # first entry is main name (unique) and |
| 1413 |
# returned as .name attribute, |
| 1414 |
# additional entries are just synonyms and can |
| 1415 |
# be used to get the range tuple |
| 1416 |
# e.g. '1 nA limited auto ranging' is identifier and |
| 1417 |
# returned as range name |
| 1418 |
# but '1 nA' also works to get the range tuple |
| 1419 |
for name2 in name: |
| 1420 |
indizes[name2] = i |
| 1421 |
else: |
| 1422 |
# only one name per index |
| 1423 |
ranges[i] = name # Index -> Name, Name not unique |
| 1424 |
indizes[name] = i # Name -> Index, only one Index per Name |
| 1425 |
|
| 1426 |
# convert all string type keys to uppercase, to avoid case-sensitivity |
| 1427 |
indizes = {key.upper(): value for key, value in indizes.items()} |
| 1428 |
self.indizes = indizes # Name -> Index |
| 1429 |
self.ranges = ranges # Index -> Name |
| 1430 |
|
| 1431 |
def __call__(self, input_value): |
| 1432 |
"""Gives named tuple (name/index) of given Range. |
| 1433 |
Throws error if range is not supported by this SMU. |
| 1434 |
|
| 1435 |
:param input: Range name or index |
| 1436 |
:type input: str or int |
| 1437 |
:return: named tuple (name/index) of range |
| 1438 |
:rtype: namedtuple |
| 1439 |
""" |
| 1440 |
# set index |
| 1441 |
if isinstance(input_value, int): |
| 1442 |
index = input_value |
| 1443 |
else: |
| 1444 |
try: |
| 1445 |
index = self.indizes[input_value.upper()] |
| 1446 |
except Exception: |
| 1447 |
raise ValueError( |
| 1448 |
('Specified Range Name {} is not valid or ' |
| 1449 |
'not supported by this SMU').format(input_value.upper())) |
| 1450 |
# get name |
| 1451 |
try: |
| 1452 |
name = self.ranges[index] |
| 1453 |
except Exception: |
| 1454 |
raise ValueError( |
| 1455 |
('Specified Range {} is not supported ' |
| 1456 |
'by this SMU').format(index)) |
| 1457 |
return self._Range(name=name, index=index) |
| 1458 |
|
| 1459 |
|
| 1460 |
class SMUVoltageRanging(): |
| 1461 |
""" Provides Range Name/Index transformation for voltage |
| 1462 |
measurement/sourcing. |
| 1463 |
Validity of ranges is checked against the type of the SMU. |
| 1464 |
|
| 1465 |
Omitting the 'limited auto ranging'/'range fixed' specification in |
| 1466 |
the range string for voltage measurement defaults to |
| 1467 |
'limited auto ranging'. |
| 1468 |
|
| 1469 |
Full specification: '2 V range fixed' or '2 V limited auto ranging' |
| 1470 |
|
| 1471 |
'2 V' defaults to '2 V limited auto ranging' |
| 1472 |
""" |
| 1473 |
|
| 1474 |
def __init__(self, smu_type): |
| 1475 |
supported_ranges = { |
| 1476 |
'HRSMU': [0, 5, 11, 20, 50, 12, 200, 13, 400, 14, 1000], |
| 1477 |
'MPSMU': [0, 5, 11, 20, 50, 12, 200, 13, 400, 14, 1000], |
| 1478 |
'HPSMU': [0, 11, 20, 12, 200, 13, 400, 14, 1000, 15, 2000], |
| 1479 |
'MCSMU': [0, 2, 11, 20, 12, 200, 13, 400], |
| 1480 |
'HCSMU': [0, 2, 11, 20, 12, 200, 13, 400], |
| 1481 |
'DHCSMU': [0, 2, 11, 20, 12, 200, 13, 400], |
| 1482 |
'HVSMU': [0, 15, 2000, 5000, 15000, 30000], |
| 1483 |
'UHCU': [0, 14, 1000], |
| 1484 |
'HVMCU': [0, 15000, 30000], |
| 1485 |
'UHVU': [0, 103] |
| 1486 |
} |
| 1487 |
supported_ranges = supported_ranges[smu_type] |
| 1488 |
|
| 1489 |
ranges = { |
| 1490 |
'0.2 V': 2, |
| 1491 |
'0.5 V': 5, |
| 1492 |
'2 V': (11, 20), |
| 1493 |
'5 V': 50, |
| 1494 |
'20 V': (12, 200), |
| 1495 |
'40 V': (13, 400), |
| 1496 |
'100 V': (14, 1000), |
| 1497 |
'200 V': (15, 2000), |
| 1498 |
'500 V': 5000, |
| 1499 |
'1500 V': 15000, |
| 1500 |
'3000 V': 30000, |
| 1501 |
'10 kV': 103 |
| 1502 |
} |
| 1503 |
|
| 1504 |
# set range attributes |
| 1505 |
self.output = Ranging(supported_ranges, ranges) |
| 1506 |
self.meas = Ranging(supported_ranges, ranges, |
| 1507 |
fixed_ranges=True) |
| 1508 |
|
| 1509 |
|
| 1510 |
class SMUCurrentRanging(): |
| 1511 |
""" Provides Range Name/Index transformation for current |
| 1512 |
measurement/sourcing. |
| 1513 |
Validity of ranges is checked against the type of the SMU. |
| 1514 |
|
| 1515 |
Omitting the 'limited auto ranging'/'range fixed' specification in |
| 1516 |
the range string for current measurement defaults to |
| 1517 |
'limited auto ranging'. |
| 1518 |
|
| 1519 |
Full specification: '1 nA range fixed' or '1 nA limited auto ranging' |
| 1520 |
|
| 1521 |
'1 nA' defaults to '1 nA limited auto ranging' |
| 1522 |
""" |
| 1523 |
|
| 1524 |
def __init__(self, smu_type): |
| 1525 |
supported_output_ranges = { |
| 1526 |
# in combination with ASU also 8 |
| 1527 |
'HRSMU': [0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], |
| 1528 |
# in combination with ASU also 8,9,10 |
| 1529 |
'MPSMU': [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], |
| 1530 |
'HPSMU': [0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], |
| 1531 |
'MCSMU': [0, 15, 16, 17, 18, 19, 20], |
| 1532 |
'HCSMU': [0, 15, 16, 17, 18, 19, 20, 22], |
| 1533 |
'DHCSMU': [0, 15, 16, 17, 18, 19, 20, 21, 23], |
| 1534 |
'HVSMU': [0, 11, 12, 13, 14, 15, 16, 17, 18], |
| 1535 |
'UHCU': [0, 26, 28], |
| 1536 |
'HVMCU': [], |
| 1537 |
'UHVU': [] |
| 1538 |
} |
| 1539 |
supported_meas_ranges = { |
| 1540 |
**supported_output_ranges, |
| 1541 |
# overwrite output ranges: |
| 1542 |
'HVMCU': [0, 19, 21], |
| 1543 |
'UHVU': [0, 15, 16, 17, 18, 19] |
| 1544 |
} |
| 1545 |
supported_output_ranges = supported_output_ranges[smu_type] |
| 1546 |
supported_meas_ranges = supported_meas_ranges[smu_type] |
| 1547 |
|
| 1548 |
ranges = { |
| 1549 |
'1 pA': 8, # for ASU |
| 1550 |
'10 pA': 9, |
| 1551 |
'100 pA': 10, |
| 1552 |
'1 nA': 11, |
| 1553 |
'10 nA': 12, |
| 1554 |
'100 nA': 13, |
| 1555 |
'1 uA': 14, |
| 1556 |
'10 uA': 15, |
| 1557 |
'100 uA': 16, |
| 1558 |
'1 mA': 17, |
| 1559 |
'10 mA': 18, |
| 1560 |
'100 mA': 19, |
| 1561 |
'1 A': 20, |
| 1562 |
'2 A': 21, |
| 1563 |
'20 A': 22, |
| 1564 |
'40 A': 23, |
| 1565 |
'500 A': 26, |
| 1566 |
'2000 A': 28 |
| 1567 |
} |
| 1568 |
|
| 1569 |
# set range attributes |
| 1570 |
self.output = Ranging(supported_output_ranges, ranges) |
| 1571 |
self.meas = Ranging(supported_meas_ranges, ranges, |
| 1572 |
fixed_ranges=True) |
| 1573 |
|
| 1574 |
|
| 1575 |
class CustomIntEnum(IntEnum): |
| 1576 |
"""Provides additional methods to IntEnum: |
| 1577 |
|
| 1578 |
* Conversion to string automatically replaces '_' with ' ' in names |
| 1579 |
and converts to title case |
| 1580 |
|
| 1581 |
* get classmethod to get enum reference with name or integer |
| 1582 |
|
| 1583 |
.. automethod:: __str__ |
| 1584 |
""" |
| 1585 |
|
| 1586 |
def __str__(self): |
| 1587 |
"""Gives title case string of enum value |
| 1588 |
""" |
| 1589 |
return str(self.name).replace("_", " ").title() |
| 1590 |
# str() conversion just because of pylint bug |
| 1591 |
|
| 1592 |
@classmethod |
| 1593 |
def get(cls, input_value): |
| 1594 |
"""Gives Enum member by specifying name or value. |
| 1595 |
|
| 1596 |
:param input_value: Enum name or value |
| 1597 |
:type input_value: str or int |
| 1598 |
:return: Enum member |
| 1599 |
""" |
| 1600 |
if isinstance(input_value, int): |
| 1601 |
return cls(input_value) |
| 1602 |
else: |
| 1603 |
return cls[input_value.upper()] |
| 1604 |
|
| 1605 |
|
| 1606 |
class ADCType(CustomIntEnum): |
| 1607 |
"""ADC Type""" |
| 1608 |
HSADC = 0, #: High-speed ADC |
| 1609 |
HRADC = 1, #: High-resolution ADC |
| 1610 |
HSADC_PULSED = 2, #: High-resolution ADC for pulsed measurements |
| 1611 |
|
| 1612 |
def __str__(self): |
| 1613 |
return str(self.name).replace("_", " ") |
| 1614 |
# .title() str() conversion just because of pylint bug |
| 1615 |
|
| 1616 |
|
| 1617 |
class ADCMode(CustomIntEnum): |
| 1618 |
"""ADC Mode""" |
| 1619 |
AUTO = 0 #: |
| 1620 |
MANUAL = 1 #: |
| 1621 |
PLC = 2 #: |
| 1622 |
TIME = 3 #: |
| 1623 |
|
| 1624 |
|
| 1625 |
class AutoManual(CustomIntEnum): |
| 1626 |
"""Auto/Manual selection""" |
| 1627 |
AUTO = 0 #: |
| 1628 |
MANUAL = 1 #: |
| 1629 |
|
| 1630 |
|
| 1631 |
class MeasMode(CustomIntEnum): |
| 1632 |
"""Measurement Mode""" |
| 1633 |
SPOT = 1 #: |
| 1634 |
STAIRCASE_SWEEP = 2 #: |
| 1635 |
SAMPLING = 10 #: |
| 1636 |
|
| 1637 |
|
| 1638 |
class MeasOpMode(CustomIntEnum): |
| 1639 |
"""Measurement Operation Mode""" |
| 1640 |
COMPLIANCE_SIDE = 0 #: |
| 1641 |
CURRENT = 1 #: |
| 1642 |
VOLTAGE = 2 #: |
| 1643 |
FORCE_SIDE = 3 #: |
| 1644 |
COMPLIANCE_AND_FORCE_SIDE = 4 #: |
| 1645 |
|
| 1646 |
|
| 1647 |
class SweepMode(CustomIntEnum): |
| 1648 |
"""Sweep Mode""" |
| 1649 |
LINEAR_SINGLE = 1 #: |
| 1650 |
LOG_SINGLE = 2 #: |
| 1651 |
LINEAR_DOUBLE = 3 #: |
| 1652 |
LOG_DOUBLE = 4 #: |
| 1653 |
|
| 1654 |
|
| 1655 |
class SamplingMode(CustomIntEnum): |
| 1656 |
"""Sampling Mode""" |
| 1657 |
LINEAR = 1 #: |
| 1658 |
LOG_10 = 2 #: Logarithmic 10 data points/decade |
| 1659 |
LOG_25 = 3 #: Logarithmic 25 data points/decade |
| 1660 |
LOG_50 = 4 #: Logarithmic 50 data points/decade |
| 1661 |
LOG_100 = 5 #: Logarithmic 100 data points/decade |
| 1662 |
LOG_250 = 6 #: Logarithmic 250 data points/decade |
| 1663 |
LOG_5000 = 7 #: Logarithmic 5000 data points/decade |
| 1664 |
|
| 1665 |
def __str__(self): |
| 1666 |
names = { |
| 1667 |
1: "Linear", |
| 1668 |
2: "Log 10 data/decade", 3: "Log 25 data/decade", |
| 1669 |
4: "Log 50 data/decade", 5: "Log 100 data/decade", |
| 1670 |
6: "Log 250 data/decade", 7: "Log 5000 data/decade"} |
| 1671 |
return names[self.value] |
| 1672 |
|
| 1673 |
|
| 1674 |
class SamplingPostOutput(CustomIntEnum): |
| 1675 |
"""Output after sampling""" |
| 1676 |
BASE = 1 #: |
| 1677 |
BIAS = 2 #: |
| 1678 |
|
| 1679 |
|
| 1680 |
class StaircaseSweepPostOutput(CustomIntEnum): |
| 1681 |
"""Output after staircase sweep""" |
| 1682 |
START = 1 #: |
| 1683 |
STOP = 2 #: |
| 1684 |
|
| 1685 |
|
| 1686 |
class CompliancePolarity(CustomIntEnum): |
| 1687 |
"""Compliance polarity""" |
| 1688 |
AUTO = 0 #: |
| 1689 |
MANUAL = 1 #: |
| 1690 |
|
| 1691 |
|
| 1692 |
class WaitTimeType(CustomIntEnum): |
| 1693 |
"""Wait time type""" |
| 1694 |
SMU_SOURCE = 1 #: |
| 1695 |
SMU_MEASUREMENT = 2 #: |
| 1696 |
CMU_MEASUREMENT = 3 #: |
| 1697 |
|
| 1698 |
############################################################################### |
| 1699 |
# Query Learn: Parse Instrument settings into human readable format |
| 1700 |
############################################################################### |
| 1701 |
|
| 1702 |
|
| 1703 |
class QueryLearn(): |
| 1704 |
"""Methods to issue and process ``*LRN?`` (learn) command and response.""" |
| 1705 |
|
| 1706 |
@staticmethod |
| 1707 |
def query_learn(ask, query_type): |
| 1708 |
""" Issues ``*LRN?`` (learn) command to the instrument to read |
| 1709 |
configuration. |
| 1710 |
Returns dictionary of commands and set values. |
| 1711 |
|
| 1712 |
:param query_type: Query type according to the programming guide |
| 1713 |
:type query_type: int |
| 1714 |
:return: Dictionary of command and set values |
| 1715 |
:rtype: dict |
| 1716 |
""" |
| 1717 |
response = ask("*LRN? " + str(query_type)) |
| 1718 |
# response.split(';') |
| 1719 |
response = re.findall( |
| 1720 |
r'(?P<command>[A-Z]+)(?P<parameter>[0-9,\+\-\.E]+)', |
| 1721 |
response) |
| 1722 |
# check if commands are unique -> suitable as keys for dict |
| 1723 |
counts = Counter([item[0] for item in response]) |
| 1724 |
# responses that start with a channel number |
| 1725 |
# the channel number should always be included in the key |
| 1726 |
include_chnum = [ |
| 1727 |
'DI', 'DV', # Sourcing |
| 1728 |
'RI', 'RV', # Ranging |
| 1729 |
'WV', 'WI', 'WSV', 'WSI', # Staircase Sweep |
| 1730 |
'PV', 'PI', 'PWV', 'PWI', # Pulsed Source |
| 1731 |
'MV', 'MI', 'MSP', # Sampling |
| 1732 |
'SSR', 'RM', 'AAD' # Series Resistor, Auto Ranging, ADC |
| 1733 |
] # probably not complete yet... |
| 1734 |
response_dict = {} |
| 1735 |
for element in response: |
| 1736 |
parameters = element[1].split(',') |
| 1737 |
name = element[0] |
| 1738 |
if (counts[name] > 1) or (name in include_chnum): |
| 1739 |
# append channel (first parameter) to command as dict key |
| 1740 |
name += parameters[0] |
| 1741 |
parameters = parameters[1:] |
| 1742 |
if len(parameters) == 1: |
| 1743 |
parameters = parameters[0] |
| 1744 |
# skip second AAD entry for each channel -> contains no information |
| 1745 |
if 'AAD' in name and name in response_dict.keys(): |
| 1746 |
continue |
| 1747 |
response_dict[name] = parameters |
| 1748 |
return response_dict |
| 1749 |
|
| 1750 |
@classmethod |
| 1751 |
def query_learn_header(cls, ask, query_type, smu_references, |
| 1752 |
single_command=False): |
| 1753 |
"""Issues ``*LRN?`` (learn) command to the instrument to |
| 1754 |
read configuration. |
| 1755 |
Processes information to human readable values for debugging |
| 1756 |
purposes or file headers. |
| 1757 |
|
| 1758 |
:param ask: ask method of the instrument |
| 1759 |
:type ask: Instrument.ask |
| 1760 |
:param query_type: Number according to Programming Guide |
| 1761 |
:type query_type: int or str |
| 1762 |
:param smu_references: SMU references by channel |
| 1763 |
:type smu_references: dict |
| 1764 |
:param single_command: if only a single command should be returned, |
| 1765 |
defaults to False |
| 1766 |
:type single_command: str |
| 1767 |
:return: Read configuration |
| 1768 |
:rtype: dict |
| 1769 |
""" |
| 1770 |
response = cls.query_learn(ask, query_type) |
| 1771 |
if single_command is not False: |
| 1772 |
response = response[single_command] |
| 1773 |
ret = {} |
| 1774 |
for key, value in response.items(): |
| 1775 |
# command without channel |
| 1776 |
command = re.findall(r'(?P<command>[A-Z]+)', key)[0] |
| 1777 |
new_dict = getattr(cls, command)( |
| 1778 |
key, value, smu_references=smu_references) |
| 1779 |
ret = {**ret, **new_dict} |
| 1780 |
return ret |
| 1781 |
|
| 1782 |
@staticmethod |
| 1783 |
def to_dict(parameters, names, *args): |
| 1784 |
""" Takes parameters returned by :meth:`query_learn` and ordered list |
| 1785 |
of corresponding parameter names (optional function) and returns |
| 1786 |
dict of parameters including names. |
| 1787 |
|
| 1788 |
:param parameters: Parameters for one command returned |
| 1789 |
by :meth:`query_learn` |
| 1790 |
:type parameters: dict |
| 1791 |
:param names: list of names or (name, function) tuples, ordered |
| 1792 |
:type names: list |
| 1793 |
:return: Parameter name and (processed) parameter |
| 1794 |
:rtype: dict |
| 1795 |
""" |
| 1796 |
ret = OrderedDict() |
| 1797 |
if isinstance(parameters, str): |
| 1798 |
# otherwise string is enumerated |
| 1799 |
parameters_iter = [(0, parameters)] |
| 1800 |
else: |
| 1801 |
parameters_iter = enumerate(parameters) |
| 1802 |
for i, parameter in parameters_iter: |
| 1803 |
if isinstance(names[i], tuple): |
| 1804 |
ret[names[i][0]] = names[i][1](parameter, *args) |
| 1805 |
else: |
| 1806 |
ret[names[i]] = parameter |
| 1807 |
return ret |
| 1808 |
|
| 1809 |
@staticmethod |
| 1810 |
def _get_smu(key, smu_references): |
| 1811 |
# command without channel |
| 1812 |
command = re.findall(r'(?P<command>[A-Z]+)', key)[0] |
| 1813 |
channel = key[len(command) :] # noqa: E203 |
| 1814 |
return smu_references[int(channel)] |
| 1815 |
|
| 1816 |
# SMU Modes |
| 1817 |
@classmethod |
| 1818 |
def DI(cls, key, parameters, smu_references={}): |
| 1819 |
smu = cls._get_smu(key, smu_references) |
| 1820 |
names = [ |
| 1821 |
('Current Range', |
| 1822 |
lambda parameter: |
| 1823 |
smu.current_ranging.output(int(parameter)).name), |
| 1824 |
'Current Output (A)', 'Compliance Voltage (V)', |
| 1825 |
('Compliance Polarity', |
| 1826 |
lambda parameter: str(CompliancePolarity.get(int(parameter)))), |
| 1827 |
('Voltage Compliance Ranging Type', |
| 1828 |
lambda parameter: |
| 1829 |
smu.voltage_ranging.meas(int(parameter)).name) |
| 1830 |
] |
| 1831 |
ret = cls.to_dict(parameters, names) |
| 1832 |
ret['Source Type'] = 'Constant Current' |
| 1833 |
ret.move_to_end('Source Type', last=False) # make first entry |
| 1834 |
return {smu.name: ret} |
| 1835 |
|
| 1836 |
@classmethod |
| 1837 |
def DV(cls, key, parameters, smu_references={}): |
| 1838 |
smu = cls._get_smu(key, smu_references) |
| 1839 |
names = [ |
| 1840 |
('Voltage Range', |
| 1841 |
lambda parameter: |
| 1842 |
smu.voltage_ranging.output(int(parameter)).name), |
| 1843 |
'Voltage Output (V)', 'Compliance Current (A)', |
| 1844 |
('Compliance Polarity', |
| 1845 |
lambda parameter: str(CompliancePolarity.get(int(parameter)))), |
| 1846 |
('Current Compliance Ranging Type', |
| 1847 |
lambda parameter: |
| 1848 |
smu.current_ranging.meas(int(parameter)).name) |
| 1849 |
] |
| 1850 |
ret = cls.to_dict(parameters, names) |
| 1851 |
ret['Source Type'] = 'Constant Voltage' |
| 1852 |
ret.move_to_end('Source Type', last=False) # make first entry |
| 1853 |
return {smu.name: ret} |
| 1854 |
|
| 1855 |
@classmethod |
| 1856 |
def CL(cls, key, parameters, smu_references={}): |
| 1857 |
smu = cls._get_smu(key + parameters, smu_references) |
| 1858 |
return {smu.name: 'OFF'} |
| 1859 |
|
| 1860 |
# Instrument Settings: 31 |
| 1861 |
@classmethod |
| 1862 |
def TM(cls, key, parameters, smu_references={}): |
| 1863 |
names = ['Trigger Mode'] # enum + setting not implemented yet |
| 1864 |
return cls.to_dict(parameters, names) |
| 1865 |
|
| 1866 |
@classmethod |
| 1867 |
def AV(cls, key, parameters, smu_references={}): |
| 1868 |
names = [ |
| 1869 |
'ADC Averaging Number', |
| 1870 |
('ADC Averaging Mode', |
| 1871 |
lambda parameter: str(AutoManual(int(parameter)))) |
| 1872 |
] |
| 1873 |
return cls.to_dict(parameters, names) |
| 1874 |
|
| 1875 |
@classmethod |
| 1876 |
def CM(cls, key, parameters, smu_references={}): |
| 1877 |
names = [ |
| 1878 |
('Auto Calibration Mode', |
| 1879 |
lambda parameter: bool(int(parameter))) |
| 1880 |
] |
| 1881 |
return cls.to_dict(parameters, names) |
| 1882 |
|
| 1883 |
@classmethod |
| 1884 |
def FMT(cls, key, parameters, smu_references={}): |
| 1885 |
names = ['Output Data Format', 'Output Data Mode'] |
| 1886 |
# enum + setting not implemented yet |
| 1887 |
return cls.to_dict(parameters, names) |
| 1888 |
|
| 1889 |
@classmethod |
| 1890 |
def MM(cls, key, parameters, smu_references={}): |
| 1891 |
names = [ |
| 1892 |
('Measurement Mode', |
| 1893 |
lambda parameter: str(MeasMode(int(parameter)))) |
| 1894 |
] |
| 1895 |
ret = cls.to_dict(parameters[0], names) |
| 1896 |
smu_names = [] |
| 1897 |
for channel in parameters[1:]: |
| 1898 |
smu_names.append(smu_references[int(channel)].name) |
| 1899 |
ret['Measurement Channels'] = ', '.join(smu_names) |
| 1900 |
return ret |
| 1901 |
|
| 1902 |
# Measurement Ranging: 32 |
| 1903 |
@classmethod |
| 1904 |
def RI(cls, key, parameters, smu_references={}): |
| 1905 |
smu = cls._get_smu(key, smu_references) |
| 1906 |
names = [ |
| 1907 |
(smu.name + ' Current Measurement Range', |
| 1908 |
lambda parameter: |
| 1909 |
smu.current_ranging.meas(int(parameter)).name) |
| 1910 |
] |
| 1911 |
return cls.to_dict(parameters, names) |
| 1912 |
|
| 1913 |
@classmethod |
| 1914 |
def RV(cls, key, parameters, smu_references={}): |
| 1915 |
smu = cls._get_smu(key, smu_references) |
| 1916 |
names = [ |
| 1917 |
(smu.name + ' Voltage Measurement Range', |
| 1918 |
lambda parameter: |
| 1919 |
smu.voltage_ranging.meas(int(parameter)).name) |
| 1920 |
] |
| 1921 |
return cls.to_dict(parameters, names) |
| 1922 |
|
| 1923 |
# Sweep: 33 |
| 1924 |
@classmethod |
| 1925 |
def WM(cls, key, parameters, smu_references={}): |
| 1926 |
names = [ |
| 1927 |
('Auto Abort Status', |
| 1928 |
lambda parameter: |
| 1929 |
{2: True, 1: False}[int(parameter)]), |
| 1930 |
('Output after Measurement', |
| 1931 |
lambda parameter: |
| 1932 |
str(StaircaseSweepPostOutput(int(parameter)))) |
| 1933 |
] |
| 1934 |
return cls.to_dict(parameters, names) |
| 1935 |
|
| 1936 |
@classmethod |
| 1937 |
def WT(cls, key, parameters, smu_references={}): |
| 1938 |
names = [ |
| 1939 |
'Hold Time (s)', 'Delay Time (s)', 'Step Delay Time (s)', |
| 1940 |
'Step Source Trigger Delay Time (s)', |
| 1941 |
'Step Measurement Trigger Delay Time (s)' |
| 1942 |
] |
| 1943 |
return cls.to_dict(parameters, names) |
| 1944 |
|
| 1945 |
@classmethod |
| 1946 |
def WV(cls, key, parameters, smu_references={}): |
| 1947 |
smu = cls._get_smu(key, smu_references) |
| 1948 |
names = [ |
| 1949 |
("Sweep Mode", |
| 1950 |
lambda parameter: str(SweepMode(int(parameter)))), |
| 1951 |
("Voltage Range", |
| 1952 |
lambda parameter: |
| 1953 |
smu.voltage_ranging.output(int(parameter)).name), |
| 1954 |
"Start Voltage (V)", "Stop Voltage (V)", "Number of Steps", |
| 1955 |
"Current Compliance (A)", "Power Compliance (W)" |
| 1956 |
] |
| 1957 |
ret = cls.to_dict(parameters, names) |
| 1958 |
ret['Source Type'] = 'Voltage Sweep Source' |
| 1959 |
ret.move_to_end('Source Type', last=False) # make first entry |
| 1960 |
return {smu.name: ret} |
| 1961 |
|
| 1962 |
@classmethod |
| 1963 |
def WI(cls, key, parameters, smu_references={}): |
| 1964 |
smu = cls._get_smu(key, smu_references) |
| 1965 |
names = [ |
| 1966 |
("Sweep Mode", lambda parameter: str(SweepMode(int(parameter)))), |
| 1967 |
("Current Range", |
| 1968 |
lambda parameter: |
| 1969 |
smu.current_ranging.output(int(parameter)).name), |
| 1970 |
"Start Current (A)", "Stop Current (A)", "Number of Steps", |
| 1971 |
"Voltage Compliance (V)", "Power Compliance (W)" |
| 1972 |
] |
| 1973 |
ret = cls.to_dict(parameters, names) |
| 1974 |
ret['Source Type'] = 'Current Sweep Source' |
| 1975 |
ret.move_to_end('Source Type', last=False) # make first entry |
| 1976 |
return {smu.name: ret} |
| 1977 |
|
| 1978 |
@classmethod |
| 1979 |
def WSV(cls, key, parameters, smu_references={}): |
| 1980 |
smu = cls._get_smu(key, smu_references) |
| 1981 |
names = [ |
| 1982 |
("Voltage Range", |
| 1983 |
lambda parameter: |
| 1984 |
smu.voltage_ranging.output(int(parameter)).name), |
| 1985 |
"Start Voltage (V)", "Stop Voltage (V)", |
| 1986 |
"Current Compliance (A)", "Power Compliance (W)" |
| 1987 |
] |
| 1988 |
ret = cls.to_dict(parameters, names) |
| 1989 |
ret['Source Type'] = 'Synchronous Voltage Sweep Source' |
| 1990 |
ret.move_to_end('Source Type', last=False) # make first entry |
| 1991 |
return {smu.name: ret} |
| 1992 |
|
| 1993 |
@classmethod |
| 1994 |
def WSI(cls, key, parameters, smu_references={}): |
| 1995 |
smu = cls._get_smu(key, smu_references) |
| 1996 |
names = [ |
| 1997 |
("Current Range", |
| 1998 |
lambda parameter: |
| 1999 |
smu.current_ranging.output(int(parameter)).name), |
| 2000 |
"Start Current (A)", "Stop Current (A)", |
| 2001 |
"Voltage Compliance (V)", "Power Compliance (W)" |
| 2002 |
] |
| 2003 |
ret = cls.to_dict(parameters, names) |
| 2004 |
ret['Source Type'] = 'Synchronous Current Sweep Source' |
| 2005 |
ret.move_to_end('Source Type', last=False) # make first entry |
| 2006 |
return {smu.name: ret} |
| 2007 |
|
| 2008 |
# SMU Measurement Operation Mode: 46 |
| 2009 |
@classmethod |
| 2010 |
def CMM(cls, key, parameters, smu_references={}): |
| 2011 |
smu = cls._get_smu(key, smu_references) |
| 2012 |
names = [ |
| 2013 |
(smu.name + ' Measurement Operation Mode', |
| 2014 |
lambda parameter: |
| 2015 |
str(MeasOpMode(int(parameter)))) |
| 2016 |
] |
| 2017 |
return cls.to_dict(parameters, names) |
| 2018 |
|
| 2019 |
# Sampling: 47 |
| 2020 |
@classmethod |
| 2021 |
def MSC(cls, key, parameters, smu_references={}): |
| 2022 |
names = [ |
| 2023 |
('Auto Abort Status', |
| 2024 |
lambda parameter: |
| 2025 |
{2: True, 1: False}[int(parameter)]), |
| 2026 |
('Output after Measurement', |
| 2027 |
lambda parameter: |
| 2028 |
str(SamplingPostOutput(int(parameter)))) |
| 2029 |
] |
| 2030 |
return cls.to_dict(parameters, names) |
| 2031 |
|
| 2032 |
@classmethod |
| 2033 |
def MT(cls, key, parameters, smu_references={}): |
| 2034 |
names = [ |
| 2035 |
'Hold Bias Time (s)', 'Sampling Interval (s)', |
| 2036 |
'Number of Samples', 'Hold Base Time (s)' |
| 2037 |
] |
| 2038 |
return cls.to_dict(parameters, names) |
| 2039 |
|
| 2040 |
@classmethod |
| 2041 |
def ML(cls, key, parameters, smu_references={}): |
| 2042 |
names = [ |
| 2043 |
('Sampling Mode', |
| 2044 |
lambda parameter: str(SamplingMode(int(parameter)))) |
| 2045 |
] |
| 2046 |
return cls.to_dict(parameters, names) |
| 2047 |
|
| 2048 |
@classmethod |
| 2049 |
def MV(cls, key, parameters, smu_references={}): |
| 2050 |
smu = cls._get_smu(key, smu_references) |
| 2051 |
names = [ |
| 2052 |
("Voltage Range", |
| 2053 |
lambda parameter: |
| 2054 |
smu.voltage_ranging.output(int(parameter)).name), |
| 2055 |
"Base Voltage (V)", "Bias Voltage (V)", |
| 2056 |
"Current Compliance (A)" |
| 2057 |
] |
| 2058 |
ret = cls.to_dict(parameters, names) |
| 2059 |
ret['Source Type'] = 'Voltage Source Sampling' |
| 2060 |
ret.move_to_end('Source Type', last=False) # make first entry |
| 2061 |
return {smu.name: ret} |
| 2062 |
|
| 2063 |
@classmethod |
| 2064 |
def MI(cls, key, parameters, smu_references={}): |
| 2065 |
smu = cls._get_smu(key, smu_references) |
| 2066 |
names = [ |
| 2067 |
("Current Range", |
| 2068 |
lambda parameter: |
| 2069 |
smu.current_ranging.output(int(parameter)).name), |
| 2070 |
"Base Current (A)", "Bias Current (A)", |
| 2071 |
"Voltage Compliance (V)" |
| 2072 |
] |
| 2073 |
ret = cls.to_dict(parameters, names) |
| 2074 |
ret['Source Type'] = 'Current Source Sampling' |
| 2075 |
ret.move_to_end('Source Type', last=False) # make first entry |
| 2076 |
return {smu.name: ret} |
| 2077 |
|
| 2078 |
# SMU Series Resistor: 53 |
| 2079 |
@classmethod |
| 2080 |
def SSR(cls, key, parameters, smu_references={}): |
| 2081 |
smu = cls._get_smu(key, smu_references) |
| 2082 |
names = [ |
| 2083 |
(smu.name + ' Series Resistor', |
| 2084 |
lambda parameter: bool(int(parameter))) |
| 2085 |
] |
| 2086 |
return cls.to_dict(parameters, names) |
| 2087 |
|
| 2088 |
# Auto Ranging Mode: 54 |
| 2089 |
@classmethod |
| 2090 |
def RM(cls, key, parameters, smu_references={}): |
| 2091 |
smu = cls._get_smu(key, smu_references) |
| 2092 |
names = [ |
| 2093 |
smu.name + ' Ranging Mode', |
| 2094 |
smu.name + ' Ranging Mode Parameter' |
| 2095 |
] |
| 2096 |
return cls.to_dict(parameters, names) |
| 2097 |
|
| 2098 |
# ADC: 55, 56 |
| 2099 |
@classmethod |
| 2100 |
def AAD(cls, key, parameters, smu_references={}): |
| 2101 |
smu = cls._get_smu(key, smu_references) |
| 2102 |
names = [ |
| 2103 |
(smu.name + ' ADC', |
| 2104 |
lambda parameter: |
| 2105 |
str(ADCType(int(parameter)))) |
| 2106 |
] |
| 2107 |
return cls.to_dict(parameters, names) |
| 2108 |
|
| 2109 |
@classmethod |
| 2110 |
def AIT(cls, key, parameters, smu_references={}): |
| 2111 |
adc_type = key[3:] |
| 2112 |
adc_name = str(ADCType(int(adc_type))) |
| 2113 |
names = [ |
| 2114 |
(adc_name + ' Mode', |
| 2115 |
lambda parameter: |
| 2116 |
str(ADCMode(int(parameter)))), |
| 2117 |
adc_name + ' Parameter' |
| 2118 |
] |
| 2119 |
return cls.to_dict(parameters, names) |
| 2120 |
|
| 2121 |
@classmethod |
| 2122 |
def AZ(cls, key, parameters, smu_references={}): |
| 2123 |
names = [ |
| 2124 |
('ADC Auto Zero', |
| 2125 |
lambda parameter: str(bool(int(parameter)))) |
| 2126 |
] |
| 2127 |
return cls.to_dict(parameters, names) |
| 2128 |
|
| 2129 |
# Time Stamp: 60 |
| 2130 |
@classmethod |
| 2131 |
def TSC(cls, key, parameters, smu_references={}): |
| 2132 |
names = [ |
| 2133 |
('Time Stamp', |
| 2134 |
lambda parameter: str(bool(int(parameter)))) |
| 2135 |
] |
| 2136 |
return cls.to_dict(parameters, names) |