Introduction to SCPI Language

34980A

Introduction to the SCPI Language

SCPI (Standard Commands for Programmable Instruments) is an ASCII-based instrument command language designed for test and measurement instruments. SCPI commands are based on a hierarchical structure, also known as a tree system. In this system, associated commands are grouped together under a common node or root, thus forming subsystems. A portion of the SENSe subsystem is shown below to illustrate the tree system.

SENSe:
         VOLTage:
                  DC:RANGe {<range>|MIN|MAX}[,(@<ch_list>)]
                  DC:RANGe? [(@<ch_list>)|MIN|MAX}]

         RESistance:
                  OCOMpensated {OFF|0|ON|1}[,(@<ch_list>)]
                  OCOMpensated? [(@<ch_list>)]

         TEMPerature:
                  RJUNction? [(@<ch_list>)]

SENSe is the root keyword of the command, VOLTage and RESistance are second-level keywords, and DC and OCOMpensated are third-level keywords. A colon ( : ) separates a command keyword from a lower-level keyword.

Syntax Conventions

The format used to show commands is illustrated below:

VOLTage:DC:RANGe {<range>|MIN|MAX}[,(@<ch_list>)]

The command syntax shows most commands (and some parameters) as a mixture of upper- and lower-case letters. The upper-case letters indicate the abbreviated spelling for the command. For shorter program lines, you can send the abbreviated form. For better program readability, you can send the long form.

For example, in the above syntax statement, VOLT and VOLTAGE are both acceptable forms. You can use upper- or lower-case letters. Therefore, VOLTAGE, volt, and Volt are all acceptable. Other forms, such as VOL and VOLTAG, are not valid and will generate an error.

  • Braces ( { } ) enclose the parameter choices for a given command string. The braces are not sent with the command string.

  • A vertical bar ( | ) separates multiple parameter choices for a given command string.

  • Triangle brackets ( < > ) indicate that you must specify a value for the enclosed parameter. For example, the above syntax statement shows the <range> parameter enclosed in triangle brackets. The brackets are not sent with the command string. You must specify a value for the parameter (e.g., "VOLT:DC:RANG 10").

  • Some parameters are enclosed in square brackets ( [ ] ). This indicates that the parameter is optional and can be omitted. The brackets are not sent with the command string. If you do not specify a value for an optional parameter, the instrument chooses a default value.

Command Separators

A colon ( : ) is used to separate a command keyword from a lower-level keyword. You must insert a blank space to separate a parameter from a command keyword. If a command requires more than one parameter, you must separate adjacent parameters using a comma as shown below:

"CONF:VOLT:DC 10,0.003"

A semicolon ( ; ) is used to separate commands within the same subsystem, and can also minimize typing. For example, sending the following command string:

"TRIG:SOUR EXT; COUNT 10"

... is the same as sending the following two commands:

"TRIG:SOUR EXT"
"TRIG:COUNT 10"

Use a colon and a semicolon to link commands from different subsystems. For example, in the following command string, an error is generated if you do not use both the colon and semicolon:

"ROUT:CHAN:DELAY 1;:TRIG:SOUR EXT"

Using the MIN and MAX Parameters

For many commands, you can substitute "MIN" or "MAX" in place of a parameter. For example, consider the following command:

VOLTage:DC:RANGe {<range>|MIN|MAX}[,(@<ch_list>)]

Instead of selecting a specific value for the <range> parameter, you can substitute MIN to set the range to its minimum value or MAX to set the range to its maximum value.

Querying Parameter Settings

You can query the current value of most parameters by adding a question mark ( ) to the command. For example, the following command sets the scan count to 10 sweeps:

"TRIG:COUNT 10"

You can then query the scan count value by sending:

"TRIG:COUNT?"

You can also query the minimum or maximum scan count allowed as follows:

"TRIG:COUNT? MIN"
"TRIG:COUNT? MAX"

SCPI Command Terminators

A command string sent to the instrument must terminate with a <new line> (<NL>) character. The IEEE-488 EOI (End-Or-Identify) message is interpreted as a <NL> character and can be used to terminate a command string in place of a <NL> character. A <carriage return> followed by a <NL> is also accepted. Command string termination will always reset the current SCPI command path to the root level.

IEEE-488.2 Common Commands

The IEEE-488.2 standard defines a set of common commands that perform functions such as reset, self-test, and status operations. Common commands always begin with an asterisk ( * ), are three characters in length, and may include one or more parameters. The command keyword is separated from the first parameter by a blank space. Use a semicolon ( ; ) to separate multiple commands as shown below:

"*RST; *CLS; *ESE 32; *OPC?"

SCPI Parameter Types

The SCPI language defines several data formats to be used in program messages and response messages.

Numeric Parameters

Commands that require numeric parameters will accept all commonly used decimal representations of numbers including optional signs, decimal points, and scientific notation. Special values for numeric parameters such as MIN, MAX, and DEF are also accepted. You can also send engineering unit suffixes with numeric parameters (e.g.,  M, K, or u). If only specific numeric values are accepted, the instrument will automatically round the input numeric parameters. The following command requires a numeric parameter for the range value:

VOLTage:DC:RANGe {<range>|MIN|MAX}[,(@<ch_list>)]

Discrete Parameters

Discrete parameters are used to program settings that have a limited number of values (like BUS, IMMediate, EXTernal). They have a short form and a long form just like command keywords. You can mix upper- and lower-case letters. Query responses will always return the short form in all upper-case letters. The following command requires a discrete parameter for the temperature units:

UNIT:TEMPerature {C|F|K}[,(@<ch_list>)]

Boolean Parameters

Boolean parameters represent a single binary condition that is either true or false. For a false condition, the instrument will accept "OFF" or "0". For a true condition, the instrument will accept "ON" or "1". When you query a boolean setting, the instrument will always return "0" or "1". The following command requires a boolean parameter:

INPut:IMPedance:AUTO {OFF|0|ON|1}[,(@<ch_list>)]

ASCII String Parameters

String parameters can contain virtually any set of ASCII characters. A string must begin and end with matching quotes; either with a single quote or a double quote. You can include the quote delimiter as part of the string by typing it twice without any characters in between. The following command uses a string parameter:

DISPlay:TEXT <quoted string>

For example, the following command displays the message "SCANNING..." on the instrument's front panel (the quotes are not displayed).

DISP:TEXT "SCANNING..."

You can also display the same message using the following command with single quotes.

DISP:TEXT 'SCANNING...'

Channel List Parameters

Channel list parameters have the form (@sccc), where s is the mainframe slot number (1 through 8) and ccc is the channel number. You can specify a single channel, multiple channels, or a range of channels. The channel list must be preceded with the "@" symbol and must be enclosed in parentheses. The following commands use a channel list (<ch_list>) parameter:

ROUTe:CLOSe (@<ch_list>)

INPut:IMPedance:AUTO <mode> [, (@<ch_list>)]

As shown above, the <ch_list> parameter is optional for some commands (as indicated by square brackets). If you omit the <ch_list> parameter, the command will be applied to the internal DMM.

The following command closes channel 10 on the module in slot 3.

ROUT:CLOS (@3010)

The following command closes channels 10, 12, and 15 on the module in slot 2.  

ROUT:CLOS (@2010,2012,2015)

The following command closes channels 5 through 10 (slot 1) and channel 15 (slot 2). When you specify a range of channels, any channels that are invalid will be ignored (no error will be generated) but the first and last channel in the range must be valid.

ROUT:CLOS (@1005:1010,2015)

The Analog Bus relays (numbered s911, s912, s913, etc.) on the multiplexer and matrix modules are ignored if they are included in a range of channels. An error will be generated if an Analog Bus relay is specified as the first or last channel in a range of channels. For example, the following command closes all valid channels between channel 30 (slot 1) and channel 5 (slot 2). In addition, this command closes Analog Bus relay 911 on the module in slot 1 (Bank 1). Note that although the specified range of channels includes the other Analog Bus relays, they are ignored and are not closed by this command.

ROUT:CLOS (@1030:2005,1911)

The following command will generate an error since the Analog Bus relays cannot be specified as the first or last channel in a range of channels (none of the channels will be closed).

ROUT:CLOS (@1005:1911)  !Generates an error

In the following command, since the optional <ch_list> parameter is omitted, the command will be applied to the internal DMM. If the internal DMM is disabled (see INSTrument:DMM[:STATe] command) or is not present, an error will be generated.

INP:IMP:AUTO ON  !Applies to the internal DMM

Scan List Parameters

Before you can initiate a scan, you must set up a scan list to include the desired multiplexer, digital, or totalizer channels. Like channel list parameters (see Channel List Parameters above), scan list parameters specify one or more channels in the instrument. The scan list must be preceded with the "@" symbol and must be enclosed in parentheses. The following command uses a scan list (<scan_list>) parameter:

ROUTe:SCAN (@<scan_list>)

Commands which accept a <scan_list> parameter will reprogram the scan list each time you send the command to the instrument. The <scan_list> parameter is never an optional parameter. By default, the instrument scans the list of channels in ascending order from slot 1 through slot 8 (channels are reordered as needed). If your application requires non-ordered scanning of the channels in the present scan list, you can use the ROUTe:SCAN:ORDered command to enable the non-sequential scanning mode. In either mode, channels which are not in the scan list are skipped during the scan.

If a command specifies an illegal operation on a given channel, the instrument will generate an error on the offending channel and the command will not be performed on any of the channels. For example, the following command will generate an error since channel 911 is an Analog Bus relay which cannot be added to the scan list (assumes a multiplexer module is installed in slot 1).

ROUT:SCAN (@1001,1911)  !Generates an error

The Analog Bus relays (numbered s911, s912, s913, etc.) on the multiplexer modules are ignored if they are included in a range of channels in a scan list. An error will be generated if an Analog Bus relay is specified as the first or last channel in a range of channels. For example, the following command configures the scan list to include all valid channels between channel 30 (slot 1) and channel 5 (slot 2). Note that although the specified range of channels includes the four Analog Bus relays, they are ignored and are not added to the scan list.

ROUT:SCAN (@1030:2005)

However, if an illegal channel is either the first or last channel specified in the range, the instrument will generate an error (none of the channels will be added to the scan list). For example, the following command will generate an error since Analog Bus relay 911 is specified as the ending point in the range.

ROUT:SCAN (@1001:1911)  !Generates an error

Using Device Clear

Device Clear is an IEEE-488 low-level bus message that you can use to return the instrument to a responsive state (e.g., during a lengthy query). Different programming languages and IEEE-488 interface cards provide access to this capability through their own unique commands. The status registers, the error queue, and all configuration states are left unchanged when a Device Clear message is received.

Device Clear performs the following actions:

  • If a scan is running, it is aborted.

  • The instrument returns to the trigger "idle" state.

  • The instrument's input and output buffers are cleared.

  • The instrument is prepared to accept a new command string.

  • An overlapped command, if any, will be terminated with no "Operation Complete" indication.
     

The ABORt command is the recommended method to terminate a measurement.

 

It is recommended that you allow for a two-second wait following a Device Clear to enable the instrument to process the clear operation.