Answer
This Python example shows how to transfer 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 (FW: 2.23 SP1)
- VSE Software (1.70)
- PyVISA 1.10.1
Author: R&S Support
Updated on 09.04.2020
Version: v1.2
Technical support -> https://www.rohde-schwarz.com/support
Before running, please always check this script for unsuitable setting !
This example does not claim to be complete. All information have been
compiled with care. However, errors can’t be ruled out.
import pyvisa
rm = pyvisa.ResourceManager()
# adjust the VISA Resource string to fit your instrument
instr = rm.open_resource('TCPIP::192.168.0.1::INSTR')
instr.timeout = 3000
vse = rm.open_resource('TCPIP::127.0.0.1::INSTR') # do not change localhost
vse.timeout = 3000
vse.write('*RST')
instr.write('*RST')
instr.write('*CLS')v
instr.write('INIT:CONT OFF')
print('\n' + instr.query('*IDN?'))
instr.write('FREQ:CENT 1e9')
instr.write('DISP:TRAC:Y:RLEV 0')
instr.write('TRAC1:IQ ON')
instr.write('TRAC1:IQ:SRAT 32 MHZ')
instr.write('TRAC1:IQ:RLEN 691') # Range: 1 ... 209715200(200*1024*1024)
instr.query('*OPC?')
filePathPc = r"c:\temp\data.iq.tar"
filePathInstr = r"c:\temp\dev_data.iq.tar"
instr.write('INIT')
instr.query('*OPC?'
# save IQ-data file on instrument hard drive
instr.write('MMEM:STOR:IQ:STAT 1, "{}"'.format(filePathInstr))
# ask for file data from instrument and save to local hard drive
fileData = instr.query_binary_values('MMEM:DATA? "{}"'.format(filePathInstr), datatype='s')[0]
newFile = open(filePathPc, "wb")
newFile.write(fileData)
newFile.close()
print(instr.query('SYST:ERR?'))
instr.close()
# load file into VSE software
vse.write('MMEM:LOAD:IQ:STAT 1, "{}"'.format(filePathPc))
vse.close()