Programming with SCPI : SCPI Command Programming Examples
 
SCPI Command Programming Examples
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 arguments.
Notational Examples
[:SENSe]:FREQuency:STARt <numeric_value>{HZ|KHZ|MHZ|GHZ}
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.
:CALCulate:MARKer{[1]|2|3|4|5|6|7|8|9|10|11|12}:X <numeric_value>{HZ|KHZ|MHZ|GHZ}
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 59001 of the local PC.
//Set the Start and Stop Frequencies
SENS:FREQ:START 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?