-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLockin_SR_class.py
More file actions
38 lines (32 loc) · 1.26 KB
/
Lockin_SR_class.py
File metadata and controls
38 lines (32 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pyvisa
import re
class Lockin:
def __init__(self, gpibport):
rm = pyvisa.ResourceManager()
self.lockin = rm.open_resource(f'GPIB0::{gpibport}::INSTR')
# # get SR name and model (830 / 844). It is important for aux_out !!!!
self.name = self.lockin.query("*IDN?")
match = re.search(r"SR(\d{3})", self.name)
self.model = int(match.group(1))
# self.model = 830
self.state = f'Lock-in is connected. Model {self.model}'
def getXYR(self):
# get X Y R signals from SR844
out_signal = self.lockin.query("SNAP? 1,2,3")
signal = out_signal.split(",")
sigX = float(signal[0])
sigY = float(signal[1])
sigR = float(signal[2])
return [sigX, sigY, sigR]
def set_aux(self, voltage):
if self.model == 844: # check the model number
# set aux_out_1 voltage to SR844
self.lockin.write("AUXO 1, " + str(voltage)) # !!!! SR844 command. SR830 has another string
return voltage
elif self.model == 830: # check the model number
self.lockin.write("AUXV 1, " + str(voltage)) # SR830
return voltage
if __name__ == "__main__":
lia = Lockin(8)
print(lia.state)
print(lia.getXYR())