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.
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."""