| 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 |
|
| 27 |
from pymeasure.instruments import Instrument, SCPIUnknownMixin |
| 28 |
from pymeasure.instruments.validators import ( |
| 29 |
truncated_range, truncated_discrete_set, |
| 30 |
strict_discrete_set |
| 31 |
) |
| 32 |
from .buffer import KeithleyBuffer |
| 33 |
|
| 34 |
log = logging.getLogger(__name__) |
| 35 |
log.addHandler(logging.NullHandler()) |
| 36 |
|
| 37 |
|
| 38 |
class Keithley2000(KeithleyBuffer, SCPIUnknownMixin, Instrument): |
| 39 |
""" Represents the Keithley 2000 Multimeter and provides a high-level |
| 40 |
interface for interacting with the instrument. |
| 41 |
|
| 42 |
.. code-block:: python |
| 43 |
|
| 44 |
meter = Keithley2000("GPIB::1") |
| 45 |
meter.measure_voltage() |
| 46 |
print(meter.voltage) |
| 47 |
|
| 48 |
""" |
| 49 |
MODES = { |
| 50 |
'current': 'CURR:DC', 'current ac': 'CURR:AC', |
| 51 |
'voltage': 'VOLT:DC', 'voltage ac': 'VOLT:AC', |
| 52 |
'resistance': 'RES', 'resistance 4W': 'FRES', |
| 53 |
'period': 'PER', 'frequency': 'FREQ', |
| 54 |
'temperature': 'TEMP', 'diode': 'DIOD', |
| 55 |
'continuity': 'CONT' |
| 56 |
} |
| 57 |
|
| 58 |
mode = Instrument.control( |
| 59 |
":CONF?", ":CONF:%s", |
| 60 |
""" A string property that controls the configuration mode for measurements, |
| 61 |
which can take the values: ``current`` (DC), ``current ac``, |
| 62 |
``voltage`` (DC), ``voltage ac``, ``resistance`` (2-wire), |
| 63 |
``resistance 4W`` (4-wire), ``period``, |
| 64 |
``temperature``, ``diode``, and ``frequency``.""", |
| 65 |
validator=strict_discrete_set, |
| 66 |
values=MODES, |
| 67 |
map_values=True, |
| 68 |
get_process=lambda v: v.replace('"', '') |
| 69 |
) |
| 70 |
|
| 71 |
beep_state = Instrument.control( |
| 72 |
":SYST:BEEP:STAT?", |
| 73 |
":SYST:BEEP:STAT %g", |
| 74 |
""" A string property that enables or disables the system status beeper, |
| 75 |
which can take the values: ``enabled`` and ``disabled``. """, |
| 76 |
validator=strict_discrete_set, |
| 77 |
values={'enabled': 1, 'disabled': 0}, |
| 78 |
map_values=True |
| 79 |
) |
| 80 |
|
| 81 |
############### |
| 82 |
# Current (A) # |
| 83 |
############### |
| 84 |
|
| 85 |
current = Instrument.measurement( |
| 86 |
":READ?", |
| 87 |
""" Reads a DC or AC current measurement in Amps, based on the |
| 88 |
active :attr:`~.Keithley2000.mode`. """ |
| 89 |
) |
| 90 |
current_range = Instrument.control( |
| 91 |
":SENS:CURR:RANG?", ":SENS:CURR:RANG:AUTO 0;:SENS:CURR:RANG %g", |
| 92 |
""" A floating point property that controls the DC current range in |
| 93 |
Amps, which can take values from 0 to 3.1 A. |
| 94 |
Auto-range is disabled when this property is set. """, |
| 95 |
validator=truncated_range, |
| 96 |
values=[0, 3.1] |
| 97 |
) |
| 98 |
current_reference = Instrument.control( |
| 99 |
":SENS:CURR:REF?", ":SENS:CURR:REF %g", |
| 100 |
""" A floating point property that controls the DC current reference |
| 101 |
value in Amps, which can take values from -3.1 to 3.1 A. """, |
| 102 |
validator=truncated_range, |
| 103 |
values=[-3.1, 3.1] |
| 104 |
) |
| 105 |
current_nplc = Instrument.control( |
| 106 |
":SENS:CURR:NPLC?", ":SENS:CURR:NPLC %g", |
| 107 |
""" A floating point property that controls the number of power line cycles |
| 108 |
(NPLC) for the DC current measurements, which sets the integration period |
| 109 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 110 |
Fast, Medium, and Slow respectively. """ |
| 111 |
) |
| 112 |
current_digits = Instrument.control( |
| 113 |
":SENS:CURR:DIG?", ":SENS:CURR:DIG %d", |
| 114 |
""" An integer property that controls the number of digits in the DC current |
| 115 |
readings, which can take values from 4 to 7. """, |
| 116 |
validator=truncated_discrete_set, |
| 117 |
values=[4, 5, 6, 7], |
| 118 |
cast=int, |
| 119 |
) |
| 120 |
current_ac_range = Instrument.control( |
| 121 |
":SENS:CURR:AC:RANG?", ":SENS:CURR:AC:RANG:AUTO 0;:SENS:CURR:AC:RANG %g", |
| 122 |
""" A floating point property that controls the AC current range in |
| 123 |
Amps, which can take values from 0 to 3.1 A. |
| 124 |
Auto-range is disabled when this property is set. """, |
| 125 |
validator=truncated_range, |
| 126 |
values=[0, 3.1] |
| 127 |
) |
| 128 |
current_ac_reference = Instrument.control( |
| 129 |
":SENS:CURR:AC:REF?", ":SENS:CURR:AC:REF %g", |
| 130 |
""" A floating point property that controls the AC current reference |
| 131 |
value in Amps, which can take values from -3.1 to 3.1 A. """, |
| 132 |
validator=truncated_range, |
| 133 |
values=[-3.1, 3.1] |
| 134 |
) |
| 135 |
current_ac_nplc = Instrument.control( |
| 136 |
":SENS:CURR:AC:NPLC?", ":SENS:CURR:AC:NPLC %g", |
| 137 |
""" A floating point property that controls the number of power line cycles |
| 138 |
(NPLC) for the AC current measurements, which sets the integration period |
| 139 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 140 |
Fast, Medium, and Slow respectively. """ |
| 141 |
) |
| 142 |
current_ac_digits = Instrument.control( |
| 143 |
":SENS:CURR:AC:DIG?", ":SENS:CURR:AC:DIG %d", |
| 144 |
""" An integer property that controls the number of digits in the AC current |
| 145 |
readings, which can take values from 4 to 7. """, |
| 146 |
validator=truncated_discrete_set, |
| 147 |
values=[4, 5, 6, 7], |
| 148 |
cast=int |
| 149 |
) |
| 150 |
current_ac_bandwidth = Instrument.control( |
| 151 |
":SENS:CURR:AC:DET:BAND?", ":SENS:CURR:AC:DET:BAND %g", |
| 152 |
""" A floating point property that sets the AC current detector |
| 153 |
bandwidth in Hz, which can take the values 3, 30, and 300 Hz. """, |
| 154 |
validator=truncated_discrete_set, |
| 155 |
values=[3, 30, 300] |
| 156 |
) |
| 157 |
|
| 158 |
############### |
| 159 |
# Voltage (V) # |
| 160 |
############### |
| 161 |
|
| 162 |
voltage = Instrument.measurement( |
| 163 |
":READ?", |
| 164 |
""" Reads a DC or AC voltage measurement in Volts, based on the |
| 165 |
active :attr:`~.Keithley2000.mode`. """ |
| 166 |
) |
| 167 |
voltage_range = Instrument.control( |
| 168 |
":SENS:VOLT:RANG?", ":SENS:VOLT:RANG:AUTO 0;:SENS:VOLT:RANG %g", |
| 169 |
""" A floating point property that controls the DC voltage range in |
| 170 |
Volts, which can take values from 0 to 1010 V. |
| 171 |
Auto-range is disabled when this property is set. """, |
| 172 |
validator=truncated_range, |
| 173 |
values=[0, 1010] |
| 174 |
) |
| 175 |
voltage_reference = Instrument.control( |
| 176 |
":SENS:VOLT:REF?", ":SENS:VOLT:REF %g", |
| 177 |
""" A floating point property that controls the DC voltage reference |
| 178 |
value in Volts, which can take values from -1010 to 1010 V. """, |
| 179 |
validator=truncated_range, |
| 180 |
values=[-1010, 1010] |
| 181 |
) |
| 182 |
voltage_nplc = Instrument.control( |
| 183 |
":SENS:CURRVOLT:NPLC?", ":SENS:VOLT:NPLC %g", |
| 184 |
""" A floating point property that controls the number of power line cycles |
| 185 |
(NPLC) for the DC voltage measurements, which sets the integration period |
| 186 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 187 |
Fast, Medium, and Slow respectively. """ |
| 188 |
) |
| 189 |
voltage_digits = Instrument.control( |
| 190 |
":SENS:VOLT:DIG?", ":SENS:VOLT:DIG %d", |
| 191 |
""" An integer property that controls the number of digits in the DC voltage |
| 192 |
readings, which can take values from 4 to 7. """, |
| 193 |
validator=truncated_discrete_set, |
| 194 |
values=[4, 5, 6, 7], |
| 195 |
cast=int |
| 196 |
) |
| 197 |
voltage_ac_range = Instrument.control( |
| 198 |
":SENS:VOLT:AC:RANG?", ":SENS:VOLT:RANG:AUTO 0;:SENS:VOLT:AC:RANG %g", |
| 199 |
""" A floating point property that controls the AC voltage range in |
| 200 |
Volts, which can take values from 0 to 757.5 V. |
| 201 |
Auto-range is disabled when this property is set. """, |
| 202 |
validator=truncated_range, |
| 203 |
values=[0, 757.5] |
| 204 |
) |
| 205 |
voltage_ac_reference = Instrument.control( |
| 206 |
":SENS:VOLT:AC:REF?", ":SENS:VOLT:AC:REF %g", |
| 207 |
""" A floating point property that controls the AC voltage reference |
| 208 |
value in Volts, which can take values from -757.5 to 757.5 Volts. """, |
| 209 |
validator=truncated_range, |
| 210 |
values=[-757.5, 757.5] |
| 211 |
) |
| 212 |
voltage_ac_nplc = Instrument.control( |
| 213 |
":SENS:VOLT:AC:NPLC?", ":SENS:VOLT:AC:NPLC %g", |
| 214 |
""" A floating point property that controls the number of power line cycles |
| 215 |
(NPLC) for the AC voltage measurements, which sets the integration period |
| 216 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 217 |
Fast, Medium, and Slow respectively. """ |
| 218 |
) |
| 219 |
voltage_ac_digits = Instrument.control( |
| 220 |
":SENS:VOLT:AC:DIG?", ":SENS:VOLT:AC:DIG %d", |
| 221 |
""" An integer property that controls the number of digits in the AC voltage |
| 222 |
readings, which can take values from 4 to 7. """, |
| 223 |
validator=truncated_discrete_set, |
| 224 |
values=[4, 5, 6, 7], |
| 225 |
cast=int |
| 226 |
) |
| 227 |
voltage_ac_bandwidth = Instrument.control( |
| 228 |
":SENS:VOLT:AC:DET:BAND?", ":SENS:VOLT:AC:DET:BAND %g", |
| 229 |
""" A floating point property that sets the AC voltage detector |
| 230 |
bandwidth in Hz, which can take the values 3, 30, and 300 Hz. """, |
| 231 |
validator=truncated_discrete_set, |
| 232 |
values=[3, 30, 300] |
| 233 |
) |
| 234 |
|
| 235 |
#################### |
| 236 |
# Resistance (Ohm) # |
| 237 |
#################### |
| 238 |
|
| 239 |
resistance = Instrument.measurement( |
| 240 |
":READ?", |
| 241 |
""" Reads a resistance measurement in Ohms for both 2-wire and 4-wire |
| 242 |
configurations, based on the active :attr:`~.Keithley2000.mode`. """ |
| 243 |
) |
| 244 |
resistance_range = Instrument.control( |
| 245 |
":SENS:RES:RANG?", ":SENS:RES:RANG:AUTO 0;:SENS:RES:RANG %g", |
| 246 |
""" A floating point property that controls the 2-wire resistance range |
| 247 |
in Ohms, which can take values from 0 to 120 MOhms. |
| 248 |
Auto-range is disabled when this property is set. """, |
| 249 |
validator=truncated_range, |
| 250 |
values=[0, 120e6] |
| 251 |
) |
| 252 |
resistance_reference = Instrument.control( |
| 253 |
":SENS:RES:REF?", ":SENS:RES:REF %g", |
| 254 |
""" A floating point property that controls the 2-wire resistance |
| 255 |
reference value in Ohms, which can take values from 0 to 120 MOhms. """, |
| 256 |
validator=truncated_range, |
| 257 |
values=[0, 120e6] |
| 258 |
) |
| 259 |
resistance_nplc = Instrument.control( |
| 260 |
":SENS:RES:NPLC?", ":SENS:RES:NPLC %g", |
| 261 |
""" A floating point property that controls the number of power line cycles |
| 262 |
(NPLC) for the 2-wire resistance measurements, which sets the integration period |
| 263 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 264 |
Fast, Medium, and Slow respectively. """ |
| 265 |
) |
| 266 |
resistance_digits = Instrument.control( |
| 267 |
":SENS:RES:DIG?", ":SENS:RES:DIG %d", |
| 268 |
""" An integer property that controls the number of digits in the 2-wire |
| 269 |
resistance readings, which can take values from 4 to 7. """, |
| 270 |
validator=truncated_discrete_set, |
| 271 |
values=[4, 5, 6, 7], |
| 272 |
cast=int |
| 273 |
) |
| 274 |
resistance_4W_range = Instrument.control( |
| 275 |
":SENS:FRES:RANG?", ":SENS:FRES:RANG:AUTO 0;:SENS:FRES:RANG %g", |
| 276 |
""" A floating point property that controls the 4-wire resistance range |
| 277 |
in Ohms, which can take values from 0 to 120 MOhms. |
| 278 |
Auto-range is disabled when this property is set. """, |
| 279 |
validator=truncated_range, |
| 280 |
values=[0, 120e6] |
| 281 |
) |
| 282 |
resistance_4W_reference = Instrument.control( |
| 283 |
":SENS:FRES:REF?", ":SENS:FRES:REF %g", |
| 284 |
""" A floating point property that controls the 4-wire resistance |
| 285 |
reference value in Ohms, which can take values from 0 to 120 MOhms. """, |
| 286 |
validator=truncated_range, |
| 287 |
values=[0, 120e6] |
| 288 |
) |
| 289 |
resistance_4W_nplc = Instrument.control( |
| 290 |
":SENS:FRES:NPLC?", ":SENS:FRES:NPLC %g", |
| 291 |
""" A floating point property that controls the number of power line cycles |
| 292 |
(NPLC) for the 4-wire resistance measurements, which sets the integration period |
| 293 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 294 |
Fast, Medium, and Slow respectively. """ |
| 295 |
) |
| 296 |
resistance_4W_digits = Instrument.control( |
| 297 |
":SENS:FRES:DIG?", ":SENS:FRES:DIG %d", |
| 298 |
""" An integer property that controls the number of digits in the 4-wire |
| 299 |
resistance readings, which can take values from 4 to 7. """, |
| 300 |
validator=truncated_discrete_set, |
| 301 |
values=[4, 5, 6, 7], |
| 302 |
cast=int |
| 303 |
) |
| 304 |
|
| 305 |
################## |
| 306 |
# Frequency (Hz) # |
| 307 |
################## |
| 308 |
|
| 309 |
frequency = Instrument.measurement( |
| 310 |
":READ?", |
| 311 |
""" Reads a frequency measurement in Hz, based on the |
| 312 |
active :attr:`~.Keithley2000.mode`. """ |
| 313 |
) |
| 314 |
frequency_reference = Instrument.control( |
| 315 |
":SENS:FREQ:REF?", ":SENS:FREQ:REF %g", |
| 316 |
""" A floating point property that controls the frequency reference |
| 317 |
value in Hz, which can take values from 0 to 15 MHz. """, |
| 318 |
validator=truncated_range, |
| 319 |
values=[0, 15e6] |
| 320 |
) |
| 321 |
frequency_digits = Instrument.control( |
| 322 |
":SENS:FREQ:DIG?", ":SENS:FREQ:DIG %d", |
| 323 |
""" An integer property that controls the number of digits in the frequency |
| 324 |
readings, which can take values from 4 to 7. """, |
| 325 |
validator=truncated_discrete_set, |
| 326 |
values=[4, 5, 6, 7], |
| 327 |
cast=int |
| 328 |
) |
| 329 |
frequency_threshold = Instrument.control( |
| 330 |
":SENS:FREQ:THR:VOLT:RANG?", ":SENS:FREQ:THR:VOLT:RANG %g", |
| 331 |
""" A floating point property that controls the voltage signal threshold |
| 332 |
level in Volts for the frequency measurement, which can take values |
| 333 |
from 0 to 1010 V. """, |
| 334 |
validator=truncated_range, |
| 335 |
values=[0, 1010] |
| 336 |
) |
| 337 |
frequency_aperature = Instrument.control( |
| 338 |
":SENS:FREQ:APER?", ":SENS:FREQ:APER %g", |
| 339 |
""" A floating point property that controls the frequency aperature in seconds, |
| 340 |
which sets the integration period and measurement speed. Takes values |
| 341 |
from 0.01 to 1.0 s. """, |
| 342 |
validator=truncated_range, |
| 343 |
values=[0.01, 1.0] |
| 344 |
) |
| 345 |
|
| 346 |
############## |
| 347 |
# Period (s) # |
| 348 |
############## |
| 349 |
|
| 350 |
period = Instrument.measurement( |
| 351 |
":READ?", |
| 352 |
""" Reads a period measurement in seconds, based on the |
| 353 |
active :attr:`~.Keithley2000.mode`. """ |
| 354 |
) |
| 355 |
period_reference = Instrument.control( |
| 356 |
":SENS:PER:REF?", ":SENS:PER:REF %g", |
| 357 |
""" A floating point property that controls the period reference value |
| 358 |
in seconds, which can take values from 0 to 1 s. """, |
| 359 |
validator=truncated_range, |
| 360 |
values=[0, 1] |
| 361 |
) |
| 362 |
period_digits = Instrument.control( |
| 363 |
":SENS:PER:DIG?", ":SENS:PER:DIG %d", |
| 364 |
""" An integer property that controls the number of digits in the period |
| 365 |
readings, which can take values from 4 to 7. """, |
| 366 |
validator=truncated_discrete_set, |
| 367 |
values=[4, 5, 6, 7], |
| 368 |
cast=int |
| 369 |
) |
| 370 |
period_threshold = Instrument.control( |
| 371 |
":SENS:PER:THR:VOLT:RANG?", ":SENS:PRE:THR:VOLT:RANG %g", |
| 372 |
""" A floating point property that controls the voltage signal threshold |
| 373 |
level in Volts for the period measurement, which can take values |
| 374 |
from 0 to 1010 V. """, |
| 375 |
validator=truncated_range, |
| 376 |
values=[0, 1010] |
| 377 |
) |
| 378 |
period_aperature = Instrument.control( |
| 379 |
":SENS:PER:APER?", ":SENS:PER:APER %g", |
| 380 |
""" A floating point property that controls the period aperature in seconds, |
| 381 |
which sets the integration period and measurement speed. Takes values |
| 382 |
from 0.01 to 1.0 s. """, |
| 383 |
validator=truncated_range, |
| 384 |
values=[0.01, 1.0] |
| 385 |
) |
| 386 |
|
| 387 |
################### |
| 388 |
# Temperature (C) # |
| 389 |
################### |
| 390 |
|
| 391 |
temperature = Instrument.measurement( |
| 392 |
":READ?", |
| 393 |
""" Reads a temperature measurement in Celsius, based on the |
| 394 |
active :attr:`~.Keithley2000.mode`. """ |
| 395 |
) |
| 396 |
temperature_reference = Instrument.control( |
| 397 |
":SENS:TEMP:REF?", ":SENS:TEMP:REF %g", |
| 398 |
""" A floating point property that controls the temperature reference value |
| 399 |
in Celsius, which can take values from -200 to 1372 C. """, |
| 400 |
validator=truncated_range, |
| 401 |
values=[-200, 1372] |
| 402 |
) |
| 403 |
temperature_nplc = Instrument.control( |
| 404 |
":SENS:TEMP:NPLC?", ":SENS:TEMP:NPLC %g", |
| 405 |
""" A floating point property that controls the number of power line cycles |
| 406 |
(NPLC) for the temperature measurements, which sets the integration period |
| 407 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 408 |
Fast, Medium, and Slow respectively. """ |
| 409 |
) |
| 410 |
temperature_digits = Instrument.control( |
| 411 |
":SENS:TEMP:DIG?", ":SENS:TEMP:DIG %d", |
| 412 |
""" An integer property that controls the number of digits in the temperature |
| 413 |
readings, which can take values from 4 to 7. """, |
| 414 |
validator=truncated_discrete_set, |
| 415 |
values=[4, 5, 6, 7], |
| 416 |
cast=int |
| 417 |
) |
| 418 |
|
| 419 |
########### |
| 420 |
# Trigger # |
| 421 |
########### |
| 422 |
|
| 423 |
trigger_count = Instrument.control( |
| 424 |
":TRIG:COUN?", ":TRIG:COUN %d", |
| 425 |
""" An integer property that controls the trigger count, |
| 426 |
which can take values from 1 to 9,999. """, |
| 427 |
validator=truncated_range, |
| 428 |
values=[1, 9999], |
| 429 |
cast=int |
| 430 |
) |
| 431 |
trigger_delay = Instrument.control( |
| 432 |
":TRIG:SEQ:DEL?", ":TRIG:SEQ:DEL %g", |
| 433 |
""" A floating point property that controls the trigger delay |
| 434 |
in seconds, which can take values from 1 to 9,999,999.999 s. """, |
| 435 |
validator=truncated_range, |
| 436 |
values=[0, 999999.999] |
| 437 |
) |
| 438 |
|
| 439 |
def __init__(self, adapter, name="Keithley 2000 Multimeter", **kwargs): |
| 440 |
super().__init__( |
| 441 |
adapter, name, **kwargs |
| 442 |
) |
| 443 |
|
| 444 |
def measure_voltage(self, max_voltage=1, ac=False): |
| 445 |
""" Configures the instrument to measure voltage, |
| 446 |
based on a maximum voltage to set the range, and |
| 447 |
a boolean flag to determine if DC or AC is required. |
| 448 |
|
| 449 |
:param max_voltage: A voltage in Volts to set the voltage range |
| 450 |
:param ac: False for DC voltage, and True for AC voltage |
| 451 |
""" |
| 452 |
if ac: |
| 453 |
self.mode = 'voltage ac' |
| 454 |
self.voltage_ac_range = max_voltage |
| 455 |
else: |
| 456 |
self.mode = 'voltage' |
| 457 |
self.voltage_range = max_voltage |
| 458 |
|
| 459 |
def measure_current(self, max_current=10e-3, ac=False): |
| 460 |
""" Configures the instrument to measure current, |
| 461 |
based on a maximum current to set the range, and |
| 462 |
a boolean flag to determine if DC or AC is required. |
| 463 |
|
| 464 |
:param max_current: A current in Volts to set the current range |
| 465 |
:param ac: False for DC current, and True for AC current |
| 466 |
""" |
| 467 |
if ac: |
| 468 |
self.mode = 'current ac' |
| 469 |
self.current_ac_range = max_current |
| 470 |
else: |
| 471 |
self.mode = 'current' |
| 472 |
self.current_range = max_current |
| 473 |
|
| 474 |
def measure_resistance(self, max_resistance=10e6, wires=2): |
| 475 |
""" Configures the instrument to measure voltage, |
| 476 |
based on a maximum voltage to set the range, and |
| 477 |
a boolean flag to determine if DC or AC is required. |
| 478 |
|
| 479 |
:param max_voltage: A voltage in Volts to set the voltage range |
| 480 |
:param ac: False for DC voltage, and True for AC voltage |
| 481 |
""" |
| 482 |
if wires == 2: |
| 483 |
self.mode = 'resistance' |
| 484 |
self.resistance_range = max_resistance |
| 485 |
elif wires == 4: |
| 486 |
self.mode = 'resistance 4W' |
| 487 |
self.resistance_4W_range = max_resistance |
| 488 |
else: |
| 489 |
raise ValueError("Keithley 2000 only supports 2 or 4 wire" |
| 490 |
"resistance measurements.") |
| 491 |
|
| 492 |
def measure_period(self): |
| 493 |
""" Configures the instrument to measure the period. """ |
| 494 |
self.mode = 'period' |
| 495 |
|
| 496 |
def measure_frequency(self): |
| 497 |
""" Configures the instrument to measure the frequency. """ |
| 498 |
self.mode = 'frequency' |
| 499 |
|
| 500 |
def measure_temperature(self): |
| 501 |
""" Configures the instrument to measure the temperature. """ |
| 502 |
self.mode = 'temperature' |
| 503 |
|
| 504 |
def measure_diode(self): |
| 505 |
""" Configures the instrument to perform diode testing. """ |
| 506 |
self.mode = 'diode' |
| 507 |
|
| 508 |
def measure_continuity(self): |
| 509 |
""" Configures the instrument to perform continuity testing. """ |
| 510 |
self.mode = 'continuity' |
| 511 |
|
| 512 |
def _mode_command(self, mode=None): |
| 513 |
if mode is None: |
| 514 |
mode = self.mode |
| 515 |
return self.MODES[mode] |
| 516 |
|
| 517 |
def auto_range(self, mode=None): |
| 518 |
""" Sets the active mode to use auto-range, |
| 519 |
or can set another mode by its name. |
| 520 |
|
| 521 |
:param mode: A valid :attr:`~.Keithley2000.mode` name, or None for the active mode |
| 522 |
""" |
| 523 |
self.write(":SENS:%s:RANG:AUTO 1" % self._mode_command(mode)) |
| 524 |
|
| 525 |
def enable_reference(self, mode=None): |
| 526 |
""" Enables the reference for the active mode, |
| 527 |
or can set another mode by its name. |
| 528 |
|
| 529 |
:param mode: A valid :attr:`~.Keithley2000.mode` name, or None for the active mode |
| 530 |
""" |
| 531 |
self.write(":SENS:%s:REF:STAT 1" % self._mode_command(mode)) |
| 532 |
|
| 533 |
def disable_reference(self, mode=None): |
| 534 |
""" Disables the reference for the active mode, |
| 535 |
or can set another mode by its name. |
| 536 |
|
| 537 |
:param mode: A valid :attr:`~.Keithley2000.mode` name, or None for the active mode |
| 538 |
""" |
| 539 |
self.write(":SENS:%s:REF:STAT 0" % self._mode_command(mode)) |
| 540 |
|
| 541 |
def acquire_reference(self, mode=None): |
| 542 |
""" Sets the active value as the reference for the active mode, |
| 543 |
or can set another mode by its name. |
| 544 |
|
| 545 |
:param mode: A valid :attr:`~.Keithley2000.mode` name, or None for the active mode |
| 546 |
""" |
| 547 |
self.write(":SENS:%s:REF:ACQ" % self._mode_command(mode)) |
| 548 |
|
| 549 |
def enable_filter(self, mode=None, type='repeat', count=1): |
| 550 |
""" Enables the averaging filter for the active mode, |
| 551 |
or can set another mode by its name. |
| 552 |
|
| 553 |
:param mode: A valid :attr:`~.Keithley2000.mode` name, or None for the active mode |
| 554 |
:param type: The type of averaging filter, either 'repeat' or 'moving'. |
| 555 |
:param count: A number of averages, which can take take values from 1 to 100 |
| 556 |
""" |
| 557 |
self.write(":SENS:%s:AVER:STAT 1") |
| 558 |
self.write(":SENS:%s:AVER:TCON %s") |
| 559 |
self.write(":SENS:%s:AVER:COUN %d") |
| 560 |
|
| 561 |
def disable_filter(self, mode=None): |
| 562 |
""" Disables the averaging filter for the active mode, |
| 563 |
or can set another mode by its name. |
| 564 |
|
| 565 |
:param mode: A valid :attr:`~.Keithley2000.mode` name, or None for the active mode |
| 566 |
""" |
| 567 |
self.write(":SENS:%s:AVER:STAT 0" % self._mode_command(mode)) |
| 568 |
|
| 569 |
def local(self): |
| 570 |
""" Returns control to the instrument panel, and enables |
| 571 |
the panel if disabled. """ |
| 572 |
self.write(":SYST:LOC") |
| 573 |
|
| 574 |
def remote(self): |
| 575 |
""" Places the instrument in the remote state, which is |
| 576 |
does not need to be explicitly called in general. """ |
| 577 |
self.write(":SYST:REM") |
| 578 |
|
| 579 |
def remote_lock(self): |
| 580 |
""" Disables and locks the front panel controls to prevent |
| 581 |
changes during remote operations. This is disabled by |
| 582 |
calling :meth:`~.Keithley2000.local`. """ |
| 583 |
self.write(":SYST:RWL") |
| 584 |
|
| 585 |
def reset(self): |
| 586 |
""" Resets the instrument state. """ |
| 587 |
self.write(":STAT:QUEUE:CLEAR;*RST;:STAT:PRES;:*CLS;") |
| 588 |
|
| 589 |
def beep(self, frequency, duration): |
| 590 |
""" Sounds a system beep. |
| 591 |
|
| 592 |
:param frequency: A frequency in Hz between 65 Hz and 2 MHz |
| 593 |
:param duration: A time in seconds between 0 and 7.9 seconds |
| 594 |
""" |
| 595 |
self.write(f":SYST:BEEP {frequency:g}, {duration:g}") |