comparison rs_fsp7_noisetest.py @ 77:23c96322cfb6

Spell Rohde Schwarz correctly.
author Daniel O'Connor <doconnor@gsoft.com.au>
date Fri, 27 Sep 2024 11:34:16 +0930
parents 91b476ebc0f2
children 4b4ae555067b
comparison
equal deleted inserted replaced
76:e2bb136bd2ed 77:23c96322cfb6
46 46
47 # Convert to dB 47 # Convert to dB
48 rtndb = 10 * math.log10(rtn) 48 rtndb = 10 * math.log10(rtn)
49 49
50 return rtndb 50 return rtndb
51 51
52 def setup(r, freq, span, sweeps, bw): 52 def setup(r, freq, span, sweeps, bw):
53 # Reset to defaults 53 # Reset to defaults
54 r.write("*RST") 54 r.write("*RST")
55 55
56 # Set to single sweep mode 56 # Set to single sweep mode
78 # Set resolution bandwidth 78 # Set resolution bandwidth
79 r.write("SENS1:BAND:RES %f Hz" % (bw)) 79 r.write("SENS1:BAND:RES %f Hz" % (bw))
80 80
81 # Set video bandwidth (10x res BW) 81 # Set video bandwidth (10x res BW)
82 r.write("SENS1:BAND:VID %f Hz" % (bw * 10)) 82 r.write("SENS1:BAND:VID %f Hz" % (bw * 10))
83 83
84 def getnoise(r): 84 def getnoise(r):
85 # Trigger the sweep 85 # Trigger the sweep
86 r.write("INIT;*WAI") 86 r.write("INIT;*WAI")
87 87
88 # Wait for it to be done 88 # Wait for it to be done
89 r.write("*OPC?") 89 r.write("*OPC?")
90 opc = scpi.getdata(r.read(None), int) 90 opc = scpi.getdata(r.read(None), int)
91 #print "OPC - %d" % (opc) 91 #print "OPC - %d" % (opc)
92 assert(opc == 1) 92 assert(opc == 1)
93 93
94 # Set data format 94 # Set data format
95 r.write("FORM:DATA ASC") 95 r.write("FORM:DATA ASC")
96 96
97 # Read noise value 97 # Read noise value
98 r.write("CALC:MARK1:FUNC:NOIS:RES?") 98 r.write("CALC:MARK1:FUNC:NOIS:RES?")
115 ydb = ondb - offdb 115 ydb = ondb - offdb
116 y = 10 ** (ydb / 10) 116 y = 10 ** (ydb / 10)
117 enr = 10 ** (enrdb / 10) 117 enr = 10 ** (enrdb / 10)
118 nf = 10 * math.log10(enr / (y - 1)) 118 nf = 10 * math.log10(enr / (y - 1))
119 return nf 119 return nf
120 120
121 def donoisetest(r, enr): 121 def donoisetest(r, enr):
122 print("Acquiring with noise off..") 122 print("Acquiring with noise off..")
123 setnoise(r, False) 123 setnoise(r, False)
124 off = getnoise(r) 124 off = getnoise(r)
125 print("Acquiring with noise on..") 125 print("Acquiring with noise on..")
126 setnoise(r, True) 126 setnoise(r, True)
127 on = getnoise(r) 127 on = getnoise(r)
128 return off, on, calcnf(enr, off, on) 128 return off, on, calcnf(enr, off, on)
129 129
130 if __name__ == '__main__': 130 if __name__ == '__main__':
131 parser = optparse.OptionParser(usage = '%prog [options] address frequency', 131 parser = optparse.OptionParser(usage = '%prog [options] address frequency',
132 description = 'Configures a Rhode Schwartz FSP7 spectrum analyser to do a noise figure test', 132 description = 'Configures a Rohde Schwarz FSP7 spectrum analyser to do a noise figure test',
133 epilog = 'video bandwidth is set to 10 times the resolution bandwidth') 133 epilog = 'video bandwidth is set to 10 times the resolution bandwidth')
134 parser.add_option('-s', '--span', dest = 'span', default = 1e6, help = 'Span frequency in Hz (default: %default)', type = float) 134 parser.add_option('-s', '--span', dest = 'span', default = 1e6, help = 'Span frequency in Hz (default: %default)', type = float)
135 parser.add_option('-i', '--input', dest = 'input', default = None, help = 'Frequency used to compute ENR (defaults to frequency)', type = float) 135 parser.add_option('-i', '--input', dest = 'input', default = None, help = 'Frequency used to compute ENR (defaults to frequency)', type = float)
136 parser.add_option('-w', '--sweeps', dest = 'sweeps', default = 20, help = 'Number of sweeps (default: %default)', type = int) 136 parser.add_option('-w', '--sweeps', dest = 'sweeps', default = 20, help = 'Number of sweeps (default: %default)', type = int)
137 parser.add_option('-b', '--bw', dest = 'bw', default = 1000, help = 'Resolution bandwidth in Hz (default: %default)', type = float) 137 parser.add_option('-b', '--bw', dest = 'bw', default = 1000, help = 'Resolution bandwidth in Hz (default: %default)', type = float)