changeset 51:03b06d71f0fd

Allow bandwith to be set (maintains a 10:1 ratio of vid:res BW)
author Daniel O'Connor <doconnor@gsoft.com.au>
date Thu, 21 Mar 2013 11:11:10 +1030
parents d143ef509fb7
children c1891d9074c1
files rs_fsp7_noisetest.py
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rs_fsp7_noisetest.py	Thu Jan 31 13:00:11 2013 +1030
+++ b/rs_fsp7_noisetest.py	Thu Mar 21 11:11:10 2013 +1030
@@ -49,7 +49,7 @@
 
     return rtndb
     
-def setup(r, freq, span, sweeps):
+def setup(r, freq, span, sweeps, bw):
     # Reset to defaults
     r.write("*RST")
 
@@ -76,10 +76,10 @@
     r.write("SWE:COUN %d" % (sweeps))
 
     # Set resolution bandwidth
-    r.write("SENS1:BAND:RES 1kHz")
+    r.write("SENS1:BAND:RES %f Hz" % (bw))
 
     # Set video bandwidth (10x res BW)
-    r.write("SENS1:BAND:VID 10kHz")
+    r.write("SENS1:BAND:VID %f Hz" % (bw * 10))
     
 def getnoise(r):
     # Trigger the sweep
@@ -87,7 +87,7 @@
 
     # Wait for it to be done
     r.write("*OPC?")
-    opc = scpi.getdata(r.read(60), int)
+    opc = scpi.getdata(r.read(None), int)
     #print "OPC - %d" % (opc)
     assert(opc == 1)
     
@@ -132,6 +132,7 @@
     parser.add_option('-s', '--span', dest = 'span', default = 1e6, help = 'Span frequency (Hz)', type = float)
     parser.add_option('-i', '--input', dest = 'input', default = None, help = 'Input frequency (Hz) for down converters', type = float)
     parser.add_option('-w', '--sweeps', dest = 'sweeps', default = 20, help = 'Number of sweeps', type = int)
+    parser.add_option('-b', '--bw', dest = 'bw', default = 1000, help = 'Bandwidth (Hz)', type = float)
 
     (options, args) = parser.parse_args()
 
@@ -158,11 +159,11 @@
     print "ID is " + r.read(5)
 
     # Setup parameters
-    setup(r, freq, options.span, options.sweeps)
+    setup(r, freq, options.span, options.sweeps, options.bw)
 
     r.write("INIT:CONT OFF")
 
-    print "Centre: %.1f Mhz, Span %.1f Mhz, Input %.1f MHz, %d sweeps, ENR %.2f dB" % (freq / 1e6, options.span / 1e6, options.input / 1e6, options.sweeps, enr)
+    print "Centre: %.1f Mhz, Span %.1f Mhz, Input %.1f MHz, BW %.1f kHz, %d sweeps, ENR %.2f dB" % (freq / 1e6, options.span / 1e6, options.input / 1e6, options.bw / 1e3, options.sweeps, enr)
     while True:
         off, on, nf = donoisetest(r, enr)
         print "Off %.3f dBm/Hz, on %.3f dBm/Hz, NF %.2f dB" % (off, on, nf)