| 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 |
|
| 26 |
import logging |
| 27 |
|
| 28 |
from pymeasure.instruments import Instrument, SCPIUnknownMixin |
| 29 |
from pymeasure.instruments.validators import truncated_range |
| 30 |
|
| 31 |
from pymeasure.adapters import VISAAdapter |
| 32 |
|
| 33 |
log = logging.getLogger(__name__) |
| 34 |
log.addHandler(logging.NullHandler()) |
| 35 |
|
| 36 |
|
| 37 |
class KeysightN5767A(SCPIUnknownMixin, Instrument): |
| 38 |
""" Represents the Keysight N5767A Power supply |
| 39 |
interface for interacting with the instrument. |
| 40 |
""" |
| 41 |
############### |
| 42 |
# Current (A) # |
| 43 |
############### |
| 44 |
current_range = Instrument.control( |
| 45 |
":CURR?", ":CURR %g", |
| 46 |
"""Control the DC current range in |
| 47 |
Amps, which can take values from 0 to 25 A. |
| 48 |
Auto-range is disabled when this property is set. (float)""", |
| 49 |
validator=truncated_range, |
| 50 |
values=[0, 25], |
| 51 |
) |
| 52 |
|
| 53 |
current = Instrument.measurement(":MEAS:CURR?", |
| 54 |
""" Get current in Amps. """ |
| 55 |
) |
| 56 |
|
| 57 |
############### |
| 58 |
# Voltage (V) # |
| 59 |
############### |
| 60 |
voltage_range = Instrument.control( |
| 61 |
":VOLT?", ":VOLT %g V", |
| 62 |
""" Control the DC voltage range in |
| 63 |
Volts, which can take values from 0 to 60 V. |
| 64 |
Auto-range is disabled when this property is set. """, |
| 65 |
validator=truncated_range, |
| 66 |
values=[0, 60] |
| 67 |
) |
| 68 |
|
| 69 |
voltage = Instrument.measurement("MEAS:VOLT?", |
| 70 |
""" Get a DC voltage measurement in Volts. """ |
| 71 |
) |
| 72 |
|
| 73 |
################# |
| 74 |
# _status (0/1) # |
| 75 |
################# |
| 76 |
_status = Instrument.measurement(":OUTP?", |
| 77 |
""" Get power supply current output status. """, |
| 78 |
) |
| 79 |
|
| 80 |
def enable(self): |
| 81 |
""" Enables the flow of current. |
| 82 |
""" |
| 83 |
self.write(":OUTP 1") |
| 84 |
|
| 85 |
def disable(self): |
| 86 |
""" Disables the flow of current. |
| 87 |
""" |
| 88 |
self.write(":OUTP 0") |
| 89 |
|
| 90 |
def is_enabled(self): |
| 91 |
""" Returns True if the current supply is enabled. |
| 92 |
""" |
| 93 |
return bool(self._status) |
| 94 |
|
| 95 |
def __init__(self, adapter, name="Keysight N5767A power supply", **kwargs): |
| 96 |
super().__init__( |
| 97 |
adapter, name, **kwargs |
| 98 |
) |
| 99 |
# Set up data transfer format |
| 100 |
if isinstance(self.adapter, VISAAdapter): |
| 101 |
self.adapter.config( |
| 102 |
is_binary=False, |
| 103 |
datatype='float32', |
| 104 |
converter='f', |
| 105 |
separator=',' |
| 106 |
) |