-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSRS.py
94 lines (86 loc) · 3.86 KB
/
SRS.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import time
import numpy as np
import socket
from serial import Serial
from pyscpi.SCPI import SCPI_parameter,GeneratorBase
import visa
class SRS_DS345(GeneratorBase):
frequency = SCPI_parameter('FREQ', data_type=float) #Frequency
power = SCPI_parameter('AMPL',data_type=float,units='DB') #Amplitude of RF (Type-N Output) in dBm
temperature = SCPI_parameter('TEMP',read_only=True,data_type=float) #tempearture
output_en = SCPI_parameter('ENBR', restrict_values=(0,1),data_type=int) # On/Off
has_list_mode = False
has_fm_modulation = False
open_resource_kwargs = dict(read_termination='\r\n')
def __init__(self, **kwargs):
super(SRS_DS345,self).__init__(**kwargs)
self.dev.timeout=2000
def FMext(self,val):
if abs(val)>1e2:
raise NotImplemented
class SRS_SG382(GeneratorBase):
rm = visa.ResourceManager()
has_fm_modulation = True
has_list_mode = False
frequency = SCPI_parameter('FREQ', data_type=float) #Frequency
power = SCPI_parameter('AMPR',data_type=float) #Amplitude of RF (Type-N Output) in dBm
power_bnc = SCPI_parameter('AMPL',data_type=float) #Amplitude of LF (BNC Output) in dBm
temperature = SCPI_parameter('TEMP',read_only=True,data_type=float) #tempearture
output_en = SCPI_parameter('ENBR', restrict_values=(0,1),data_type=int) # On/Off
mod_dccouple = SCPI_parameter('COUP', restrict_values=(0,1),data_type=int) # DC copling, recomended value is 1
mod_type = SCPI_parameter('TYPE', restrict_values=(0,1,2,3,4,5,6),data_type=int) #Modulation Type AM/FM/ΦM/Sweep/Pulse/Blank/IQ (if option 3 is installed)
mod_rate = SCPI_parameter('RATE',data_type=float) #Modulation Rate for AM/FM/ΦM
mod_fdev = SCPI_parameter('FDEV',data_type=float) #FM Deviation
mod_en = SCPI_parameter('MODL', data_type=int , restrict_values=(0,1)) # modulation disabled/enable
mod_func = SCPI_parameter('MFNC', data_type=int , restrict_values=(0,1,2,3,4,5)) # modulation function : Sine/Ramp/Triangle/Square/Noise/EXT
def __init__(self,**kwargs):
super(SRS_SG382, self).__init__(**kwargs)
def Temp(self):
return self.temp
def mod_rate_(self):
# return self.dev.ask('RATE?')
return self.mod_rate
def mod_depth_(self):
return self.mod_fdev
def FMext(self, depth):
if depth==0:
# self.dev.write('FDEV 0')
# self.dev.write('MODL 0') # modulation disabled
self.mod_fdev = 0
self.mod_en = 0
else:
# self.dev.write('FDEV {0}'.format(depth))
# self.dev.write('COUP 1') # DC coupling
# self.dev.write('MFNC 5') # External
# self.dev.write('MODL 1') # modulation enabled
# self.dev.write('TYPE 1') # modulation enabled
self.mod_fdev = depth
self.mod_dccouple = 1 #DC
self.mod_func = 5 #EXT
self.mod_en = 1 #Enable modulation
self.mod_type = 1 #FM
def FMint(self, freq, depth):
self.mod_fdev = depth
self.mod_func = 0
self.mod_rate = freq
self.mod_type = 1
# self.dev.write('FDEV {0}'.format(depth))
# self.dev.write('MFNC 0') # internal modulation Sine
# self.dev.write('RATE {0}'.format(freq))
# self.dev.write('TYPE 1') # modulation enabled
def CW(self, freq = None, power = None):
"""
states freq and power and makes CW regime
:param freq:
:param power:
:return:
"""
if freq is not None:
self.frequency = freq
if power is not None:
self.power = power
if freq is None and power is None:
self.output_en = 0
else:
self.output_en = 1
return