Introduction to the SCPI Language

SCPI (Standard Commands for Programmable Instruments) is an ASCII-based programming language for test and measurement instruments. SCPI commands use a hierarchical structure known as a tree system. Associated commands are grouped under a common node or root, thus forming subsystems. A portion of the SENSe subsystem illustrates this, below.

SENSe:
         VOLTage:
                  DC:RANGe {<range>|MIN|MAX|DEF}
                  DC:RANGe? [MINimum|MAXimum|DEFault]

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

Syntax Conventions

The command syntax format is illustrated below:

VOLTage:DC:RANGe {<range>|MIN|MAX|DEF}

Most commands (and some parameters) are a mixture of upper- and lower-case letters. The upper-case letters indicate the command's abbreviated spelling, which yields shorter program lines. For better program readability, use the long form.

For example, consider the keyword VOLTage, above. You can type VOLT or VOLTage in any combination of upper- or lower-case letters. Therefore, VolTaGe, volt and Volt are all acceptable. Other forms, such as VOL and VOLTAG, generate errors.

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

A vertical bar ( | ) separates parameter choices. For example, {<range>|MIN|MAX|DEF} in the above command indicates that you can specify a numeric range parameter, or "MIN", "MAX" or "DEF". The bar is not sent with the command string.

Angle brackets ( < > ) indicate that you must specify a value for the enclosed parameter. For example, the above syntax statement shows the <range> parameter in angle brackets. Do not send the brackets with the command string. You must specify a value for the parameter (for example "VOLT:DC:RANG 10") unless you select one of the other options shown in the syntax (for example "VOLT:DC:RANG MIN").

Optional parameters are enclosed in square brackets ( [ ] ). The brackets are not sent with the command string. If you do not specify a value for an optional parameter, the instrument uses a default value.

Command Separators

A colon ( : ) separates consecutive keywords. You must insert a blank space to separate a parameter from a command keyword. If a command requires more than one parameter, separate adjacent parameters using a comma:

CONF:VOLT:DC 10,0.003

A semicolon ( ; ) separates commands within the same subsystem and can also minimize typing. For example, the following string:

TRIG:SOUR EXT;COUNT 10

is equivalent to 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 example, an error is generated if you do not use both the colon and semicolon:

TRIG:COUN MIN;:SAMP:COUN MIN

Using the MIN, MAX and DEF Parameters

For many commands, you can substitute "MIN" or "MAX" in place of a parameter. In some cases you may also substitute "DEF". For example, consider The following example:

VOLTage:DC:RANGe {<range>|MIN|MAX|DEF}

Instead of selecting a specific value for the <range> parameter, you can substitute MIN to set the range to its minimum value, MAX to set the range to its maximum value or DEF to set the range to its default 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 example sets the trigger count to 10 measurements:

TRIG:COUN 10

You can then query the count value by sending:

TRIG:COUN?

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

TRIG:COUN? MIN
TRIG:COUN? MAX

SCPI Command Terminators

A command string sent to the instrument must terminate with a <new line> (<NL>) character (ASCII decimal 10). 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 always resets the current SCPI command path to the root level.

Note

For every SCPI message that includes a query and is sent to the instrument, the instrument terminates the returned response with a <NL> or line-feed character (EOI). For example, if R? is sent, the response is terminated with a <NL> after the block of data that is returned. If a SCPI message includes multiple queries separated by semicolons (for example "ROUTe:TERMinals?;R?"), the returned response is again terminated by a <NL> after the response to the last query. In either case, the program must read this <NL> in the response before another command is sent to the instrument or an error occurs.

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 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, m or u). If a command accepts only certain specific values, the instrument rounds the input numeric parameters to the accepted values. The following command requires a numeric parameter for the range value:

VOLTage:DC:RANGe {<range>|MIN|MAX|DEF}

Note

Because the SCPI parser is case-insensitive, there is some confusion over the letter "M" (or "m"). For your convenience, the instrument interprets "mV" (or "MV") as millivolts, but "MHZ" (or "mhz") as megahertz. Likewise "MΩ" (or "mΩ") is interpreted as megΩ. You can use the prefix "MA" for mega. For example, "MAV" is interpreted as megavolts.


Discrete Parameters

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

UNIT:TEMPerature {C|F|K}

Boolean Parameters

Boolean parameters represent a single binary condition that is either true or false. For a false condition, the instrument accepts "OFF" or "0". For a true condition, the instrument accepts "ON" or "1". When you query a Boolean setting, the instrument returns "0" or "1". The following example requires a Boolean parameter:

DISPlay:STATe {ON|1|OFF|0}

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 example displays the message "WAITING..." on the instrument's front panel (the quotes are not displayed).

DISP:TEXT "WAITING..."

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

DISP:TEXT 'WAITING...'

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

Note

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