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
|
from qolab.hardware.rf_generator import RFGeneratorSCPI
from qolab.data.trace import Trace
import re
import numpy as np
class AgilentE8257D(RFGeneratorSCPI):
""" Agilent E8257D RF generator """
def __init__(self, resource):
super().__init__(resource)
self.resource.read_termination='\n'
self.config['Device model'] = 'Agilent E8257D'
self.deviceProperties.extend([
'RFPowerState',
'RFAmplitude',
'ModulationState',
'SweepCentralFreq', 'SweepSpan',
])
""" Note: Fixed frequency and Center frequency (of sweep) are different in this model """
def getFreqFixed(self):
qstr = f':FREQuency:Fixed?'
rstr = self.query(qstr)
return( float(rstr) )
def setFreqFixed(self, freq):
cstr = f':FREQuency:FIXED {freq}Hz'
self.write(cstr)
def getSweepCentralFreq(self):
qstr = f':FREQuency:CENTer?'
rstr = self.query(qstr)
return( float(rstr) )
def setSweepCentralFreq(self, cfreq):
cstr = f':FREQuency:CENTer {cfreq}Hz'
self.write(cstr)
def getSweepSpan(self):
qstr = f':FREQuency:SPAN?'
rstr = self.query(qstr)
return( float(rstr) )
def setSweepSpan(self, span):
cstr = f':FREQuency:SPAN {span}Hz'
self.write(cstr)
def setSweep(self, cfreq=None, span=None):
if cfreq is not None:
self.setSweepCentralFreq(cfreq)
if cfreq is not None:
self.setSweepSpan(span)
def getModulationState(self):
return(int(self.query(f':MODulation:STATe?')))
def setModulationState(self, val):
rstr = self.write(f':MODulation:STATe {val}')
def getRFPowerState(self):
return(int(self.query(f':OUTPut:STATe?')))
def setRFPowerState(self, val):
rstr = self.write(f':OUTPut:STATe {val}')
def getRFAmplitude(self):
return(float(self.query(f':POWer:AMPLitude?')))
def seRFAmplitude(self, val):
rstr = self.write(f':POWer:AMPLitude {val}')
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 -------------')
|