| 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 |
from pymeasure.instruments import Instrument, Channel, SCPIUnknownMixin |
| 27 |
from pymeasure.instruments.validators import truncated_range, strict_discrete_set |
| 28 |
|
| 29 |
log = logging.getLogger(__name__) |
| 30 |
log.addHandler(logging.NullHandler()) |
| 31 |
|
| 32 |
|
| 33 |
class Keithley2306Channel(Channel): |
| 34 |
""" Implementation of a Keithley 2306 channel. """ |
| 35 |
|
| 36 |
enabled = Channel.control( |
| 37 |
":OUTPUT{ch}:STAT?", ":OUTPUT{ch}:STAT %d", |
| 38 |
"""A boolean property that controls whether the output is enabled, takes |
| 39 |
values True or False. """, |
| 40 |
validator=strict_discrete_set, |
| 41 |
values={True: 1, False: 0}, |
| 42 |
map_values=True |
| 43 |
) |
| 44 |
|
| 45 |
bandwidth = Channel.control( |
| 46 |
":OUTPUT{ch}:BAND?", ":OUTPUT{ch}:BAND %s", |
| 47 |
"""A string property that controls the output bandwidth when the output |
| 48 |
is enabled and the current range is set to 5 A. Takes values 'HIGH' or |
| 49 |
'LOW'. If the output is disabled or the current range is set to 5 mA the |
| 50 |
bandwidth is 'LOW'. """, |
| 51 |
validator=strict_discrete_set, |
| 52 |
values={'low': 'LOW', 'high': 'HIGH'}, |
| 53 |
map_values=True, |
| 54 |
) |
| 55 |
|
| 56 |
sense_mode = Channel.control( |
| 57 |
":SENS{ch}:FUNC?", ":SENS{ch}:FUNC \"%s\"", |
| 58 |
"""A string property that controls the channel sense mode, which can |
| 59 |
take the values 'voltage', 'current', 'dvm', 'pulse_current', |
| 60 |
or 'long_integration'. """, |
| 61 |
validator=strict_discrete_set, |
| 62 |
values={'voltage': 'VOLT', 'current': 'CURR', 'dvm': 'DVM', |
| 63 |
'pulse_current': 'PCUR', 'long_integration': 'LINT'}, |
| 64 |
map_values=True, |
| 65 |
get_process=lambda v: v.replace('"', ''), |
| 66 |
) |
| 67 |
|
| 68 |
nplc = Channel.control( |
| 69 |
":SENS{ch}:NPLC?", ":SENS{ch}:NPLC %g", |
| 70 |
"""A floating point property that controls the number of power line |
| 71 |
cycles (NPLC) for voltage, current, and DVM measurements. Takes |
| 72 |
values from 0.01 to 10. """, |
| 73 |
validator=truncated_range, |
| 74 |
values=[0.01, 10], |
| 75 |
) |
| 76 |
|
| 77 |
average_count = Channel.control( |
| 78 |
":SENS{ch}:AVER?", ":SENS{ch}:AVER %d", |
| 79 |
"""An integer property that controls the average count for voltage, |
| 80 |
current, and DVM measurements. Takes values from 1 to 10. """, |
| 81 |
validator=truncated_range, |
| 82 |
values=[1, 10], |
| 83 |
) |
| 84 |
|
| 85 |
current_range = Channel.control( |
| 86 |
":SENS{ch}:CURR:RANG?", ":SENS{ch}:CURR:RANG %g", |
| 87 |
"""A floating point property that controls the current range which |
| 88 |
takes values of 5 mA and 5 A (or 500 mA and 5 A for the 2306-PJ).""", |
| 89 |
validator=strict_discrete_set, |
| 90 |
values=[0.005, 0.5, 5], |
| 91 |
) |
| 92 |
|
| 93 |
current_range_auto = Channel.control( |
| 94 |
":SENS{ch}:CURR:RANG:AUTO?", ":SENS{ch}:CURR:RANG:AUTO %d", |
| 95 |
"""A boolean point property that controls whether current range |
| 96 |
is in auto mode. """, |
| 97 |
validator=strict_discrete_set, |
| 98 |
values={True: 1, False: 0}, |
| 99 |
map_values=True |
| 100 |
) |
| 101 |
|
| 102 |
pulse_current_average_count = Channel.control( |
| 103 |
":SENS{ch}:PCUR:AVER?", ":SENS{ch}:PCUR:AVER %d", |
| 104 |
"""An integer property that controls the average count for pulse |
| 105 |
current measurements. Takes values from 1 to either 100 if |
| 106 |
pulse_current_measure_enabled is set to True, 5000 otherwise. """, |
| 107 |
validator=truncated_range, |
| 108 |
values=[1, 5000], |
| 109 |
) |
| 110 |
|
| 111 |
pulse_current_measure_enabled = Channel.control( |
| 112 |
":SENS{ch}:PCUR:SYNC?", ":SENS{ch}:PCUR:SYNC %d", |
| 113 |
"""A boolean property that controls whether pulse current |
| 114 |
measurements are enabled (True) or whether the channel is in |
| 115 |
digitization mode (False). """, |
| 116 |
validator=strict_discrete_set, |
| 117 |
values={True: 1, False: 0}, |
| 118 |
map_values=True |
| 119 |
) |
| 120 |
|
| 121 |
pulse_current_trigger_delay = Channel.control( |
| 122 |
":SENS{ch}:PCUR:SYNC:DEL?", ":SENS{ch}:PCUR:SYNC:DEL %g", |
| 123 |
"""A floating point property that controls the pulse current trigger |
| 124 |
delay in seconds. Takes values from 0 to either 0.1 if |
| 125 |
pulse_current_measure_enabled is set to True, 5 otherwise.""", |
| 126 |
validator=truncated_range, |
| 127 |
values=[0, 5], |
| 128 |
) |
| 129 |
|
| 130 |
pulse_current_trigger_level = Channel.control( |
| 131 |
":SENS{ch}:PCUR:SYNC:TLEV?", ":SENS{ch}:PCUR:SYNC:TLEV %g", |
| 132 |
"""A floating point property that controls the pulse current trigger |
| 133 |
level in amps. Takes values between 0 and 5.""", |
| 134 |
validator=truncated_range, |
| 135 |
values=[0, 5], |
| 136 |
) |
| 137 |
|
| 138 |
pulse_current_mode = Channel.control( |
| 139 |
":SENS{ch}:PCUR:MODE?", ":SENS{ch}:PCUR:MODE %s", |
| 140 |
"""A string property that controls the pulse current measurement |
| 141 |
mode, which can take the values 'high', 'low', or 'average'. """, |
| 142 |
validator=strict_discrete_set, |
| 143 |
values={'high': 'HIGH', 'low': 'LOW', 'average': 'AVER'}, |
| 144 |
map_values=True, |
| 145 |
) |
| 146 |
|
| 147 |
def pulse_current_time_auto(self): |
| 148 |
"""Arranges for the instrument to control integration times. """ |
| 149 |
self.write(":SENS{ch}:PCUR:TIME:AUTO") |
| 150 |
|
| 151 |
pulse_current_time_high = Channel.control( |
| 152 |
":SENS{ch}:PCUR:TIME:HIGH?", ":SENS{ch}:PCUR:TIME:HIGH %g", |
| 153 |
"""A floating point property that controls the integration time (in |
| 154 |
seconds) for high pulse measurements. Takes on values between |
| 155 |
33.33333e-06 and 0.8333. """, |
| 156 |
validator=truncated_range, |
| 157 |
values=[33.33333e-06, 0.8333], |
| 158 |
) |
| 159 |
|
| 160 |
pulse_current_time_low = Channel.control( |
| 161 |
":SENS{ch}:PCUR:TIME:LOW?", ":SENS{ch}:PCUR:TIME:LOW %g", |
| 162 |
"""A floating point property that controls the integration time (in |
| 163 |
seconds) for low pulse measurements. Takes on values between |
| 164 |
33.33333e-06 and 0.8333. """, |
| 165 |
validator=truncated_range, |
| 166 |
values=[33.33333e-06, 0.8333], |
| 167 |
) |
| 168 |
|
| 169 |
pulse_current_time_average = Channel.control( |
| 170 |
":SENS{ch}:PCUR:TIME:AVER?", ":SENS{ch}:PCUR:TIME:AVER %g", |
| 171 |
"""A floating point property that controls the integration time (in |
| 172 |
seconds) for average pulse measurements. Takes on values between |
| 173 |
33.33333e-06 and 0.8333. """, |
| 174 |
validator=truncated_range, |
| 175 |
values=[33.33333e-06, 0.8333], |
| 176 |
) |
| 177 |
|
| 178 |
pulse_current_time_digitize = Channel.control( |
| 179 |
":SENS{ch}:PCUR:TIME:DIG?", ":SENS{ch}:PCUR:TIME:DIG %g", |
| 180 |
"""A floating point property that controls the integration time (in |
| 181 |
seconds) for digitizing or burst pulse measurements. Takes on values |
| 182 |
between 33.33333e-06 and 0.8333. """, |
| 183 |
validator=truncated_range, |
| 184 |
values=[33.33333e-06, 0.8333], |
| 185 |
) |
| 186 |
|
| 187 |
pulse_current_fast_enabled = Channel.control( |
| 188 |
":SENS{ch}:PCUR:FAST?", ":SENS{ch}:PCUR:FAST %d", |
| 189 |
"""A boolean property that controls whether pulse current fast readings |
| 190 |
are enabled. """, |
| 191 |
validator=strict_discrete_set, |
| 192 |
values={True: 1, False: 0}, |
| 193 |
map_values=True |
| 194 |
) |
| 195 |
|
| 196 |
pulse_current_search_enabled = Channel.control( |
| 197 |
":SENS{ch}:PCUR:SEAR?", ":SENS{ch}:PCUR:SEAR %d", |
| 198 |
"""A boolean property that controls whether pulse current search |
| 199 |
is enabled. """, |
| 200 |
validator=strict_discrete_set, |
| 201 |
values={True: 1, False: 0}, |
| 202 |
map_values=True |
| 203 |
) |
| 204 |
|
| 205 |
pulse_current_detect_enabled = Channel.control( |
| 206 |
":SENS{ch}:PCUR:DET?", ":SENS{ch}:PCUR:DET %d", |
| 207 |
"""A boolean property that controls whether pulse current detection |
| 208 |
mode is enabled. """, |
| 209 |
validator=strict_discrete_set, |
| 210 |
values={True: 1, False: 0}, |
| 211 |
map_values=True |
| 212 |
) |
| 213 |
|
| 214 |
pulse_current_timeout = Channel.control( |
| 215 |
":SENS{ch}:PCUR:TOUT?", ":SENS{ch}:PCUR:TOUT %g", |
| 216 |
"""A floating point property that controls the pulse current timeout |
| 217 |
in seconds, which takes on values between 0.005 and 32. """, |
| 218 |
validator=truncated_range, |
| 219 |
values=[0.005, 32], |
| 220 |
) |
| 221 |
|
| 222 |
long_integration_trigger_edge = Channel.control( |
| 223 |
":SENS{ch}:LINT:TEDG?", ":SENS{ch}:LINT:TEDG %s", |
| 224 |
"""A string property that controls the long integration trigger edge, |
| 225 |
which can take the values 'rising', 'falling', or 'neither'. """, |
| 226 |
validator=strict_discrete_set, |
| 227 |
values={'rising': 'RISING', 'falling': 'FALLING', 'neither': 'NEITHER'}, |
| 228 |
map_values=True, |
| 229 |
) |
| 230 |
|
| 231 |
long_integration_time = Channel.control( |
| 232 |
":SENS{ch}:LINT:TIME?", ":SENS{ch}:LINT:TIME %g", |
| 233 |
"""A floating point property that controls the long integration time |
| 234 |
in seconds, which takes on values in the range of 0.850 for 60 Hz and |
| 235 |
0.840 for 50 Hz up to 60. """, |
| 236 |
validator=truncated_range, |
| 237 |
values=[0.840, 60], |
| 238 |
) |
| 239 |
|
| 240 |
def long_integration_time_auto(self): |
| 241 |
"""Arranges for the instrument to control integration times. """ |
| 242 |
self.write(":SENS{ch}:LINT:TIME:AUTO") |
| 243 |
|
| 244 |
long_integration_trigger_level = Channel.control( |
| 245 |
":SENS{ch}:LINT:TLEV?", ":SENS{ch}:LINT:TLEV %g", |
| 246 |
"""A floating point property that controls the long integration trigger |
| 247 |
level in amps, which takes values between 0 and 5. """, |
| 248 |
validator=truncated_range, |
| 249 |
values=[0, 5], |
| 250 |
) |
| 251 |
|
| 252 |
long_integration_timeout = Channel.control( |
| 253 |
":SENS{ch}:LINT:TOUT?", ":SENS{ch}:LINT:TOUT %g", |
| 254 |
"""A floating point property that controls the long integration timeout |
| 255 |
in seconds, which takes values between 1 and 63. """, |
| 256 |
validator=truncated_range, |
| 257 |
values=[1, 63], |
| 258 |
) |
| 259 |
|
| 260 |
long_integration_fast_enabled = Channel.control( |
| 261 |
":SENS{ch}:LINT:FAST?", ":SENS{ch}:LINT:FAST %d", |
| 262 |
"""A boolean property that controls whether long integration fast |
| 263 |
readings are enabled. """, |
| 264 |
validator=strict_discrete_set, |
| 265 |
values={True: 1, False: 0}, |
| 266 |
map_values=True |
| 267 |
) |
| 268 |
|
| 269 |
long_integration_search_enabled = Channel.control( |
| 270 |
":SENS{ch}:LINT:SEAR?", ":SENS{ch}:LINT:SEAR %d", |
| 271 |
"""A boolean property that controls whether long integration search |
| 272 |
is enabled. """, |
| 273 |
validator=strict_discrete_set, |
| 274 |
values={True: 1, False: 0}, |
| 275 |
map_values=True |
| 276 |
) |
| 277 |
|
| 278 |
long_integration_detect_enabled = Channel.control( |
| 279 |
":SENS{ch}:LINT:DET?", ":SENS{ch}:LINT:DET %d", |
| 280 |
"""A boolean property that controls whether long integration detection |
| 281 |
mode is enabled. """, |
| 282 |
validator=strict_discrete_set, |
| 283 |
values={True: 1, False: 0}, |
| 284 |
map_values=True |
| 285 |
) |
| 286 |
|
| 287 |
source_voltage = Channel.control( |
| 288 |
":SOUR{ch}:VOLT?", ":SOUR{ch}:VOLT %g", |
| 289 |
"""A floating point property that controls the source voltage in volts, |
| 290 |
which takes values between 0 and 15. """, |
| 291 |
validator=truncated_range, |
| 292 |
values=[0, 15], |
| 293 |
) |
| 294 |
|
| 295 |
source_voltage_protection = Channel.control( |
| 296 |
":SOUR{ch}:VOLT:PROT?", ":SOUR{ch}:VOLT:PROT %g", |
| 297 |
"""A floating point property that controls the source voltage protection |
| 298 |
offset in volts, which takes values between 0 and 8. """, |
| 299 |
validator=truncated_range, |
| 300 |
values=[0, 8], |
| 301 |
) |
| 302 |
|
| 303 |
source_voltage_protection_enabled = Channel.measurement( |
| 304 |
":SOUR{ch}:VOLT:PROT:STAT?", |
| 305 |
"""A boolean property that returns the source voltage protection state. |
| 306 |
If this property is True, the source has been shut off in accordance |
| 307 |
with the source voltage protection settings. If this property is False, |
| 308 |
the source has not been shut off due to voltage protection. """, |
| 309 |
cast=bool |
| 310 |
) |
| 311 |
|
| 312 |
source_voltage_protection_clamp_enabled = Channel.control( |
| 313 |
":SOUR{ch}:VOLT:PROT:CLAM?", ":SOUR{ch}:VOLT:PROT:CLAM %d", |
| 314 |
"""A boolean property that controls whether source voltage protection |
| 315 |
clamp is enabled. """, |
| 316 |
validator=strict_discrete_set, |
| 317 |
values={True: 1, False: 0}, |
| 318 |
map_values=True |
| 319 |
) |
| 320 |
|
| 321 |
source_current_limit = Channel.control( |
| 322 |
":SOUR{ch}:CURR?", ":SOUR{ch}:CURR %g", |
| 323 |
"""A floating point property that controls the source current limit in |
| 324 |
amps, which takes values between 0.006 and 5. """, |
| 325 |
validator=truncated_range, |
| 326 |
values=[0.006, 5], |
| 327 |
) |
| 328 |
|
| 329 |
source_current_limit_type = Channel.control( |
| 330 |
":SOUR{ch}:CURR:TYPE?", ":SOUR{ch}:CURR:TYPE %s", |
| 331 |
"""A string property that controls source current limit type, which can |
| 332 |
take the values 'limit' or 'trip'. """, |
| 333 |
validator=strict_discrete_set, |
| 334 |
values={'limit': 'LIM', 'trip': 'TRIP'}, |
| 335 |
map_values=True, |
| 336 |
) |
| 337 |
|
| 338 |
source_current_limit_enabled = Channel.measurement( |
| 339 |
":SOUR{ch}:CURR:STAT?", |
| 340 |
"""A boolean property that returns the source current limit state. If |
| 341 |
this property is True, the source is in either in current limit mode, |
| 342 |
or has tripped (shut off), based on the `source_current_limit_type` |
| 343 |
setting. If this property is False, the source is not being limited and |
| 344 |
has not been tripped. """, |
| 345 |
cast=bool |
| 346 |
) |
| 347 |
|
| 348 |
last_reading = Channel.measurement( |
| 349 |
":FETCH{ch}?", |
| 350 |
"""A floating point property that returns the last reading. """ |
| 351 |
) |
| 352 |
|
| 353 |
last_readings = Channel.measurement( |
| 354 |
":FETCH{ch}:ARR?", |
| 355 |
"""A floating point array property that returns the last readings. """, |
| 356 |
get_process=lambda v: v if isinstance(v, list) else [v] |
| 357 |
) |
| 358 |
|
| 359 |
reading = Channel.measurement( |
| 360 |
":READ{ch}?", |
| 361 |
"""A floating point property that triggers and returns a reading |
| 362 |
in accordance with sense_mode. """ |
| 363 |
) |
| 364 |
|
| 365 |
readings = Channel.measurement( |
| 366 |
":READ{ch}:ARR?", |
| 367 |
"""A floating point array property that triggers and returns readings |
| 368 |
in accordance with sense_mode. """, |
| 369 |
get_process=lambda v: v if isinstance(v, list) else [v] |
| 370 |
) |
| 371 |
|
| 372 |
measured_voltage = Channel.measurement( |
| 373 |
":MEAS{ch}:VOLT?", |
| 374 |
"""A floating point property that triggers and returns a voltage |
| 375 |
reading. """ |
| 376 |
) |
| 377 |
|
| 378 |
measured_voltages = Channel.measurement( |
| 379 |
":MEAS{ch}:ARR:VOLT?", |
| 380 |
"""A floating point array property that triggers and returns |
| 381 |
voltage readings. """, |
| 382 |
get_process=lambda v: v if isinstance(v, list) else [v] |
| 383 |
) |
| 384 |
|
| 385 |
measured_current = Channel.measurement( |
| 386 |
":MEAS{ch}:CURR?", |
| 387 |
"""A floating point property that triggers and returns a current |
| 388 |
reading. """ |
| 389 |
) |
| 390 |
|
| 391 |
measured_currents = Channel.measurement( |
| 392 |
":MEAS{ch}:ARR:CURR?", |
| 393 |
"""A floating point array property that triggers and returns |
| 394 |
current readings. """, |
| 395 |
get_process=lambda v: v if isinstance(v, list) else [v] |
| 396 |
) |
| 397 |
|
| 398 |
dvm_voltage = Channel.measurement( |
| 399 |
":MEAS{ch}:DVM?", |
| 400 |
"""A floating point property that triggers and returns a DVM voltage |
| 401 |
reading. """ |
| 402 |
) |
| 403 |
|
| 404 |
dvm_voltages = Channel.measurement( |
| 405 |
":MEAS{ch}:ARR:DVM?", |
| 406 |
"""A floating point array property that triggers and returns |
| 407 |
DVM voltage readings. """, |
| 408 |
get_process=lambda v: v if isinstance(v, list) else [v] |
| 409 |
) |
| 410 |
|
| 411 |
pulse_current = Channel.measurement( |
| 412 |
":MEAS{ch}:PCUR?", |
| 413 |
"""A floating point property that returns a pulse current reading. """ |
| 414 |
) |
| 415 |
|
| 416 |
pulse_currents = Channel.measurement( |
| 417 |
":MEAS{ch}:ARR:PCUR?", |
| 418 |
"""A floating point array property that triggers and returns |
| 419 |
pulse current readings. """, |
| 420 |
get_process=lambda v: v if isinstance(v, list) else [v] |
| 421 |
) |
| 422 |
|
| 423 |
long_integration_current = Channel.measurement( |
| 424 |
":MEAS{ch}:LINT?", |
| 425 |
"""A floating point property that returns a long integration current |
| 426 |
reading. """ |
| 427 |
) |
| 428 |
|
| 429 |
long_integration_currents = Channel.measurement( |
| 430 |
":MEAS{ch}:ARR:LINT?", |
| 431 |
"""A floating point array property that triggers and returns |
| 432 |
long integration current readings. """, |
| 433 |
get_process=lambda v: v if isinstance(v, list) else [v] |
| 434 |
) |
| 435 |
|
| 436 |
|
| 437 |
class BatteryChannel(Keithley2306Channel): |
| 438 |
""" Implementation of a Keithley 2306 battery channel. """ |
| 439 |
|
| 440 |
impedance = Keithley2306Channel.control( |
| 441 |
":OUTPUT{ch}:IMP?", ":OUTPUT{ch}:IMP %g", |
| 442 |
"""A floating point property that controls the output impedance in ohms. |
| 443 |
Takes values from 0 to 1, in 10 milliohm steps.""", |
| 444 |
validator=truncated_range, |
| 445 |
values=[0, 1], |
| 446 |
) |
| 447 |
|
| 448 |
pulse_current_step_enabled = Keithley2306Channel.control( |
| 449 |
":SENS{ch}:PCUR:STEP?", ":SENS{ch}:PCUR:STEP %d", |
| 450 |
"""A boolean property that controls whether a series of pulse current |
| 451 |
step measurements is enabled.""", |
| 452 |
validator=strict_discrete_set, |
| 453 |
values={True: 1, False: 0}, |
| 454 |
map_values=True |
| 455 |
) |
| 456 |
|
| 457 |
pulse_current_step_up_count = Keithley2306Channel.control( |
| 458 |
":SENS{ch}:PCUR:STEP:UP?", ":SENS{ch}:PCUR:STEP:UP %d", |
| 459 |
"""An integer property that controls the number of up steps. Takes |
| 460 |
values from 0 to 20 (max is both up and down combined). """, |
| 461 |
validator=truncated_range, |
| 462 |
values=[0, 20], |
| 463 |
) |
| 464 |
|
| 465 |
pulse_current_step_down_count = Keithley2306Channel.control( |
| 466 |
":SENS{ch}:PCUR:STEP:DOWN?", ":SENS{ch}:PCUR:STEP:DOWN %d", |
| 467 |
"""An integer property that controls the number of down steps. Takes |
| 468 |
values from 0 to 20 (max is both up and down combined). """, |
| 469 |
validator=truncated_range, |
| 470 |
values=[0, 20], |
| 471 |
) |
| 472 |
|
| 473 |
pulse_current_step_time = Keithley2306Channel.control( |
| 474 |
":SENS{ch}:PCUR:STEP:TIME?", ":SENS{ch}:PCUR:STEP:TIME %g", |
| 475 |
"""A floating point property that controls the integration time for up |
| 476 |
plus down steps in seconds. Takes values from 33.33333e-06 to 100e-3. """, |
| 477 |
validator=truncated_range, |
| 478 |
values=[33.33333e-06, 100e-3], |
| 479 |
) |
| 480 |
|
| 481 |
pulse_current_step_timeout = Keithley2306Channel.control( |
| 482 |
":SENS{ch}:PCUR:STEP:TOUT?", ":SENS{ch}:PCUR:STEP:TOUT %g", |
| 483 |
"""A floating point property that controls the integration timeout for |
| 484 |
pulse current steps in seconds (for all but the first step). Takes values |
| 485 |
from 2e-3 to 200e-3. """, |
| 486 |
validator=truncated_range, |
| 487 |
values=[2e-3, 200e-3], |
| 488 |
) |
| 489 |
|
| 490 |
pulse_current_step_timeout_initial = Keithley2306Channel.control( |
| 491 |
":SENS{ch}:PCUR:STEP:TOUT:INIT?", ":SENS{ch}:PCUR:STEP:TOUT:INIT %g", |
| 492 |
"""A floating point property that controls the integration timeout for |
| 493 |
the initial pulse current step in seconds. Takes values from 10e-3 |
| 494 |
to 60. """, |
| 495 |
validator=truncated_range, |
| 496 |
values=[10e-3, 60], |
| 497 |
) |
| 498 |
|
| 499 |
pulse_current_step_delay = Keithley2306Channel.control( |
| 500 |
":SENS{ch}:PCUR:STEP:DEL?", ":SENS{ch}:PCUR:STEP:DEL %g", |
| 501 |
"""A floating point property that controls the pulse current step delay |
| 502 |
in seconds. Takes values from 0 to 100e-3 in 10e-6 increments. """, |
| 503 |
validator=truncated_range, |
| 504 |
values=[0, 100e-3], |
| 505 |
) |
| 506 |
|
| 507 |
pulse_current_step_range = Keithley2306Channel.control( |
| 508 |
":SENS{ch}:PCUR:STEP:RANG?", ":SENS{ch}:PCUR:STEP:RANG %g", |
| 509 |
"""A floating point property that controls the pulse current step trigger |
| 510 |
level range in amps. Takes values of 100e-3, 1, or 5. """, |
| 511 |
validator=strict_discrete_set, |
| 512 |
values=[100e-3, 1, 5], |
| 513 |
) |
| 514 |
|
| 515 |
pulse_current_trigger_level_range = Keithley2306Channel.control( |
| 516 |
":SENS{ch}:PCUR:SYNC:TLEV:RANG?", ":SENS{ch}:PCUR:SYNC:TLEV:RANG %g", |
| 517 |
"""A floating point property that controls the pulse current trigger |
| 518 |
level range in amps. Takes values of 100e-3, 1, or 5. """, |
| 519 |
validator=strict_discrete_set, |
| 520 |
values=[100e-3, 1, 5], |
| 521 |
) |
| 522 |
|
| 523 |
long_integration_trigger_level_range = Keithley2306Channel.control( |
| 524 |
":SENS{ch}:LINT:TLEV:RANG?", ":SENS{ch}:LINT:TLEV:RANG %g", |
| 525 |
"""A floating point property that controls the long integration trigger |
| 526 |
level range in amps. Takes values of 100e-3, 1, or 5. """, |
| 527 |
validator=strict_discrete_set, |
| 528 |
values=[100e-3, 1, 5], |
| 529 |
) |
| 530 |
|
| 531 |
def pulse_current_step(self, step_number): |
| 532 |
"""Create a new current step point for this instrument. |
| 533 |
|
| 534 |
:param: step_number: |
| 535 |
int: the number of the step to be created |
| 536 |
:type: :class:`.Step` |
| 537 |
|
| 538 |
""" |
| 539 |
return Step(self.parent, step_number) |
| 540 |
|
| 541 |
|
| 542 |
class Step(Channel): |
| 543 |
""" Implementation of a Keithley 2306 step. """ |
| 544 |
placeholder = 'step' |
| 545 |
trigger_level = Channel.control( |
| 546 |
":SENS:PCUR:STEP:TLEV{step}?", ":SENS:PCUR:STEP:TLEV{step} %g", |
| 547 |
"""A floating point property that controls the pulse current step trigger |
| 548 |
level range in amps. Takes values from 0 up to the range set via |
| 549 |
pulse_current_step_range.""", |
| 550 |
validator=truncated_range, |
| 551 |
values=[0, 5], |
| 552 |
) |
| 553 |
|
| 554 |
def __init__(self, instrument, number, **kwargs): |
| 555 |
super().__init__(instrument, number, **kwargs) |
| 556 |
|
| 557 |
|
| 558 |
class Relay(Channel): |
| 559 |
""" Implementation of a Keithley 2306 relay. """ |
| 560 |
|
| 561 |
closed = Channel.control( |
| 562 |
":OUTP:REL{ch}?", ":OUTP:REL{ch} %s", |
| 563 |
"""A boolean property that controls whether the relay is closed (True) |
| 564 |
or open (False). """, |
| 565 |
validator=strict_discrete_set, |
| 566 |
values={True: 'ONE', False: 'ZERO'}, |
| 567 |
map_values=True |
| 568 |
) |
| 569 |
|
| 570 |
|
| 571 |
class Keithley2306(SCPIUnknownMixin, Instrument): |
| 572 |
""" Represents the Keithley 2306 Dual Channel Battery/Charger Simulator. |
| 573 |
""" |
| 574 |
|
| 575 |
def __init__(self, adapter, name="Keithley 2306", **kwargs): |
| 576 |
super().__init__( |
| 577 |
adapter, |
| 578 |
name, |
| 579 |
**kwargs |
| 580 |
) |
| 581 |
self.ch1 = BatteryChannel(self, 1) |
| 582 |
self.ch2 = Keithley2306Channel(self, 2) |
| 583 |
self.relay1 = Relay(self, 1) |
| 584 |
self.relay2 = Relay(self, 2) |
| 585 |
self.relay3 = Relay(self, 3) |
| 586 |
self.relay4 = Relay(self, 4) |
| 587 |
|
| 588 |
display_enabled = Instrument.control( |
| 589 |
":DISP:ENAB?", ":DISP:ENAB %d", |
| 590 |
"""A boolean property that controls whether the display is enabled, |
| 591 |
takes values True or False. """, |
| 592 |
validator=strict_discrete_set, |
| 593 |
values={True: 1, False: 0}, |
| 594 |
map_values=True |
| 595 |
) |
| 596 |
|
| 597 |
display_brightness = Instrument.control( |
| 598 |
":DISP:BRIG?", ":DISP:BRIG %g", |
| 599 |
"""A floating point property that controls the display brightness, |
| 600 |
takes values beteween 0.0 and 1.0. A blank display is 0.0, |
| 601 |
1/4 brightness is for values less or equal to 0.25, otherwise 1/2 |
| 602 |
brightness for values less than or equal to 0.5, otherwise 3/4 |
| 603 |
brightness for values less than or equal to 0.75, otherwise full |
| 604 |
brightness. """, |
| 605 |
validator=truncated_range, |
| 606 |
values=[0, 1], |
| 607 |
) |
| 608 |
|
| 609 |
display_channel = Instrument.control( |
| 610 |
":DISP:CHAN?", ":DISP:CHAN %d", |
| 611 |
"""An integer property that controls the display channel, takes |
| 612 |
values 1 or 2. """, |
| 613 |
validator=strict_discrete_set, |
| 614 |
values=[1, 2], |
| 615 |
) |
| 616 |
|
| 617 |
display_text_data = Instrument.control( |
| 618 |
":DISP:TEXT:DATA?", ":DISP:TEXT:DATA \"%s\"", |
| 619 |
"""A string property that control text to be displayed, takes strings |
| 620 |
up to 32 characters. """, |
| 621 |
get_process=lambda v: v.replace('"', '') |
| 622 |
) |
| 623 |
|
| 624 |
display_text_enabled = Instrument.control( |
| 625 |
":DISP:TEXT:STAT?", ":DISP:TEXT:STAT %d", |
| 626 |
"""A boolean property that controls whether display text is enabled, |
| 627 |
takes values True or False. """, |
| 628 |
validator=strict_discrete_set, |
| 629 |
values={True: 1, False: 0}, |
| 630 |
map_values=True, |
| 631 |
) |
| 632 |
|
| 633 |
both_channels_enabled = Instrument.setting( |
| 634 |
":BOTHOUT%s", |
| 635 |
"""A boolean setting that controls whether both channel outputs are |
| 636 |
enabled, takes values of True or False. """, |
| 637 |
validator=strict_discrete_set, |
| 638 |
values={True: "ON", False: "OFF"}, |
| 639 |
map_values=True, |
| 640 |
) |
| 641 |
|
| 642 |
def ch(self, channel_number): |
| 643 |
"""Get a channel from this instrument. |
| 644 |
|
| 645 |
:param: channel_number: |
| 646 |
int: the number of the channel to be selected |
| 647 |
:type: :class:`.Keithley2306Channel` |
| 648 |
|
| 649 |
""" |
| 650 |
if channel_number == 1: |
| 651 |
return self.ch1 |
| 652 |
elif channel_number == 2: |
| 653 |
return self.ch2 |
| 654 |
else: |
| 655 |
raise ValueError("Invalid channel number. Must be 1 or 2.") |
| 656 |
|
| 657 |
def relay(self, relay_number): |
| 658 |
"""Get a relay channel from this instrument. |
| 659 |
|
| 660 |
:param: relay_number: |
| 661 |
int: the number of the relay to be selected |
| 662 |
:type: :class:`~Relay` |
| 663 |
|
| 664 |
""" |
| 665 |
if relay_number == 1: |
| 666 |
return self.relay1 |
| 667 |
elif relay_number == 2: |
| 668 |
return self.relay2 |
| 669 |
elif relay_number == 3: |
| 670 |
return self.relay3 |
| 671 |
elif relay_number == 4: |
| 672 |
return self.relay4 |
| 673 |
else: |
| 674 |
raise ValueError("Invalid relay number. Must be 1, 2, 3, or 4") |