This section provides information on spectrum trace data and I/Q data via SCPI commands.
Spectrum Trace Data via SCPI
SCPI commands are sent to port 9001 of the instrument. Below is a simple example to capture spectrum trace data.
SENS:FREQ:START 88 MHz SENS:FREQ:STOP 108 MHz
//Set sweep mode
SWEEP:MODE FFT
//Set RBW 30 kHz
BANDWIDTH 30 KHz
//Set Reference Level to -30 dBm
DISP:WIND:TRAC:Y:SCAL:RLEV -30
//Set to single sweep
INIT:CONT OFF
//Get trace amplitude data
TRACE:DATA? 1
//Get number of display points to calculate frequency array
DISP:POIN?
Spectrum Trace Data Format
Trace data uses SCPI standard (IEEE 488.2) block data format. The data format is '#AXD', where D is a comma separated list of amplitudes (in ASCII), X is one or more ASCII digits specifying the number of bytes in D, and A is a single ASCII digit specifying the number of digits in X.
Trace data only contains amplitude. The frequency information for each point is
Frequency = [start_frequency + (span/(display_points-1))*N N = 0, 1, … display_points
Raw Socket Connection
import socket
from time import sleep, time
class SocketConnection:
"""Provides a means to connect and send SCPI commands to the DUT using a raw TCP socket."""
def __init__(self, ipAddress):
"""
Initializes an instance of SocketConnection class
@param ipAddress The IP address of the device
"""
# split out port number if given
splitIpAddress = ipAddress.split(':')
assert len(splitIpAddress) > 0
assert len(splitIpAddress) <= 2
self._ipAddress = splitIpAddress[0]
#assign port
if len(splitIpAddress) == 2:
self._portNumber = int(splitIpAddress[1])
else:
self._portNumber = 9001
self._socketConnection = None
self._timeoutInSec = 120
self._socketReadSize = 4096
self.__nonBulkDataSizeCuttoff = 32768
# Time to let the other end of the connection close
self.__timeoutAfterCloseInSec = 1
self._terminatedBlockResponse = False
self.prefix = ''
self._verbose = False
self._establishConnection()
def __del__(self):
"""
This gets called by the garbage collector so it is possible that the connection will
remain open for a while before this gets collected.
SENS:FREQ:CENTER 100 MHz SENS:FREQ:SPAN 20 MHz SWEEP:MODE FFT //Set RBW 30 kHz BANDWIDTH 30 KHz //Set Reference Level to -30 dBm DISP:WIND:TRAC:Y:SCAL:RLEV -30 //Set to single sweep INIT:CONT OFF //abort any sweep in progress :ABORT
//Set Capture bandwidth. Not same as RBW. IQ:BANDWIDTH 20 MHz
//Set 16 bit resolution IQ:BITS 16
//Set to I/Q block capture mode IQ:MODE SINGLE //enable time stamp SENS:IQ:TIME 1
//Set capture length to 5 msec IQ:LENGTH 5 ms
//Start IQ Capture. Triggers single capture. Data is saved to DDR2 SDRAM memory. MEAS:IQ:CAPT
//Check if capture is completed normally STATus:OPERation?
//The STATus:OPERation? query responds with a integer. Convert this integer to binary. //Bit 9 is set to 1 when the MEAS:IQ:CAPT command is issued. //Bit 9 is set to 0 when the capture is completed normally in block mode.