Standard Commands for Programmable Instruments: Difference between revisions

Content deleted Content added
typo: past should be paste (twice)
 
(209 intermediate revisions by 74 users not shown)
Line 1:
{{Short description|Communications protocol for test equipment}}
{{cleanup-date|February 2006}}
{{redirect|SCPI}}
The '''Standard Commands for Programmable Instrumentation (SCPI)''' defines a standard set of commands to control programmable test and measurement devices in [[instrumentation]] systems.
[[File:Digitaloszilloskop Schnittstellen IMGP1974 WP.jpg|thumb|right|Rear-panel of [[Tektronix]] TDS210 digital [[oscilloscope]] showing [[RS-232]] (DE9) and [[IEEE-488]] connectors that accept remote SCPI commands.<ref>[https://download.tek.com/manual/TBS1000-B-EDU-TDS2000-B-C-TDS1000-B-C-EDU-TDS200-TPS2000-B-Programmer-077044403_RevB.pdf Tektronix TDS2010 Digital Oscilloscope Programmer Manual; 2020; 291 pages.]</ref>]]
[[File:Rigol DS1074Z Oscilloscope - back.jpg|thumb|right|Rear-panel of [[Rigol]] DS1074Z digital [[oscilloscope]] showing [[USB]]-B and [[Ethernet]] ([[RJ45]]) connectors that accept remote SCPI commands.<ref>[https://int.rigol.com/Public/Uploads/uploadfile/files/ftp/DS/手册/DS1000Z/EN/DS1000Z_ProgrammingGuide_EN.pdf Rigol DS1074Z Oscilloscope Programmer Manual; 2019; 264 pages.]</ref>]]
 
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]].<ref name="SCPI-1999-spec">[https://www.ivifoundation.org/downloads/SCPI/scpi-99.pdf SCPI-1999 Specification; SCPI Consortium.]</ref>
The SCPI Standard specifies a [[command structure]] and [[syntax]] for programmable instruments control. The physical communications link, such as [[GPIB]], [[RS232]], [[USB]], [[VXIbus]] etc, is NOT defined by SCPI. SCPI also includes standard command sets for several classes of instruments, e.g. power supplies, loads, and measurement devices such as Voltmeters and [[oscilloscopes]].
 
== Overview ==
SCPI commands are [[ASCII]] textual strings, which are handled well by most general purpose programing languages; including C/[[C++]], [[Visual Basic]], [[Python programming language|Python]], etc. GUI based Application Software such as Lab View and HP VEE, interact with the instruments using these commands. [[SQL]] is another well recognized textual command language, which has some advantages when [[Software Configuration Management]] (SCM) tools are used. Both [[ISO_9000]] and [[Sarbanes-Oxley Act|SOX]] require audit, history, and controlled distribution methods for production software. One low cost way to surpass most auditors expectations is to combine an SCM tool like [[SubVersion]] with a scripting language like Python that has SCPI commands embedded. Some programmers find a web viewable interface to the SCM repository helpful, like [http://www.viewvc.org/ ViewVC], and if shown to an auditor that may be worth something also. Program development with SCPI commands is generally comparable to GUI methods, however cut, paste, modify of textual routines is much faster, so once a number of SCIP routines is developed productivity increases substantially.
SCPI was defined as an additional layer on top of the {{nowrap|IEEE 488.2-1987}} specification "Standard Codes, Formats, Protocols, and Common Commands".<ref>[http://zone.ni.com/devzone/cda/tut/p/id/3419 ni.com - History of GPIB - Developer Zone]</ref> The standard specifies a common [[syntax]], [[command (computing)|command]] structure, and [[Data type|data format]]s, to be used with all instruments. It introduced generic commands (such as <code>CONFigure</code> and <code>MEASure</code>) 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 <code>DCPSUPPLY</code> base functionality class. Instrument classes specify which subsystems they implement, as well as any instrument-specific features.
 
The physical hardware communications link (physical layer) is not defined by SCPI.<ref name="IVI-SCPI"/> While it was originally created for the [[IEEE-488]].1 (GPIB) bus,<ref name="IVI-SCPI"/> SCPI can also be used with [[RS-232]], [[RS-422]], [[RS-485]], [[Universal Serial Bus|USB]], [[Ethernet]], [[VME eXtensions for Instrumentation|VXIbus]], [[HiSLIP]], etc.<ref name="IVI-SCPI">{{cite web |title=The SCPI Standard (overview) |url=https://www.ivifoundation.org/About-IVI/scpi.html |website=IVI Foundation |archive-url=https://web.archive.org/web/20240921020849/https://www.ivifoundation.org/About-IVI/scpi.html |archive-date=September 21, 2024 |url-status=live}}</ref>
Some instrument manufactures, notably Agilent and Tektronix, have implemented SCPI on all new general purpose instruments. Agilent has even back ported the standard on a few instruments, e.g. 6030A. Many other manufactures never signed up to this standard, Voltech, Xantrex. In truth these small players have very little impact on the goal of the standards. As long as new products remain backward compatible with old command sets no one is hurt, unfortunately command set creep has been a problem with some manufactures. The major advantage of the SCPI command set is compactness and encapsulation, which allows test system designers to spend less time fussing with individual instruments. A side benefit is less command set creep and long term compatibility, one example is the Agilent N3300A includs the same SCPI commands found on the last generation 6050A.
 
SCPI commands are [[ASCII]] textual strings,<ref name="IVI-SCPI"/> which are sent to the instrument over the physical layer.<ref name="IVI-SCPI"/> Commands are a series of one or more keywords, many of which take parameters. In the specification, keywords are written <code>CONFigure</CODE>: 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.<ref name="SCPI-1999-spec"/>
Instrument communication interfaces are in a phase of rapid transition, many new instruments are introduced with multiple interface options including; USB, LAN and GPIB. SCPI works the same on all of them. It is reasonable to write software wrappers for any interface and bind to the interface within software as needed. LAN and USB is quickly gaining favor for low cost test systems, however older instruments with GPIB will linger around for many years.
 
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 one free [[PDF]] file that includes all four volumes.<ref name="SCPI-1999-spec"/>
SCPI and SQL are readable textual command languages, which are liked by some programmers because they are crufty, they can be directly [[Diff]]erenced against other versions, reusing is as easy as cut and paste, and logical flow is as easy to discern as reading. Some of these positives are considered negativities by other programmers, so its probably best for each group of developers to decide how to solve the issues of concern.
 
===SCPI history===
==References==
First released in 1990,<ref name="SCPI-1999-spec"/><ref>{{cite web |title=History of GPIB |publisher=National Instruments |url=http://zone.ni.com/devzone/cda/tut/p/id/3419 |quote=In 1990, the IEEE 488.2 specification included the Standard Commands for Programmable Instrumentation (SCPI) document. |access-date=2010-02-06}}</ref> 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.<ref name="scpi_home">{{cite web |title=SCPI |url=http://www.ivifoundation.org/scpi/default.aspx |publisher=IVI Foundation |access-date=2010-06-02}}</ref>
* [http://www.scpiconsortium.org/scpiinfo2.htm The SCPI consortium]
* [http://www.jpacsoft.com/scpi_explained.htm JPA conulting]
* [http://epccs.org/indexes/Software/PyWinGPIB/ Python GPIB to try some SCPI with]
 
In 2002-2003, the ''SCPI Consortium'' voted to become part of the ''IVI Foundation'' (Interchangeable Virtual Instruments).<ref name="scpi_home"/>
[[Category:Electronic engineering]]
 
===IEEE 488.2 history===
[[de:SCPI]]
In 1987, [[IEEE]] introduced IEEE&nbsp;488.2-1987 specification "''Standard Codes, Formats, Protocols, and Common Commands''", it was later revised in 1992 as '''IEEE&nbsp;488.2-1992'''.<ref>{{Citation |title=IEEE Standard Codes, Formats, Protocols, and Common Commands for Use With IEEE Std 488.1-1987, IEEE Standard Digital Interface for Programmable Instrumentation |publisher=[[Institute of Electrical and Electronics Engineers]] |year=1992 |id=IEEE Std 488.2-1992 |isbn=1-55937-238-9 }}</ref>
 
While IEEE&nbsp;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,<ref>Project Mate in 1985</ref> and later Hewlett-Packard, recognized this problem. In 1989, HP developed their TML language<ref>{{cite web |title=GPIB 101, A Tutorial of the GPIB Bus |publisher=ICS Electronics |url=http://www.icselect.com/ab_note.html#anchor338658 |page=5, paragraph=SCPI Commands}}</ref> which was the forerunner to SCPI.
 
The [[International Electrotechnical Commission|IEC]] developed their own standards in parallel with the IEEE, with IEC&nbsp;60625-2-1993 (IEC&nbsp;625). In 2004, the IEEE and IEC combined their respective standards into a "dual logo" IEEE/IEC standard '''IEC&nbsp;60488-2-2004''','' Part 2: Codes, Formats, Protocols and Common Commands'',<ref name="488.2-1992-spec">{{cite book |title=Standard Digital Interface for Programmable Instrumentation- Part 2: Codes, Formats, Protocols and Common Commands (Adoption of (IEEE Std 488.2-1992) |publisher=IEEE |doi=10.1109/IEEESTD.2004.95390 |hdl=11059/14380 |isbn=978-0-7381-4100-8 }}</ref> replaces IEEE&nbsp;488.2-1992 and IEC&nbsp;60625-2-1993.<ref>{{cite web |title=Replaced or Withdrawn Publications |url=http://www.iec.ch/cgi-bin/procgi.pl/www/iecwww.p?header=IEC&search=replaced&wwwprog=sea22.p |publisher=IEC |access-date=2010-02-06 |url-status=dead |archive-url=https://archive.today/20120417191411/http://www.iec.ch/cgi-bin/procgi.pl/www/iecwww.p?header=IEC&search=replaced&wwwprog=sea22.p |archive-date=2012-04-17 }}</ref>
 
== 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 <code>ACQuire:MODe</code> command or it could be queried by using the <code>ACQuire:MODe?</code> command. Some commands can both set and query an instrument at once. For example, the <code>*CAL?</code> 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.<ref name="SCPI-1999-spec"/> For example, any instruction to read a measurement from an instrument will begin with "<code>MEASure</code>". Specific sub-commands within the hierarchy are nested with a colon (<code>:</code>) character. For example, the command to "Measure a DC voltage" would take the form <code>MEASure:VOLTage:DC?</code>, and the command to "Measure an AC current" would take the form <code>MEASure:CURRent:AC?</code>.
 
:MEASure
:VOLTage
:DC?
:AC?
:CURRent
:DC?
:AC?
...
 
===Case===
Though the command syntax above shows commands in mixed case, SCPI is not [[Case sensitivity|case sensitive]].
 
:For example, for <code>VOLTage</code>, all of the following are valid representations:<code>VOLTAGE</code>, <code>voltage</code>, <code>Voltage</code>, <code>VoLtAgE</code>.
 
===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.<ref name="SCPI-1999-spec"/>
 
:For example, the command “<code>SYSTem:COMMunicate:SERial:BAUD 2400</code>” would set an RS-232 serial communications interface to 2400 [[Bit rate|bit/s]]. This could also alternatively be abbreviated “<code>SYST:COMM:SER:BAUD 2400</code>”. The query command “<code>SYSTem:COMMunicate:SERial:BAUD?</code>” or “<code>SYST:COMM:SER:BAUD?</code>” would instruct the instrument to report its current baud rate.
 
The only valid commands are the short form and long form of each command, all other subset variations are invalid.
 
:For example, for <code>COMMunicate</code>, only <code>COMM</code> (short form) and <code>COMMUNICATE</code> (long form) are valid, but <code>COM</code>, <code>COMMUN</code>, <code>COMMUNIC</code> subsets are invalid, also appended letters are invalid too, such as <code>COMMUNICATED</code>.
 
=== 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 (<code>;</code>).
 
:For example, the command to "Measure a DC voltage then measure an AC current" would be issued as <code>MEASure:VOLTage:DC?;:MEASure:CURRent:AC?</code>.
 
Simple commands which start with a colon (<code>:</code>) 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 accept or require one or more additional arguments. Arguments are given after the command, and are separated from the command using a space.<ref name="488.2-1992-spec"/> For example, the command to set the trigger mode of an instrument to "normal" may be given as "<code>TRIGger:MODe NORMal</code>". Here, the word "<code>NORMal</code>" is used as the argument to the "<code>TRIGger:MODe</code>" command. When multiple arguments are provided, the arguments are written as a comma-separated list. For example, a query command that performs an AC Volts measurement on a digital multimeter, using the meter's 10&nbsp;VRMS measurement range, and displaying the measured voltage value with 4-1/2 digits of resolution, would be written as "<code>MEASure:VOLTage:AC?&nbsp;10,4</code>".
 
===Integer arguments===
For commands that accept [[integer]] arguments, values may be specified in multiple [[computer number format]]s: decimal, hexadecimal, octal, binary. The last three formats are defined by IEEE 488.2,<ref name="488.2-1992-spec"/> which SCPI is based upon.<ref name="SCPI-1999-spec"/> [[Decimal]] numbers ([[radix]] 10) aren't prefixed, [[hexadecimal]] numbers (radix 16) are prefixed with <code>#[[H]]</code> or <code>#h</code>, [[octal]] numbers (radix 8) with <code>#[[Q#Uppercase_.22Q.22|Q]]</code> or <code>#[[Q#Lowercase_.22q.22|q]]</code>, and [[Binary number|binary]] numbers (radix 2) with <code>#[[B]]</code> or <code>#b</code>. 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).<ref name="488.2-1992-spec"/>
 
The following argument examples are numerically equivalent:
* Decimal: <code>26</code>
* Hexadecimal: <code>#H1A</code> or <code>#h1a</code>
* Octal: <code>#Q32</code> or <code>#q32</code>
* Binary: <code>#B11010</code> or <code>#b11010</code>
 
===488.2 commands===
Since SCPI was defined as an additional layer on top of the IEEE 488.2 specification, a SCPI compliant device should recognize various 488.2 commands too.<ref name="SCPI-1999-spec"/> These commands might also be known unofficially as asterisk commands (or star commands), because they start with the [[asterisk]] <code>*</code> character.
 
According to section 4.1.1 of Volume 1 of SCPI, all SCPI devices must implement the following 488.2 commands.<ref name="SCPI-1999-spec"/> In the real world some low-end test equipment may only support a subset of these 488.2 commands, or may even accept the commands but not perform any operation. A user should check the official programmers manual for each device before assuming all of these 488.2 commands are supported.
{{Div col|colwidth=15em}}
* <code>*CLS</code>
* <code>*ESE</code>
* <code>*ESE?</code>
* <code>*ESR?</code>
* <code>*IDN?</code>
* <code>*OPC</code>
* <code>*OPC?</code>
* <code>*RST</code>
* <code>*SRE</code>
* <code>*SRE?</code>
* <code>*STB?</code>
* <code>*TST?</code>
* <code>*WAI</code>
{{Div col end}}
 
According to section 4.1.2 of Volume 1 of SCPI, all other 488.2 commands not listed above are considered optional and not required by SCPI.<ref name="SCPI-1999-spec"/>
{{Div col|colwidth=15em}}
* <code>*AAD</code>
* <code>*CAL?</code>
* <code>*DDT</code>
* <code>*DDT?</code>
* <code>*DLF</code>
* <code>*DMC</code>
* <code>*EMC</code>
* <code>*EMC?</code>
* <code>*GMC?</code>
* <code>*IST?</code>
* <code>*LMC?</code>
* <code>*LRN?</code>
* <code>*OPT?</code>
* <code>*PCB</code>
* <code>*PMC</code>
* <code>*PRE</code>
* <code>*PRE?</code>
* <code>*PSC</code>
* <code>*PSC?</code>
* <code>*PUD</code>
* <code>*PUD?</code>
* <code>*RCL</code>
* <code>*RDT</code>
* <code>*RDT?</code>
* <code>*SAV</code>
* <code>*TRG</code>
* <code>*RMC</code>
* <code>*SDS</code>
{{Div col end}}
 
== See also ==
* [[IEEE-488]] (GPIB)
* [[Virtual Instrument Software Architecture]] (VISA)
* [[Instrument driver]]
* [[List of TCP and UDP port numbers]] - scpi-raw on TCP port 5025 and UDP port 5025
 
==References==
{{Reflist}}
 
==External links==
{{Commonscat}}
* [https://www.ivifoundation.org/About-IVI/scpi.html SCPI Organization], official website
;Specifications
* [https://www.ivifoundation.org/downloads/SCPI/scpi-99.pdf SCPI-1999, Volume 1-4], 819 page PDF file, '''free''' download ''(doesn't include asterisk (*) commands, because they are specified in IEEE 488.2 & IEC 60488-2)''
* [https://ieeexplore.ieee.org/document/8705775 IEEE 488.2-1992], 254 page PDF file, costs [https://www.techstreet.com/ieee/standards/ieee-488-2-1992?product_id=1888634 USD$54] in 2025 ''(superseded by IEEE/IEC 60488-2-2004)''
* [https://ieeexplore.ieee.org/document/1352831 IEEE/IEC 60488-2-2004], 264 page PDF file, costs [https://www.techstreet.com/ieee/standards/ieee-iec-60488-2-2004?product_id=1779348 USD$388] in 2025
 
===Programming Manual Examples===
;Multimeters
* [https://web.archive.org/web/20240104233333/https://download.tek.com/manual/DMM6500-901-01B_Sept_2019_Ref.pdf Tektronix DMM6500], 1202 page PDF file.
;Oscilloscopes
* [https://web.archive.org/web/20240104231432/https://keysight-docs.s3-us-west-2.amazonaws.com/keysight-pdfs/DSOV084A/Programmer_s+Guide+for+Infiniium+Oscilloscop.pdf Keysight InfiniiVision Families], 1896 page PDF file.
* [https://web.archive.org/web/20240104233600/https://scdn.rohde-schwarz.com/ur/pws/dl_downloads/pdm/cl_manuals/user_manual/1335_5337_01/MXO4_UserManual_en_06.pdf Rohde-Schwarz MXO 4 Series], 848 page PDF file.
* [https://web.archive.org/web/20240104233536/https://download.tek.com/manual/4-5-6-Series-MSO-Programmer_077130521.pdf Tektronix MSO 4/5/6 Families], 2050 page PDF file.
 
[[Category:Electronic engineering]]
[[Category:Electronics standards]]
[[Category:Input/output]]
[[Category:Electronic test equipment]]