""" This simple Python example shows how to tranfer an IQ-data file from Spectrum Analyzer to the controller PC and open it with VSE signal analysis software. Tested with FSVR Real-Time Spectrum Analyzer. Updated on 24.03.2020 """ import pyvisa rm = pyvisa.ResourceManager() instr = rm.open_resource('TCPIP::192.168.0.1::INSTR') # replace by your IP-address instr.timeout = 10*1000 vse = rm.open_resource('TCPIP::127.0.0.1::INSTR') # do not change localhost vse.timeout = 10*1000 vse.write('*RST') instr.write('*RST') instr.write('*CLS') print(instr.query('*IDN?')) instr.write('FREQ:CENT 1e9') instr.write('INIT:CONT OFF') instr.write('TRACe1:IQ ON') instr.write('TRACe1:IQ:SRAT 32 MHZ') instr.write('TRACe1:IQ:RLEN 691') # Range: 1 ... 209715200(200*1024*1024) instr.write('INIT') instr.query('*OPC?') print(instr.query('SYST:ERR?')) # save IQ-data file on instrument hard drive instr.write('MMEM:STOR:IQ:STAT 1, \'C:\\temp\\data.iq.tar\'') PCfilePath = r'c:\Temp\data.iq.tar' query = 'MMEM:DATA? \'c:\\temp\\data.iq.tar\'' # ask for file data from instrument and save to local hard drive fileData = instr.query_binary_values(query, datatype='s')[0] newFile = open(PCfilePath, "wb") newFile.write(fileData) newFile.close() instr.close() # load file into VSE software vse.write('MMEM:LOAD:IQ:STAT 1, \'C:\\temp\\data.iq.tar\'') vse.close()