SCPI commands are sent to port 9001 of the instrument. Command statements read from left to right and from top to bottom. In the command statement below, the :FREQuency keyword immediately follows the :SENSe keyword with no separating space. A space is used between the command string and its argument.
The following command syntax all produce the same result:
:SENSe:FREQuency:STARt 1 MHZ
:SENS:FREQ:STAR 1 MHZ
:sense:frequency:start 1000000
:FREQ:STAR 1000 KHZ
Note
Note that the first keyword in the command string does not require a leading colon; however, it is good practice to always use a leading colon for all keywords. Note also that the :SENSe keyword is optional. This is a SCPI convention for all voltage or signal source type instruments that allows shorter command statements to be used.
The first two commands below set the location of marker 1, the third command sets the location of marker 2:
:CALC:MARK:X 1 GHZ
:CALC:MARK1:X 1 GHZ
:CALC:MARK2:X 2ghz
:UNIT:POWer <DBM|DBUV>
The following command syntax is identical:
:UNIT:POWer DBM
:unit:pow dbm
:INITiate:CONTinuous <0|1|ON|OFF>
The following commands are identical:
:INITiate:CONTinuous OFF
:init:cont 0
The following is an example of a multiple command statement that uses two separate commands in a single program line:
:FREQuency:STARt 10E6;:FREQuency:STOP 20E9
Note
A semicolon is used to join the commands and a leading colon used immediately after the semicolon to start the second command.
Application Mode Switching
This section provides abbreviated examples of switching between measurement applications and modes via SCPI commands. SCPI commands are sent to port 9001 of the instrument.
//Turn off all Apps:
INST:APPL:STAT SPA, 0
INST:APPL:STAT HIPM, 0
INST:APPL:STAT CAAUSB, 0
//Turn on HIPM:
INST:APPL:STAT HIPM, 1
//Wait 18 seconds
inst:nsel?
//Turn on CAAUSB:
w:INST:APPL:STAT CAAUSB, 1
//Wait 25 seconds
inst:nsel?
//Turn on SPA:
INST:APPL:STAT SPA, 1
//Wait 33 seconds
inst:nsel?
Spectrum Trace Data via SCPI
This section provides an abbreviated example of setting up and capturing spectrum trace data via SCPI commands. SCPI commands are sent to port 9001 of the instrument.
//Set the Start and Stop Frequencies
SENS:FREQ:STAR 88 MHz SENS:FREQ:STOP 108 MHz
//Set the RBW to 30 kHz
BAND:RES 30 KHz
//Set the 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?
C/C++
This example is run on the command line using the USBTMC interface. It sends the *IDN? query to the instrument and prints the response to the console.
// IdnExample.cpp : Microsoft Visual Studio-Generated Example
"""Closes the socket connection and asserts that it closed. This informs the other end of the socket that it should close but it may take some time depending on implementation, network conditions, etc."""
if self._socketConnection is not None:
self._socketConnection.shutdown(socket.SHUT_RDWR)
self._socketConnection.close()
self._socketConnection = None
sleep(self.__timeoutAfterCloseInSec)
assert self._socketConnection is None, "Socket connection not closed"
def _getBlockDataResponse(self):
""" Receives a SCPI block data response of the form 'AXD' where A is a single ASCII byte specifying the number of digits in X, X is one or more ASCII bytes specifying the number of bytes in D, and D is one or more bytes containing the response binary data."""
print("Read bytes of block data: ", len(readBuffer))
return readBuffer
def reset(self, delay_seconds=-1):
"""Resets the established connection @param delay_seconds: Wait time between closing the connection and attempting tore-establish the connection. This is useful when rebooting an instrument."""
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. [:SENSe]:IQ:SAMPle SB2
//Set 16 bit resolution IQ:BITS I16
//Set to IQ 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.
IQ Capture Data to Absolute Power Level
This is a sample Matlab/Octave program that shows how Raw IQ capture data can be related to an Absolute power level.
%Copy data into captureData array
%Separate the data and build the complex IQ vector.