| 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 |
from pymeasure.instruments import Instrument, SCPIUnknownMixin |
| 26 |
from pymeasure.instruments.validators import strict_range |
| 27 |
|
| 28 |
from time import sleep |
| 29 |
|
| 30 |
import numpy as np |
| 31 |
|
| 32 |
|
| 33 |
class SM7045D(SCPIUnknownMixin, Instrument): |
| 34 |
""" This is the class for the SM 70-45 D power supply. |
| 35 |
|
| 36 |
.. code-block:: python |
| 37 |
|
| 38 |
source = SM7045D("GPIB::8") |
| 39 |
|
| 40 |
source.ramp_to_zero(1) # Set output to 0 before enabling |
| 41 |
source.enable() # Enables the output |
| 42 |
source.current = 1 # Sets a current of 1 Amps |
| 43 |
|
| 44 |
""" |
| 45 |
VOLTAGE_RANGE = [0, 70] |
| 46 |
CURRENT_RANGE = [0, 45] |
| 47 |
|
| 48 |
voltage = Instrument.control( |
| 49 |
"SO:VO?", "SO:VO %g", |
| 50 |
""" A floating point property that represents the output voltage |
| 51 |
setting of the power supply in Volts. This property can be set. """, |
| 52 |
validator=strict_range, |
| 53 |
values=VOLTAGE_RANGE |
| 54 |
) |
| 55 |
|
| 56 |
current = Instrument.control( |
| 57 |
"SO:CU?", "SO:CU %g", |
| 58 |
""" A floating point property that represents the output current of |
| 59 |
the power supply in Amps. This property can be set. """, |
| 60 |
validator=strict_range, |
| 61 |
values=CURRENT_RANGE |
| 62 |
) |
| 63 |
|
| 64 |
max_voltage = Instrument.control( |
| 65 |
"SO:VO:MA?", "SO:VO:MA %g", |
| 66 |
""" A floating point property that represents the maximum output |
| 67 |
voltage of the power supply in Volts. This property can be set. """, |
| 68 |
validator=strict_range, |
| 69 |
values=VOLTAGE_RANGE |
| 70 |
) |
| 71 |
|
| 72 |
max_current = Instrument.control( |
| 73 |
"SO:CU:MA?", "SO:CU:MA %g", |
| 74 |
""" A floating point property that represents the maximum output |
| 75 |
current of the power supply in Amps. This property can be set. """, |
| 76 |
validator=strict_range, |
| 77 |
values=CURRENT_RANGE |
| 78 |
) |
| 79 |
|
| 80 |
measure_voltage = Instrument.measurement( |
| 81 |
"ME:VO?", |
| 82 |
""" Measures the actual output voltage of the power supply in |
| 83 |
Volts. """, |
| 84 |
) |
| 85 |
|
| 86 |
measure_current = Instrument.measurement( |
| 87 |
"ME:CU?", |
| 88 |
""" Measures the actual output current of the power supply in |
| 89 |
Amps. """, |
| 90 |
) |
| 91 |
|
| 92 |
rsd = Instrument.measurement( |
| 93 |
"SO:FU:RSD?", |
| 94 |
""" Check whether remote shutdown is enabled/disabled and thus if the |
| 95 |
output of the power supply is disabled/enabled. """, |
| 96 |
) |
| 97 |
|
| 98 |
def __init__(self, adapter, name="Delta Elektronika SM 70-45 D", **kwargs): |
| 99 |
super().__init__( |
| 100 |
adapter, |
| 101 |
name, |
| 102 |
**kwargs |
| 103 |
) |
| 104 |
|
| 105 |
def enable(self): |
| 106 |
""" |
| 107 |
Disable remote shutdown, hence output will be enabled. |
| 108 |
""" |
| 109 |
self.write("SO:FU:RSD 0") |
| 110 |
|
| 111 |
def disable(self): |
| 112 |
""" |
| 113 |
Enables remote shutdown, hence input will be disabled. |
| 114 |
""" |
| 115 |
self.write("SO:FU:RSD 1") |
| 116 |
|
| 117 |
def ramp_to_current(self, target_current, current_step=0.1): |
| 118 |
""" |
| 119 |
Gradually increase/decrease current to target current. |
| 120 |
|
| 121 |
:param target_current: Float that sets the target current (in A) |
| 122 |
:param current_step: Optional float that sets the current steps |
| 123 |
/ ramp rate (in A/s) |
| 124 |
""" |
| 125 |
|
| 126 |
curr = self.current |
| 127 |
n = round(abs(curr - target_current) / current_step) + 1 |
| 128 |
for i in np.linspace(curr, target_current, n): |
| 129 |
self.current = i |
| 130 |
sleep(0.1) |
| 131 |
|
| 132 |
def ramp_to_zero(self, current_step=0.1): |
| 133 |
""" |
| 134 |
Gradually decrease the current to zero. |
| 135 |
|
| 136 |
:param current_step: Optional float that sets the current steps |
| 137 |
/ ramp rate (in A/s) |
| 138 |
""" |
| 139 |
|
| 140 |
self.ramp_to_current(0, current_step) |
| 141 |
|
| 142 |
def shutdown(self): |
| 143 |
""" |
| 144 |
Set the current to 0 A and disable the output of the power source. |
| 145 |
""" |
| 146 |
self.ramp_to_zero() |
| 147 |
self.disable() |
| 148 |
super().shutdown() |