Debian Codegraph @

pymeasure/instruments/keysight/keysightE36312A.py

raw
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, Channel, SCPIMixin
29 from pymeasure.instruments.validators import strict_range, strict_discrete_set
30
31 log = logging.getLogger(__name__)
32 log.addHandler(logging.NullHandler())
33
34
35 class VoltageChannel(Channel):
36 voltage_setpoint = Channel.control(
37 "VOLT? (@{ch})",
38 "VOLT %g, (@{ch})",
39 """Control the output voltage of this channel, range depends on channel.""",
40 validator=strict_range,
41 values=[0, 25],
42 dynamic=True,
43 )
44
45 current_limit = Channel.control(
46 "CURR? (@{ch})",
47 "CURR %g, (@{ch})",
48 """Control the current limit of this channel, range depends on channel.""",
49 validator=strict_range,
50 values=[0, 1],
51 dynamic=True,
52 )
53
54 voltage = Channel.measurement(
55 "MEASure:VOLTage? (@{ch})",
56 """Measure actual voltage of this channel."""
57 )
58
59 current = Channel.measurement(
60 "MEAS:CURRent? (@{ch})",
61 """Measure the actual current of this channel."""
62 )
63
64 output_enabled = Channel.control(
65 "OUTPut? (@{ch})",
66 "OUTPut %d, (@{ch})",
67 """Control whether the channel output is enabled (boolean).""",
68 validator=strict_discrete_set,
69 map_values=True,
70 values={True: 1, False: 0},
71 )
72
73
74 class KeysightE36312A(SCPIMixin, Instrument):
75 """ Represents the Keysight E36312A Power supply
76 interface for interacting with the instrument.
77
78 .. code-block:: python
79
80 supply = KeysightE36312A(resource)
81 supply.ch_1.voltage_setpoint=10
82 supply.ch_1.current_setpoint=0.1
83 supply.ch_1.output_enabled=True
84 print(supply.ch_1.voltage)
85 """
86
87 ch_1 = Instrument.ChannelCreator(VoltageChannel, 1)
88
89 ch_2 = Instrument.ChannelCreator(VoltageChannel, 2)
90
91 ch_3 = Instrument.ChannelCreator(VoltageChannel, 3)
92
93 def __init__(self, adapter, name="Keysight E36312A", **kwargs):
94 super().__init__(
95 adapter, name, **kwargs
96 )
97 self.channels[1].voltage_setpoint_values = [0, 6]
98 self.channels[1].current_limit_values = [0, 5]