| 1 |
# |
| 2 |
# This file is part of the PyMeasure package. |
| 3 |
# |
| 4 |
# Copyright (c) 2013-2024 PyMeasure Developers |
| 5 |
# |
| 6 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 |
# of this software and associated documentation files (the "Software"), to deal |
| 8 |
# in the Software without restriction, including without limitation the rights |
| 9 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 |
# copies of the Software, and to permit persons to whom the Software is |
| 11 |
# furnished to do so, subject to the following conditions: |
| 12 |
# |
| 13 |
# The above copyright notice and this permission notice shall be included in |
| 14 |
# all copies or substantial portions of the Software. |
| 15 |
# |
| 16 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 |
# THE SOFTWARE. |
| 23 |
# |
| 24 |
|
| 25 |
import logging |
| 26 |
import time |
| 27 |
from warnings import warn |
| 28 |
|
| 29 |
import numpy as np |
| 30 |
|
| 31 |
from pymeasure.instruments import Instrument, SCPIMixin |
| 32 |
from pymeasure.instruments.validators import truncated_range, strict_discrete_set |
| 33 |
from .buffer import KeithleyBuffer |
| 34 |
|
| 35 |
# Setup logging |
| 36 |
log = logging.getLogger(__name__) |
| 37 |
log.addHandler(logging.NullHandler()) |
| 38 |
|
| 39 |
|
| 40 |
class Keithley2450(KeithleyBuffer, SCPIMixin, Instrument): |
| 41 |
""" Represents the Keithley 2450 SourceMeter and provides a |
| 42 |
high-level interface for interacting with the instrument. |
| 43 |
|
| 44 |
.. code-block:: python |
| 45 |
|
| 46 |
keithley = Keithley2450("GPIB::1") |
| 47 |
|
| 48 |
keithley.apply_current() # Sets up to source current |
| 49 |
keithley.source_current_range = 10e-3 # Sets the source current range to 10 mA |
| 50 |
keithley.compliance_voltage = 10 # Sets the compliance voltage to 10 V |
| 51 |
keithley.source_current = 0 # Sets the source current to 0 mA |
| 52 |
keithley.enable_source() # Enables the source output |
| 53 |
|
| 54 |
keithley.measure_voltage() # Sets up to measure voltage |
| 55 |
|
| 56 |
keithley.ramp_to_current(5e-3) # Ramps the current to 5 mA |
| 57 |
print(keithley.voltage) # Prints the voltage in Volts |
| 58 |
|
| 59 |
keithley.shutdown() # Ramps the current to 0 mA and disables output |
| 60 |
|
| 61 |
""" |
| 62 |
|
| 63 |
def __init__(self, adapter, name="Keithley 2450 SourceMeter", **kwargs): |
| 64 |
super().__init__( |
| 65 |
adapter, |
| 66 |
name, |
| 67 |
**kwargs |
| 68 |
) |
| 69 |
|
| 70 |
source_mode = Instrument.control( |
| 71 |
":SOUR:FUNC?", ":SOUR:FUNC %s", |
| 72 |
""" A string property that controls the source mode, which can |
| 73 |
take the values 'current' or 'voltage'. The convenience methods |
| 74 |
:meth:`~.Keithley2450.apply_current` and :meth:`~.Keithley2450.apply_voltage` |
| 75 |
can also be used. """, |
| 76 |
validator=strict_discrete_set, |
| 77 |
values={'current': 'CURR', 'voltage': 'VOLT'}, |
| 78 |
map_values=True |
| 79 |
) |
| 80 |
|
| 81 |
source_enabled = Instrument.measurement( |
| 82 |
"OUTPUT?", |
| 83 |
""" Reads a boolean value that is True if the source is enabled. """, |
| 84 |
cast=bool |
| 85 |
) |
| 86 |
|
| 87 |
############### |
| 88 |
# Current (A) # |
| 89 |
############### |
| 90 |
|
| 91 |
current = Instrument.measurement( |
| 92 |
":READ?", |
| 93 |
""" Reads the current in Amps, if configured for this reading. |
| 94 |
""" |
| 95 |
) |
| 96 |
|
| 97 |
current_range = Instrument.control( |
| 98 |
":SENS:CURR:RANG?", ":SENS:CURR:RANG:AUTO 0;:SENS:CURR:RANG %g", |
| 99 |
""" A floating point property that controls the measurement current |
| 100 |
range in Amps, which can take values between -1.05 and +1.05 A. |
| 101 |
Auto-range is disabled when this property is set. """, |
| 102 |
validator=truncated_range, |
| 103 |
values=[-1.05, 1.05] |
| 104 |
) |
| 105 |
|
| 106 |
current_nplc = Instrument.control( |
| 107 |
":SENS:CURR:NPLC?", ":SENS:CURR:NPLC %g", |
| 108 |
""" A floating point property that controls the number of power line cycles |
| 109 |
(NPLC) for the DC current measurements, which sets the integration period |
| 110 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 111 |
Fast, Medium, and Slow respectively. """, |
| 112 |
values=[0.01, 10] |
| 113 |
) |
| 114 |
|
| 115 |
compliance_current = Instrument.control( |
| 116 |
":SOUR:VOLT:ILIM?", ":SOUR:VOLT:ILIM %g", |
| 117 |
""" A floating point property that controls the compliance current |
| 118 |
in Amps. """, |
| 119 |
validator=truncated_range, |
| 120 |
values=[-1.05, 1.05] |
| 121 |
) |
| 122 |
|
| 123 |
source_current = Instrument.control( |
| 124 |
":SOUR:CURR?", ":SOUR:CURR:LEV %g", |
| 125 |
""" A floating point property that controls the source current |
| 126 |
in Amps. """ |
| 127 |
) |
| 128 |
|
| 129 |
source_current_range = Instrument.control( |
| 130 |
":SOUR:CURR:RANG?", ":SOUR:CURR:RANG:AUTO 0;:SOUR:CURR:RANG %g", |
| 131 |
""" A floating point property that controls the source current |
| 132 |
range in Amps, which can take values between -1.05 and +1.05 A. |
| 133 |
Auto-range is disabled when this property is set. """, |
| 134 |
validator=truncated_range, |
| 135 |
values=[-1.05, 1.05] |
| 136 |
) |
| 137 |
|
| 138 |
source_current_delay = Instrument.control( |
| 139 |
":SOUR:CURR:DEL?", ":SOUR:CURR:DEL %g", |
| 140 |
""" A floating point property that sets a manual delay for the source |
| 141 |
after the output is turned on before a measurement is taken. When this |
| 142 |
property is set, the auto delay is turned off. Valid values are |
| 143 |
between 0 [seconds] and 999.9999 [seconds].""", |
| 144 |
validator=truncated_range, |
| 145 |
values=[0, 999.9999], |
| 146 |
) |
| 147 |
|
| 148 |
source_current_delay_auto = Instrument.control( |
| 149 |
":SOUR:CURR:DEL:AUTO?", ":SOUR:CURR:DEL:AUTO %d", |
| 150 |
""" A boolean property that enables or disables auto delay. Valid |
| 151 |
values are True and False. """, |
| 152 |
values={True: 1, False: 0}, |
| 153 |
map_values=True, |
| 154 |
) |
| 155 |
|
| 156 |
############### |
| 157 |
# Voltage (V) # |
| 158 |
############### |
| 159 |
|
| 160 |
voltage = Instrument.measurement( |
| 161 |
":READ?", |
| 162 |
""" Reads the voltage in Volts, if configured for this reading. |
| 163 |
""" |
| 164 |
) |
| 165 |
|
| 166 |
voltage_range = Instrument.control( |
| 167 |
":SENS:VOLT:RANG?", ":SENS:VOLT:RANG:AUTO 0;:SENS:VOLT:RANG %g", |
| 168 |
""" A floating point property that controls the measurement voltage |
| 169 |
range in Volts, which can take values from -210 to 210 V. |
| 170 |
Auto-range is disabled when this property is set. """, |
| 171 |
validator=truncated_range, |
| 172 |
values=[-210, 210] |
| 173 |
) |
| 174 |
|
| 175 |
voltage_nplc = Instrument.control( |
| 176 |
":SENS:VOLT:NPLC?", ":SENS:VOLT:NPLC %g", |
| 177 |
""" A floating point property that controls the number of power line cycles |
| 178 |
(NPLC) for the DC voltage measurements, which sets the integration period |
| 179 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 180 |
Fast, Medium, and Slow respectively. """ |
| 181 |
) |
| 182 |
|
| 183 |
compliance_voltage = Instrument.control( |
| 184 |
":SOUR:CURR:VLIM?", ":SOUR:CURR:VLIM %g", |
| 185 |
""" A floating point property that controls the compliance voltage |
| 186 |
in Volts. """, |
| 187 |
validator=truncated_range, |
| 188 |
values=[-210, 210] |
| 189 |
) |
| 190 |
|
| 191 |
source_voltage = Instrument.control( |
| 192 |
":SOUR:VOLT?", ":SOUR:VOLT:LEV %g", |
| 193 |
""" A floating point property that controls the source voltage |
| 194 |
in Volts. """ |
| 195 |
) |
| 196 |
|
| 197 |
source_voltage_range = Instrument.control( |
| 198 |
":SOUR:VOLT:RANG?", ":SOUR:VOLT:RANG:AUTO 0;:SOUR:VOLT:RANG %g", |
| 199 |
""" A floating point property that controls the source voltage |
| 200 |
range in Volts, which can take values from -210 to 210 V. |
| 201 |
Auto-range is disabled when this property is set. """, |
| 202 |
validator=truncated_range, |
| 203 |
values=[-210, 210] |
| 204 |
) |
| 205 |
|
| 206 |
source_voltage_delay = Instrument.control( |
| 207 |
":SOUR:VOLT:DEL?", ":SOUR:VOLT:DEL %g", |
| 208 |
""" A floating point property that sets a manual delay for the source |
| 209 |
after the output is turned on before a measurement is taken. When this |
| 210 |
property is set, the auto delay is turned off. Valid values are |
| 211 |
between 0 [seconds] and 999.9999 [seconds].""", |
| 212 |
validator=truncated_range, |
| 213 |
values=[0, 999.9999], |
| 214 |
) |
| 215 |
|
| 216 |
source_voltage_delay_auto = Instrument.control( |
| 217 |
":SOUR:VOLT:DEL:AUTO?", ":SOUR:VOLT:DEL:AUTO %d", |
| 218 |
""" A boolean property that enables or disables auto delay. Valid |
| 219 |
values are True and False. """, |
| 220 |
values={True: 1, False: 0}, |
| 221 |
map_values=True, |
| 222 |
) |
| 223 |
|
| 224 |
#################### |
| 225 |
# Resistance (Ohm) # |
| 226 |
#################### |
| 227 |
|
| 228 |
resistance = Instrument.measurement( |
| 229 |
":READ?", |
| 230 |
""" Reads the resistance in Ohms, if configured for this reading. |
| 231 |
""" |
| 232 |
) |
| 233 |
|
| 234 |
resistance_range = Instrument.control( |
| 235 |
":SENS:RES:RANG?", ":SENS:RES:RANG:AUTO 0;:SENS:RES:RANG %g", |
| 236 |
""" A floating point property that controls the resistance range |
| 237 |
in Ohms, which can take values from 0 to 210 MOhms. |
| 238 |
Auto-range is disabled when this property is set. """, |
| 239 |
validator=truncated_range, |
| 240 |
values=[0, 210e6] |
| 241 |
) |
| 242 |
resistance_nplc = Instrument.control( |
| 243 |
":SENS:RES:NPLC?", ":SENS:RES:NPLC %g", |
| 244 |
""" A floating point property that controls the number of power line cycles |
| 245 |
(NPLC) for the 2-wire resistance measurements, which sets the integration period |
| 246 |
and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are |
| 247 |
Fast, Medium, and Slow respectively. """ |
| 248 |
) |
| 249 |
|
| 250 |
wires = Instrument.control( |
| 251 |
":SENS:RES:RSENSE?", ":SENS:RES:RSENSE %d", |
| 252 |
""" An integer property that controls the number of wires in |
| 253 |
use for resistance measurements, which can take the value of |
| 254 |
2 or 4. |
| 255 |
""", |
| 256 |
validator=strict_discrete_set, |
| 257 |
values={4: 1, 2: 0}, |
| 258 |
map_values=True |
| 259 |
) |
| 260 |
|
| 261 |
buffer_points = Instrument.control( |
| 262 |
":TRAC:POIN?", ":TRAC:POIN %d", |
| 263 |
""" An integer property that controls the number of buffer points. This |
| 264 |
does not represent actual points in the buffer, but the configuration |
| 265 |
value instead. """, |
| 266 |
validator=truncated_range, |
| 267 |
values=[1, 6875000], |
| 268 |
cast=int |
| 269 |
) |
| 270 |
|
| 271 |
means = Instrument.measurement( |
| 272 |
":TRACe:STATistics:AVERage?", |
| 273 |
""" Reads the calculated means (averages) for voltage, |
| 274 |
current, and resistance from the buffer data as a list. """ |
| 275 |
) |
| 276 |
|
| 277 |
maximums = Instrument.measurement( |
| 278 |
":TRACe:STATistics:MAXimum?", |
| 279 |
""" Returns the calculated maximums for voltage, current, and |
| 280 |
resistance from the buffer data as a list. """ |
| 281 |
) |
| 282 |
|
| 283 |
minimums = Instrument.measurement( |
| 284 |
":TRACe:STATistics:MINimum?", |
| 285 |
""" Returns the calculated minimums for voltage, current, and |
| 286 |
resistance from the buffer data as a list. """ |
| 287 |
) |
| 288 |
|
| 289 |
standard_devs = Instrument.measurement( |
| 290 |
":TRACe:STATistics:STDDev?", |
| 291 |
""" Returns the calculated standard deviations for voltage, |
| 292 |
current, and resistance from the buffer data as a list. """ |
| 293 |
) |
| 294 |
|
| 295 |
########### |
| 296 |
# Filters # |
| 297 |
########### |
| 298 |
|
| 299 |
current_filter_type = Instrument.control( |
| 300 |
":SENS:CURR:AVER:TCON?", ":SENS:CURR:AVER:TCON %s", |
| 301 |
""" A String property that controls the filter's type for the current. |
| 302 |
REP : Repeating filter |
| 303 |
MOV : Moving filter""", |
| 304 |
validator=strict_discrete_set, |
| 305 |
values=['REP', 'MOV'], |
| 306 |
map_values=False) |
| 307 |
|
| 308 |
current_filter_count = Instrument.control( |
| 309 |
":SENS:CURR:AVER:COUNT?", ":SENS:CURR:AVER:COUNT %d", |
| 310 |
""" A integer property that controls the number of readings that are |
| 311 |
acquired and stored in the filter buffer for the averaging""", |
| 312 |
validator=truncated_range, |
| 313 |
values=[1, 100], |
| 314 |
cast=int) |
| 315 |
|
| 316 |
current_filter_state = Instrument.control( |
| 317 |
":SENS:CURR:AVER?", ":SENS:CURR:AVER %s", |
| 318 |
""" A string property that controls if the filter is active.""", |
| 319 |
validator=strict_discrete_set, |
| 320 |
values=['ON', 'OFF'], |
| 321 |
map_values=False) |
| 322 |
|
| 323 |
voltage_filter_type = Instrument.control( |
| 324 |
":SENS:VOLT:AVER:TCON?", ":SENS:VOLT:AVER:TCON %s", |
| 325 |
""" A String property that controls the filter's type for the current. |
| 326 |
REP : Repeating filter |
| 327 |
MOV : Moving filter""", |
| 328 |
validator=strict_discrete_set, |
| 329 |
values=['REP', 'MOV'], |
| 330 |
map_values=False) |
| 331 |
|
| 332 |
voltage_filter_count = Instrument.control( |
| 333 |
":SENS:VOLT:AVER:COUNT?", ":SENS:VOLT:AVER:COUNT %d", |
| 334 |
""" A integer property that controls the number of readings that are |
| 335 |
acquired and stored in the filter buffer for the averaging""", |
| 336 |
validator=truncated_range, |
| 337 |
values=[1, 100], |
| 338 |
cast=int) |
| 339 |
|
| 340 |
##################### |
| 341 |
# Output subsystem # |
| 342 |
##################### |
| 343 |
|
| 344 |
current_output_off_state = Instrument.control( |
| 345 |
":OUTP:CURR:SMOD?", ":OUTP:CURR:SMOD %s", |
| 346 |
""" Select the output-off state of the SourceMeter. |
| 347 |
HIMP : output relay is open, disconnects external circuitry. |
| 348 |
NORM : V-Source is selected and set to 0V, Compliance is set to 0.5% |
| 349 |
full scale of the present current range. |
| 350 |
ZERO : V-Source is selected and set to 0V, compliance is set to the |
| 351 |
programmed Source I value or to 0.5% full scale of the present current |
| 352 |
range, whichever is greater. |
| 353 |
GUAR : I-Source is selected and set to 0A""", |
| 354 |
validator=strict_discrete_set, |
| 355 |
values=['HIMP', 'NORM', 'ZERO', 'GUAR'], |
| 356 |
map_values=False) |
| 357 |
|
| 358 |
voltage_output_off_state = Instrument.control( |
| 359 |
":OUTP:VOLT:SMOD?", ":OUTP:VOLT:SMOD %s", |
| 360 |
""" Select the output-off state of the SourceMeter. |
| 361 |
HIMP : output relay is open, disconnects external circuitry. |
| 362 |
NORM : V-Source is selected and set to 0V, Compliance is set to 0.5% |
| 363 |
full scale of the present current range. |
| 364 |
ZERO : V-Source is selected and set to 0V, compliance is set to the |
| 365 |
programmed Source I value or to 0.5% full scale of the present current |
| 366 |
range, whichever is greater. |
| 367 |
GUAR : I-Source is selected and set to 0A""", |
| 368 |
validator=strict_discrete_set, |
| 369 |
values=['HIMP', 'NORM', 'ZERO', 'GUAR'], |
| 370 |
map_values=False) |
| 371 |
|
| 372 |
#################### |
| 373 |
# Methods # |
| 374 |
#################### |
| 375 |
|
| 376 |
def enable_source(self): |
| 377 |
""" Enables the source of current or voltage depending on the |
| 378 |
configuration of the instrument. """ |
| 379 |
self.write("OUTPUT ON") |
| 380 |
|
| 381 |
def disable_source(self): |
| 382 |
""" Disables the source of current or voltage depending on the |
| 383 |
configuration of the instrument. """ |
| 384 |
self.write("OUTPUT OFF") |
| 385 |
|
| 386 |
def measure_resistance(self, nplc=1, resistance=2.1e5, auto_range=True): |
| 387 |
""" Configures the measurement of resistance. |
| 388 |
|
| 389 |
:param nplc: Number of power line cycles (NPLC) from 0.01 to 10 |
| 390 |
:param resistance: Upper limit of resistance in Ohms, from -210 MOhms to 210 MOhms |
| 391 |
:param auto_range: Enables auto_range if True, else uses the set resistance |
| 392 |
""" |
| 393 |
log.info("%s is measuring resistance.", self.name) |
| 394 |
self.write(":SENS:FUNC 'RES';" |
| 395 |
":SENS:RES:NPLC %f;" % nplc) |
| 396 |
if auto_range: |
| 397 |
self.write(":SENS:RES:RANG:AUTO 1;") |
| 398 |
else: |
| 399 |
self.resistance_range = resistance |
| 400 |
self.check_errors() |
| 401 |
|
| 402 |
def measure_voltage(self, nplc=1, voltage=21.0, auto_range=True): |
| 403 |
""" Configures the measurement of voltage. |
| 404 |
|
| 405 |
:param nplc: Number of power line cycles (NPLC) from 0.01 to 10 |
| 406 |
:param voltage: Upper limit of voltage in Volts, from -210 V to 210 V |
| 407 |
:param auto_range: Enables auto_range if True, else uses the set voltage |
| 408 |
""" |
| 409 |
log.info("%s is measuring voltage.", self.name) |
| 410 |
self.write(":SENS:FUNC 'VOLT';" |
| 411 |
":SENS:VOLT:NPLC %f;" % nplc) |
| 412 |
if auto_range: |
| 413 |
self.write(":SENS:VOLT:RANG:AUTO 1;") |
| 414 |
else: |
| 415 |
self.voltage_range = voltage |
| 416 |
self.check_errors() |
| 417 |
|
| 418 |
def measure_current(self, nplc=1, current=1.05e-4, auto_range=True): |
| 419 |
""" Configures the measurement of current. |
| 420 |
|
| 421 |
:param nplc: Number of power line cycles (NPLC) from 0.01 to 10 |
| 422 |
:param current: Upper limit of current in Amps, from -1.05 A to 1.05 A |
| 423 |
:param auto_range: Enables auto_range if True, else uses the set current |
| 424 |
""" |
| 425 |
log.info("%s is measuring current.", self.name) |
| 426 |
self.write(":SENS:FUNC 'CURR';" |
| 427 |
":SENS:CURR:NPLC %f;" % nplc) |
| 428 |
if auto_range: |
| 429 |
self.write(":SENS:CURR:RANG:AUTO 1;") |
| 430 |
else: |
| 431 |
self.current_range = current |
| 432 |
self.check_errors() |
| 433 |
|
| 434 |
def auto_range_source(self): |
| 435 |
""" Configures the source to use an automatic range. |
| 436 |
""" |
| 437 |
if self.source_mode == 'current': |
| 438 |
self.write(":SOUR:CURR:RANG:AUTO 1") |
| 439 |
else: |
| 440 |
self.write(":SOUR:VOLT:RANG:AUTO 1") |
| 441 |
|
| 442 |
def apply_current(self, current_range=None, |
| 443 |
compliance_voltage=0.1): |
| 444 |
""" Configures the instrument to apply a source current, and |
| 445 |
uses an auto range unless a current range is specified. |
| 446 |
The compliance voltage is also set. |
| 447 |
|
| 448 |
:param compliance_voltage: A float in the correct range for a |
| 449 |
:attr:`~.Keithley2450.compliance_voltage` |
| 450 |
:param current_range: A :attr:`~.Keithley2450.current_range` value or None |
| 451 |
""" |
| 452 |
log.info("%s is sourcing current.", self.name) |
| 453 |
self.source_mode = 'current' |
| 454 |
if current_range is None: |
| 455 |
self.auto_range_source() |
| 456 |
else: |
| 457 |
self.source_current_range = current_range |
| 458 |
self.compliance_voltage = compliance_voltage |
| 459 |
self.check_errors() |
| 460 |
|
| 461 |
def apply_voltage(self, voltage_range=None, |
| 462 |
compliance_current=0.1): |
| 463 |
""" Configures the instrument to apply a source voltage, and |
| 464 |
uses an auto range unless a voltage range is specified. |
| 465 |
The compliance current is also set. |
| 466 |
|
| 467 |
:param compliance_current: A float in the correct range for a |
| 468 |
:attr:`~.Keithley2450.compliance_current` |
| 469 |
:param voltage_range: A :attr:`~.Keithley2450.voltage_range` value or None |
| 470 |
""" |
| 471 |
log.info("%s is sourcing voltage.", self.name) |
| 472 |
self.source_mode = 'voltage' |
| 473 |
if voltage_range is None: |
| 474 |
self.auto_range_source() |
| 475 |
else: |
| 476 |
self.source_voltage_range = voltage_range |
| 477 |
self.compliance_current = compliance_current |
| 478 |
self.check_errors() |
| 479 |
|
| 480 |
def beep(self, frequency, duration): |
| 481 |
""" Sounds a system beep. |
| 482 |
|
| 483 |
:param frequency: A frequency in Hz between 65 Hz and 2 MHz |
| 484 |
:param duration: A time in seconds between 0 and 7.9 seconds |
| 485 |
""" |
| 486 |
self.write(f":SYST:BEEP {frequency:g}, {duration:g}") |
| 487 |
|
| 488 |
def triad(self, base_frequency, duration): |
| 489 |
""" Sounds a musical triad using the system beep. |
| 490 |
|
| 491 |
:param base_frequency: A frequency in Hz between 65 Hz and 1.3 MHz |
| 492 |
:param duration: A time in seconds between 0 and 7.9 seconds |
| 493 |
""" |
| 494 |
self.beep(base_frequency, duration) |
| 495 |
time.sleep(duration) |
| 496 |
self.beep(base_frequency * 5.0 / 4.0, duration) |
| 497 |
time.sleep(duration) |
| 498 |
self.beep(base_frequency * 6.0 / 4.0, duration) |
| 499 |
|
| 500 |
@property |
| 501 |
def error(self): |
| 502 |
warn("Deprecated to use `error`, use `next_error` instead.", FutureWarning) |
| 503 |
return self.next_error |
| 504 |
|
| 505 |
def reset(self): |
| 506 |
""" Resets the instrument and clears the queue. """ |
| 507 |
self.write("*RST;:stat:pres;:*CLS;") |
| 508 |
|
| 509 |
def ramp_to_current(self, target_current, steps=30, pause=20e-3): |
| 510 |
""" Ramps to a target current from the set current value over |
| 511 |
a certain number of linear steps, each separated by a pause duration. |
| 512 |
|
| 513 |
:param target_current: A current in Amps |
| 514 |
:param steps: An integer number of steps |
| 515 |
:param pause: A pause duration in seconds to wait between steps |
| 516 |
""" |
| 517 |
currents = np.linspace( |
| 518 |
self.source_current, |
| 519 |
target_current, |
| 520 |
steps |
| 521 |
) |
| 522 |
for current in currents: |
| 523 |
self.source_current = current |
| 524 |
time.sleep(pause) |
| 525 |
|
| 526 |
def ramp_to_voltage(self, target_voltage, steps=30, pause=20e-3): |
| 527 |
""" Ramps to a target voltage from the set voltage value over |
| 528 |
a certain number of linear steps, each separated by a pause duration. |
| 529 |
|
| 530 |
:param target_voltage: A voltage in Amps |
| 531 |
:param steps: An integer number of steps |
| 532 |
:param pause: A pause duration in seconds to wait between steps |
| 533 |
""" |
| 534 |
voltages = np.linspace( |
| 535 |
self.source_voltage, |
| 536 |
target_voltage, |
| 537 |
steps |
| 538 |
) |
| 539 |
for voltage in voltages: |
| 540 |
self.source_voltage = voltage |
| 541 |
time.sleep(pause) |
| 542 |
|
| 543 |
def trigger(self): |
| 544 |
""" Executes a bus trigger. |
| 545 |
""" |
| 546 |
return self.write("*TRG") |
| 547 |
|
| 548 |
@property |
| 549 |
def mean_voltage(self): |
| 550 |
""" Returns the mean voltage from the buffer """ |
| 551 |
return self.means[0] |
| 552 |
|
| 553 |
@property |
| 554 |
def max_voltage(self): |
| 555 |
""" Returns the maximum voltage from the buffer """ |
| 556 |
return self.maximums[0] |
| 557 |
|
| 558 |
@property |
| 559 |
def min_voltage(self): |
| 560 |
""" Returns the minimum voltage from the buffer """ |
| 561 |
return self.minimums[0] |
| 562 |
|
| 563 |
@property |
| 564 |
def std_voltage(self): |
| 565 |
""" Returns the voltage standard deviation from the buffer """ |
| 566 |
return self.standard_devs[0] |
| 567 |
|
| 568 |
@property |
| 569 |
def mean_current(self): |
| 570 |
""" Returns the mean current from the buffer """ |
| 571 |
return self.means[1] |
| 572 |
|
| 573 |
@property |
| 574 |
def max_current(self): |
| 575 |
""" Returns the maximum current from the buffer """ |
| 576 |
return self.maximums[1] |
| 577 |
|
| 578 |
@property |
| 579 |
def min_current(self): |
| 580 |
""" Returns the minimum current from the buffer """ |
| 581 |
return self.minimums[1] |
| 582 |
|
| 583 |
@property |
| 584 |
def std_current(self): |
| 585 |
""" Returns the current standard deviation from the buffer """ |
| 586 |
return self.standard_devs[1] |
| 587 |
|
| 588 |
@property |
| 589 |
def mean_resistance(self): |
| 590 |
""" Returns the mean resistance from the buffer """ |
| 591 |
return self.means[2] |
| 592 |
|
| 593 |
@property |
| 594 |
def max_resistance(self): |
| 595 |
""" Returns the maximum resistance from the buffer """ |
| 596 |
return self.maximums[2] |
| 597 |
|
| 598 |
@property |
| 599 |
def min_resistance(self): |
| 600 |
""" Returns the minimum resistance from the buffer """ |
| 601 |
return self.minimums[2] |
| 602 |
|
| 603 |
@property |
| 604 |
def std_resistance(self): |
| 605 |
""" Returns the resistance standard deviation from the buffer """ |
| 606 |
return self.standard_devs[2] |
| 607 |
|
| 608 |
def use_rear_terminals(self): |
| 609 |
""" Enables the rear terminals for measurement, and |
| 610 |
disables the front terminals. """ |
| 611 |
self.write(":ROUT:TERM REAR") |
| 612 |
|
| 613 |
def use_front_terminals(self): |
| 614 |
""" Enables the front terminals for measurement, and |
| 615 |
disables the rear terminals. """ |
| 616 |
self.write(":ROUT:TERM FRON") |
| 617 |
|
| 618 |
def shutdown(self): |
| 619 |
""" Ensures that the current or voltage is turned to zero |
| 620 |
and disables the output. """ |
| 621 |
log.info("Shutting down %s.", self.name) |
| 622 |
if self.source_mode == 'current': |
| 623 |
self.ramp_to_current(0.0) |
| 624 |
else: |
| 625 |
self.ramp_to_voltage(0.0) |
| 626 |
self.stop_buffer() |
| 627 |
self.disable_source() |
| 628 |
super().shutdown() |