| 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_discrete_set, \ |
| 27 |
truncated_discrete_set, truncated_range |
| 28 |
|
| 29 |
|
| 30 |
class SR570(SCPIUnknownMixin, Instrument): |
| 31 |
|
| 32 |
def __init__(self, adapter, name="Stanford Research Systems SR570 Lock-in amplifier", |
| 33 |
**kwargs): |
| 34 |
super().__init__( |
| 35 |
adapter, |
| 36 |
name, |
| 37 |
**kwargs |
| 38 |
) |
| 39 |
|
| 40 |
SENSITIVITIES = [ |
| 41 |
1e-12, 2e-12, 5e-12, 10e-12, 20e-12, 50e-12, 100e-12, 200e-12, 500e-12, |
| 42 |
1e-9, 2e-9, 5e-9, 10e-9, 20e-9, 50e-9, 100e-9, 200e-9, 500e-9, |
| 43 |
1e-6, 2e-6, 5e-6, 10e-6, 20e-6, 50e-6, 100e-6, 200e-6, 500e-6, |
| 44 |
1e-3 |
| 45 |
] |
| 46 |
|
| 47 |
FREQUENCIES = [ |
| 48 |
0.03, 0.1, 0.3, 1, 3, 10, 30, 100, 300, 1e3, 3e3, 1e4, 3e4, |
| 49 |
1e5, 3e5, 1e6 |
| 50 |
] |
| 51 |
|
| 52 |
FILT_TYPES = ['6dB Highpass', '12dB Highpass', '6dB Bandpass', |
| 53 |
'6dB Lowpass', '12dB Lowpass', 'none'] |
| 54 |
|
| 55 |
BIAS_LIMITS = [-5, 5] |
| 56 |
|
| 57 |
OFFSET_CURRENTS = [ |
| 58 |
1e-12, 2e-12, 5e-12, 10e-12, 20e-12, 50e-12, 100e-12, 200e-12, 500e-12, |
| 59 |
1e-9, 2e-9, 5e-9, 10e-9, 20e-9, 50e-9, 100e-9, 200e-9, 500e-9, |
| 60 |
1e-6, 2e-6, 5e-6, 10e-6, 20e-6, 50e-6, 100e-6, 200e-6, 500e-6, |
| 61 |
1e-3, 2e-3, 5e-3 |
| 62 |
] |
| 63 |
|
| 64 |
GAIN_MODES = [ |
| 65 |
'Low Noise', 'High Bandwidth', 'Low Drift' |
| 66 |
] |
| 67 |
|
| 68 |
sensitivity = Instrument.setting( |
| 69 |
"SENS %d", |
| 70 |
""" A floating point value that sets the sensitivity of the |
| 71 |
amplifier, which takes discrete values in a 1-2-5 sequence. |
| 72 |
Values are truncated to the closest allowed value if not exact. |
| 73 |
Allowed values range from 1 pA/V to 1 mA/V.""", |
| 74 |
validator=truncated_discrete_set, |
| 75 |
values=SENSITIVITIES, |
| 76 |
map_values=True) |
| 77 |
|
| 78 |
filter_type = Instrument.setting( |
| 79 |
"FLTT %d", |
| 80 |
""" A string that sets the filter type. |
| 81 |
Allowed values are: {}""".format(FILT_TYPES), |
| 82 |
validator=truncated_discrete_set, |
| 83 |
values=FILT_TYPES, |
| 84 |
map_values=True) |
| 85 |
|
| 86 |
low_freq = Instrument.setting( |
| 87 |
"LFRQ %d", |
| 88 |
""" A floating point value that sets the lowpass frequency of the |
| 89 |
amplifier, which takes a discrete value in a 1-3 sequence. |
| 90 |
Values are truncated to the closest allowed value if not exact. |
| 91 |
Allowed values range from 0.03 Hz to 1 MHz.""", |
| 92 |
validator=truncated_discrete_set, |
| 93 |
values=FREQUENCIES, |
| 94 |
map_values=True) |
| 95 |
|
| 96 |
high_freq = Instrument.setting( |
| 97 |
"HFRQ %d", |
| 98 |
""" A floating point value that sets the highpass frequency of the |
| 99 |
amplifier, which takes a discrete value in a 1-3 sequence. |
| 100 |
Values are truncated to the closest allowed value if not exact. |
| 101 |
Allowed values range from 0.03 Hz to 1 MHz.""", |
| 102 |
validator=truncated_discrete_set, |
| 103 |
values=FREQUENCIES, |
| 104 |
map_values=True) |
| 105 |
|
| 106 |
bias_level = Instrument.setting( |
| 107 |
"BSLV %g", |
| 108 |
""" A floating point value in V that sets the bias voltage level of the |
| 109 |
amplifier, in the [-5V,+5V] limits. |
| 110 |
The values are up to 1 mV precision level.""", |
| 111 |
validator=truncated_range, |
| 112 |
values=BIAS_LIMITS, |
| 113 |
set_process=lambda v: int(1000 * v)) |
| 114 |
|
| 115 |
offset_current = Instrument.setting( |
| 116 |
"BSLV %f", |
| 117 |
""" A floating point value in A that sets the absolute value |
| 118 |
of the offset current of the amplifier, in the [1pA,5mA] limits. |
| 119 |
The offset current takes discrete values in a 1-2-5 sequence. |
| 120 |
Values are truncated to the closest allowed value if not exact. """, |
| 121 |
validator=truncated_discrete_set, |
| 122 |
values=OFFSET_CURRENTS, |
| 123 |
map_values=True) |
| 124 |
|
| 125 |
offset_current_sign = Instrument.setting( |
| 126 |
"IOSN %d", |
| 127 |
""" An string that sets the offset current sign. |
| 128 |
Allowed values are: 'positive' and 'negative'. """, |
| 129 |
validator=strict_discrete_set, |
| 130 |
values={'positive': 1, 'negative': 0}, |
| 131 |
map_values=True) |
| 132 |
|
| 133 |
gain_mode = Instrument.setting( |
| 134 |
"GNMD %d", |
| 135 |
""" A string that sets the gain mode. |
| 136 |
Allowed values are: {}""".format(GAIN_MODES), |
| 137 |
validator=truncated_discrete_set, |
| 138 |
values=GAIN_MODES, |
| 139 |
map_values=True) |
| 140 |
|
| 141 |
invert_signal_sign = Instrument.setting( |
| 142 |
"INVT %d", |
| 143 |
""" An boolean sets the signal invert sense. |
| 144 |
Allowed values are: True (inverted) and False (not inverted). """, |
| 145 |
validator=strict_discrete_set, |
| 146 |
values={True: 1, False: 0}, |
| 147 |
map_values=True) |
| 148 |
|
| 149 |
bias_enabled = Instrument.setting( |
| 150 |
"BSON %d", |
| 151 |
""" Boolean that turns the bias on or off. |
| 152 |
Allowed values are: True (bias on) and False (bias off)""", |
| 153 |
validator=strict_discrete_set, |
| 154 |
values={True: 1, False: 0}, |
| 155 |
map_values=True) |
| 156 |
|
| 157 |
offset_current_enabled = Instrument.setting( |
| 158 |
"IOON %d", |
| 159 |
""" Boolean that turns the offset current on or off. |
| 160 |
Allowed values are: True (current on) and False (current off).""", |
| 161 |
validator=strict_discrete_set, |
| 162 |
values={True: 1, False: 0}, |
| 163 |
map_values=True) |
| 164 |
|
| 165 |
front_blanked = Instrument.setting( |
| 166 |
"BLNK %d", |
| 167 |
""" Boolean that blanks(True) or un-blanks (False) the front panel""", |
| 168 |
validator=strict_discrete_set, |
| 169 |
values={True: 1, False: 0}, |
| 170 |
map_values=True) |
| 171 |
|
| 172 |
signal_inverted = Instrument.setting( |
| 173 |
"INVT %d", |
| 174 |
""" Boolean that inverts the signal if True""", |
| 175 |
validator=strict_discrete_set, |
| 176 |
values={True: 1, False: 0}, |
| 177 |
map_values=True) |
| 178 |
|
| 179 |
#################### |
| 180 |
# Methods # |
| 181 |
#################### |
| 182 |
|
| 183 |
def enable_bias(self): |
| 184 |
"""Turns the bias voltage on""" |
| 185 |
self.bias_enabled = True |
| 186 |
|
| 187 |
def disable_bias(self): |
| 188 |
"""Turns the bias voltage off""" |
| 189 |
self.bias_enabled = False |
| 190 |
|
| 191 |
def enable_offset_current(self): |
| 192 |
""""Enables the offset current """ |
| 193 |
self.offset_current_enabled = True |
| 194 |
|
| 195 |
def disable_offset_current(self): |
| 196 |
""""Disables the offset current """ |
| 197 |
self.offset_current_enabled = False |
| 198 |
|
| 199 |
def clear_overload(self): |
| 200 |
""""Reset the filter capacitors to clear an overload condition""" |
| 201 |
self.write("ROLD") |
| 202 |
|
| 203 |
def blank_front(self): |
| 204 |
""""Blanks the frontend output of the device""" |
| 205 |
self.front_blanked = True |
| 206 |
|
| 207 |
def unblank_front(self): |
| 208 |
"""Un-blanks the frontend output of the device""" |
| 209 |
self.front_blanked = False |