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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
from qolab.hardware.basic import BasicInstrument
from qolab.hardware.rf_generator import RFGeneratorSCPI
class AgilentE8257D(RFGeneratorSCPI):
""" Agilent E8257D RF generator """
def __init__(self, resource, *args, **kwds):
super().__init__(resource, *args, **kwds)
self.resource.read_termination='\n'
self.config['Device model'] = 'Agilent E8257D'
self.deviceProperties.update({
'RFPowerState',
'RFAmplitude',
'ModulationState',
'FM1State',
'FM1Source',
'FM1ModulationDepth',
'FM2State',
'FM2Source',
'FM2ModulationDepth',
'FrequencyMode', # sweep or continious
'SweepCentralFreq', 'SweepSpan',
})
""" Note: Fixed frequency and Center frequency (of sweep) are different in this model """
@BasicInstrument.tsdb_append
def getFreqFixed(self):
qstr = f':FREQuency:Fixed?'
rstr = self.query(qstr)
return( float(rstr) )
@BasicInstrument.tsdb_append
def setFreqFixed(self, freq):
cstr = f':FREQuency:FIXED {freq}Hz'
self.write(cstr)
@BasicInstrument.tsdb_append
def getSweepCentralFreq(self):
qstr = f':FREQuency:CENTer?'
rstr = self.query(qstr)
return( float(rstr) )
@BasicInstrument.tsdb_append
def setSweepCentralFreq(self, cfreq):
cstr = f':FREQuency:CENTer {cfreq}Hz'
self.write(cstr)
@BasicInstrument.tsdb_append
def getSweepSpan(self):
qstr = f':FREQuency:SPAN?'
rstr = self.query(qstr)
return( float(rstr) )
@BasicInstrument.tsdb_append
def setSweepSpan(self, span):
cstr = f':FREQuency:SPAN {span}Hz'
self.write(cstr)
@BasicInstrument.tsdb_append
def setSweep(self, cfreq=None, span=None):
if cfreq is not None:
self.setSweepCentralFreq(cfreq)
if cfreq is not None:
self.setSweepSpan(span)
@BasicInstrument.tsdb_append
def getModulationState(self):
return(int(self.query(f':MODulation:STATe?')))
@BasicInstrument.tsdb_append
def setModulationState(self, val):
rstr = self.write(f':MODulation:STATe {val}')
@BasicInstrument.tsdb_append
def getRFPowerState(self):
return(int(self.query(f':OUTPut:STATe?')))
@BasicInstrument.tsdb_append
def setRFPowerState(self, val):
rstr = self.write(f':OUTPut:STATe {val}')
@BasicInstrument.tsdb_append
def getRFAmplitude(self):
return(float(self.query(f':POWer:AMPLitude?')))
@BasicInstrument.tsdb_append
def setRFAmplitude(self, val):
rstr = self.write(f':POWer:AMPLitude {val}')
@BasicInstrument.tsdb_append
def getFM1ModulationDepth(self):
return(float(self.query(f':FM1:Deviation?')))
@BasicInstrument.tsdb_append
def setFM1ModulationDepth(self, val):
rstr = self.write(f':FM1:Deviation {val}')
@BasicInstrument.tsdb_append
def getFM2ModulationDepth(self):
return(float(self.query(f':FM2:Deviation?')))
@BasicInstrument.tsdb_append
def setFM2ModulationDepth(self, val):
rstr = self.write(f':FM2:Deviation {val}')
@BasicInstrument.tsdb_append
def getFM1Source(self):
return(str(self.query(f':FM1:Source?')))
@BasicInstrument.tsdb_append
def setFM1Source(self, val):
rstr = self.write(f':FM1:Source {val}')
@BasicInstrument.tsdb_append
def getFM2Source(self):
return(str(self.query(f':FM2:Source?')))
@BasicInstrument.tsdb_append
def setFM2Source(self, val):
rstr = self.write(f':FM2:Source {val}')
@BasicInstrument.tsdb_append
def getFM1State(self):
return(int(self.query(f':FM1:State?')))
@BasicInstrument.tsdb_append
def setFM1State(self, val):
rstr = self.write(f':FM1:State {val}')
@BasicInstrument.tsdb_append
def getFM2State(self):
return(int(self.query(f':FM2:State?')))
@BasicInstrument.tsdb_append
def setFM2State(self, val):
rstr = self.write(f':FM2:State {val}')
@BasicInstrument.tsdb_append
def getFrequencyMode(self):
return(str(self.query(f':Frequency:Mode?')))
@BasicInstrument.tsdb_append
def setFrequencyMode(self, val):
rstr = self.write(f':Frequency:Mode {val}')
@BasicInstrument.tsdb_append
def startFrequencySweep(self):
self.setFrequencyMode('Sweep')
def stopFrequencySweep(self):
self.setFrequencyMode('FIXED')
if __name__ == '__main__':
import pyvisa
print("testing")
rm = pyvisa.ResourceManager()
print(rm.list_resources())
instr=rm.open_resource('TCPIP::192.168.0.114::INSTR')
rfgen = AgilentE8257D(instr)
print('------ Header start -------------')
print(str.join('\n', rfgen.getHeader()))
print('------ Header ends -------------')
|