| 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 |
# List of Kepco BOP's (Vmax,Imax) [single channel output] |
| 26 |
# 100 W: |
| 27 |
# 5-20 |
| 28 |
# 20-5 |
| 29 |
# 50-2 |
| 30 |
# 100-1 |
| 31 |
|
| 32 |
# 200 W: |
| 33 |
# 5-30 |
| 34 |
# 20-10 |
| 35 |
# 36-6 |
| 36 |
# 50-4 |
| 37 |
# 72-3 |
| 38 |
# 100-2 |
| 39 |
# 200-1 |
| 40 |
|
| 41 |
# 400 W: |
| 42 |
# 20-20 |
| 43 |
# 36-12 |
| 44 |
# 50-8 |
| 45 |
# 72-6 |
| 46 |
# 100-4 |
| 47 |
|
| 48 |
from enum import IntFlag |
| 49 |
from pymeasure.instruments import Instrument, SCPIMixin |
| 50 |
from pymeasure.instruments.validators import strict_discrete_set, \ |
| 51 |
truncated_range |
| 52 |
|
| 53 |
OPERATING_MODES = ['VOLT', 'CURR'] |
| 54 |
|
| 55 |
|
| 56 |
class TestErrorCode(IntFlag): |
| 57 |
QUARTER_SCALE_VOLTAGE_READBACK = 512 |
| 58 |
QUARTER_SCALE_VOLTAGE = 256 |
| 59 |
MIN_VOLTAGE_OUTPUT = 128 |
| 60 |
MAX_VOLTAGE_OUTPUT = 64 |
| 61 |
LOOP_BACK_TEST = 32 |
| 62 |
DIGITAL_POT = 16 |
| 63 |
OPTICAL_BUFFER = 8 |
| 64 |
FLASH = 4 |
| 65 |
RAM = 2 |
| 66 |
ROM = 1 |
| 67 |
OK = 0 |
| 68 |
|
| 69 |
|
| 70 |
class KepcoBOP3612(SCPIMixin, Instrument): |
| 71 |
""" |
| 72 |
Represents the Kepco BOP 36-12 (M or D) 400 W bipolar power supply |
| 73 |
fitted with BIT 4886 digital interface card (minimal implementation) |
| 74 |
and provides a high-level interface for interacting with the instrument. |
| 75 |
""" |
| 76 |
_Vmax = 36 |
| 77 |
_Imax = 12 |
| 78 |
|
| 79 |
def __init__(self, adapter, name="Kepco BOP 36-12 Bipolar Power Supply", |
| 80 |
**kwargs): |
| 81 |
super().__init__( |
| 82 |
adapter=adapter, |
| 83 |
name=name, |
| 84 |
read_termination="\n", |
| 85 |
write_termination="\n", |
| 86 |
**kwargs |
| 87 |
) |
| 88 |
|
| 89 |
output_enabled = Instrument.control( |
| 90 |
"OUTPut?", |
| 91 |
"OUTPut %d", |
| 92 |
""" |
| 93 |
Control whether the source is enabled, takes values True or False (bool) |
| 94 |
""", |
| 95 |
validator=strict_discrete_set, |
| 96 |
values={True: 1, False: 0}, |
| 97 |
map_values=True, |
| 98 |
) |
| 99 |
|
| 100 |
def beep(self): |
| 101 |
"""Cause the unit to emit a brief audible tone.""" |
| 102 |
self.write("SYSTem:BEEP") |
| 103 |
|
| 104 |
confidence_test = Instrument.measurement( |
| 105 |
"*TST?", |
| 106 |
""" |
| 107 |
Get error code after performing interface self-test procedure. |
| 108 |
|
| 109 |
Returns 0 if all tests passed, otherwise corresponding error code |
| 110 |
as detailed in manual. |
| 111 |
""", |
| 112 |
get_process=lambda v: TestErrorCode(v), |
| 113 |
) |
| 114 |
|
| 115 |
bop_test = Instrument.measurement( |
| 116 |
"DIAG:TST?", |
| 117 |
""" |
| 118 |
Get error code after performing full power supply self-test. |
| 119 |
|
| 120 |
Returns 0 if all tests passed, otherwise corresponding error code |
| 121 |
as detailed in manual. |
| 122 |
Caution: Output will switch on and swing to maximum values. |
| 123 |
Disconnect any load before testing. |
| 124 |
""", |
| 125 |
get_process=lambda v: TestErrorCode(v), |
| 126 |
) |
| 127 |
|
| 128 |
def wait_to_continue(self): |
| 129 |
""" Cause the power supply to wait until all previously issued |
| 130 |
commands and queries are complete before executing subsequent |
| 131 |
commands or queries. """ |
| 132 |
self.write("*WAI") |
| 133 |
|
| 134 |
voltage = Instrument.measurement( |
| 135 |
"MEASure:VOLTage?", |
| 136 |
""" |
| 137 |
Measure voltage present across the output terminals in Volts. |
| 138 |
""", |
| 139 |
cast=float |
| 140 |
) |
| 141 |
|
| 142 |
current = Instrument.measurement( |
| 143 |
"MEASure:CURRent?", |
| 144 |
""" |
| 145 |
Measure current through the output terminals in Amps. |
| 146 |
""", |
| 147 |
cast=float |
| 148 |
) |
| 149 |
|
| 150 |
operating_mode = Instrument.control( |
| 151 |
"FUNCtion:MODE?", "FUNCtion:MODE %s", |
| 152 |
""" |
| 153 |
Control the operating mode of the BOP. |
| 154 |
|
| 155 |
As a command, a string, VOLT or CURR, is sent. |
| 156 |
As a query, a 0 or 1 is returned, corresponding to VOLT or CURR respectively. |
| 157 |
This is mapped to corresponding string. |
| 158 |
""", |
| 159 |
validator=strict_discrete_set, |
| 160 |
values=OPERATING_MODES, |
| 161 |
get_process=lambda x: OPERATING_MODES[int(x)] |
| 162 |
) |
| 163 |
|
| 164 |
current_setpoint = Instrument.control( |
| 165 |
"CURRent?", "CURRent %g", |
| 166 |
""" |
| 167 |
Control the output current setpoint. |
| 168 |
|
| 169 |
Functionality depends on the operating mode. |
| 170 |
If power supply in current mode, this sets the output current setpoint. |
| 171 |
The current achieved depends on the voltage compliance and load conditions |
| 172 |
(see: `current`). |
| 173 |
If power supply in voltage mode, this sets the compliance current |
| 174 |
for the corresponding voltage set point. |
| 175 |
Query returns programmed value, meaning of which is dependent on |
| 176 |
power supply operating context (see: `operating_mode`). |
| 177 |
|
| 178 |
Output must be enabled separately (see: `output_enabled`) |
| 179 |
""", |
| 180 |
validator=truncated_range, |
| 181 |
values=[-1*_Imax, _Imax] |
| 182 |
) |
| 183 |
|
| 184 |
voltage_setpoint = Instrument.control( |
| 185 |
"VOLTage?", "VOLTage %g", |
| 186 |
""" |
| 187 |
Control the output voltage setpoint. |
| 188 |
|
| 189 |
Functionality depends on the operating mode. |
| 190 |
If power supply in voltage mode, this sets the output voltage setpoint. |
| 191 |
The voltage achieved depends on the current compliance and load conditions |
| 192 |
(see: `voltage`). |
| 193 |
If power supply in current mode, this sets the compliance voltage |
| 194 |
for the corresponding current set point. |
| 195 |
Query returns programmed value, meaning of which is dependent on |
| 196 |
power supply operating context (see: `operating_mode`). |
| 197 |
|
| 198 |
Output must be enabled separately (see: `output_enabled`) |
| 199 |
""", |
| 200 |
validator=truncated_range, |
| 201 |
values=[-1*_Vmax, _Vmax] |
| 202 |
) |