Debian Codegraph @

pymeasure/instruments/signalrecovery/dsp7265.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 # Libraries / modules
27 # =============================================================================
28
29 from .dsp_base import DSPBase
30 from pymeasure.instruments import Instrument
31 from pymeasure.instruments.validators import strict_range
32 import logging
33 from time import sleep
34
35 # =============================================================================
36 # Logging
37 # =============================================================================
38
39 log = logging.getLogger(__name__)
40 log.addHandler(logging.NullHandler())
41
42
43 # =============================================================================
44 # Instrument file
45 # =============================================================================
46
47
48 class DSP7265(DSPBase):
49 """Represents the Signal Recovery DSP 7265 lock-in amplifier.
50
51 Class inherits commands from the DSPBase parent class and utilizes dynamic
52 properties for various properties and includes additional functionality.
53
54 .. code-block:: python
55
56 lockin7265 = DSP7265("GPIB0::12::INSTR")
57 lockin7265.imode = "voltage mode" # Set to measure voltages
58 lockin7265.reference = "internal" # Use internal oscillator
59 lockin7265.fet = 1 # Use FET pre-amp
60 lockin7265.shield = 0 # Ground shields
61 lockin7265.coupling = 0 # AC input coupling
62 lockin7265.time_constant = 0.10 # Filter time set to 100 ms
63 lockin7265.sensitivity = 2E-3 # Sensitivity set to 2 mV
64 lockin7265.frequency = 100 # Set oscillator frequency to 100 Hz
65 lockin7265.voltage = 1 # Set oscillator amplitude to 1 V
66 lockin7265.gain = 20 # Set AC gain to 20 dB
67 print(lockin7265.x) # Measure X channel voltage
68 lockin7265.shutdown() # Instrument shutdown
69
70 """
71
72 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 # Dynamic values - Override base class validator values
74 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75
76 frequency_values = [0.001, 2.5e5]
77 harmonic_values = [1, 65535]
78 curve_buffer_bit_values = [1, 2097151]
79
80 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81 # Constants
82 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83
84 CURVE_BITS = ['x', 'y', 'magnitude', 'phase', 'sensitivity', 'adc1',
85 'adc2', 'adc3', 'dac1', 'dac2', 'noise', 'ratio', 'log ratio',
86 'event', 'frequency part 1', 'frequency part 2',
87 # Dual modes
88 'x2', 'y2', 'magnitude2', 'phase2', 'sensitivity2']
89
90 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91 # Initializer
92 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93
94 def __init__(self, adapter, name="Signal Recovery DSP 7265", **kwargs):
95 super().__init__(
96 adapter,
97 name,
98 **kwargs
99 )
100
101 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102 # Additional properties
103 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104
105 dac3 = Instrument.control(
106 "DAC. 3", "DAC. 3 %g",
107 """Control the voltage of the DAC3 output on the rear panel.
108
109 Valid values are floating point numbers between -12 to 12 V.
110 """,
111 validator=strict_range,
112 values=[-12, 12]
113 )
114
115 dac4 = Instrument.control(
116 "DAC. 4", "DAC. 4 %g",
117 """Control the voltage of the DAC4 output on the rear panel.
118
119 Valid values are floating point numbers between -12 to 12 V.
120 """,
121 validator=strict_range,
122 values=[-12, 12]
123 )
124
125 @property
126 def adc3(self):
127 """Measure the ADC3 input voltage."""
128 # 50,000 for 1V signal over 1 s
129 integral = self.values("ADC 3")[0]
130 return integral / (50000.0 * self.adc3_time)
131
132 @property
133 def adc3_time(self):
134 """Control the ADC3 sample time in seconds."""
135 # Returns time in seconds
136 return self.values("ADC3TIME")[0] / 1000.0
137
138 @adc3_time.setter
139 def adc3_time(self, value):
140 # Takes time in seconds
141 self.write("ADC3TIME %g" % int(1000 * value))
142 sleep(value * 1.2)