
Standard Commands for Programmable Instruments

The Standard Commands for Programmable Instruments (SCPI; often pronounced "skippy") defines a standard for syntax and commands to use in controlling programmable test and measurement devices, such as automatic test equipment and electronic test equipment.
Overview.
SCPI was defined as an additional layer on top of the specification "Standard Codes, Formats, Protocols, and Common Commands". The standard specifies a common syntax, command structure, and data formats, to be used with all instruments. It introduced generic commands (such as codice_1 and codice_2) that could be used with any instrument. These commands are grouped into subsystems. SCPI also defines several classes of instruments. For example, any controllable power supply would implement the same codice_3 base functionality class. Instrument classes specify which subsystems they implement, as well as any instrument-specific features.
The physical hardware communications link is not defined by SCPI. While it was originally created for the IEEE-488.1 (GPIB) bus, SCPI can also be used with RS-232, RS-422, Ethernet, USB, VXIbus, HiSLIP, etc.
SCPI commands are ASCII textual strings, which are sent to the instrument over the physical layer (e.g., IEEE-488.1). Commands are a series of one or more keywords, many of which take parameters. In the specification, keywords are written codice_4: The entire keyword can be used, or it can be abbreviated to just the uppercase portion. Responses to query commands are typically ASCII strings. However, for bulk data, binary formats can be used.
The SCPI specification consists of four volumes: Volume 1: "Syntax and Style", Volume 2: "Command Reference", Volume 3: "Data Interchange Format", Volume 4: "Instrument Classes". The specification was originally released as non-free printed manuals, then later as a free PDF file.
SCPI history.
First released in 1990, SCPI originated as an additional layer for IEEE-488. IEEE-488.1 specified the physical and electrical bus, and IEEE-488.2 specified protocol and data format, but neither specified instrument commands. Different manufacturers, and even different models, of the same type of instrument would use different command sets. SCPI created a standard which could be common across all manufacturers and models. It requires use of the IEEE-488.2 data formats, but does not mandate the IEEE-488.1 bus.
In 2002-2003, the "SCPI Consortium" voted to become part of the "IVI Foundation" (Interchangeable Virtual Instruments).
IEEE 488.2 history.
In 1987, IEEE introduced IEEE 488.2-1987 specification "Standard Codes, Formats, Protocols, and Common Commands", it was later revised in 1992 as IEEE 488.2-1992.
While IEEE 488.2 provided a device-independent syntax, there was still no standard for instrument-specific commands. Commands to control the same class of instrument, e.g., multimeters, would vary between manufacturers and even models. The United States Air Force, and later Hewlett-Packard, recognized this problem. In 1989, HP developed their TML language which was the forerunner to SCPI.
The IEC developed their own standards in parallel with the IEEE, with IEC 60625-2-1993 (IEC 625). In 2004, the IEEE and IEC combined their respective standards into a "dual logo" IEEE/IEC standard IEC 60488-2-2004," Part 2: Codes, Formats, Protocols and Common Commands", replaces IEEE 488.2-1992 and IEC 60625-2-1993.
Command syntax.
SCPI commands to an instrument may either perform a "set" operation (e.g. switching a power supply on) or a "query" operation (e.g. reading a voltage). Queries are issued to an instrument by appending a question-mark to the end of a command. Some commands can be used for both setting and querying an instrument. For example, the data-acquisition mode of an instrument could be set by using the codice_5 command or it could be queried by using the codice_6 command. Some commands can both set and query an instrument at once. For example, the codice_7 command runs a self-calibration routine on some equipment, and then returns the results of the calibration.
Similar commands are grouped into a hierarchy or "tree" structure. For example, any instruction to read a measurement from an instrument will begin with "codice_2". Specific sub-commands within the hierarchy are nested with a colon (codice_9) character. For example, the command to "Measure a DC voltage" would take the form codice_10, and the command to "Measure an AC current" would take the form codice_11.
 :MEASure
 :VOLTage
 :DC?
 :AC?
 :CURRent
 :DC?
 :AC?
Abbreviating commands.
The command syntax shows some characters in a mixture of upper and lower case. Abbreviating the command to only sending the upper case has the same meaning as sending the upper and lower case command.
For example, the command “codice_12” would set an RS-232 serial communications interface to 2400 bit/s. This could also alternatively be abbreviated “codice_13”. The query command “codice_14” or “codice_15” would instruct the instrument to report its current baud rate.
Concatenating commands.
Multiple commands can be issued to an instrument in a single string. They are made of simple commands separated by a semicolon character (codice_16). For example, the command to "Measure a DC voltage then measure an AC current" would be issued as codice_17.
Simple commands which start with a colon (codice_9) are interpreted with respect to the root of the command tree. Otherwise, they refer implicitly to the last node of the previous command (unless they already begin with an asterisk). For example,
 :SOURce:FREQuency:STARt 100;STOP 200
is a shorthand for the message
 :SOURce:FREQuency:STARt 100;:SOURce:FREQuency:STOP 200
Arguments.
Some commands require an additional argument. Arguments are given after the command, and are separated by a space. For example, the command to set the trigger mode of an instrument to "normal" may be given as "codice_19". Here, the word "codice_20" is used as the argument to the "codice_21" command.
Integers arguments.
For commands that accept integer arguments, values may be specified in multiple computer number formats: decimal, hexadecimal, octal, binary. The last three formats are defined by IEEE 488.2, which SCPI is based upon. Decimal numbers (radix 10) aren't prefixed, hexadecimal numbers (radix 16) are prefixed with codice_22 or codice_23, octal numbers (radix 8) with codice_24 or codice_25, and binary numbers (radix 2) with codice_26 or codice_27. Hexadecimal digits may use either uppercase letters (ABCDEF), or lowercase letters (abcdef), or mixed case letters (aBcDeF). For octal, the letter "Q" was chosen instead of the letter "O" to minimize the visual confusion with the number "0" (zero).
The following argument examples are numerically equivalent: