Introduction to SCPI Commands


Introduction to SCPI Commands

Introduction

Standard Commands for Programmable Instruments (SCPI) is a standardized set of commands for controlling and managing test and measurement devices. SCPI commands are widely used for remote instrument control, and they are based on ASCII strings. 

SCPI was introduced in 1990 as an enhancement of the IEEE 488.2 standard, which was developed in the late 1970s. The IEEE 488.2 provided a framework for programmable instrument control, but IEEE 488.2 did not specify any command syntax or structure.

Recognizing this gap, various test and measurement companies formed the SCPI Consortium to standardize a common set of commands. The result is the SCPI language, which leverages the foundation of IEEE 488.2 but includes a standardized command structure, enabling easier and more consistent programming across different instruments.

In this article, we will discuss the basics of a SCPI command and, common commands, syntax conventions, and how SCPI commands are used in instrument control.

Command Syntax and Formatting

A SCPI message follows a specific syntax and formatting to ensure accurate communication between devices. Here are some common types of commands used in SCPI:

Query Command

Query commands are used to request information from an instrument. They end with a question mark (?). For example, the `*IDN?` command is used to request identification information from the device.

Command Statement

Command statements are instructions that tell an instrument to perform a specific action. They do not end with a question mark. For example, the `*RST` command instructs the device to reset.

Multiple Commands

Multiple commands combine multiple queries to perform a complex operation. They are separated by a semicolon (;). For example, `*CLS; *OPC` first clears the event status register and then waits for all pending operations to complete.

Parameter Types

Parameters provide additional information for specific commands and can be of different types - numeric, string and Boolean. Numeric parameters represent numerical values, string parameters represent alphanumeric strings, and Boolean parameters represent the logical states of TRUE or FALSE.

Response Message

This message is the reply sent by the instrument to acknowledge a command. It usually contains information about the operation being performed or any errors encountered during execution. These messages are typically in plain text format and can be used to verify if a command was executed successfully.

Error Queue

This queue is a buffer that stores the most recent errors generated by an instrument. It can be accessed by using the `SYST:ERR?` command and contains information on the type, number, and description of errors. This feature is useful for troubleshooting issues with programmable instruments.

Characters in SCPI Commands

In a SCPI command, characters play a significant role in determining the nature of the command. The entire command string is case-insensitive, allowing for flexibility in command input.

Colon (:)

The colon is used to denote a command tree path between keywords also known as the command tree. For example, in the command `:SENS:VOLT?`, the colon indicates that VOLT is a sub-command of SENS. The command tree can help the user navigate through complex commands more efficiently.

Question Mark (?)

The question mark is added to the end of a command to signify a query or request for information.

Alphanumeric Characters

Alphanumeric characters in SCPI commands represent different command keywords. These keywords are usually abbreviated forms of words that describe the action to be performed. For instance, `MEAS` stands for measure, `VOLT` for voltage, and so on.

Numerical Characters

Numerical characters in SCPI commands usually indicate parameter values passed along with the command keywords. They provide specific values for the actions to be performed by the command.

Special Characters

Special characters such as the underscore (_) and dash (-) are used within command keywords to enhance readability and comprehension. They are not used for any specific functionality.

Angle brackets

(<>) are used to enclose a mandatory parameter in a compound command. The value for the parameter must be provided for the command to execute successfully.

Square Brackets

([]) are used to enclose an optional parameter or multiple parameter choices in a compound command. The value for the parameter is not required for the command to execute successfully, because commands can have a default value, but can provide additional functionality or customization.

Triangle brackets

(<<>>) are used to enclose a parameter that can be repeated multiple times in a compound command. This allows for more flexibility in the number of parameters that can be passed with a single command, making it easier to automate complex operations.

Command string termination

Although not considered a character, it is important to note that a line feed or carriage return character must be included at the end of every SCPI command. This signals the end of the command string and allows for proper parsing and execution by the instrument.

Standard Commands

There are a few standard commands for programmable instrumentation control. These include:

*CLS - Clear Status

This command clears any error or event status registers on the instrument, resetting them to their default values.

*ESE - Standard Event Status Enable

The *ESE command sets or queries the standard event status register. This register provides information about the events that have occurred on the device, such as errors or completion of a command. The command can be used to enable or disable specific event codes and also allows for checking the current status.

*OPC - Operation Complete

This command instructs the instrument to wait until all pending commands have been completed before executing the next one. This is useful when performing multiple commands in a sequence.

*RST - Reset

The *RST command resets the instrument to its power-on state, clearing any settings or configurations that have been applied. This is useful when starting a new test or measurement session.

*SRE - Service Request Enable

The *SRE command sets or queries the service request enable register. This register controls which events will generate a service request.

*STB - Read Status Byte

The *STB command is used to read the status byte register. This register includes bits for the operation, question, and status summary.

*WAI - Wait-to-Continue

The *WAI command causes the device to wait until all preceding commands have been executed before proceeding with any following commands. This can be highly useful when precise timing is required in the command sequence.

*TST - Self-Test

The *TST command initiates a self-test procedure on the device. The device will return a 0 if the test passes or a non-zero number if the test fails, allowing for quick and easy diagnostics of device health.

These commands provide a foundation for controlling and managing test instruments using SCPI. It is important to note that the specifics of implementing these commands can vary depending on the instrument and manufacturer, so always refer to the device's user manual for detailed instructions.

Application-Specific SCPI Command Sets

Beyond the standard commands, SCPI also includes application-specific command sets for test and measurement instruments that are tailor-made. These customized command sets enable users to take full advantage of the specific features and functions of their instruments.

Oscilloscope Commands

Oscilloscopes are one of the most commonly used measurement instruments in electronics and telecommunications. Given their widespread use, it is not surprising that there is a rich set of SCPI commands dedicated to controlling and managing oscilloscopes.

Some common SCPI commands include:

  • `:CHANnel<n>:SCALe <value>` - sets the vertical scale of the specified channel in the numeric parameter volts per division
  • `:MEASure:COUNt` - returns a measurement count for all triggered measurements, including frequency, period, and peak-to-peak voltage
  • `:AUToscale` - automatically sets the vertical and horizontal scales to provide a clear view of the input signal

Power Supply Commands

Power supplies are essential for providing stable and precise voltages for testing electronic devices. They too have their own set of specific SCPI commands, allowing users to remotely control voltage levels and current limits, as well as monitor output status and protection settings.

Some common commands for power supplies include:

  • `:SOURce<V>:VOLTage <value>` - sets the desired output voltage level in volts
  • `:SOURce<I>:CURRent <value>` - sets the current limit for the output channel in amps
  • `:OUTPut<n>:STATe` - returns a 1 if the specified output channel is on and a 0 if it is off

Signal Generator Commands

Signal generators are another essential tool for testing and measuring electronic devices. SCPI commands for signal generators allow for precise control over frequency, amplitude, and waveform shape.

Some common SCPI commands used for signal generators include:

  • `:FREQuency <value>` - sets the output frequency in Hertz
  • `:VOLTage` - sets the output voltage level in volts
  • `:SOURce<WAVeform>:SHAPe <value>` - specifies the desired waveform shape, such as sine, square, or triangle

Overall, understanding the application-specific command sets for different types of instruments is crucial for effectively communicating with and utilizing programmable devices.

With these commands in your arsenal, you can take full control of your testing and measurement processes, saving time and increasing efficiency. So always make sure to familiarize yourself with the specific SCPI commands for your instrument to unlock its full potential.

Software for SCPI

To easily send SCPI commands to your programmable device we have developed SAFE. A test software platform that makes it easy to send SCPI commands from a single instrument or multiple instruments and automate measurements from a single platform without any code.