Debian Codegraph @

pymeasure/instruments/keysight/keysightE3631A.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 """Implementation of a power supply base class channel"""
37
38 voltage_setpoint = Channel.control(
39 "INST:NSEL {ch};:VOLT?",
40 "INST:NSEL {ch};:VOLT %g",
41 """Control the output voltage of this channel, range depends on channel.""",
42 validator=strict_range,
43 values=[0, 25],
44 dynamic=True,
45 )
46
47 current_limit = Channel.control(
48 "INST:NSEL {ch};:CURR?",
49 "INST:NSEL {ch};:CURR %g",
50 """Control the current limit of this channel, range depends on channel.""",
51 validator=strict_range,
52 values=[0, 1],
53 dynamic=True,
54 )
55
56 voltage = Channel.measurement(
57 "INST:NSEL {ch};:MEAS:VOLT?",
58 """Measure actual voltage of this channel.""",
59 )
60
61 current = Channel.measurement(
62 "INST:NSEL {ch};:MEAS:CURR?",
63 """Measure the actual current of this channel.""",
64 )
65
66
67 class KeysightE3631A(SCPIMixin, Instrument):
68 """ Represents the Keysight E3631A Triple Output DC Power Supply
69 interface for interacting with the instrument.
70
71 .. code-block:: python
72
73 supply = KeysightE3631A(resource)
74 supply.ch_1.voltage_setpoint=10
75 supply.ch_1.current_setpoint=0.1
76 supply.ch_1.output_enabled=True
77 print(supply.ch_1.voltage)
78 """
79
80 ch_1 = Instrument.ChannelCreator(VoltageChannel, 1)
81
82 ch_2 = Instrument.ChannelCreator(VoltageChannel, 2)
83
84 ch_3 = Instrument.ChannelCreator(VoltageChannel, 3)
85
86 def __init__(self, adapter, name="Keysight E3631A", **kwargs):
87 super().__init__(
88 adapter, name,
89 **kwargs
90 )
91 self.channels[1].voltage_setpoint_values = [0, 6]
92 self.channels[1].current_limit_values = [0, 5]
93 self.channels[3].voltage_setpoint_values = [0, -25]
94
95 tracking_enabled = Instrument.control(
96 ":OUTP:TRAC?",
97 ":OUTP:TRAC %s",
98 """Control whether the power supply operates in the track mode (boolean)""",
99 validator=strict_discrete_set,
100 values={True: 1, False: 0},
101 map_values=True,
102 )
103
104 output_enabled = Instrument.control(
105 "OUTPut?",
106 "OUTPut %d",
107 """Control whether the channel output is enabled (boolean).""",
108 validator=strict_discrete_set,
109 map_values=True,
110 values={True: 1, False: 0},
111 dynamic=True,
112 )