If it helps, here's a simple python script that works with my CMU200:
David
#!/usr/bin/python
import serial
import time
real = True
echo = True
if real:
s = serial.Serial('/dev/ttyUSB0', 115200, timeout=3, xonxoff=False) #might need to add enable control settings
def cmd(cmd_string):
if echo:
print cmd_string
if real:
s.write(cmd_string + '\n')
#s.readline() #unclear if this is needed
def query(query_string):
if echo:
print query_string
if real:
s.write(query_string + '\n')
result = s.readline()
if echo:
print "-> " + result
return result
#MAIN
#sweep settings (MHz)
freq_start = 900
freq_end = 999
query("*IDN?")
query("*RST;*OPC?")
cmd("*SEC 0")
cmd("SYST:NONV:DIS") #disable NVRAM, manual says this is important for performance
cmd("*SEC 1")
#set input and output connectors
cmd("INP RF4")
cmd("OUTP RF2")
#setup generator
#cmd("SOURce:RFGenerator:TX:FREQuency 1MHZ")
cmd("SOUR:RFG:TX:FREQ %dE6" % freq_start) #default level is -27dBm
query("INIT:RFG;*OPC?")
#exit()
#setup analyzer either NPOW or POW, TBD
#TODO Set BW, delay, measurement time, etc. here
#cmd("LEV:MAX 0")
#cmd("CONF:POW:CONT SCAL,NONE") #might not want this
#cmd("CONF:SUB:POW IVAL,0,1")
cmd("RFAN:BAND 1000e3")
cmd("INIT:RFAN") #unclear if I need this, it's in the example
#cmd("INIT:WPOW")
t1 = time.time()
for f in range(freq_start,freq_end):
#cmd("POW:FREQ:CENT %dE6" % f)
cmd("RFAN:FREQ %dE6" % f)
cmd("SOUR:RFG:FREQ %dE6;*WAI" % f)
#query("SOUR:RFG:FREQ %dE6;*OPC?" % f)
#query("READ:SUB:POW?") #may not work with SCAL
query("READ:RFAN:POW?")
#query("READ:WPOW?")
t2 = time.time()
print "%0.3fs for %d points, %f points/s" % (t2-t1, freq_end-freq_start, (freq_end-freq_start)/(t2-t1))