1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
#
# This file is part of the PyMeasure package.
#
# Copyright (c) 2013-2024 PyMeasure Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
from pymeasure.instruments import Instrument, SCPIUnknownMixin
from pymeasure.instruments.validators import strict_discrete_set
import logging
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())
class HP33120A(SCPIUnknownMixin, Instrument):
""" Represents the Hewlett Packard 33120A Arbitrary Waveform
Generator and provides a high-level interface for interacting
with the instrument.
"""
def __init__(self, adapter, name="Hewlett Packard 33120A Function Generator", **kwargs):
super().__init__(
adapter,
name,
**kwargs
)
self.amplitude_units = 'Vpp'
SHAPES = {
'sinusoid': 'SIN', 'square': 'SQU', 'triangle': 'TRI',
'ramp': 'RAMP', 'noise': 'NOIS', 'dc': 'DC', 'user': 'USER'
}
shape = Instrument.control(
"SOUR:FUNC:SHAP?", "SOUR:FUNC:SHAP %s",
"""Control the shape of the wave,
which can take the values: sinusoid, square, triangle, ramp,
noise, dc, and user. (str)""",
validator=strict_discrete_set,
values=SHAPES,
map_values=True
)
frequency = Instrument.control(
"SOUR:FREQ?", "SOUR:FREQ %g",
"""Control the frequency of the
output in Hz. The allowed range depends on the waveform shape
and can be queried with :attr:`~.max_frequency` and
:attr:`~.min_frequency`. (float)"""
)
max_frequency = Instrument.measurement(
"SOUR:FREQ? MAX",
""" Get the maximum :attr:`~.HP33120A.frequency` in Hz for the given shape """
)
min_frequency = Instrument.measurement(
"SOUR:FREQ? MIN",
""" Get the minimum :attr:`~.HP33120A.frequency` in Hz for the given shape """
)
amplitude = Instrument.control(
"SOUR:VOLT?", "SOUR:VOLT %g",
""" Control the voltage amplitude of the
output signal. The default units are in peak-to-peak Volts, but can be
controlled by :attr:`~.amplitude_units`. The allowed range depends
on the waveform shape and can be queried with :attr:`~.max_amplitude`
and :attr:`~.min_amplitude`. (float)"""
)
max_amplitude = Instrument.measurement(
"SOUR:VOLT? MAX",
""" Get the maximum :attr:`~.amplitude` in Volts for the given shape """
)
min_amplitude = Instrument.measurement(
"SOUR:VOLT? MIN",
""" Get the minimum :attr:`~.amplitude` in Volts for the given shape """
)
offset = Instrument.control(
"SOUR:VOLT:OFFS?", "SOUR:VOLT:OFFS %g",
""" Control the amplitude voltage offset
in Volts. The allowed range depends on the waveform shape and can be
queried with :attr:`~.max_offset` and :attr:`~.min_offset`. """
)
max_offset = Instrument.measurement(
"SOUR:VOLT:OFFS? MAX",
""" Get the maximum :attr:`~.offset` in Volts for the given shape """
)
min_offset = Instrument.measurement(
"SOUR:VOLT:OFFS? MIN",
""" Get the minimum :attr:`~.offset` in Volts for the given shape """
)
AMPLITUDE_UNITS = {'Vpp': 'VPP', 'Vrms': 'VRMS', 'dBm': 'DBM', 'default': 'DEF'}
amplitude_units = Instrument.control(
"SOUR:VOLT:UNIT?", "SOUR:VOLT:UNIT %s",
""" Control the units of the amplitude,
which can take the values Vpp, Vrms, dBm, and default. (str)
""",
validator=strict_discrete_set,
values=AMPLITUDE_UNITS,
map_values=True
)
burst_enabled = Instrument.control(
"BM:STATE?", "BM:STATE %d",
"""Control state of burst modulation""",
validator=strict_discrete_set,
values={True: 1, False: 0},
map_values=True
)
burst_source = Instrument.control(
"BM:SOURCE?", "BM:SOURCE %s",
"""Control internal or external gate source for burst modulation""",
validator=strict_discrete_set,
values=['INT', 'EXT'],
)
burst_count = Instrument.control(
"BM:NCYC?", "BM:NCYC %d",
"""Control the number of cycles per burst (1 to 50,000 cycles)""",
)
min_burst_count = Instrument.measurement(
"BM:NCYC? MIN",
"""Get the minimum :attr:`~.HP33120A.burst_count`"""
)
max_burst_count = Instrument.measurement(
"BM:NCYC? MAX",
"""Get the maximum :attr:`~.HP33120A.burst_count`"""
)
burst_rate = Instrument.control(
"BM:INT:RATE?", "BM:INT:RATE %g",
"""Control the burst rate in Hz fo an internal burst source"""
)
min_burst_rate = Instrument.measurement(
"BM:INT:RATE? MIN",
"""Get the minimum :attr:`~.HP33120A.burst_rate`"""
)
max_burst_rate = Instrument.measurement(
"BM:INT:RATE? MAX",
"""Get the maximum :attr:`~.HP33120A.burst_rate`"""
)
burst_phase = Instrument.control(
"BM:PHAS?", "BM:PHAS %g",
"""Control the starting phase angle of a burst (-360 to +360 degrees)"""
)
min_burst_phase = Instrument.measurement(
"BM:PHAS? MIN",
"""Get the minimum :attr:`~.HP33120A.burst_phase`"""
)
max_burst_phase = Instrument.measurement(
"BM:PHAS? MAX",
"""Get the maximum :attr:`~.HP33120A.burst_phase`"""
)
def beep(self):
""" Causes a system beep. """
self.write("SYST:BEEP")
|