FAQs from Rohde & Schwarz

How to automatically transfer IQ-data from FSVR Spectrum Analyzer to VSE software - Python example

Question

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.

For more information about remote control of Test & Measurement equipment, please refer to the instruments user manual and R&S website:

https://www.rohde-schwarz.com/driver-pages/remote-control/drivers-remote-control_110753.html

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.90)
  • PyVISA 1.11.3
  • Python 3.9

Author: R&S Support - MP

Updated on 22.01.2021

Version: v1.3

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') # replace by your IP-address
instr.write_termination = '\n'
instr.read_termination = '\n'
instr.timeout = 3000

vse = rm.open_resource('TCPIP::127.0.0.1::INSTR') # do not change localhost
vse.timeout = 3000

vse.write('*RST')
vse.query('*OPC?')
instr.write('*RST')
instr.query('*OPC?')
instr.write('*CLS')

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(f'MMEM:STOR:IQ:STAT 1, "{filePathInstr}"')

# ask for file data from instrument and save to local hard drive
fileData = bytes(instr.query_binary_values(f'MMEM:DATA? "{filePathInstr}"', datatype='s'))
newFile = open(filePathPc, "wb")
newFile.write(fileData)
newFile.close()

print(instr.query('SYST:ERR?'))

instr.close()

# load file into VSE software
vse.write(f'MMEM:LOAD:IQ:STAT 1, "{filePathPc}"')

vse.close()

Name
Type
Version
Date
Size
FSVR IQ-data-transfer 1-3
Type
FAQ
Version
Date
04-Feb-2021
Size
54 kB