Debian Codegraph @

pymeasure/instruments/srs/sr510.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 from pymeasure.instruments import Instrument
26 from pymeasure.instruments.validators import truncated_range, truncated_discrete_set
27
28
29 class SR510(Instrument):
30 TIME_CONSTANTS = {1e-3: 1, 3e-3: 2, 10e-3: 3, 30e-3: 4, 100e-3: 5,
31 300e-3: 6, 1: 7, 3: 8, 10: 9, 30: 10, 100: 11, }
32
33 SENSITIVITIES = {10e-9: 1, 20e-9: 2, 50e-9: 3, 100e-9: 4, 200e-9: 5, 500e-9: 6,
34 1e-6: 7, 2e-6: 8, 5e-6: 9, 10e-6: 10, 20e-6: 11, 50e-6: 12, 100e-6: 13,
35 200e-6: 14, 500e-6: 15, 1e-3: 16, 2e-3: 17, 5e-3: 18, 10e-3: 19, 20e-3: 20,
36 50e-3: 21, 100e-3: 22, 200e-3: 23, 500e-3: 24, }
37
38 phase = Instrument.control(
39 "P", "P %g",
40 """A float property that represents the SR510 reference to input
41 phase offset in degrees. Queries return values between -180 and
42 180 degrees. This property can be set with a range of values
43 between -999 to 999 degrees. Set values are mapped internal in the
44 lockin to -180 and 180 degrees.""",
45 validator=truncated_range,
46 values=[-999, 999],
47 )
48
49 time_constant = Instrument.control(
50 "T1", "T1,%d",
51 """A float property that represents the SR510 PRE filter time constant.
52 This property can be set.""",
53 validator=truncated_discrete_set,
54 values=TIME_CONSTANTS,
55 map_values=True,
56 )
57
58 sensitivity = Instrument.control(
59 "G", "G%d",
60 """A float property that represents the SR510 sensitivity value.
61 This property can be set.""",
62 validator=truncated_discrete_set,
63 values=SENSITIVITIES,
64 map_values=True,
65 )
66
67 frequency = Instrument.measurement(
68 "F",
69 """A float property representing the SR510 input reference frequency""",
70 )
71
72 status = Instrument.measurement(
73 "Y",
74 """A string property representing the bits set within the SR510 status byte""",
75 get_process=lambda s: bin(int(s))[2:],
76 )
77
78 output = Instrument.measurement(
79 "Q",
80 """A float property that represents the SR510 output voltage in Volts.""",
81 )
82
83 def __init__(self, adapter, name="Stanford Research Systems SR510 Lock-in amplifier",
84 **kwargs):
85 kwargs.setdefault('write_termination', '\r')
86 super().__init__(
87 adapter,
88 name,
89 includeSCPI=False,
90 **kwargs,
91 )