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 OUTPut subsystem is shown below to illustrate the tree system.
OUTPut:
SYNC {OFF|0|ON|1}
SYNC:
MODE
{NORMal|CARRier}
POLarity
{NORMal|INVerted}
OUTPut is the root keyword, SYNC is a second-level keyword, and MODE and POLarity are third-level keywords. A colon ( : ) separates a command keyword from a lower-level keyword.
The format used to show commands is illustrated below:
[SOURce[1|2]:]VOLTage:UNIT {VPP|VRMS|DBM}
[SOURce[1|2]:]FREQuency:CENTer {<frequency>|MINimum|MAXimum|DEFault}
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.
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:
APPL:SIN 455E3,1.15,0.0
In this example, the APPLy command is specifying a sine wave at a frequency of 455 KHz, with an amplitude of 1.15 volts, and a DC offset of 0.0 volts.
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
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 command:
[SOURce[1|2]:]APPLy:DC [{<frequency>|DEF} [,{<amplitude>|DEF} [,{<offset>|MIN|MAX|DEF}]]]
Instead of selecting a specific value for the <offset> parameter, you can substitute MIN to set the offset to its minimum value, MAX to set the offset to its maximum value. You can also specify DEF to set the default value for each parameter: <frequency>, <amplitude>, and <offset>.
You can query the current value of most parameters by adding a question mark ( ? ) to the command. For example, the following command sets the trigger count to 10 readings:
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
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.
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:
The SCPI language defines several data formats to be used in program messages and response messages.
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, m, or u). If a command accepts only certain specific values, the instrument will automatically round the input numeric parameters to the accepted values. The following command requires a numeric parameter for the frequency value:
[SOURce[1|2]:]FREQuency:CENTer {<frequency>|MINimum|MAXimum}
|
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 megohms. You can use the prefix "MA" for mega. For example, "MAV" is interpreted as megavolts. |
Discrete parameters are used to program settings that have a limited number of values (like IMMediate, EXTernal, or BUS). They may 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 voltage units:
[SOURce[1|2]:]VOLTage:UNIT {VPP|VRMS|DBM}
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:
DISPlay {OFF|0|ON|1}
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 "WAITING..." on the instrument's front panel (the quotes are not displayed).
DISP:TEXT "WAITING..."
You can also display the same message using single quotes.
DISP:TEXT 'WAITING...'
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:
|
The ABORt command is the recommended method to terminate an instrument operation. |