| 1 |
# This file is part of the PyMeasure package. |
| 2 |
# |
| 3 |
# Copyright (c) 2013-2024 PyMeasure Developers |
| 4 |
# |
| 5 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
# of this software and associated documentation files (the "Software"), to deal |
| 7 |
# in the Software without restriction, including without limitation the rights |
| 8 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
# copies of the Software, and to permit persons to whom the Software is |
| 10 |
# furnished to do so, subject to the following conditions: |
| 11 |
# |
| 12 |
# The above copyright notice and this permission notice shall be included in |
| 13 |
# all copies or substantial portions of the Software. |
| 14 |
# |
| 15 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 21 |
# THE SOFTWARE. |
| 22 |
# |
| 23 |
|
| 24 |
import logging |
| 25 |
from enum import IntEnum, IntFlag |
| 26 |
from pymeasure.instruments import Instrument, Channel, SCPIUnknownMixin |
| 27 |
from pymeasure.instruments.validators import truncated_range, strict_discrete_set, \ |
| 28 |
strict_range |
| 29 |
|
| 30 |
# Setup logging |
| 31 |
log = logging.getLogger(__name__) |
| 32 |
log.addHandler(logging.NullHandler()) |
| 33 |
|
| 34 |
|
| 35 |
class SampleHold(IntEnum): |
| 36 |
MODE_0 = 0 |
| 37 |
MODE_100uS = 6 |
| 38 |
MODE_200uS = 7 |
| 39 |
MODE_500uS = 8 |
| 40 |
MODE_1mS = 9 |
| 41 |
MODE_2mS = 10 |
| 42 |
MODE_5mS = 11 |
| 43 |
MODE_10mS = 12 |
| 44 |
MODE_1PLC = 13 # Number of power line cycles |
| 45 |
MODE_2PLC = 14 |
| 46 |
MODE_5PLC = 15 |
| 47 |
MODE_10PLC = 16 |
| 48 |
MODE_20PLC = 17 |
| 49 |
|
| 50 |
|
| 51 |
class SampleMode(IntEnum): |
| 52 |
ASYNC = 1 # Asynchronous operation |
| 53 |
PULSED_SYNC = 2 # Synchronous operation of DC measurement and pulse measurement |
| 54 |
PULSED_POSITIVE = 3 # Positive tracking operation for DC measurement and pulse measurement |
| 55 |
PULSED_REVERSE = 4 # DC measurement, pulse measurement reverse polarity tracking operation |
| 56 |
SWEEP_SYNC = 5 # Synchronous operation of sweep measurement |
| 57 |
SWEEP_DELAYED = 6 # Delayed sweep operation |
| 58 |
SWEEP_DOUBLE = 7 # Double synchronous sweep operation |
| 59 |
BINARY_SEARCH = 8 # Binary search |
| 60 |
LINEAR_SEARCH = 9 # Linear search |
| 61 |
|
| 62 |
|
| 63 |
class VoltageRange(IntEnum): |
| 64 |
# When the integration time is sample hold mode (SH) and between 100 μs to 500 μs, the |
| 65 |
# resolution is as follows. |
| 66 |
# |
| 67 |
# Integration time Decomposition energy (digit) |
| 68 |
# SH, 100μs 10 digits |
| 69 |
# 200μs 5 digits |
| 70 |
# 500μs 2 digits |
| 71 |
|
| 72 |
# The range that maximizes the number of digits in the measurement data is automatically |
| 73 |
# selected. |
| 74 |
# It cannot be specified for pulse measurement and pulse sweep. |
| 75 |
|
| 76 |
AUTO = 0 # ±1μV resolution |
| 77 |
|
| 78 |
# Limited auto range |
| 79 |
# It operates in the same way as the auto range except that the specified range is minimized. |
| 80 |
# It cannot be specified for pulse measurement and pulse sweep. |
| 81 |
AUTO_600mV = 23 # ±1μV resolution |
| 82 |
AUTO_6V = 24 # ±10μV resolution |
| 83 |
AUTO_60V = 25 # ±100μV resolution |
| 84 |
AUTO_200V = 26 # ±1mV resolution |
| 85 |
|
| 86 |
# Best fixed range |
| 87 |
# - Voltage generation When measuring voltage (VSVM), the range is the same as the generation |
| 88 |
# range. |
| 89 |
# - In the case of current generation voltage measurement (ISVM), it is in the same range as the |
| 90 |
# compliance range. |
| 91 |
FIXED_BEST = 20 # ±1μV - 1mV resolution |
| 92 |
|
| 93 |
# Measure in the specified range. |
| 94 |
FIXED_600mV = 3 # ±1μV resolution |
| 95 |
FIXED_6V = 4 # ±10μV resolution |
| 96 |
FIXED_60V = 5 # ±100μV resolution |
| 97 |
FIXED_200V = 6 # ±1mV resolution |
| 98 |
|
| 99 |
|
| 100 |
class CurrentRange(IntEnum): |
| 101 |
# When the integration time is sample hold mode (SH) and between 100 μs to 500 μs, the |
| 102 |
# resolution is as follows. |
| 103 |
# |
| 104 |
# Integration time Decomposition energy (digit) |
| 105 |
# SH, 100μs 10 digits |
| 106 |
# 200μs 5 digits |
| 107 |
# 500μs 2 digits |
| 108 |
|
| 109 |
# The range that maximizes the number of digits in the measurement data is automatically |
| 110 |
# selected. |
| 111 |
# It cannot be specified for pulse measurement and pulse sweep. |
| 112 |
AUTO = 0 # ±10fA resolution |
| 113 |
|
| 114 |
# It operates in the same way as the auto range, except that the specified range is the minimum |
| 115 |
# range. It cannot be specified for pulse measurement and pulse sweep. |
| 116 |
AUTO_6nA = 23 # ±10fA resolution |
| 117 |
AUTO_60nA = 24 # ±100fA resolution |
| 118 |
AUTO_600nA = 25 # ±1pA resolution |
| 119 |
AUTO_6μA = 26 # ±10pA resolution |
| 120 |
AUTO_60μA = 27 # ±100pA resolution |
| 121 |
AUTO_600μA = 28 # ±1nA resolution |
| 122 |
AUTO_6mA = 29 # ±10nA resolution |
| 123 |
AUTO_60mA = 30 # ±100nA resolution |
| 124 |
AUTO_600mA = 31 # ±1μA resolution |
| 125 |
AUTO_2A_6A = 32 # ±10μA resolution |
| 126 |
AUTO_20A = 33 # ±100μA resolution |
| 127 |
|
| 128 |
# Current generation when measuring current (ISIM), the range is the same as the generation |
| 129 |
# range. When measuring voltage generation current (VSIM), it is in the same |
| 130 |
# range as the compliance range. |
| 131 |
FIXED_BEST = 20 # ±10fA - ±100μA resolution |
| 132 |
|
| 133 |
# A fixed range cannot be specified for internal measurements. |
| 134 |
# It can be specified only for external measurement. MEASURE INPUT-ANALOG COMMON |
| 135 |
# Also measures the voltage between the terminals as the specified current range data. |
| 136 |
FIXED_6nA = 3 # ±10fA resolution |
| 137 |
FIXED_60nA = 4 # ±100fA resolution |
| 138 |
FIXED_600nA = 5 # ±1pA resolution |
| 139 |
FIXED_6μA = 6 # ±10pA resolution |
| 140 |
FIXED_60μA = 7 # ±100pA resolution |
| 141 |
FIXED_600μA = 8 # ±1nA resolution |
| 142 |
FIXED_6mA = 9 # ±10nA resolution |
| 143 |
FIXED_60mA = 10 # ±100nA resolution |
| 144 |
FIXED_600mA = 11 # ±1μA resolution |
| 145 |
FIXED_2A_6A = 12 # ±10μA resolution |
| 146 |
FIXED_20A = 13 # ±100μA resolution |
| 147 |
|
| 148 |
|
| 149 |
class SweepMode(IntEnum): |
| 150 |
LINEAR_ONE_WAY_SWEEP = 1 |
| 151 |
LOG_ONE_WAY_SWEEP = 2 |
| 152 |
LINEAR_ROUND_TRIP_SWEEP = 3 |
| 153 |
LOG_ROUND_TRIP_SWEEP = 4 |
| 154 |
|
| 155 |
|
| 156 |
class OutputType(IntEnum): |
| 157 |
REAL_TIME_OUTPUT = 1 # there is output every time it is measured |
| 158 |
BUFFERING_OUTPUT_ALL = 2 # output all at once after sweeping |
| 159 |
BUFFERING_OUTPUT_SPECIFIED = 3 # After sweeping, only output the specified data |
| 160 |
|
| 161 |
|
| 162 |
class TriggerInputType(IntEnum): |
| 163 |
ALL = 1 |
| 164 |
SOFTWARE_ONLY = 2 |
| 165 |
CHANNELS_ONLY = 3 |
| 166 |
|
| 167 |
|
| 168 |
class MeasurementType(IntEnum): |
| 169 |
MEASURE_DATA = 1 |
| 170 |
MEASURE_DATA_AND_OCCURENCE = 2 |
| 171 |
|
| 172 |
|
| 173 |
class SequenceInterruptionType(IntEnum): |
| 174 |
""" 1. Release pause state is a valid command only in the |
| 175 |
sequence program pause state. otherwise it is ignored. |
| 176 |
|
| 177 |
2. Pause state enters the pause state when the currently |
| 178 |
executing program ends. |
| 179 |
|
| 180 |
3. Abort sequence program stops the sequence program when |
| 181 |
the currently executing program ends. If the currently running program |
| 182 |
is a sweep operation, interrupt the sweep operation and stop the sequence |
| 183 |
program. The output value will be the bias value. |
| 184 |
|
| 185 |
""" |
| 186 |
RELEASE_PAUSE = 1 |
| 187 |
PAUSE = 2 |
| 188 |
INTERRUPT_SEQUENCE = 3 |
| 189 |
|
| 190 |
|
| 191 |
class DOR(IntFlag): |
| 192 |
""" bit assigment for the Device Operation Register (DOR): |
| 193 |
|
| 194 |
========= ========================== |
| 195 |
Bit (dec) Description |
| 196 |
========= ========================== |
| 197 |
13 Indicates that the fast tokens program is running. |
| 198 |
12 Error in search measurement |
| 199 |
11 End of sequence program/high-speed sequence program execution |
| 200 |
10 Sequence program Pause state |
| 201 |
9 Fan stop detection |
| 202 |
8 Self-test error occurred (logic part) |
| 203 |
7 Trigger wait state in trigger link master operation |
| 204 |
6 Calibration mode status |
| 205 |
5 Trigger link ON state |
| 206 |
4 Trigger link bus error |
| 207 |
3 Sequence program/high-speed sequence 1 program/add/de) waiting |
| 208 |
2 Wait for sequence program wait time |
| 209 |
1 Sequence program running |
| 210 |
0 Synchronous operation state |
| 211 |
========= ========================== |
| 212 |
|
| 213 |
""" |
| 214 |
FAST_TOKENS_PROGRAM_IS_RUNNING = 1 << 13 |
| 215 |
ERROR_IN_SEARCH_MEASUREMENT = 1 << 12 |
| 216 |
END_OF_SEQUENCE_PROGRAM = 1 << 11 |
| 217 |
SEQUENCE_PROGRAM_PAUSE_STATE = 1 << 10 |
| 218 |
FAN_STOP_DETECTION = 1 << 9 |
| 219 |
SELF_TEST_ERROR_LOGIC = 1 << 8 |
| 220 |
TRIGGER_WAIT_STATE = 1 << 7 |
| 221 |
CALIBRATION_MODE_STATUS = 1 << 6 |
| 222 |
TRIGGER_LINK_ON_STATE = 1 << 5 |
| 223 |
TRIGGER_LINK_BUS_ERROR = 1 << 4 |
| 224 |
SEQUENCE_PROGRAM_WAITING = 1 << 3 |
| 225 |
WAIT_FOR_SEQUENCE_PROGRAM_WAIT_TIME = 1 << 2 |
| 226 |
SEQUENCE_PROGRAM_RUNNING = 1 << 1 |
| 227 |
SYNCHRONOUS_OPERATION_STATE = 1 << 0 |
| 228 |
|
| 229 |
|
| 230 |
class COR(IntFlag): |
| 231 |
""" bit assigment for the Channel Operations Register (COR): |
| 232 |
|
| 233 |
========= ============================================= |
| 234 |
Bit (dec) Description |
| 235 |
========= ============================================= |
| 236 |
14 The result of the comparison operation is HI |
| 237 |
13 The result of the comparison operation is GO |
| 238 |
12 The result of the comparison operation is LO |
| 239 |
11 Overheat detection |
| 240 |
10 Overload detection |
| 241 |
9 Oscillation detection |
| 242 |
8 Compliance detection |
| 243 |
7 Synchronous operation master channel |
| 244 |
6 Measurement data output specification |
| 245 |
5 There is measurement data |
| 246 |
4 Self-test error occurrence (analog part) |
| 247 |
3 Measurement data buffer full |
| 248 |
2 Waiting for trigger |
| 249 |
1 End of sweep |
| 250 |
0 Operated state |
| 251 |
========= ============================================= |
| 252 |
|
| 253 |
""" |
| 254 |
COMPARISON_RESULT_HI = 1 << 14 |
| 255 |
COMPARISON_RESULT_GO = 1 << 13 |
| 256 |
COMPARISON_RESULT_LO = 1 << 12 |
| 257 |
OVERHEAT_DETECTION = 1 << 11 |
| 258 |
OVERLOAD_DETECTION = 1 << 10 |
| 259 |
OSCILLATION_DETECTION = 1 << 9 |
| 260 |
COMPLIANCE_DETECTION = 1 << 8 |
| 261 |
SYNCHRONOUS_OPERATION_MASTER_CHANNEL = 1 << 7 |
| 262 |
MEASUREMENT_DATA_OUTPUT_SPECIFICATION = 1 << 6 |
| 263 |
HAS_MEASUREMENT_DATA = 1 << 5 |
| 264 |
SELF_TEST_ERROR_ANALOG_SECTION = 1 << 4 |
| 265 |
MEASUREMENT_DATA_BUFFER_FULL = 1 << 3 |
| 266 |
WAITING_FOR_TRIGGER = 1 << 2 |
| 267 |
END_OF_SWEEP = 1 << 1 |
| 268 |
OPERATED_STATE = 1 << 0 |
| 269 |
|
| 270 |
|
| 271 |
class SRER(IntFlag): |
| 272 |
""" bit assigment for the Service Request Enable Register (SRER): |
| 273 |
|
| 274 |
========= =========================================================== |
| 275 |
Bit (dec) Description |
| 276 |
========= =========================================================== |
| 277 |
0 none |
| 278 |
1 ERR Set when any of QYE, DDE, EXE, or CME in |
| 279 |
the Standard Event Status Register (SESR) is set. |
| 280 |
2 DOP Set when a bit in the device operation register |
| 281 |
for which the enable register is set to enabled is set. |
| 282 |
Cleared by reading the device operation register. |
| 283 |
3 none |
| 284 |
4 MAV Set when output data is set in the output queue. |
| 285 |
Cleared when output data is read. |
| 286 |
5 ESB Set when a bit in the Standard Event Status Register |
| 287 |
(SESR) is set and the enable register is set to Enabled. |
| 288 |
Cleared by reading SESR. |
| 289 |
6 RQS (MSS) Set when bit O to bit 5 and bit 7 of the |
| 290 |
Status Byte register are set. (this bit is read-only) |
| 291 |
7 COP Set when a bit in the Channel Operations Register |
| 292 |
is set with the Enable Register set to Enable. |
| 293 |
Cleared by reading the Channel Operations Register. |
| 294 |
========= =========================================================== |
| 295 |
|
| 296 |
""" |
| 297 |
ERR = 1 << 1 |
| 298 |
DOP = 1 << 2 |
| 299 |
MAV = 1 << 4 |
| 300 |
ESB = 1 << 5 |
| 301 |
RQS = 1 << 6 |
| 302 |
COP = 1 << 7 |
| 303 |
|
| 304 |
|
| 305 |
class SESR(IntFlag): |
| 306 |
""" bit assigment for the Standard Event Status Register (SESR): |
| 307 |
|
| 308 |
========= ========================== |
| 309 |
Bit (dec) Description |
| 310 |
========= ========================== |
| 311 |
0 OPC (Operation Complete) not used |
| 312 |
1 RQC unused |
| 313 |
2 QYE (Query Error) Set when the output queue |
| 314 |
overflows when reading without output data. |
| 315 |
3 DDE (Device Dependent Error) Set when an |
| 316 |
error occurs in the self-test. |
| 317 |
4 EXE (Execution Error) Set when the input |
| 318 |
data is outside the range set internally, |
| 319 |
or when the command cannot be executed. |
| 320 |
5 CME (Command Error) Set when an undefined header |
| 321 |
or data format is wrong, or when there is a |
| 322 |
syntax error in the command. |
| 323 |
6 URQ unused |
| 324 |
7 PON Set when power is switched from OFF to ON. |
| 325 |
========= ========================== |
| 326 |
|
| 327 |
""" |
| 328 |
OPC = 1 << 0 |
| 329 |
RQC = 1 << 1 |
| 330 |
QYE = 1 << 2 |
| 331 |
DDE = 1 << 3 |
| 332 |
EXE = 1 << 4 |
| 333 |
CME = 1 << 5 |
| 334 |
URQ = 1 << 6 |
| 335 |
PON = 1 << 7 |
| 336 |
|
| 337 |
|
| 338 |
class TriggerOutputSignalTiming(IntFlag): |
| 339 |
""" bit assigment for the timing of the trigger output signal |
| 340 |
output from TRIGGER OUT on the rear panel: |
| 341 |
|
| 342 |
========= ============================= |
| 343 |
Bit (dec) Description |
| 344 |
========= ============================= |
| 345 |
5 At the end of the sweep |
| 346 |
4 At the end of the pulse width |
| 347 |
3 At the end of the pulse cycle |
| 348 |
2 At the end of measurement |
| 349 |
1 At the start of measurement |
| 350 |
0 At the start of occurrence |
| 351 |
========= ============================= |
| 352 |
|
| 353 |
""" |
| 354 |
END_OF_SWEEP = 1 << 5 |
| 355 |
END_OF_THE_PULSE_WIDTH = 1 << 4 |
| 356 |
END_OF_THE_PULSE_CYCLE = 1 << 3 |
| 357 |
END_OF_MEASUREMENT = 1 << 2 |
| 358 |
START_OF_MEASUREMENT = 1 << 1 |
| 359 |
START_OF_OCCURRENCE = 1 << 0 |
| 360 |
|
| 361 |
|
| 362 |
""" |
| 363 |
TODO, implement the following commands: |
| 364 |
|
| 365 |
(54) LDS? This is a query command for reading the currently set parameters via GPIB. |
| 366 |
|
| 367 |
(93) MAR ~; NENT The MAR ~; NENT command sets the search measurement sense channel source, target |
| 368 |
measurement, |
| 369 |
and compliance values, and the search channel start/stop and compliance values. |
| 370 |
It also sets the output state after stopping for both the sense channel and search channel. |
| 371 |
(94) MAR~;CMD~;NEN During search measurement, you can set ON/OFF of the measurement data comparison |
| 372 |
calculation and the upper and lower limit data to be compared. |
| 373 |
|
| 374 |
Syntax: |
| 375 |
MAR 0, search mode, generated value after stop; command; NEN |
| 376 |
|
| 377 |
1 Binary search measurement: sense channel |
| 378 |
2 Binary search measurement: search channel (negative feedback search) |
| 379 |
3 Binary search measurement: search channel (positive feedback search) |
| 380 |
4 Linear search measurement: sense channel |
| 381 |
5 Linear search measurement: search channel |
| 382 |
|
| 383 |
Occurrence value after stopping |
| 384 |
1 Generates a bias value. |
| 385 |
2 Leave the finished generation value as is. |
| 386 |
3 Generate stop values. |
| 387 |
|
| 388 |
- The commands that can be used for search measurement are shown below. |
| 389 |
|
| 390 |
Binary search Linear search |
| 391 |
sense channel: FXI, FXV, PXI, PXV, CMD FXI, FXV, PXI, PXV, CMD |
| 392 |
search channel: WI, WV WI, WV, PWI, PWV, CMD |
| 393 |
|
| 394 |
- If you set a command other than the above with the MAR ~; NENT command, an error will occur. |
| 395 |
- The linear search CMD (comparison operation) command is set to either the sense channel or the |
| 396 |
search channel. |
| 397 |
Therefore, if the CMD command is set for both channels, the comparison operation is performed with |
| 398 |
the one that was set later. |
| 399 |
|
| 400 |
Number of steps: 2. When the source range is 600mV, search is performed in steps of 20µV. |
| 401 |
MAR 0, 1, 2;FXV 1, 20, 6, 17, 2, 0;NENT |
| 402 |
MAR 0, 2, 2;WV 2, 1, 1, 20, -3, 0, 17, 6.2E-2, -3; NENT |
| 403 |
|
| 404 |
(95) PGST~;END # Program number that specifies the command to be executed by the high-speed sequence |
| 405 |
program. This command stores in memory. |
| 406 |
|
| 407 |
Commands that can be used unconditionally |
| 408 |
DV, DI, PV, PI |
| 409 |
WT, MST, RV, RI |
| 410 |
CMD, CN, CL, OPM, FL |
| 411 |
LTL, DIOS, DIOE, EXT |
| 412 |
PCEL, MAR ~ NENT |
| 413 |
|
| 414 |
Commands that can be used with MAR ~ ; NEN commands |
| 415 |
FXV, FXI. PXV, PXI, WV, WI, PWV, PWI |
| 416 |
|
| 417 |
(96) EXT # This command is used to set a conditional jump in the program of a high-speed sequence |
| 418 |
program. |
| 419 |
(97) PGON To execute a high-speed sequence program, store the program in program numbers 1 to 20 |
| 420 |
with the PGST ; END command in advance. |
| 421 |
Note that program numbers that do not store programs are skipped without being executed. |
| 422 |
(98) PGOF This command cancels the start/enable state of the high-speed sequence program set by the |
| 423 |
PGON command. |
| 424 |
(99) PCEL This command clears the program stored in memory by the PGST command. |
| 425 |
""" |
| 426 |
|
| 427 |
|
| 428 |
def map_values(value, values): |
| 429 |
return values[strict_discrete_set(value, values)] |
| 430 |
|
| 431 |
|
| 432 |
class AdvantestR624X(SCPIUnknownMixin, Instrument): |
| 433 |
""" Represents the Advantest R624X series (channel A and B) SourceMeter and provides a |
| 434 |
high-level interface for interacting with the instrument. |
| 435 |
|
| 436 |
This is the base class for both AdvantestR6245 and AdvantestR6246 devices. It's not |
| 437 |
necessary to instantiate this class directly instead create an instance of the |
| 438 |
AdvantestR6245 or AdvantestR6246 class as shown in the following example: |
| 439 |
|
| 440 |
.. code-block:: python |
| 441 |
|
| 442 |
smu = AdvantestR6246("GPIB::1") |
| 443 |
smu.reset() # Set default parameters |
| 444 |
smu.ch_A.current_source(source_range = CurrentRange.FIXED_60mA, |
| 445 |
source_value = 0, # Source current at 0 A |
| 446 |
voltage_compliance = 10) # Voltage compliance at 10 V |
| 447 |
smu.ch_A.enable_source() # Enables the source output |
| 448 |
smu.ch_A.measure_voltage() |
| 449 |
smu.ch_A.current_change_source = 5e-3 # Change to 5mA |
| 450 |
print(smu.read_measurement()) # Read and print the voltage |
| 451 |
smu.ch_A.standby() # Put channel A in standby |
| 452 |
|
| 453 |
""" |
| 454 |
|
| 455 |
def __init__(self, adapter, name="R624X Source meter Base Class", **kwargs): |
| 456 |
super().__init__(adapter, name, **kwargs) |
| 457 |
self.sequence = [] |
| 458 |
self.store_to_sequence = False |
| 459 |
self.sequence_line_count = 0 |
| 460 |
|
| 461 |
def write(self, command, **kwargs): |
| 462 |
if self.store_to_sequence: |
| 463 |
self.append_sequence_command(command) |
| 464 |
else: |
| 465 |
super().write(command, **kwargs) |
| 466 |
|
| 467 |
def check_errors(self): |
| 468 |
errors = { |
| 469 |
100: "A fan stop was detected.", |
| 470 |
101: "Since the overload detection of the {0} channel was activated, it was set to" |
| 471 |
"standby.", |
| 472 |
102: "Since the overheat detection of the {0} channel worked, I made it a standby.", |
| 473 |
200: "Received an undefined command.", |
| 474 |
201: "There is an error in the data format.", |
| 475 |
210: "Received data outside the set range.", |
| 476 |
211: "A command was received that cannot be executed in the current settings.", |
| 477 |
221: "Data output buffer overflowed.", |
| 478 |
} |
| 479 |
|
| 480 |
error = self.ask('err?') |
| 481 |
unit = int(error[0:2]) |
| 482 |
err = int(error[2:5]) |
| 483 |
channel = f'{"B" if unit > 1 else "A"}' |
| 484 |
|
| 485 |
if err in errors: |
| 486 |
message = errors[err].format(channel) |
| 487 |
elif err > 0 and err < 100: |
| 488 |
if unit == 0: |
| 489 |
message = "As a result of the self-test, an abnormality was found in the logic" \ |
| 490 |
"part." |
| 491 |
else: |
| 492 |
message = f"Result of self-test {channel}-channel was found to be abnormal." |
| 493 |
elif err > 99 and err < 200: |
| 494 |
message = "Internal error, calibration error" |
| 495 |
else: |
| 496 |
message = "Setting error" |
| 497 |
|
| 498 |
if err == 0: |
| 499 |
return |
| 500 |
else: |
| 501 |
raise OSError( |
| 502 |
f"{self.name} Error {error[0:5]}: {message}") |
| 503 |
|
| 504 |
def enable_source(self): |
| 505 |
""" Put channel A & B into the operating state (``CN``). |
| 506 |
|
| 507 |
.. note:: |
| 508 |
When the 'interlock control' of the 'SCT' command is '2' and the |
| 509 |
clock signal is 'HI', it will not enter the operating state. |
| 510 |
""" |
| 511 |
self.write('cn 0') |
| 512 |
|
| 513 |
def standby(self): |
| 514 |
""" Put channel A & B in standby mode (``CL``). |
| 515 |
""" |
| 516 |
self.write('cl 0') |
| 517 |
|
| 518 |
def clear_status_register(self): |
| 519 |
""" Clears the Standard Event Status Register (SESR) and |
| 520 |
related queues (excluding output queues) (``*CLS``). |
| 521 |
""" |
| 522 |
self.write('*cls') |
| 523 |
|
| 524 |
srq_enabled = Instrument.setting( |
| 525 |
"s%d", |
| 526 |
""" Set a boolean that controls whether the GPIB SRQ feature is |
| 527 |
enabled, takes values of True or False (``S0/S1``). |
| 528 |
|
| 529 |
:type: bool |
| 530 |
|
| 531 |
The SRQ feature of the GPIB bus provides hardware handshaking between |
| 532 |
the GPIB controller card in the PC and the instrument. This allows |
| 533 |
synchronization between moving data to the PC with the state of the |
| 534 |
instrument without the need to use time delay functions. |
| 535 |
""", |
| 536 |
validator=strict_discrete_set, |
| 537 |
values={False: 1, True: 0}, |
| 538 |
map_values=True |
| 539 |
) |
| 540 |
|
| 541 |
def trigger(self): |
| 542 |
""" Outputs the trigger signal or the start of sweep and |
| 543 |
search measurement to both A and B channels and the trigger link (``XE``). |
| 544 |
|
| 545 |
.. note:: |
| 546 |
|
| 547 |
* When both A channel and B channel are waiting for a trigger, |
| 548 |
both channels are triggered. |
| 549 |
* When either channel A or B is waiting for a trigger, |
| 550 |
only the channel that is waiting for a trigger is triggered. |
| 551 |
* When both A channel and B channel are waiting for sweep start, |
| 552 |
this will apply sweep start to both channels. |
| 553 |
* When either channel A or B is in the sweep start waiting state, |
| 554 |
only the channel in the sweep start waiting state is started. |
| 555 |
* When either channel A or B is waiting for a trigger and the |
| 556 |
other is waiting for a sweep start, trigger and sweep start |
| 557 |
are applied, respectively. |
| 558 |
* When the trigger link is ON and this is the master unit, |
| 559 |
set the \\*TRG signal on the trigger link bus to TRUE. |
| 560 |
* When the trigger link is ON and the master unit, |
| 561 |
the trigger link is activated. |
| 562 |
|
| 563 |
""" |
| 564 |
self.write('xe 0') |
| 565 |
|
| 566 |
def stop(self): |
| 567 |
""" Stops the sweep when the sweep is started by |
| 568 |
the XE command or the trigger input signal (``SP``). """ |
| 569 |
self.write('sp 0') |
| 570 |
|
| 571 |
def set_digital_output(self, values): |
| 572 |
""" Outputs a 16-bit signal from the DIGITAL OUT output terminal |
| 573 |
on the rear panel. You can set up to 9 output data (``DIOS``). |
| 574 |
If there are multiple values specified, the data is output at |
| 575 |
intervals of about 2ms and fixed as the final data. |
| 576 |
|
| 577 |
:param values: Digital out bit values |
| 578 |
:type values: int or list |
| 579 |
|
| 580 |
.. note:: |
| 581 |
The output of digital data to the DIGITAL OUT pin is only the bits |
| 582 |
specified by the DIOE command. Bits that are not specified will |
| 583 |
result in alarm output or unused, and no digital data will be output. |
| 584 |
""" |
| 585 |
if isinstance(values, list): |
| 586 |
values = [str(i) for i in values] |
| 587 |
values = ",".join(values) |
| 588 |
self.write(f'dios 0,{values}') |
| 589 |
|
| 590 |
sweep_delay_time = Instrument.setting( |
| 591 |
"gdly 0,%.4e", |
| 592 |
""" Set the sweep delay time (Ta) or generation / delay time (Ta) |
| 593 |
of the master channel and slave channel during delayed sweep operation |
| 594 |
or synchronous operation between pulse measurements (``GDLY``). |
| 595 |
|
| 596 |
:type: float |
| 597 |
|
| 598 |
.. note:: |
| 599 |
If the sweep delay time does not meet (Ta<Tw and Ta<Td+Tit), |
| 600 |
an execution error will occur and it will not be set: |
| 601 |
|
| 602 |
Tw: Pulse width |
| 603 |
Td: Major delay time |
| 604 |
Tit: Integration time |
| 605 |
""", |
| 606 |
) |
| 607 |
|
| 608 |
def append_sequence_command(self, command): |
| 609 |
valid_commands = [ |
| 610 |
'jm', 'gdly', 'fl', 'dv', 'di', 'fxv', 'fxi', 'wv', 'wi', 'mdwv', 'mdwi', 'pv', 'pi', |
| 611 |
'pxv', 'pxi', 'pwv', 'pwi', 'mpwv', 'mpwi', 'rv', 'ri', 'mst', 'wt', 'cm', 'cmd', 'nug', |
| 612 |
'ofm', 'fmt', 'mbc', 'fmt', 'wm', 'cn', 'cl', 'opm', 'osl', 'ltl', 'tjm', 'xe', '*trg', |
| 613 |
'tot', 'sct', 'osig', 'dios', 'dioe', 'ian', 'tlnk', 'wait', 'sav', 'rcl', '*sre', |
| 614 |
'*ese', '*cls', 'coe', 'doe'] |
| 615 |
|
| 616 |
if not self.store_to_sequence: |
| 617 |
raise ValueError("init_sequence() should be called first") |
| 618 |
|
| 619 |
for s in valid_commands: |
| 620 |
if s == command.lower()[:len(s)]: |
| 621 |
self.sequence.append(command) |
| 622 |
|
| 623 |
def init_sequence(self): |
| 624 |
""" This function starts the redirection of :meth:`~.write` |
| 625 |
to :meth:`~.store_sequence_command` to automatically create a sequence program. |
| 626 |
""" |
| 627 |
self.sequence = [] |
| 628 |
self.store_to_sequence = True |
| 629 |
self.sequence_line_count = 0 |
| 630 |
|
| 631 |
def start_sequence(self, repeat=1): |
| 632 |
""" This function starts the sequence program which is |
| 633 |
initiated by :meth:`~.init_sequence` and ended by :meth:`~.end_sequence`. |
| 634 |
""" |
| 635 |
self.start_sequence_program(1, self.sequence_line_count, repeat) |
| 636 |
|
| 637 |
def end_sequence(self): |
| 638 |
""" This function ends the sequence program which is |
| 639 |
initiated by :meth:`~.init_sequence`. |
| 640 |
""" |
| 641 |
command = '' |
| 642 |
self.store_to_sequence = False |
| 643 |
for s in self.sequence: |
| 644 |
|
| 645 |
# Sequence memory has a maximum of 128x100 characters |
| 646 |
if len(command) + len(s) + 1 < 128: |
| 647 |
command += s + ';' |
| 648 |
else: |
| 649 |
self.sequence_line_count += 1 |
| 650 |
if self.sequence_line_count > 100: |
| 651 |
raise OSError( |
| 652 |
f"{self.name} Error out of sequence memory") |
| 653 |
|
| 654 |
self.store_sequence_command(self.sequence_line_count, command) |
| 655 |
command = s + ';' |
| 656 |
|
| 657 |
self.sequence_line_count += 1 |
| 658 |
self.store_sequence_command(self.sequence_line_count, command) |
| 659 |
|
| 660 |
self.sequence = [] |
| 661 |
|
| 662 |
def sequence_wait(self, wait_mode, wait_value): |
| 663 |
""" Waits for program execution and is used only for sequence programs (``WAIT``). |
| 664 |
|
| 665 |
:param int wait_mode: Whether wait time (1) or trigger input count (2) is specified |
| 666 |
:param float wait_value: Wait time or trigger input count as specified by wait_mode |
| 667 |
|
| 668 |
This command has the following functions: |
| 669 |
|
| 670 |
* Make the execution of the next program wait for the specified time. |
| 671 |
* Makes the next program execution wait until the specified number of triggers is input. |
| 672 |
|
| 673 |
Regardless of the wait mode, if the wait data is 0, the wait operation is not performed. |
| 674 |
When the wait mode is "2", the following commands and signals can be used as trigger inputs: |
| 675 |
|
| 676 |
* XE (XE 0, XE 1, XE 2) |
| 677 |
* \\*TRG |
| 678 |
* GET command (group execute trigger) |
| 679 |
* Trigger input signal on rear panel |
| 680 |
|
| 681 |
""" |
| 682 |
wait_mode = strict_discrete_set(wait_mode, [1, 2]) |
| 683 |
self.write(f'wait {wait_mode},{wait_value}') |
| 684 |
|
| 685 |
def start_sequence_program(self, start, stop, repeat): |
| 686 |
""" Starts from the program number until the stop of the sequence program (``RU``). |
| 687 |
Executes sequentially up to the program number, and repeats for the number of times of |
| 688 |
specified. |
| 689 |
|
| 690 |
:param int start: Number of the program to start from ranging 1 to 100 |
| 691 |
:param int stop: Number of the program to stop at ranging from 1 to 100 |
| 692 |
:param int repeat: Number of times repeated from 1 to 100 |
| 693 |
""" |
| 694 |
start = truncated_range(start, [1, 100]) |
| 695 |
stop = truncated_range(stop, [1, 100]) |
| 696 |
repeat = truncated_range(repeat, [1, 100]) |
| 697 |
|
| 698 |
self.write(f'ru 0,{start},{stop},{repeat}') |
| 699 |
|
| 700 |
def store_sequence_command(self, line, command): |
| 701 |
""" Stores the program to be executed in the sequence program (``ST``). |
| 702 |
If the program already exists, it is replaced with the new sequence. |
| 703 |
|
| 704 |
:param int line: Line number specified of memory location |
| 705 |
:param str command: Command(s) specified to be stored delimited by a semicolon (;) |
| 706 |
""" |
| 707 |
line = truncated_range(line, [1, 100]) |
| 708 |
if command[-1:] != ';': |
| 709 |
command += ';' |
| 710 |
self.write(f'st {line};{command}end') |
| 711 |
|
| 712 |
def interrupt_sequence_command(self, action): |
| 713 |
""" Interrupts the sequence program executed |
| 714 |
by the :py:meth:`~start_sequence_program` command (``SQSP``). |
| 715 |
|
| 716 |
:param action: Specifies sequence interruption setup |
| 717 |
:type action: :class:`SequenceInterruptionType` |
| 718 |
""" |
| 719 |
action = strict_discrete_set(action, [1, 2, 3]) |
| 720 |
self.write(f'sqsp {action}') |
| 721 |
|
| 722 |
sequence_program_number = Instrument.measurement( |
| 723 |
"lnub?", |
| 724 |
""" Measure the amount of program sequences stored in the sequence memory (``LNUB?``). |
| 725 |
""", |
| 726 |
cast=int, |
| 727 |
) |
| 728 |
|
| 729 |
def sequence_program_listing(self, line): |
| 730 |
""" This is a query command to know the command list stored in the |
| 731 |
program number of the sequence program memory (``LST?``). |
| 732 |
|
| 733 |
:param int action: Specifying the memory location for reading the commands |
| 734 |
:return: Commands stored in sequence memory |
| 735 |
:rtype: str |
| 736 |
""" |
| 737 |
line = truncated_range(line, [1, 100]) |
| 738 |
return self.ask('lst? {line}') |
| 739 |
|
| 740 |
def trigger_output_signal(self, trigger_output, alarm_output, scanner_output): |
| 741 |
""" Directly output the trigger output signal, alarm output signal, |
| 742 |
scanner (start/stop) output signal from GPIB (``OSIG``). |
| 743 |
|
| 744 |
:param int trigger_output: Number specifying type of trigger output |
| 745 |
:param int alarm_output: Number specifying type of alaram output |
| 746 |
:param int scanner_output: Number specifying the type of scanner output |
| 747 |
|
| 748 |
Trigger output: |
| 749 |
|
| 750 |
1. Do not output to trigger output. |
| 751 |
2. Output a negative pulse to the trigger output. |
| 752 |
|
| 753 |
Alarm output: |
| 754 |
|
| 755 |
1. Finish output GO, LO.HI both set to HI level. (reset) |
| 756 |
2. Finish output Set GO to LO level. |
| 757 |
3. Set home output LO to LO level. |
| 758 |
4. Terminate output HI to LO level. |
| 759 |
|
| 760 |
Scanner - (start/stop) output: |
| 761 |
|
| 762 |
1. Set the scanner scoot output to HI level. Output a negative pulse to the stop output. |
| 763 |
2. Make the scanner start output low. |
| 764 |
3. Output a HI level for the scanner start output and a negative pulse for the stop output. |
| 765 |
|
| 766 |
""" |
| 767 |
trigger_output = strict_discrete_set(trigger_output, [1, 2]) |
| 768 |
alarm_output = strict_discrete_set(alarm_output, [1, 2, 3, 4]) |
| 769 |
scanner_output = strict_discrete_set(scanner_output, [1, 2, 3]) |
| 770 |
|
| 771 |
self.write(f'osig 0,{trigger_output},{alarm_output},{scanner_output}') |
| 772 |
|
| 773 |
def set_output_format(self, delimiter_format, block_delimiter, terminator): |
| 774 |
""" Sets the format and terminator of the output data output by GPIB (``FMT``). |
| 775 |
|
| 776 |
:param int delimiter_format: Type of delimiter format |
| 777 |
:param int block_delimiter: Type of block delimiter |
| 778 |
:param int terminator: Type of termination character |
| 779 |
|
| 780 |
The output of <EOI> (End or Identify) is output at the following timing: |
| 781 |
1,2: Simultaneously with LF |
| 782 |
4: Simultaneously with the last output data |
| 783 |
|
| 784 |
If the output data format is specified as binary format, |
| 785 |
the terminator is fixed to <EOI> only and the terminator selection is ignored. |
| 786 |
|
| 787 |
delimiter_format: |
| 788 |
|
| 789 |
1. ASCII format with header |
| 790 |
2. No header, ASCII format |
| 791 |
3. Binary format |
| 792 |
|
| 793 |
block_delimiter: |
| 794 |
|
| 795 |
1. Make it the same as the terminator. |
| 796 |
2. Use semicolon ; |
| 797 |
3. Use comma , |
| 798 |
|
| 799 |
terminator: |
| 800 |
|
| 801 |
1. CR, LF<EOI> |
| 802 |
2. LF<EOI> |
| 803 |
3. LF |
| 804 |
4. <EOI> |
| 805 |
|
| 806 |
=== ================================================================================= |
| 807 |
1st character header: |
| 808 |
------------------------------------------------------------------------------------- |
| 809 |
A) Normal measurement data |
| 810 |
B) Measurement data during overrange |
| 811 |
C) Compliance (limiter) is working. |
| 812 |
D) Oscillation detection is working. |
| 813 |
E) [Indicates the generated data] |
| 814 |
F) Measurement data when an error occurs in the search measurement |
| 815 |
Z) Measurement data is not stored in the buffer memory. |
| 816 |
=== ================================================================================= |
| 817 |
|
| 818 |
=== ================================================================================= |
| 819 |
2nd character header: |
| 820 |
------------------------------------------------------------------------------------- |
| 821 |
A) A-channel data during asynchronous operation (A-channel generation data) |
| 822 |
B) B-channel data during asynchronous operation (B channel generation data) |
| 823 |
I) A-channel data for synchronous, sweeping, delayed sweep, and double synchronous |
| 824 |
sweep operations. |
| 825 |
J) B-channel data for synchronous, sweeping, delayed sweep, and double synchronous |
| 826 |
sweep operations. |
| 827 |
=== ================================================================================= |
| 828 |
|
| 829 |
=== ================================================================================= |
| 830 |
3rd character header: |
| 831 |
------------------------------------------------------------------------------------- |
| 832 |
A) Current generation, voltage measurement (ISVM) [Current generation] |
| 833 |
B) Voltage generation, current measurement (VSIM) [Voltage generation] |
| 834 |
C) Current generation, current measurement (ISIM) |
| 835 |
D) Voltage generation, voltage measurement (VSVM) |
| 836 |
E) Current generation, external voltage measurement (IS, EXT, VM) |
| 837 |
F) Voltage generation, external current measurement (VS, EXT, IM) |
| 838 |
G) Current generation, external current measurement (IS, EXT. IM) |
| 839 |
H) Voltage generation, external voltage measurement (VS, EXT, VM) |
| 840 |
Z) The measurement data is not stored in the buffer memory. |
| 841 |
=== ================================================================================= |
| 842 |
|
| 843 |
=== ================================================================================= |
| 844 |
4th character header: |
| 845 |
------------------------------------------------------------------------------------- |
| 846 |
A) No operation (fixed to A) |
| 847 |
B) Null operation result |
| 848 |
C) The result of the comparison operation is GO. |
| 849 |
D) The result of the comparison operation is LO. |
| 850 |
E) The result of the comparison operation is HI. |
| 851 |
F) The result of null operation + comparison operation is GO. |
| 852 |
G) The result of null operation + comparison operation is LO. |
| 853 |
H) The result of null operation + comparison operation is HI. |
| 854 |
Z) Measurement data is not stored in the buffer memory. |
| 855 |
=== ================================================================================= |
| 856 |
|
| 857 |
""" |
| 858 |
delimiter_format = strict_discrete_set(delimiter_format, [1, 2, 3]) |
| 859 |
block_delimiter = strict_discrete_set(block_delimiter, [1, 2, 3]) |
| 860 |
terminator = strict_discrete_set(terminator, [1, 2, 3, 4]) |
| 861 |
|
| 862 |
self.write(f'fmt 0,{delimiter_format},{block_delimiter},{terminator}') |
| 863 |
|
| 864 |
service_request_enable_register = Instrument.control( |
| 865 |
'*sre?', '*sre %i', |
| 866 |
""" Control the contents of the service request enable register (SRER) |
| 867 |
in the form of a :class:`SRER` ``IntFlag`` (``*SRE``). |
| 868 |
|
| 869 |
.. note:: |
| 870 |
Bits other than the RQS bit are not cleared by serial polling. |
| 871 |
When :meth:`~.power_on_clear` is set, status byte enable register, |
| 872 |
SESER, device operation enable register, channel operation, |
| 873 |
the enable register is cleared and no SRQ is issued. |
| 874 |
|
| 875 |
""", |
| 876 |
validator=truncated_range, |
| 877 |
values=[0, 255], |
| 878 |
get_process=lambda v: SRER(int(v)), |
| 879 |
) |
| 880 |
|
| 881 |
event_status_enable = Instrument.control( |
| 882 |
'*ese?', '*ese %i', |
| 883 |
""" Control the standard event status enable. (``*ESE``) """, |
| 884 |
validator=truncated_range, |
| 885 |
values=[0, 255], |
| 886 |
) |
| 887 |
|
| 888 |
power_on_clear = Instrument.control( |
| 889 |
'*psc?', '*psc %i', |
| 890 |
""" Control the power on clear flag, takes |
| 891 |
values True or False. (``*PSC``) """, |
| 892 |
validator=strict_discrete_set, |
| 893 |
values={True: 1, False: 0}, |
| 894 |
map_values=True |
| 895 |
) |
| 896 |
|
| 897 |
device_operation_enable_register = Instrument.control( |
| 898 |
'doe?', 'doe %i', |
| 899 |
""" Control the device operation output enable register (DOER) (``DOE?``). |
| 900 |
""", |
| 901 |
validator=truncated_range, |
| 902 |
values=[0, 65535], |
| 903 |
) |
| 904 |
|
| 905 |
digital_out_enable_data = Instrument.control( |
| 906 |
'dioe?', 'dioe 0,%i', |
| 907 |
""" Control the contents of digital out enable data set (``DIOE``). |
| 908 |
""", |
| 909 |
validator=truncated_range, |
| 910 |
values=[0, 65535], |
| 911 |
) |
| 912 |
|
| 913 |
status_byte_register = Instrument.measurement( |
| 914 |
"*stb?", |
| 915 |
""" Measure the contents of the status byte register and MSS bits without |
| 916 |
using a serial poll (``*STB?``). |
| 917 |
|
| 918 |
The Status Byte Register has a hierarchical structure. ERR, DOP, ESB, |
| 919 |
and COP bits, except RQS and MAV, have lower-level status registers. |
| 920 |
Each register is paired with an enable register that can be selected |
| 921 |
to output to the Status Byte register or not. The status byte register |
| 922 |
also has an enable register, which allows you to select whether or |
| 923 |
not to issue a service request SRQ. |
| 924 |
|
| 925 |
.. note:: |
| 926 |
|
| 927 |
\\*STB? command can read bit 6 as MSS (logical OR of other bits). |
| 928 |
""", |
| 929 |
cast=int, |
| 930 |
) |
| 931 |
|
| 932 |
event_status_register = Instrument.measurement( |
| 933 |
"*esr?", |
| 934 |
""" Measure the contents of the standard event status register (SESR) in |
| 935 |
the form of a :class:`SESR` ``IntFlag`` (``*ESR?``). |
| 936 |
|
| 937 |
.. note:: |
| 938 |
SESR is cleared after being read. |
| 939 |
|
| 940 |
""", |
| 941 |
values=[0, 255], |
| 942 |
get_process=lambda v: SESR(int(v)), |
| 943 |
) |
| 944 |
|
| 945 |
device_operation_register = Instrument.measurement( |
| 946 |
"doc?", |
| 947 |
""" Measure the contents of the device operations register (DOR) |
| 948 |
in the form of a :class:`DOR` ``IntFlag`` (``DOC?``). |
| 949 |
|
| 950 |
""", |
| 951 |
values=range(0, 65535), |
| 952 |
get_process=lambda v: DOR(int(v)), |
| 953 |
) |
| 954 |
|
| 955 |
error_register = Instrument.measurement( |
| 956 |
"err?", |
| 957 |
""" Measure the contents of the error register (``ERR?``). |
| 958 |
""", |
| 959 |
cast=int, |
| 960 |
) |
| 961 |
|
| 962 |
self_test = Instrument.measurement( |
| 963 |
"*tst?", |
| 964 |
""" A query command that runs a self-test and reads the result (``*TST?``). |
| 965 |
""", |
| 966 |
cast=int, |
| 967 |
) |
| 968 |
|
| 969 |
trigger_link_function_enabled = Instrument.setting( |
| 970 |
"tlnk 0,%d", |
| 971 |
""" Set a boolean that controls whether the trigger link function is |
| 972 |
enabled, takes values of True or False. (``TLNK``) |
| 973 |
|
| 974 |
:type: bool |
| 975 |
""", |
| 976 |
validator=strict_discrete_set, |
| 977 |
values={False: 1, True: 2}, |
| 978 |
map_values=True |
| 979 |
) |
| 980 |
|
| 981 |
display_enabled = Instrument.setting( |
| 982 |
"disp 0,%d", |
| 983 |
""" Set a boolean that controls whether the display is |
| 984 |
on or off, takes values of True or False. (``DISP``) |
| 985 |
|
| 986 |
:type: bool |
| 987 |
""", |
| 988 |
validator=strict_discrete_set, |
| 989 |
values={False: 2, True: 1}, |
| 990 |
map_values=True |
| 991 |
) |
| 992 |
|
| 993 |
line_frequency = Instrument.setting( |
| 994 |
"lf 0,%d", |
| 995 |
""" Set the used power supply frequency (``LF``) to 50 or 60hz. |
| 996 |
With this command, the integration time per PLC for the measurement |
| 997 |
will be one cycle of the power supply frequency you are using. |
| 998 |
|
| 999 |
:type: int |
| 1000 |
""", |
| 1001 |
validator=strict_discrete_set, |
| 1002 |
values={50: 1, 60: 2}, |
| 1003 |
map_values=True |
| 1004 |
) |
| 1005 |
|
| 1006 |
store_config = Instrument.setting( |
| 1007 |
"sav %d", |
| 1008 |
""" Set the memory area for the config to be stored at (``SAV``). |
| 1009 |
There are five memory areas from 0 to 4 for storing. |
| 1010 |
|
| 1011 |
:type: int |
| 1012 |
""", |
| 1013 |
validator=strict_range, |
| 1014 |
values=range(0, 4), |
| 1015 |
) |
| 1016 |
|
| 1017 |
load_config = Instrument.setting( |
| 1018 |
"rcl %d", |
| 1019 |
""" Set the memory area for the config to be loaded from (``RCL``). |
| 1020 |
There are five areas (0~4) where parameters can be loaded by the RCL command. |
| 1021 |
|
| 1022 |
:type: int |
| 1023 |
""", |
| 1024 |
validator=strict_range, |
| 1025 |
values=range(0, 4), |
| 1026 |
) |
| 1027 |
|
| 1028 |
def set_lo_common_connection_relay(self, enable, lo_relay=None): |
| 1029 |
""" Turn the connection relay on/off between the A channel |
| 1030 |
LO (internal analog common) and the LO (internal analog common) |
| 1031 |
of the B channel (``LTL``). |
| 1032 |
|
| 1033 |
:param bool enable: A boolean property that controls whether or not the |
| 1034 |
connection relay is enabled. Valid values are True and False. |
| 1035 |
:param lo_relay: A boolean property that controls whether or not the internal |
| 1036 |
analog common relay is enabled. Valid values are True, |
| 1037 |
False and None (don't change lo relay setting). |
| 1038 |
:type lo_relay: bool, optional |
| 1039 |
|
| 1040 |
""" |
| 1041 |
enable = map_values(enable, {True: 2, False: 1}) |
| 1042 |
lo_relay = map_values(lo_relay, {True: 2, False: 1, None: 3}) |
| 1043 |
|
| 1044 |
self.write(f'ltl 0,{enable},{lo_relay}') |
| 1045 |
|
| 1046 |
def parse_measurement(self, measurement): |
| 1047 |
if ' ' in measurement: |
| 1048 |
measurement = measurement.split(' ') |
| 1049 |
return (float(measurement[1]), measurement[0]) |
| 1050 |
else: |
| 1051 |
return (float(measurement), None) |
| 1052 |
|
| 1053 |
def read_measurement(self): |
| 1054 |
""" Reads the triggered value, for example triggered by the external input. |
| 1055 |
""" |
| 1056 |
return self.parse_measurement(self.read())[0] |
| 1057 |
|
| 1058 |
|
| 1059 |
class SMUChannel(Channel): |
| 1060 |
""" Instantiated by main instrument class for every SMUChannel |
| 1061 |
""" |
| 1062 |
|
| 1063 |
def __init__(self, parent, id, voltage_range, current_range): |
| 1064 |
super().__init__(parent, id) |
| 1065 |
self.voltage_range = voltage_range[id] |
| 1066 |
self.current_range = current_range[id] |
| 1067 |
|
| 1068 |
def insert_id(self, command): |
| 1069 |
return command.format_map({self.placeholder: ord(self.id) - 64}) |
| 1070 |
|
| 1071 |
def clear_measurement_buffer(self): |
| 1072 |
""" Clears the measurement data buffer (``MBC``). """ |
| 1073 |
self.write('mbc {ch}') |
| 1074 |
|
| 1075 |
def set_output_type(self, output_type, measurement_type): |
| 1076 |
""" Sets the output method and type of the GPIB output (``OFM``). |
| 1077 |
|
| 1078 |
:param output_type: A property that controls the type of output |
| 1079 |
:type output_type: int or :class:`OutputType` |
| 1080 |
:param measurement_type: A property that controls the measurement type |
| 1081 |
:type measurement_type: int or :class:`MeasurementType` |
| 1082 |
|
| 1083 |
.. note:: |
| 1084 |
|
| 1085 |
For the format of the output data, refer to :meth:`AdvantestR624X.set_output_format`. |
| 1086 |
For DC and pulse measurements, the output method is fixed to '1' (real-time output). |
| 1087 |
When the output method '3' (buffering output) is specified, the measured data is not |
| 1088 |
stored in memory. |
| 1089 |
|
| 1090 |
""" |
| 1091 |
output_type = OutputType(output_type) |
| 1092 |
measurement_type = MeasurementType(measurement_type) |
| 1093 |
self.write(f'ofm {{ch}},{output_type.value},{measurement_type.value}') |
| 1094 |
|
| 1095 |
analog_input = Channel.setting( |
| 1096 |
"fl {ch},%d", |
| 1097 |
""" Set the analog input terminal (ANALOG INPUT) on the rear panel ON or OFF (``FL``). |
| 1098 |
|
| 1099 |
:type: int |
| 1100 |
|
| 1101 |
1. Turn off the analog input. |
| 1102 |
2. Analog input ON, gain x1. |
| 1103 |
3. Analog input ON, gain x2.5. |
| 1104 |
|
| 1105 |
""", |
| 1106 |
validator=strict_range, |
| 1107 |
values=range(1, 3), |
| 1108 |
) |
| 1109 |
|
| 1110 |
trigger_output_timing = Channel.setting( |
| 1111 |
"tot {ch},%d", |
| 1112 |
""" Set the timing of the trigger output signal |
| 1113 |
output from TRIGGER OUT on the rear panel (``TOT``). |
| 1114 |
the status in the form of a :class:`TriggerOutputSignalTiming` ``IntFlag``. |
| 1115 |
|
| 1116 |
:type: :class:`.TriggerOutputSignalTiming` |
| 1117 |
|
| 1118 |
""", |
| 1119 |
validator=strict_range, |
| 1120 |
values=range(0, 63), |
| 1121 |
# get_process=lambda v: TriggerOutputSignalTiming(int(v)), |
| 1122 |
) |
| 1123 |
|
| 1124 |
def set_scanner_control(self, output, interlock): |
| 1125 |
""" Sets the SCANNER CONTROL (START, STOP) |
| 1126 |
output signal and INTERLOCK input signal on the rear panel (``SCT``). |
| 1127 |
|
| 1128 |
:param int output: A property that controls the scanner output |
| 1129 |
:param int interlock: A property that controls the scanner interlock type |
| 1130 |
|
| 1131 |
output: |
| 1132 |
|
| 1133 |
1. Scanner, Turn off the control signal output. |
| 1134 |
2. Output to the scanner control signal at the start / stop of the sweep. |
| 1135 |
3. Operate / Standby Scanner, Output to the control signal. |
| 1136 |
|
| 1137 |
interlock: |
| 1138 |
|
| 1139 |
1. Turn off the interlock signal input. |
| 1140 |
2. Set as a stamper when the interlock signal input is HI. |
| 1141 |
3. When the interlock signal input is HI, it is on standby, and when it is LO, it is |
| 1142 |
operated. |
| 1143 |
|
| 1144 |
""" |
| 1145 |
output = strict_discrete_set(output, [1, 2, 3]) |
| 1146 |
interlock = strict_discrete_set(interlock, [1, 2, 3]) |
| 1147 |
self.write(f'sct {{ch}},{output},{interlock}') |
| 1148 |
|
| 1149 |
trigger_input = Channel.setting( |
| 1150 |
"tjm {ch},%d", |
| 1151 |
""" Set the type of trigger input (``TJM``). |
| 1152 |
|
| 1153 |
:type: :class:`.TriggerInputType` |
| 1154 |
|
| 1155 |
+------------------------+---+---+---+ |
| 1156 |
| Trigger input types | 1 | 2 | 3 | |
| 1157 |
+========================+===+===+===+ |
| 1158 |
| \\*TRG | O | O | X | |
| 1159 |
+------------------------+---+---+---+ |
| 1160 |
| XE 0 | O | O | X | |
| 1161 |
+------------------------+---+---+---+ |
| 1162 |
| XE Channel | O | O | O | |
| 1163 |
+------------------------+---+---+---+ |
| 1164 |
| GET | O | O | X | |
| 1165 |
+------------------------+---+---+---+ |
| 1166 |
| Trigger input signal | O | X | X | |
| 1167 |
+------------------------+---+---+---+ |
| 1168 |
|
| 1169 |
O can be used, X cannot be used |
| 1170 |
|
| 1171 |
.. note:: |
| 1172 |
|
| 1173 |
The sweep operation cannot be started by the trigger input signal. |
| 1174 |
Be sure to start it with the 'XE' command. Once started, it is |
| 1175 |
possible to advance the sweep with a trigger input signal. |
| 1176 |
|
| 1177 |
""", |
| 1178 |
validator=strict_range, |
| 1179 |
values=range(1, 3), |
| 1180 |
# get_process=lambda v: TriggerInputType(int(v)), |
| 1181 |
) |
| 1182 |
|
| 1183 |
fast_mode_enabled = Channel.setting( |
| 1184 |
"fl {ch},%d", |
| 1185 |
""" Set the channel response mode to fast or slow, |
| 1186 |
takes values of True or False (``FL``). |
| 1187 |
|
| 1188 |
:type: bool |
| 1189 |
|
| 1190 |
""", |
| 1191 |
validator=strict_discrete_set, |
| 1192 |
values={False: 2, True: 1}, |
| 1193 |
map_values=True |
| 1194 |
) |
| 1195 |
|
| 1196 |
sample_hold_mode = Channel.setting( |
| 1197 |
"mst {ch},%d", |
| 1198 |
""" Set the integration time of the measurement (``MST``). |
| 1199 |
|
| 1200 |
:type: :class:`.SampleHold` |
| 1201 |
|
| 1202 |
.. note:: |
| 1203 |
|
| 1204 |
- Valid only for pulse measurement and pulse sweep measurement. |
| 1205 |
- In sample hold mode, the AD transformation is just before the fall |
| 1206 |
of the pulse width. |
| 1207 |
- The sample hold mode cannot be set during DC measurement and DC sweep |
| 1208 |
measurement. When set to sample-and-hold mode, the integration time is 100 µs. |
| 1209 |
However, in 2-channel synchronous operation, if one channel is in pulse |
| 1210 |
generation and the other is in sample-and-hold mode, the DC measurement |
| 1211 |
side also operates in sample-and-hold mode. |
| 1212 |
- When performing pulse measurement and pulse sweep measurement, it |
| 1213 |
is necessary to satisfy the restrictions on the pulse width (Tw), |
| 1214 |
pulse period (Tp), and measure delay time (Td) of the WT command. |
| 1215 |
If the constraint is not satisfied, the integration time is unchanged. |
| 1216 |
To lengthen the integration time, first change the pulse width (Tw) |
| 1217 |
and pulse period (Tp). When shortening the pulse width and pulse |
| 1218 |
cycle, shorten the integration time first. |
| 1219 |
|
| 1220 |
""", |
| 1221 |
validator=strict_discrete_set, |
| 1222 |
values=[0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], |
| 1223 |
# get_process=lambda v: SampleHold(int(v)), |
| 1224 |
) |
| 1225 |
|
| 1226 |
def set_sample_mode(self, mode, auto_sampling=True): |
| 1227 |
""" Sets synchronous, asynchronous, tracking operation |
| 1228 |
and search measurement between channels (``JM``). |
| 1229 |
|
| 1230 |
:param mode: Sample Mode |
| 1231 |
:type mode: :class:`.SampleMode` |
| 1232 |
:param auto_sampling: Whether or not auto sampling is enabled, defaults to True |
| 1233 |
:type auto_sampling: bool, optional |
| 1234 |
|
| 1235 |
""" |
| 1236 |
mode = SampleMode(mode) |
| 1237 |
auto_sampling = map_values(auto_sampling, {True: 1, False: 2}) |
| 1238 |
|
| 1239 |
self.write(f'jm {mode.value},{auto_sampling},{{ch}}') |
| 1240 |
|
| 1241 |
def set_timing_parameters(self, hold_time, measurement_delay, pulsed_width, pulsed_period): |
| 1242 |
""" Set the hold time, measuring time, pulse width and the pulse period (``WT``). |
| 1243 |
|
| 1244 |
:param float hold_time: total amount of time for the complete pulse, until next pulse comes |
| 1245 |
:param float measurement_delay: time between measurements |
| 1246 |
:param float pulsed_width: Time specifying the pulse width |
| 1247 |
:param float pulsed_period: Time specifying the pulse period |
| 1248 |
|
| 1249 |
.. note:: |
| 1250 |
|
| 1251 |
Pulse measurement has the following restrictions depending on the pulse period (Tp) |
| 1252 |
setting. (For pulse sweep measurements, there are no restrictions.) |
| 1253 |
|
| 1254 |
- Tp < 2ms : Not measured. |
| 1255 |
- 2ms <= Tp < 10ms : Measure once every 5 ~ 20ms. |
| 1256 |
- 10ms <= Tp: Measured at each pulse generation. |
| 1257 |
|
| 1258 |
""" |
| 1259 |
self.write(f"wt {{ch}},{hold_time:.4e},{measurement_delay:.4e},{pulsed_width:.4e}," |
| 1260 |
"{pulsed_period:.4e}") |
| 1261 |
|
| 1262 |
def select_for_output(self): |
| 1263 |
""" This is a query command to select a channel and to |
| 1264 |
output the measurement data (``FCH?``). When the output channel is selected |
| 1265 |
by the FCH command, the measured data of the same channel is |
| 1266 |
returned until the output channel is changed by the next FCH command. |
| 1267 |
|
| 1268 |
.. note:: |
| 1269 |
|
| 1270 |
Reading measurements with the RMM command does not affect channel |
| 1271 |
specification with the FCH command. In the default state, |
| 1272 |
the measurement data of channel A is output. |
| 1273 |
|
| 1274 |
""" |
| 1275 |
self.write("fch_0{ch}?") |
| 1276 |
|
| 1277 |
def trigger(self): |
| 1278 |
""" Measurement trigger command for sweep, start search measurement or sweep step action |
| 1279 |
(``XE``). |
| 1280 |
""" |
| 1281 |
self.write('xe {ch}') |
| 1282 |
|
| 1283 |
############### |
| 1284 |
# Voltage (V) # |
| 1285 |
############### |
| 1286 |
|
| 1287 |
def measure_voltage(self, enable=True, internal_measurement=True, |
| 1288 |
voltage_range=VoltageRange.AUTO): |
| 1289 |
""" Sets the voltage measurement ON/OFF, measurement input, and |
| 1290 |
voltage measurement range as parameters (``RV``). |
| 1291 |
|
| 1292 |
:param enable: boolean property that enables or disables voltage measurement. |
| 1293 |
Valid values are True (Measure the voltage flowing at the OUTPUT terminal) |
| 1294 |
and False (Measure the voltage from the rear panel -ANALOG COMMON). |
| 1295 |
:type enable: bool, optional |
| 1296 |
:param internal_measurement: A boolean property that enables or disables the internal |
| 1297 |
measurement. |
| 1298 |
:type internal_measurement: bool, optional |
| 1299 |
:param voltage_range: Specifying voltage range |
| 1300 |
:type voltage_range: :class:`.VoltageRange`, optional |
| 1301 |
|
| 1302 |
""" |
| 1303 |
voltage_range = VoltageRange(voltage_range) |
| 1304 |
enable = map_values(enable, {True: 1, False: 2}) |
| 1305 |
internal_measurement = map_values(internal_measurement, {True: 1, False: 2}) |
| 1306 |
|
| 1307 |
self.write(f'rv {{ch}},{enable},{internal_measurement},{voltage_range.value}') |
| 1308 |
|
| 1309 |
def voltage_source(self, source_range, source_value, current_compliance): |
| 1310 |
""" Sets the source range, source value and the current compliance |
| 1311 |
for the DC (constant voltage) measurement (``DV``). |
| 1312 |
|
| 1313 |
:param source_range: Specifying source range |
| 1314 |
:type source_range: :class:`.VoltageRange` |
| 1315 |
:param float source_value: A number specifying the source voltage value |
| 1316 |
:param float current_compliance: A number specifying the current compliance |
| 1317 |
|
| 1318 |
.. note:: |
| 1319 |
|
| 1320 |
Regardless of the specified current compliance polarity, both polarities (+ and -) are |
| 1321 |
set. |
| 1322 |
The current compliance range is automatically set to the minimum range that includes the |
| 1323 |
set value. |
| 1324 |
|
| 1325 |
""" |
| 1326 |
source_range = VoltageRange(source_range) |
| 1327 |
source_value = truncated_range(source_value, self.voltage_range) |
| 1328 |
|
| 1329 |
self.write(f'dv {{ch}},{source_range.value},{source_value:.4e},{current_compliance:.4e}') |
| 1330 |
|
| 1331 |
def voltage_pulsed_source(self, source_range, pulse_value, base_value, current_compliance): |
| 1332 |
""" Sets the source range, pulse value, base value and the current compliance |
| 1333 |
of the pulse (voltage) measurement (``PV``). |
| 1334 |
|
| 1335 |
.. note:: |
| 1336 |
|
| 1337 |
Regardless of the specified current compliance polarity, both polarities (+ and -) are |
| 1338 |
set. |
| 1339 |
The current compliance range is automatically set to the minimum range that includes the |
| 1340 |
set value. |
| 1341 |
|
| 1342 |
""" |
| 1343 |
source_range = VoltageRange(source_range) |
| 1344 |
pulse_value = truncated_range(pulse_value, self.voltage_range) |
| 1345 |
base_value = truncated_range(base_value, self.voltage_range) |
| 1346 |
|
| 1347 |
self.write(f'pv {{ch}},{source_range.value},{pulse_value:.4e},{base_value:.4e},' |
| 1348 |
'{current_compliance:.4e}') |
| 1349 |
|
| 1350 |
change_source_voltage = Channel.setting( |
| 1351 |
"spot {ch},%.4e", |
| 1352 |
""" Set new target voltage (``SPOT``). |
| 1353 |
|
| 1354 |
:type: float |
| 1355 |
|
| 1356 |
.. note:: |
| 1357 |
|
| 1358 |
Only the DC action source value and pulse action pulse value |
| 1359 |
are changed using the currently set DC action and pulse action parameters. |
| 1360 |
Measure after the change and set the channel to output the measured data |
| 1361 |
to the specified ch. In other words, it's the same as running the following |
| 1362 |
commands: |
| 1363 |
|
| 1364 |
1. DV/DI/PV/PI |
| 1365 |
2. XE xx |
| 1366 |
3. FCH xx |
| 1367 |
|
| 1368 |
""", |
| 1369 |
) |
| 1370 |
|
| 1371 |
def voltage_fixed_level_sweep( |
| 1372 |
self, voltage_range, voltage_level, measurement_count, current_compliance, bias=0): |
| 1373 |
""" Sets the fixed level sweep (voltage) generation range, level value, |
| 1374 |
current compliance and the bias value (``FXV``). |
| 1375 |
|
| 1376 |
.. note:: |
| 1377 |
|
| 1378 |
Regardless of the specified current compliance polarity, both polarities (+ and -) are |
| 1379 |
set. |
| 1380 |
The current compliance range is automatically set to the minimum range that includes the |
| 1381 |
set value. |
| 1382 |
|
| 1383 |
""" |
| 1384 |
voltage_range = VoltageRange(voltage_range) |
| 1385 |
voltage_level = truncated_range(voltage_level, self.voltage_range) |
| 1386 |
|
| 1387 |
self.write(f'fxv {{ch}},{voltage_range.value},{voltage_level:.4e},' |
| 1388 |
'{measurement_count},{current_compliance:.4e},{bias:.4e}') |
| 1389 |
|
| 1390 |
def voltage_fixed_pulsed_sweep( |
| 1391 |
self, voltage_range, pulse, base, measurement_count, current_compliance, bias=0): |
| 1392 |
""" Sets the fixed pulse (voltage) sweep generation range, |
| 1393 |
pulse value, base value, number of measurements, current compliance and the bias value |
| 1394 |
(``PXV``). |
| 1395 |
|
| 1396 |
.. note:: |
| 1397 |
|
| 1398 |
Regardless of the specified current compliance polarity, both polarities (+ and -) are |
| 1399 |
set. |
| 1400 |
The current compliance range is automatically set to the minimum range that includes the |
| 1401 |
set value. |
| 1402 |
|
| 1403 |
""" |
| 1404 |
voltage_range = VoltageRange(voltage_range) |
| 1405 |
pulse = truncated_range(pulse, self.voltage_range) |
| 1406 |
base = truncated_range(base, self.voltage_range) |
| 1407 |
|
| 1408 |
self.write(f'pxv {{ch}},{voltage_range.value},{pulse:.4e},{base:.4e},' |
| 1409 |
'{measurement_count},{current_compliance:.4e},{bias:.4e}') |
| 1410 |
|
| 1411 |
def voltage_sweep( |
| 1412 |
self, sweep_mode, repeat, voltage_range, start_value, stop_value, steps, |
| 1413 |
current_compliance, bias=0): |
| 1414 |
""" Sets the sweep mode, number of repeats, source range, |
| 1415 |
start value, stop value, number of steps, current compliance, |
| 1416 |
and the bias value for staircase (linear/log) voltage sweep (``WV``). |
| 1417 |
|
| 1418 |
.. note:: |
| 1419 |
|
| 1420 |
- Sweep mode, number of repeats, and number of steps are subject to the following |
| 1421 |
restrictions. |
| 1422 |
|
| 1423 |
- Let N = number of steps, m = l (one-way sweep), m = 2 (round-trip sweep). |
| 1424 |
|
| 1425 |
- When the OFM command sets the output data output method to 1 or 2 m x number |
| 1426 |
of refreshes x N <= 2048 |
| 1427 |
- m x N <= 2048 when the OFM command sets the output data output method to 3. |
| 1428 |
|
| 1429 |
- Regardless of the specified current compliance polarity, both polarities (+ and -) are |
| 1430 |
set. |
| 1431 |
- The current compliance range is automatically set to the minimum range that includes |
| 1432 |
the set value. |
| 1433 |
|
| 1434 |
""" |
| 1435 |
sweep_mode = SweepMode(sweep_mode) |
| 1436 |
repeat = truncated_range(repeat, [0, 1024]) |
| 1437 |
steps = truncated_range(steps, [2, 2048]) |
| 1438 |
voltage_range = VoltageRange(voltage_range) |
| 1439 |
|
| 1440 |
self.write(f'wv {{ch}},{sweep_mode.value},{repeat},{voltage_range.value},' |
| 1441 |
'{start_value:.4e},{stop_value:.4e},{steps}, ' |
| 1442 |
'{current_compliance:.4e},{bias:.4e}') |
| 1443 |
|
| 1444 |
def voltage_pulsed_sweep( |
| 1445 |
self, sweep_mode, repeat, voltage_range, base, start_value, stop_value, steps, |
| 1446 |
current_compliance, bias=0): |
| 1447 |
""" Sets the sweep mode, repeat count, generation range, |
| 1448 |
base value, start value, stop value, number of steps, current compliance |
| 1449 |
and the bias value for a pulse wave (linear/log) voltage sweep (``PWV``). |
| 1450 |
|
| 1451 |
.. note:: |
| 1452 |
|
| 1453 |
- The sweep mode, number of refreshes, and number of steps are subject to the following |
| 1454 |
restrictions: |
| 1455 |
|
| 1456 |
- Let N = number of steps, m = l (one-way sweep), m = 2 (round-trip sweep). |
| 1457 |
|
| 1458 |
- When the OFM command sets the output data output method to 1 or 2 m x number |
| 1459 |
of refreshes x N <= 2048 |
| 1460 |
- m x N <= 2048 when the OFM command sets the output data output method to 3. |
| 1461 |
|
| 1462 |
- For the current compliance polarity, regardless of the specified current compliance |
| 1463 |
polarity, the compliance of both polarities (+ and -) is set. |
| 1464 |
- The current compliance range is automatically set to the minimum range that includes |
| 1465 |
the set value. |
| 1466 |
|
| 1467 |
""" |
| 1468 |
sweep_mode = SweepMode(sweep_mode) |
| 1469 |
repeat = truncated_range(repeat, [0, 1024]) |
| 1470 |
steps = truncated_range(steps, [2, 2048]) |
| 1471 |
voltage_range = VoltageRange(voltage_range) |
| 1472 |
|
| 1473 |
self.write(f'pwv {{ch}},{sweep_mode.value},{repeat},{voltage_range.value},{base:.4e},' |
| 1474 |
'{start_value:.4e},{stop_value:.4e},{steps},{current_compliance:.4e},' |
| 1475 |
'{bias:.4e}') |
| 1476 |
|
| 1477 |
def voltage_random_sweep( |
| 1478 |
self, sweep_mode, repeat, start_address, stop_address, current_compliance, bias=0): |
| 1479 |
""" Sets the sweep mode, repeat count, start address, stop address, |
| 1480 |
current compliance and the bias value of constant voltage random sweep (``MDWV``). |
| 1481 |
|
| 1482 |
.. note:: |
| 1483 |
|
| 1484 |
- Sweep mode, number of repeats, start address and stop address are subject to the |
| 1485 |
following restrictions: |
| 1486 |
|
| 1487 |
- Start address < Stop address |
| 1488 |
- Let N = number of steps, m = l (one-way sweep), m = 2 (round-trip sweep). |
| 1489 |
|
| 1490 |
- When the OFM command sets the output data output method to 1 or 2 m x number of |
| 1491 |
refreshes x N <= 2048 |
| 1492 |
- m x N <= 2048 when the OFM command sets the output data output method to 3. |
| 1493 |
|
| 1494 |
- Regardless of the specified current compliance polarity, both polarities (+ and -) are |
| 1495 |
set. |
| 1496 |
- The current compliance range is automatically set to the minimum range that includes the |
| 1497 |
set value. |
| 1498 |
|
| 1499 |
""" |
| 1500 |
sweep_mode = SweepMode(sweep_mode) |
| 1501 |
repeat = truncated_range(repeat, [0, 1024]) |
| 1502 |
start_address = truncated_range(start_address, [1, 2048]) |
| 1503 |
stop_address = truncated_range(stop_address, [1, 2048]) |
| 1504 |
|
| 1505 |
self.write(f'mdwv {{ch}},{sweep_mode.value},{repeat},{start_address},{stop_address},' |
| 1506 |
'{current_compliance:.4e},{bias:.4e}') |
| 1507 |
|
| 1508 |
def voltage_random_pulsed_sweep( |
| 1509 |
self, sweep_mode, repeat, start_address, stop_address, current_compliance, bias=0): |
| 1510 |
""" Sets the sweep mode, repeat count, base value, start address, |
| 1511 |
stop address, current compliance and the bias value of the constant voltage random pulse |
| 1512 |
sweep (``MPWV``). |
| 1513 |
|
| 1514 |
.. note:: |
| 1515 |
|
| 1516 |
- Sweep mode, number of repeats, start address and stop address are subject to the |
| 1517 |
following restrictions: |
| 1518 |
|
| 1519 |
- Start address < Stop address |
| 1520 |
- Let N = number of steps, m = l (one-way sweep), m = 2 (round-trip sweep). |
| 1521 |
|
| 1522 |
- When the OFM command sets the output data output method to 1 or 2 m x number of |
| 1523 |
refreshes x N <= 2048 |
| 1524 |
- m x N <= 2048 when the OFM command sets the output data output method to 3. |
| 1525 |
|
| 1526 |
- Regardless of the specified current compliance polarity, both polarities (+ and -) are |
| 1527 |
set. |
| 1528 |
- The current compliance range is automatically set to the minimum range that includes the |
| 1529 |
set value. |
| 1530 |
|
| 1531 |
""" |
| 1532 |
sweep_mode = SweepMode(sweep_mode) |
| 1533 |
repeat = truncated_range(repeat, [0, 1024]) |
| 1534 |
start_address = truncated_range(start_address, [1, 2048]) |
| 1535 |
stop_address = truncated_range(stop_address, [1, 2048]) |
| 1536 |
|
| 1537 |
self.write(f'mpwv {{ch}},{sweep_mode.value},{repeat},{start_address},{stop_address},' |
| 1538 |
'{current_compliance:.4e},{bias:.4e}') |
| 1539 |
|
| 1540 |
def voltage_set_random_memory(self, address, voltage_range, output, current_compliance): |
| 1541 |
""" The command stores the specified value to the randomly generated data memory (``RMS``). |
| 1542 |
|
| 1543 |
Stored generated values are swept within the specified memory |
| 1544 |
address range by the MDWV, MDWI, MPWV, MPWI commands. |
| 1545 |
|
| 1546 |
""" |
| 1547 |
|
| 1548 |
voltage_range = VoltageRange(voltage_range) |
| 1549 |
address = truncated_range(address, [1, 2048]) |
| 1550 |
|
| 1551 |
self.write(f'rms {address};dv{{ch}},{voltage_range.value},{output:.4e},' |
| 1552 |
'{current_compliance:.4e};rend') |
| 1553 |
|
| 1554 |
############### |
| 1555 |
# Current (A) # |
| 1556 |
############### |
| 1557 |
|
| 1558 |
def current_source(self, source_range, source_value, voltage_compliance): |
| 1559 |
""" Sets the source range, source value, voltage compliance |
| 1560 |
of the DC (constant current) measurement (``DI``). |
| 1561 |
|
| 1562 |
:param source_range: Specifying source range |
| 1563 |
:type source_range: :class:`.CurrentRange` |
| 1564 |
:param float source_value: A number specifying the source current value |
| 1565 |
:param float voltage_compliance: A number specifying the voltage compliance |
| 1566 |
|
| 1567 |
.. note:: |
| 1568 |
|
| 1569 |
Regardless of the specified voltage compliance polarity, both polarities (+ and -) are |
| 1570 |
set. |
| 1571 |
The voltage compliance range is automatically set to the minimum range that includes the |
| 1572 |
set value. |
| 1573 |
|
| 1574 |
""" |
| 1575 |
source_range = CurrentRange(source_range) |
| 1576 |
source_value = truncated_range(source_value, self.current_range) |
| 1577 |
|
| 1578 |
self.write(f'di {{ch}},{source_range.value},{source_value:.4e},{voltage_compliance:.4e}') |
| 1579 |
|
| 1580 |
def current_pulsed_source(self, source_range, pulse_value, base_value, voltage_compliance): |
| 1581 |
""" Sets the source range, pulse value, base value and the voltage compliance |
| 1582 |
of the pulse (current) measurement (``PI``). |
| 1583 |
|
| 1584 |
.. note:: |
| 1585 |
|
| 1586 |
Regardless of the specified voltage compliance polarity, both polarities (+ and -) are |
| 1587 |
set. |
| 1588 |
The voltage compliance range is automatically set to the minimum range that includes the |
| 1589 |
set value. |
| 1590 |
|
| 1591 |
""" |
| 1592 |
source_range = CurrentRange(source_range) |
| 1593 |
pulse_value = truncated_range(pulse_value, self.current_range) |
| 1594 |
base_value = truncated_range(base_value, self.current_range) |
| 1595 |
|
| 1596 |
self.write(f'pi {{ch}},{source_range.value},{pulse_value:.4e},{base_value:.4e},' |
| 1597 |
'{voltage_compliance:.4e}') |
| 1598 |
|
| 1599 |
change_source_current = Channel.setting( |
| 1600 |
"spot {ch},%.4e", |
| 1601 |
""" Set new target current (``SPOT``). |
| 1602 |
|
| 1603 |
:type: float |
| 1604 |
|
| 1605 |
.. note:: |
| 1606 |
|
| 1607 |
Only the DC action source value and pulse action pulse value |
| 1608 |
are changed using the currently set DC action and pulse action parameters. |
| 1609 |
Measure after the change and set the channel to output the measured data |
| 1610 |
to the specified ch. In other words, it's the same as running the following |
| 1611 |
commands: |
| 1612 |
|
| 1613 |
1. DV/DI/PV/PI |
| 1614 |
2. XE xx |
| 1615 |
3. FCH xx |
| 1616 |
|
| 1617 |
""" |
| 1618 |
) |
| 1619 |
|
| 1620 |
def current_fixed_level_sweep( |
| 1621 |
self, current_range, current_level, measurement_count, voltage_compliance, bias=0): |
| 1622 |
""" Sets the fixed level sweep (current) generation range, level value, |
| 1623 |
voltage compliance and the bias value (``FXI``). |
| 1624 |
|
| 1625 |
.. note:: |
| 1626 |
|
| 1627 |
Regardless of the specified voltage compliance polarity, both polarities (+ and -) are |
| 1628 |
set. |
| 1629 |
The voltage compliance range is automatically set to the minimum range that includes the |
| 1630 |
set value. |
| 1631 |
|
| 1632 |
""" |
| 1633 |
current_range = CurrentRange(current_range) |
| 1634 |
|
| 1635 |
self.write(f'fxi {{ch}},{current_range.value},{current_level:.4e},{measurement_count},' |
| 1636 |
'{voltage_compliance:.4e},{bias:.4e}') |
| 1637 |
|
| 1638 |
def current_fixed_pulsed_sweep( |
| 1639 |
self, current_range, pulse, base, measurement_count, voltage_compliance, bias=0): |
| 1640 |
""" Sets the fixed pulse (current) sweep generation range, |
| 1641 |
pulse value, base value, number of measurements, voltage compliance and the bias value |
| 1642 |
(``PXI``). |
| 1643 |
|
| 1644 |
.. note:: |
| 1645 |
|
| 1646 |
Regardless of the specified voltage compliance polarity, both polarities of + and - are |
| 1647 |
set. |
| 1648 |
The voltage compliance range is automatically set to the minimum range that includes the |
| 1649 |
set value. |
| 1650 |
|
| 1651 |
""" |
| 1652 |
current_range = CurrentRange(current_range) |
| 1653 |
|
| 1654 |
self.write(f'pxi {{ch}},{current_range.value},{pulse:.4e},{base:.4e},{measurement_count},' |
| 1655 |
'{voltage_compliance:.4e},{bias:.4e}') |
| 1656 |
|
| 1657 |
def current_sweep( |
| 1658 |
self, sweep_mode, repeat, current_range, start_value, stop_value, steps, |
| 1659 |
voltage_compliance, bias=0): |
| 1660 |
""" Sets the sweep mode, number of repeats, source range, |
| 1661 |
start value, stop value, number of steps, voltage compliance |
| 1662 |
and bias value for the staircase (linear/log) current sweep (``WI``). |
| 1663 |
|
| 1664 |
.. note:: |
| 1665 |
|
| 1666 |
- The sweep mode, number of refreshes, and number of steps are subject to the following |
| 1667 |
restrictions: |
| 1668 |
|
| 1669 |
- Let N = number of steps, m = l (one-way sweep), m = 2 (round-trip sweep). |
| 1670 |
|
| 1671 |
- When the OFM command sets the output data output method to 1 or 2, m x number |
| 1672 |
of repeats x N <= 2048. |
| 1673 |
- m x N <= 2048 when the OFM command sets the output data output method to 3. |
| 1674 |
|
| 1675 |
- Regardless of the specified voltage compliance polarity, both polarities (+ and -) are |
| 1676 |
set. |
| 1677 |
- The voltage compliance range is automatically set to the minimum range that includes |
| 1678 |
the set value. |
| 1679 |
|
| 1680 |
""" |
| 1681 |
sweep_mode = SweepMode(sweep_mode) |
| 1682 |
repeat = truncated_range(repeat, [0, 1024]) |
| 1683 |
steps = truncated_range(steps, [2, 2048]) |
| 1684 |
current_range = CurrentRange(current_range) |
| 1685 |
|
| 1686 |
self.write(f'wi {{ch}},{sweep_mode.value},{repeat},{current_range.value},' |
| 1687 |
'{start_value:.4e},{stop_value:.4e},{steps},{voltage_compliance:.4e},' |
| 1688 |
'{bias:.4e}') |
| 1689 |
|
| 1690 |
def current_pulsed_sweep( |
| 1691 |
self, sweep_mode, repeat, current_range, base, start_value, stop_value, steps, |
| 1692 |
voltage_compliance, bias=0): |
| 1693 |
""" Sets the sweep mode, repeat count, generation range, |
| 1694 |
base value, start value, stop value, number of steps, voltage compliance |
| 1695 |
and the bias value for a pulse wave (linear/log) current sweep (``PWI``). |
| 1696 |
|
| 1697 |
.. note:: |
| 1698 |
|
| 1699 |
- The sweep mode, number of refreshes, and number of steps are subject to the following |
| 1700 |
restrictions: |
| 1701 |
|
| 1702 |
- Let N = number of steps, m = l (one-way sweep), m = 2 (round-trip sweep). |
| 1703 |
|
| 1704 |
- When the OFM command sets the output data output method to 1 or 2, m x number |
| 1705 |
of repeats x N <= 2048. |
| 1706 |
- m x N <= 2048 when the OFM command sets the output data output method to 3. |
| 1707 |
|
| 1708 |
- Regardless of the specified voltage compliance polarity, both polarities (+ and -) are |
| 1709 |
set. |
| 1710 |
- The voltage compliance range is automatically set to the minimum range that includes |
| 1711 |
the set value. |
| 1712 |
|
| 1713 |
""" |
| 1714 |
sweep_mode = SweepMode(sweep_mode) |
| 1715 |
repeat = truncated_range(repeat, [0, 1024]) |
| 1716 |
steps = truncated_range(steps, [2, 2048]) |
| 1717 |
current_range = CurrentRange(current_range) |
| 1718 |
|
| 1719 |
self.write( |
| 1720 |
f'pwi {{ch}},{sweep_mode.value},{repeat},{current_range.value},{base:.4e},' |
| 1721 |
'{start_value:.4e},{stop_value:.4e},{steps},{voltage_compliance:.4e},{bias:.4e}') |
| 1722 |
|
| 1723 |
def measure_current(self, enable=True, internal_measurement=True, |
| 1724 |
current_range=CurrentRange.AUTO): |
| 1725 |
""" Set the current measurement ON/OFF, measurement input, and current measurement range as |
| 1726 |
parameters (``RI``). |
| 1727 |
|
| 1728 |
:param enable: boolean property that enables or disables current measurement. |
| 1729 |
Valid values are True (Measure the current flowing at the OUTPUT terminal) and False |
| 1730 |
(Measure the current from the rear panel -ANALOG COMMON). |
| 1731 |
:type enable: bool, optional |
| 1732 |
:param internal_measurement: A boolean property that enables or disables the internal |
| 1733 |
measurement. |
| 1734 |
:type internal_measurement: bool, optional |
| 1735 |
:param current_range: Specifying voltage range |
| 1736 |
:type current_range: :class:`.CurrentRange`, optional |
| 1737 |
|
| 1738 |
""" |
| 1739 |
current_range = CurrentRange(current_range) |
| 1740 |
enable = map_values(enable, {True: 1, False: 2}) |
| 1741 |
internal_measurement = map_values(internal_measurement, {True: 1, False: 2}) |
| 1742 |
|
| 1743 |
self.write(f'ri {{ch}},{enable},{internal_measurement},{current_range.value}') |
| 1744 |
|
| 1745 |
def current_random_sweep( |
| 1746 |
self, sweep_mode, repeat, start_address, stop_address, current_compliance, bias=0): |
| 1747 |
""" Sets the sweep mode, repeat count, start address, |
| 1748 |
stop address, voltage compliance and the bias value of constant current random sweep |
| 1749 |
(``MDWI``). |
| 1750 |
|
| 1751 |
.. note:: |
| 1752 |
|
| 1753 |
- Sweep mode, number of repeats, start address and stop address are subject to the |
| 1754 |
following restrictions: |
| 1755 |
|
| 1756 |
- Start address < Stop address |
| 1757 |
- Let N = (stop number 1 - start number + 1), m = 1 (one-way sweep), m = 2 |
| 1758 |
(round-trip sweep). |
| 1759 |
|
| 1760 |
- When the output data output method is set to 1 or 2 with the OFM command m x |
| 1761 |
number of repeats x N <= 2048 |
| 1762 |
- When the output data output method is set to 3 with the OFM command m x N <= |
| 1763 |
2048 |
| 1764 |
|
| 1765 |
- For the voltage compliance polarity, regardless of the specified voltage compliance |
| 1766 |
polarity, both polarities of + and – are set. |
| 1767 |
- The voltage compliance range is automatically set to the minimum range that includes |
| 1768 |
the set value. |
| 1769 |
|
| 1770 |
""" |
| 1771 |
sweep_mode = SweepMode(sweep_mode) |
| 1772 |
repeat = truncated_range(repeat, [0, 1024]) |
| 1773 |
start_address = truncated_range(start_address, [1, 2048]) |
| 1774 |
stop_address = truncated_range(stop_address, [1, 2048]) |
| 1775 |
|
| 1776 |
self.write( |
| 1777 |
f'mdwi {{ch}},{sweep_mode.value},{repeat},{start_address},{stop_address},' |
| 1778 |
'{current_compliance:.4e},{bias:.4e}') |
| 1779 |
|
| 1780 |
def current_random_pulsed_sweep( |
| 1781 |
self, sweep_mode, repeat, start_address, stop_address, current_compliance, bias=0): |
| 1782 |
""" Sets the sweep mode, repeat count, base value, start address, |
| 1783 |
stop address, voltage compliance and the bias value of constant current random pulse sweep |
| 1784 |
(``MPWI``). |
| 1785 |
|
| 1786 |
.. note:: |
| 1787 |
- Sweep mode, number of repeats, start address and stop address are subject to the |
| 1788 |
following restrictions: |
| 1789 |
|
| 1790 |
- Start address < Stop address |
| 1791 |
- Let N = (stop number 1 - start number + 1), m = 1 (one-way sweep), m = 2 |
| 1792 |
(round-trip sweep). |
| 1793 |
|
| 1794 |
- When the output data output method is set to 1 or 2 with the OFM command m x |
| 1795 |
number of repeats x N <= 2048 |
| 1796 |
- When the output data output method is set to 3 with the OFM command m x N <= |
| 1797 |
2048 |
| 1798 |
|
| 1799 |
- For the voltage compliance polarity, regardless of the specified voltage compliance |
| 1800 |
polarity, both polarities of + and – are set. |
| 1801 |
- The voltage compliance range is automatically set to the minimum range that includes |
| 1802 |
the set value. |
| 1803 |
|
| 1804 |
""" |
| 1805 |
sweep_mode = SweepMode(sweep_mode) |
| 1806 |
repeat = truncated_range(repeat, [0, 1024]) |
| 1807 |
start_address = truncated_range(start_address, [1, 2048]) |
| 1808 |
stop_address = truncated_range(stop_address, [1, 2048]) |
| 1809 |
|
| 1810 |
self.write( |
| 1811 |
f'mpwi {{ch}},{sweep_mode.value},{repeat},{start_address},{stop_address},' |
| 1812 |
'{current_compliance:.4e},{bias:.4e}') |
| 1813 |
|
| 1814 |
def current_set_random_memory(self, address, current_range, output, voltage_compliance): |
| 1815 |
""" Store the current parameters to randomly generated data memory (``RMS``). |
| 1816 |
|
| 1817 |
Stored generated values are swept within the specified memory |
| 1818 |
address range by the MDWV, MDWI, MPWV, MPWI commands. |
| 1819 |
|
| 1820 |
""" |
| 1821 |
current_range = CurrentRange(current_range) |
| 1822 |
address = truncated_range(address, [1, 2048]) |
| 1823 |
|
| 1824 |
self.write( |
| 1825 |
f'rms {address};di{{ch}},{current_range.value},{output:.4e},' |
| 1826 |
'{voltage_compliance:.4e};rend') |
| 1827 |
|
| 1828 |
def read_random_memory(self, address): |
| 1829 |
""" Return memory specified by address location (``RMS?``). |
| 1830 |
|
| 1831 |
:param int address: Adress to specify memory location. |
| 1832 |
:returns: Set values returned by the device from the specified address location. |
| 1833 |
:rtype: str |
| 1834 |
|
| 1835 |
""" |
| 1836 |
address = truncated_range(address, [1, 2048]) |
| 1837 |
return self.ask(f'rms_1{{ch}}? {address}') |
| 1838 |
|
| 1839 |
def enable_source(self): |
| 1840 |
""" Put the specified channel into an operating state (``CN``). |
| 1841 |
""" |
| 1842 |
self.write('cn {ch}') |
| 1843 |
|
| 1844 |
def standby(self): |
| 1845 |
""" Put the specified channel into standby state (``CL``). |
| 1846 |
""" |
| 1847 |
self.write('cl {ch}') |
| 1848 |
|
| 1849 |
def stop(self): |
| 1850 |
""" Stops the sweep when the sweep is started by the |
| 1851 |
XE command or the trigger input signal (``SP``). |
| 1852 |
""" |
| 1853 |
self.write('sp {ch}') |
| 1854 |
|
| 1855 |
def output_all_measurements(self): |
| 1856 |
""" Output all measurements in the measurement |
| 1857 |
data buffer of the specified channel (``RMM?``). |
| 1858 |
|
| 1859 |
.. note:: |
| 1860 |
|
| 1861 |
For the output format, refer to :meth:`AdvantestR624X.set_output_format`. |
| 1862 |
When a memory address where no measurement data is stored is read, 999.999E+99 will be |
| 1863 |
returned. |
| 1864 |
|
| 1865 |
""" |
| 1866 |
self.write('rmm_0{ch}?') |
| 1867 |
|
| 1868 |
def read_measurement_from_addr(self, addr): |
| 1869 |
""" Output only one measurement at the specified |
| 1870 |
memory address from the measurement data buffer of the specified channel. |
| 1871 |
|
| 1872 |
:param int addr: Specifies the address to read from. |
| 1873 |
:return: float Measurement data |
| 1874 |
|
| 1875 |
.. note:: |
| 1876 |
|
| 1877 |
For the output format, refer to :meth:`AdvantestR624X.set_output_format`. |
| 1878 |
When a memory address where no measurement data is stored is read, 999.999E+99 will be |
| 1879 |
returned. |
| 1880 |
|
| 1881 |
""" |
| 1882 |
measurement = self.ask(f'rmm_1{{ch}}? {addr}') |
| 1883 |
return self.parent.parse_measurement(measurement) |
| 1884 |
|
| 1885 |
measurement_count = Channel.measurement( |
| 1886 |
"nub_0{ch}?", |
| 1887 |
""" Measaure the number of measurements contained in the measurement |
| 1888 |
data buffer (``NUB?``). """, |
| 1889 |
cast=int |
| 1890 |
) |
| 1891 |
|
| 1892 |
null_operation_enabled = Channel.setting( |
| 1893 |
"nug {ch},%d", |
| 1894 |
""" Set a boolean that controls whether the null operation |
| 1895 |
is enabled, takes values of True or False (``NUG``). |
| 1896 |
|
| 1897 |
:type: bool |
| 1898 |
|
| 1899 |
.. Acquisition timing of null data:: |
| 1900 |
|
| 1901 |
- Null data captures the next measurement data for which null computation is |
| 1902 |
enabled as null data during DC measurement or pulse measurement. |
| 1903 |
- A sweep operation does not capture null data. |
| 1904 |
- If null calculation is enabled during sweep operation, null data obtained |
| 1905 |
by DC operation or pulse operation will be used for calculation. |
| 1906 |
- Indicates the timing of null data acquisition during DC operation. |
| 1907 |
|
| 1908 |
.. note:: |
| 1909 |
|
| 1910 |
- Null data is not rewritten even if the null operation is disabled. |
| 1911 |
- Null data is rewritten only when null operation is changed from OFF to ON or |
| 1912 |
initialized in case of DC operation or pulse operation. |
| 1913 |
|
| 1914 |
""", |
| 1915 |
validator=strict_discrete_set, |
| 1916 |
values={False: 1, True: 2}, |
| 1917 |
map_values=True |
| 1918 |
) |
| 1919 |
|
| 1920 |
def set_wire_mode(self, four_wire, lo_guard=True): |
| 1921 |
""" Used to switch remote sense and to set the LO-GUARD relay ON/OFF. |
| 1922 |
It operates regardless of operating state or standby state (``OSL``). |
| 1923 |
|
| 1924 |
:param bool four_wire: A boolean property that enables or disables four wire measurements. |
| 1925 |
Valid values are True (enables 4-wire sensing) and False (enables two-terminal sensing). |
| 1926 |
:param bool lo_guard: A boolean property that enables or disables the LO-GUARD relay. |
| 1927 |
|
| 1928 |
""" |
| 1929 |
four_wire = map_values(four_wire, {True: 1, False: 2}) |
| 1930 |
lo_guard = map_values(lo_guard, {True: 1, False: 2}) |
| 1931 |
|
| 1932 |
self.write(f'osl {{ch}},{four_wire},{lo_guard}') |
| 1933 |
|
| 1934 |
auto_zero_enabled = Channel.setting( |
| 1935 |
"cm {ch},%d", |
| 1936 |
""" Set the auto zero option to ON or OFF. Valid values are |
| 1937 |
True (enabled) and False (disabled) (``CM``). |
| 1938 |
|
| 1939 |
:type: bool |
| 1940 |
|
| 1941 |
This command sets auto zero (automatically calibrate the |
| 1942 |
zero point of the measured value operation. |
| 1943 |
|
| 1944 |
1. Periodically perform auto zero. |
| 1945 |
2. Auto zero once, no periodic auto zeros thereafter. |
| 1946 |
|
| 1947 |
When the auto zero mode is set to True, the following operations are performed. |
| 1948 |
|
| 1949 |
- For DC operation and pulse operation: |
| 1950 |
|
| 1951 |
- At the end of one sweep, if he has exceeded the last autozero by more than 10 seconds, |
| 1952 |
he will do one autozero. |
| 1953 |
- If sweep start is specified during auto zero, the sweep will start after auto zero |
| 1954 |
ends. |
| 1955 |
|
| 1956 |
- Sweep operation |
| 1957 |
|
| 1958 |
- Auto zero is performed once every 10 seconds. |
| 1959 |
- If measurement or pulse output is specified during auto zero, it will be executed |
| 1960 |
after auto zero ends. |
| 1961 |
|
| 1962 |
""", |
| 1963 |
validator=strict_discrete_set, |
| 1964 |
values={False: 2, True: 1}, |
| 1965 |
map_values=True |
| 1966 |
) |
| 1967 |
|
| 1968 |
def set_comparison_limits(self, comparison, voltage_value, upper_limit, lower_limit): |
| 1969 |
""" Sets the channel ON/OFF based on the measurement comparison |
| 1970 |
and the data of the upper and lower limits to be compared (``CMD``). |
| 1971 |
|
| 1972 |
:param bool comparison: A boolean property that controls whether or not |
| 1973 |
the comparison function is enabled. Valid values are True or False. |
| 1974 |
:param bool voltage_value: A boolean property that controls whether or not |
| 1975 |
voltage or current values are passed. Valid values are True or False. |
| 1976 |
:param float upper_limit: Number specifying the upper comparison limit |
| 1977 |
:param float lower_limit: Number specifying the lower comparison limit |
| 1978 |
|
| 1979 |
""" |
| 1980 |
comparison = map_values(comparison, {True: 2, False: 1}) |
| 1981 |
voltage_value = map_values(voltage_value, {True: 1, False: 2}) |
| 1982 |
|
| 1983 |
self.write(f'cmd {{ch}},{comparison},{voltage_value},{upper_limit:.4e},{lower_limit:.4e}') |
| 1984 |
|
| 1985 |
relay_mode = Channel.setting( |
| 1986 |
"opm {ch},%d", |
| 1987 |
""" Set the HI/LO relays for standby mode. |
| 1988 |
This command does not operate the Operate Relay (``OPM``). |
| 1989 |
|
| 1990 |
:type: int |
| 1991 |
|
| 1992 |
1. When executing an operation only the HI side turns ON, in standby both HI and LO are |
| 1993 |
turned OFF. |
| 1994 |
2. When executing an operation only the LO side turns ON, in standby both HI and LO are |
| 1995 |
turned OFF. |
| 1996 |
3. When executing an operation both HI and LO turn ON, in standby both HI and LO are turned |
| 1997 |
OFF. |
| 1998 |
4. When executing an operation only the HI side turns ON, in standby only the HI side is |
| 1999 |
turned OFF. |
| 2000 |
|
| 2001 |
""", |
| 2002 |
validator=strict_range, |
| 2003 |
values=range(1, 4), |
| 2004 |
) |
| 2005 |
|
| 2006 |
operation_register = Channel.measurement( |
| 2007 |
"coc_0{ch}?", |
| 2008 |
""" Measure the contents of the Channel Operations Register (COR) |
| 2009 |
in the form of a :class:`COR` ``IntFlag`` (``COC?``). |
| 2010 |
|
| 2011 |
""", |
| 2012 |
values=range(0, 65535), |
| 2013 |
get_process=lambda v: COR(int(v)), |
| 2014 |
) |
| 2015 |
|
| 2016 |
output_enable_register = Channel.control( |
| 2017 |
"coe_0{ch}?", |
| 2018 |
"coe_0{ch} %d", |
| 2019 |
""" Control the settings of the channel operation output enable |
| 2020 |
register (COER) in the form of a :class:`COR` IntFlag ?(``COE?``). |
| 2021 |
|
| 2022 |
""", |
| 2023 |
validator=strict_range, |
| 2024 |
values=range(0, 65535), |
| 2025 |
get_process=lambda v: COR(int(v)), |
| 2026 |
) |
| 2027 |
|
| 2028 |
def calibration_init(self): |
| 2029 |
""" Initialize the calibration data (``CINI``). """ |
| 2030 |
self.write('cini {ch}') |
| 2031 |
|
| 2032 |
def calibration_store_factor(self): |
| 2033 |
""" Store the calibration factor |
| 2034 |
in the non-volatile memory (EEPROM) (``CSRT``). """ |
| 2035 |
self.write('csrt {ch}') |
| 2036 |
|
| 2037 |
calibration_measured_value = Channel.setting( |
| 2038 |
"std {ch},%.4e", |
| 2039 |
""" Set the measured value measured by an external standard |
| 2040 |
for the generated value of this instrument and start calibration (``STD``). |
| 2041 |
|
| 2042 |
:type: float |
| 2043 |
|
| 2044 |
""", |
| 2045 |
) |
| 2046 |
|
| 2047 |
calibration_generation_factor = Channel.setting( |
| 2048 |
"ccs {ch},%.4e", |
| 2049 |
""" Set the increment or decrement for the generation |
| 2050 |
calibration factor of the current generation range (``CCS``). It is used when |
| 2051 |
the generated value deviates from the true value. |
| 2052 |
|
| 2053 |
:type: float |
| 2054 |
|
| 2055 |
""", |
| 2056 |
) |
| 2057 |
|
| 2058 |
calibration_factor = Channel.setting( |
| 2059 |
"ccm {ch},%.4e", |
| 2060 |
""" Set the increment of the measurement calibration |
| 2061 |
factor of the current measurement range (``CCM``). |
| 2062 |
|
| 2063 |
:type: float |
| 2064 |
""", |
| 2065 |
) |
| 2066 |
|
| 2067 |
|
| 2068 |
class AdvantestR6245(AdvantestR624X): |
| 2069 |
""" Main instrument class for Advantest R6245 DC Voltage/Current Source/Monitor |
| 2070 |
""" |
| 2071 |
voltage_range = {'A': [-220.0, 220.0], 'B': [-220.0, 220.0]} |
| 2072 |
current_range = {'A': [-2.0, 2.0], 'B': [-2.0, 2.0]} |
| 2073 |
|
| 2074 |
ch_A = Instrument.ChannelCreator(SMUChannel, 'A', |
| 2075 |
voltage_range=voltage_range, |
| 2076 |
current_range=current_range) |
| 2077 |
|
| 2078 |
ch_B = Instrument.ChannelCreator(SMUChannel, 'B', |
| 2079 |
voltage_range=voltage_range, |
| 2080 |
current_range=current_range) |
| 2081 |
|
| 2082 |
def __init__(self, adapter, name="Advantest R6245 SourceMeter", **kwargs): |
| 2083 |
kwargs |
| 2084 |
super().__init__( |
| 2085 |
adapter, |
| 2086 |
name, |
| 2087 |
**kwargs |
| 2088 |
) |
| 2089 |
|
| 2090 |
|
| 2091 |
class AdvantestR6246(AdvantestR624X): |
| 2092 |
""" Main instrument class for Advantest R6246 DC Voltage/Current Source/Monitor |
| 2093 |
""" |
| 2094 |
voltage_range = {'A': [-62.0, 62.0], 'B': [-220.0, 220.0]} |
| 2095 |
current_range = {'A': [-20.0, 20.0], 'B': [-2.0, 2.0]} |
| 2096 |
|
| 2097 |
ch_A = Instrument.ChannelCreator(SMUChannel, 'A', |
| 2098 |
voltage_range=voltage_range, |
| 2099 |
current_range=current_range) |
| 2100 |
|
| 2101 |
ch_B = Instrument.ChannelCreator(SMUChannel, 'B', |
| 2102 |
voltage_range=voltage_range, |
| 2103 |
current_range=current_range) |
| 2104 |
|
| 2105 |
def __init__(self, adapter, name="Advantest R6246 SourceMeter", **kwargs): |
| 2106 |
super().__init__( |
| 2107 |
adapter, |
| 2108 |
name, |
| 2109 |
**kwargs |
| 2110 |
) |