GpibProgTut PDF
GpibProgTut PDF
11 January 2000 Electronics Group, Free University Amsterdam, The Netherlands Faculty of Sciences Phone : +31-20-4447973 Fax : +31-20-4447899 E-mail : [email protected] (Rob Limburg) Web : http://www.few.vu.nl/~elec
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 Gpib bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 Gpib bus standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Measurement setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Gpib Instruments from our group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 The communication principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1 Commands and queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Common commands and queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.2 Compound commands and queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Numerical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.2 Text data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.3 Arbitrary Block data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Combining commands and queries with data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1 1 1 1 1 1 3 3 3 4 4 4 5 5 6 6
3 Construction rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.1 More in one line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.2 Query form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.3 White spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.4 Omitting the header path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.5 Abbreviation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.6 Default headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.7 Forgiving listening and precise talking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.8 Default, minimum and maximum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.9 Oops, typo! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.8.1 Error checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.8.2 The error queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.8.3 It hangs! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4 Instrument status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1 Status Byte registers (STB and SRE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Serial poll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Service Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 Standard Event Status Registers (ESR and ESE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5 Using the status system in your application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 13 14 14 14 15
5 Reset and Clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 6 Trigger mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.1 Standard Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 7 Overlapped commands and synchronisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
ii
21 21 22 22 22 23
8 Instrument standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.1 Standard common commands and queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2 Standard subsystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.2 System sub-system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.3 Micros sub-system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9 Error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 10 Software revisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 11 Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Appendix A Quick Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A1 What you need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A2 What you need to know before you begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A2 What you need to do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 31 31 31
1 Introduction
If you want to get started quickly and ignore most of the (background) information, go to appendix A Quick start.
System Controller
(PC,MAC, Workstation)
Device
Device
Device
Device
GPIB bus
least one device (instrument). The system controller has to have a gpib controller card. These cards can be bought from different vendors such as Hewlett-Packard, National Instruments, Computerboards, Ines and others) The physical connection is a cable with standard connectors on both sides. The standard connector is the Amphenol or Cinch Series 57 MICRORIBBON or AMP CHAMP type. The connectors can be stacked to connect all the devices. 1.2.1 Restrictions The following restrictions are typical for normal operation: 1. A maximum separation of 4 m between any two devices and an average separation of 2 m over the entire bus 2. A maximum total cable length of 20 m 3. No more than 15 device loads connected to each bus, with no less than two-thirds powered on
Plug in cards The G96 plug in cards can be off the shelf developed by our group or can be bought from an plug in card vendor. Also, custom plug in cards can be developed on demand. These custom plug in cards come in two favours: Prototype quality. These cards are developed usually for incidental/special purposes. The cards are build using Wire-Wrap techniques on a prototype card. There is usually only one (1) card build. Production quality A PCB (printed circuit board) is designed. Large amount of these cards can be build.
There is usually no difference in functionality or performance between the two types of cards. Only the production method differs. Check the web pages of the Electronics Group for the available off the shelf plug in boards or visit us at T012/T016. The Software The software is equally important as the hardware. All the software can be custom developed, but we also maintain standard software components that we can assemble into a new applications. Custom hardware needs custom software, so it is clear that for those parts new code has to be developed. One major software component is the SCPI Engine. This software component allows us to build modular SCPI based software. All the command, query and data parsing and formatting is done by the SCPI Engine. This allows us to concentrate on the design of new modules rather than to be bothered by the syntax intricacies of SCPI and IEEE488.2. The SCPI Engine supports the separation of independent software parts. In SCPI naming convention these are called subsystems. More on this later.
(instrument)
Events. The GPIB bus has a number of special control lines which allow fast and simple passing of primitive information, called events. This primitive information is also called Interface Events or Interface Messages because they are initiated and processed by the interface hardware. An example of an event is the IFC (InterFace Clear) event, Which forces the instrument to be able to listen to the system controller. Events are discussed last in this chapter. Commands. Commands are strings which cause the instrument to perform an action, such as taking measurements or activate a motor. Queries. Queries are strings which cause the instrument to generate response. Queries usually do not cause an instrument to perform an action. Queries always end with a question mark (?). Data units. Data units are used to pass information. Data can be in the form of parameters which come with commands or queries to the instrument. Data can also be in the form of response from an instrument.
The GPIB bus operates block oriented, multiple commands, queries and data strings units can be combined into one line of text. An instrument will start executing commands and queries if a complete line of text has been received. To know when a complete line is transferred, the EOI (End Or Identify) event has to be generated simultaneously when the last byte is send. Important note : Software drivers of some gpib cards default have EOI disabled! Configure the driver that EOI is enabled otherwise the instrument will not work!
Common Command
Header
Common Query
Header
2.1.2 Compound commands and queries The instrument specific functionality is controlled with compound commands and queries. Compound commands and queries represent a hierarchical structure also called a header tree. Compound Command Compound commands and queries are build up : from one or more headers separated by colons (:). Each header represent a node in the tree, the leftmost header represents the highest level. The Header : rightmost header should represent the leaf node, which is the lowest level in the tree. The compound query follows the same rules but Compound Query has an question mark appended to its last : header. For example: :ad16_:trig:reset Resets the trigger mechanism of the AD16 plug in card.
Header
Compound commands are further explained in Construction rules, from page 8. As with common commands there are also standard compound commands and queries. These are all contained in so called subsystems. Sub-systems are groups of commands and queries which are strongly related. For example, the AD16 plug in card has a corresponding SCPI subsystem called (suprise!) ad16_ . The standard subsystems that are present in every programmable instrument from our group are listed in Instrument standards at page 29.
2.2 Data
Data is used to pass information. Data is separated into parameters and responses. Parameters are used to pass information along with commands and queries. This information is directed towards the instrument. Responses are used to return information as a reply to queries. This information is directed from the instrument. There are different types of data, they can be grouped into numerical, text and block data types. The purpose is to transfer information in a flexible, human oriented way. Almost all data types are ASCII encoded, only the binary block data type contains a data field with arbitrary encoding. 2.2.1 Numerical data Numerical data is used to transfer decimal and non-decimal values. Decimal numeric data Decimal numeric data can be represented in three different formats: Integer numbers. This form is denoted as NR1 (Numeric Representation 1). Positive or negative whole numbers. Examples: 4 -23 90 Real numbers. This form is denoted as NR2 (Numeric Representation 2). Fixed point numbers. Examples: 23.45 1.22 -4.55 Exponential numbers. This form is denoted as NR3 (Numeric Representation 3). Floating point numbers. Examples: 4.3E-3 -8.9456E8 123E-5 Decimal numeric data may be received with greater precision than the capability of the device, such values are first rounded to the greatest precision possible. For example: An power source can adjust its output voltage up to 0.1Volts, having a 100 Volt span. This power source receives a parameter to set the output voltage with the value of 41.46. The power source will round the value to 41.5 Volts and set the output voltage accordingly. Non decimal numerical data Positive integer numbers can be represented in non decimal numerical data. Three different formats
are allowed for the bases 16 (hexadecimal), 8 (octal) and 2 (binary). Hexadecimal. Start with #H or #h, followed by digits (0..9) and/or hex characters (A..F, a..f). Example the decimal value 63 is represented in the hexadecimal format as #H3F or as #h3f Octal. Start with #O or #o, followed by digits (0..7). Example the decimal value 63 is represented in the octal format as #OH77 or as #o77 Binary. Start with #B or #b, followed by digits (0..1). Example the decimal value 63 is represented in the binary format as #B111111 or as #b111111 Additional information about the appliance of numerical data can be found in chapter 3 from page 8.
2.2.2 Text data Text data can be separated into character data and string data. Character data Character data is used for information which can be best expressed as mnemonics. Character data follows the same rules as the headers described in Chapter 2.1: A header is a string of maximum 12 characters. There is no distinction between upper and lowercase. The header may contain digits, but will always starts with a character or an underscore (_). There are two types of commands and queries; the common and the compound types. If a header is longer than 4 characters, it may be abbreviated. See 3.3 Abbreviation on page 9. Example: A data acquisition instrument has 3 types of trigger sources available. To select one of these, the command TRIGger:SELect can be used. It accepts the following character data parameter values; BUS ,TIMer and EXTernal. From this example it is clear that these character data values need almost no explanation. String data String data is used (in contrast to character data) for more free form textual data. String data may contain all 7 bit ASCII characters, including the non-printable ones. This data type is very useful when some form of formatting is required. For instance when text is to be displayed on a terminal or on a printer. String data is always placed between single quotes () or double quotes (). When string data is delimited by single quotes, double quotes can be freely used. Also, when string data is delimited by double quotes, single quotes can be freely used. Special care should be taken when single quotes should be used within string data delimited with single quotes. The rule here is to insert an extra single quote before the existing single quote. The two single quotes will be interpreted as one single quote character and not as an delimiter. The same rule also applies for double quote delimiters. ASCII response data ASCII response data is only used in query response directed from the instrument. It is not valid to use this data format as a parameter. In contrast to string data, ASCII response data is not delimited. It may contain any 7 bit ASCII characters.
2.2.3 Arbitrary Block data Arbitrary block data can be used to transfer data fast without any encoding. There is no way to recover the encoding other than by some formal convention
Electronics Group (http://www.few.vu.nl/~elec)
Non-zero digit
Digit
(documentation). The only encoding available is the block length in bytes. This is provided by the header which is ASCII encoded. The first character in the header is the # followed by a non-zero digit indicating the amount of digits to follow. The digits that follow represent the amount of data bytes in the arbitrary block data. Example: (<b> represents a single byte in this example) #213<b><b><b><b><b><b><b><b><b><b><b><b><b> the digit 2' means that the next 2 digits will form the block length. The block length is 13 bytes.
2.4 Events
The GPIB bus has a number of special control lines which allow fast and simple passing of predefined primitive information, called events. This primitive information is also called Interface Events or Interface Messages because they are initiated and processed by the interface hardware. Events contain no data, they are either single control line signal levels(single line events) or certain data bus values combined with the ATN control line asserted (multiline events). This section gives a short introduction of the most important events. In order to create a perfect measurement setup with optimum performance some knowledge of these events is inevitable. Check chapter 9 on page 30 for more information on further reading. Some single line events are: IFC. InterFace Clear, forces the instrument to be able to listen to the system controller. REN. Remote ENable, signal line to claim control over an instrument which can also be
A White space character is defined as a single ASCII character in the range 0..9, 0B..20 (hex).
Free University Amsterdam, Faculty of Sciences
operated by a local front panel. EOI. End Or Identify. When ATN = 0, used to indicate the end of a data transfer. When ATN = 1, used by the controller to perform a parallel poll. SRQ. Service ReQuest. This allows the instrument to get the attention of the controller. A very important feature of the GPIB. See 4.5 Service request on page 14.
Some multiline events are: DCL. Device CLear. Clears the input and output buffers in all instruments on the bus. See chapter 5 Reset and Clear on page 17. SDC. Selected Device Clear. Clears the input and output buffers in one selected instrument on the bus. See chapter 5 Reset and Clear on page 17. GET. Group Execute Trigger. All instruments on the bus receive a trigger pulse. See chapter 6 Trigger Mechanism on page 18.
3 Construction rules
In 2.3 Combining commands and queries with data the basic construction rule for creating a command or query with data is defined. The Construction rules defined here take it one step further. They are primary intended to make life easier. Some enhance readability, some enhance performance and others reduce programming effort.
The length of a single line may never exceed the size of the instruments input buffer. An GPIB instrument designed at our group always has a query (SYSTem:INBuf?) which returns the actual size of the input buffer.
Electronics Group (http://www.few.vu.nl/~elec) Free University Amsterdam, Faculty of Sciences
When using compound commands and/or queries it is possible in some cases to omit the leading header path. This is a very powerful feature because it can shorten the commands and queries considerable and reduces the search time within the header tree in the instrument. The queries: :system:version?;:system:err? Omitting the header path for the second query: :system:version?;err? The header part (:system) of the second query may be omitted here. The second query does not specify its absolute position (it does not start with (:)). Because the instruments parser saves the last position in the header tree, it can find the err? query when searching from this saved position. The queries: :system:version?;:ad16_:anout? Omitting the header path for the second query: :system:version?;anout? Will generate an error as the last saved position is in the :system branch, not in the ad16_ branch. The anout? query will not be found at the :system level in the header tree. Omitting the header path of a command or query is only possible within one single line. The first command or query on a line is assumed to be specified from the root. This also means that the colon leading the first header on a new line is optional. Common commands and queries (beginning with a *) do not affect the saved position. Consider the following: :ad16_:trigger:count 100;:ad16_:trigger:delay 50;:ad16_:trigger:arm;*trg Omitting the header paths: ad16_:trigger:count 100;delay 50;arm;*trg The first colon and the header paths for the delay and arm commands are omitted resulting in better performance and good readability.
3.5 Abbreviation
Compound commands or queries are build up using headers. These headers have a short form if their length exceeds 4 characters. The short form is always 4 characters or less. The short form should be noted in the documentation. To distinct the short form from the long form the short form is printed in capitals, the remainder in non-capitals. Example when the documentation defines: :SYSTem :ERRor? The following is: :syst:error? valid :system:err? valid :syst:err? valid :syste:err? invalid, :syste is not a short nor a long form
10
Consider an instrument with the following header branch: :SYSTem :CONFig :VIEW? An updated version of this instrument has the same header branch expanded to: :SYSTem :CONFig :VIEW [:ALL]? (new default header but same functionality) :REGion (new added header) The :SYSTem:CONFig:VIEW? query will work on the old and on the new instrument. The :SYSTem:CONFig:VIEW:ALL? will work on the new instrument only.
11
IV.
V.
Errors are reported as an error code with a short description in the error queue (see next section). Also, summary bits are available for each category (command, execution, device dependant, and query error) in the status system (see chapter 4 Instrument status).
3.8.2 The error queue Each time an error occurs the corresponding error (or status) code and a short description (if possible) is stored in the error queue. The error queue can be read by the user with the :SYSTem:ERRor? query. This query returns the first error code with description: <numeric value>,<string> Error and status messages are queued using a FIFO (First-In, First-Out) strategy. The numeric value is in the range [-32768, 32767]. An error/event value of zero indicates that no
12
error or event has occurred. If the queue overflows, the last error/event in the queue is replaced with the error: -350,Queue overflow Reading an error/event from the queue removes that error/event from the queue. When all errors/events have been read from the queue, further error/event queries shall return: 0,No error Example: Controller sends: syst:err? The instrument could reply: -500,Power up Controller sends: syst:err? The instrument could reply: 0,No error Command errors specify the character position of the header which caused the error, so it should be fairly easy to find: Example: Controller sends: ad16_:triz:count 4 The instrument could reply: -113,Undefined header; At position 7" Position 7 is the start of the erroneous header :triz (which should be :trig or :trigger). 3.8.3 It hangs! A requirement of an IEEE488.2 compatible instrument is that it will not talk when it has nothing to say. This means when an invalid query is received, the instrument will append an error in the error queue, but will not send any reply. The controller however, expects a response and will wait for it until some defined timeout value expires. After that it will probably issue an error to the user. This is often referred to as a bug, but it isnt. After the controllers timeout period the instrument can be programmed as usual. One can read the error queue and find out what caused the problem. It is possible to get an IEEE488.2 instrument to hang, better speaking, to get it into a deadlock situation. Of course it is also possible that there is fault. To (try to) end such an situation it is best to first send an IFC (InterFace Clear) interface event and then a DCL (Device CLear). If this doesnt help, pushing the reset button or cycling power is the only solution (sigh). If you did not get the instrument to react in the first place check out if the controller card is configured as system controller, the gpib-id (default 15) is set correctly and insure that EOI (End Or Identify) is enabled in your program or software driver.
13
4 Instrument status
IEEE488.2 compatible instruments have to be equipped with a status structure, as shown on the figure below. The purpose of this structure is to supply information to the controller about the status of the instrument. Since this structure is part of the IEEE488.2 standard, all instruments will supply this information in the same consistent manner. Also, the status structure can be programmed in a way that a certain event will generate a SRQ (Service ReQuest, see 4.5). The status can be modified and queried by a serial poll and several common commands and queries. Some parts of the status structure are controlled by the instrument itself, others can be manipulated by the common commands and queries.
Power On Device Query User Command Execution Dependen Error Request Error Error Error Request Operation Control Complete
7
(128)
6
(64)
5
(32)
4
(16)
3
(8)
2
(4)
1
(2)
0
(1)
Output queue
7
(128)
6
(64)
5
(32)
4
(16)
3
(8)
2
(4)
1
(2)
0
(1)
Sstandard Event Status Enable Register (ESE). Read by *ESE? Set by *ESE <NRf>
Message AVailable in queue Errors/ Events AVailable in queue*
SRQ
7
(128)
ESB 5 (32)
MAV 4 (16)
3
(8)
EAV 2 (4)
1
(2)
0
(1)
7
(128)
5
(32)
4
(16)
3
(8)
2
(4)
1
(2)
0
(1)
Service Request Enable Register (SRE). Read by *SRE? Set by *SRE <NRf>
14
5 4
32 16
RQS, ReQuested Service. This bit is set when the instrument has requested service by means of the SeRvice Request (SRQ). When the controller reacts by performing a serial poll, the STatus Byte register (STB) is transmitted with this bit set. Afand cleared afterwards. It is only set again when a new event occurs that requires service. MSS, Master Summary Status. This bit is a summary of the STB and the SRE register bits 1..5 and 7. Thus it is not cleared when a serial poll occurs. It is cleared when the event which caused the setting of MSS is cleared or when the corresponding bits in the SRE register are cleared. ESB, Event Summary Bit. This is a summary bit of the standard status registers ESR and ESE. MAV, Message AVailable. This bit is set when there is data in the output queue waiting to be read.
The STatus Byte register (STB) forms a basis in which more registers can have their summary bit. The ESB bit (5) is an example of that.
15
3 2 1 0
8 4 2 1
turning a knob on the front panel. Command Error. A command error has occurred. Execution error. The instrument was not able to execute a command for some reason. The reason can be that the supplied data is out of range but can also be an external event like a safety switch/knob or some hardware / software error. Device Specific Error. Query Error. Error occurred during query processing. Request Control. The instrument is requesting to become active controller. Operation Complete. The instrument has completed all operations. This bit is used for synchronisation purposes, see chapter 7 for more information.
As can be seen in the figure on page 13,the standard Event Status Enable register (ESE) is used to control which bits from the ESR are summarized in the ESB bit (5) in the Status Byte register (STB). By setting bit 5 in the Service Request Enable register (SRE), this can result in a service request. This ESE register is read/write. It can be controlled by the *ESE command and *ESE? query. The register is represented in NR1 (Numerical Representation #1) format. Examples will follow in 4.5.
Example to detect command and query errors in a smarter way: *ESE 36 Summarize command error bit (5) and the query error bit (2) into ESB bit (5) of the status byte register blabla? Just send the query, do not try to read the response as this could lead to a timeout when the query does not exist. This example will generate a query error. SPOLL Serial poll the instrument. Returns: 32 The Event Status Bit (ESB) (5) is set, the MAV bit (4) is not set thus the query did not generate any response. A stepper motor controller instrument uses bit 0 in the Status byte to indicate a jammed motor. The application on the host computer should be notified as soon as possible: *SRE 1 Generate a service request when bit 0 in the status byte gets set. Motor gets jammed: SRQ Instrument generates a service request.
Electronics Group (http://www.few.vu.nl/~elec) Free University Amsterdam, Faculty of Sciences
16
Host computer serial polls all instruments, at a certain moment this one: SPOLL Serial poll the instrument. Returns: 65 65= 64 + 1. This instrument caused the SRQ and has bit 0 set. The host computer interprets bit 0, and takes the appropriate actions (turning off power, notify users ect).
17
In order to get comparable results as cycling power, the controller must send an IFC, DCL or SDC, *CLS command and a *RST command.
18
6 Trigger mechanism
A GPIB instrument can be BUS triggered by means of a GET interface event, a *TRG common command. Triggering from any other (internal or external) signal is completely instrument specific. For an instrument GET and the *TRG command have the same effect but for the measurement setup there can be differences: The *TRG command has to be interpreted, which introduces software delays and jitter. The GET interface event needs less processing. GET applies to all instruments on the same GPIB bus, the *TRG command applies only to the addressed instrument.
Most of our instruments are modular. To allow flexible operation of our instruments a trigger mechanism had to be selected. This mechanism should allow each independent part of our instrument (subsystems, see xx) to be programmed in the way it reacts to a trigger. The next section presents the default mechanism used in our instruments. If an instrument uses a different approach, refer to its documentation.
Power On *RST
Idle
(ignore trigger)
TRIGger:ARM
TRIGger:ABORt TRIGger:RESet
Armed
(wait for trigger) trigger received
Running
(process trigger)
Retired
(trigger processed)
When the trigger is processed, the mechanism comes into the Retired state. mode = ONEShot In the NORMal mode the mechanism falls directly to the Armed state waiting for the next trigger to arrive. In the ONEShot mode, it stays in the Retired state until it is forced out. It can be forced into the Idle state by the TRIGger:ABORt or the TRIGger:RESet command. It can also be forced back into the Armed state by the TRIGger:ARM command. The trigger mechanism is reset by the TRIGger:RESet command, it forces the mechanism to the Idle state and resets the mode to NORMal and the source to BUS. The TRIGger:ABORt command just forces the Idle state but leaves the mode and source settings unaffected.
19
Cmnd/Query *WAI
Meaning Wait command. Wait until all pending commands and queries are processed. The following :HOME;*WAI;:FORWARD ensures that :FORWARD is not started until :HOME has finished. OPeration Complete query. This query returns '1' when all pending commands and/or queries are finished. During the period that there are pending commands and/or queries this query gives NO response! While the controller is waiting for the response the whole bus is stalled until the instrument is idle (or the controller times out).
When to use To force synchronisation between commands and/or queries. (the controller will not know the length of the waiting period *WAI introduces).
*OPC?
Synchronisation between controller and instrument for short waiting periods. When the delay is too long (several seconds) a controller timeout can occur resulting in an error situation. So it is not advisable for unpredictable or long delays.
20
Synchronisation between controller and instrument. Suitable for short, long and unpredictable delays. Knowledge of the status system mandatory.
21
8 Instrument standards
8.1 Standard common commands and queries
The following table lists the available common commands and queries available in all GPIB based instruments from our group. General *RST *IDN? *TST? *TRG
Reset command. Abort all activities and initialize the device. See page 17,Reset and clear. Identification query. Returns an identification string in the following format: 'Manufacturer, Model, Serial number, Firmware level' Self test query. Perform a self-test. Returns 0' if self test completed without errors, all other values determine an error cause. Trigger command. Execute trigger function(s). This command has the same effect as the IEEE488.1 Group Execute Trigger (GET) interface-message. See page 18 Trigger Mechanism.
Synchronisation (See page 19, Overlapped commands and synchronisation) *OPC Operation Complete command. Set the Operation Complete bit in the Standard Event Status Register if all commands and queries are finished. *OPC? Operation Complete query. Return ASCII '1' as soon as all commands and queries are finished. *WAI Wait To Continue command. Wait until all commands and queries are finished. Instrument Status (See page 13,Instrument status) *CLS Clear Status command. Clears the whole status structure. *ESE Standard Event Status Enable command. Modify the contents of the Event Status Enable Register. *ESE? Standard Event Status Enable query. Return the contents of the Event Status Enable Register. *ESR? Standard Event Status Register query. Return the contents of the Event Status Register. *SRE Service Request Enable command. Modify the contents of the Service Request Enable Register. *SRE? Service Request Enable query. Return the contents of the Service Request Enable Register. *STB? Status Byte query. Return the contents of the Status Byte Register.
22
8.2.1 Introduction As mentioned before, the header tree is a hierarchical structure that can comfortably reflect the modular structure of our instruments. The header tree is divided into subsystems. Sub-systems are groups of commands and queries which are strongly related. For example, the AD16 plug in card has a corresponding SCPI subsystem called ad16_ . The standard subsystems that are present in every programmable instrument from our group are listed here.
8.2.2 System sub-system :SYSTem (Node) The SYSTem subsystem provides the user with commands and queries that are not related to instrument performance. :ERRor? (Query only) Get the next entry from the instruments error/event queue. Returns <error/status value>, an integer, followed by <description> which is a string. Error and status messages are queued using a FIFO (First-In, First-Out) strategy. Items in this queue contain an integer in the range [-32768, 32767] denoting an error/event number and associated descriptive text. An error/event value of zero indicates that no error or event has occurred. If the queue overflows, the last error/event in the queue is replaced with the error: -350,Queue overflow Reading an error/event from the queue removes that error/event from the queue. When all errors/events have been read from the queue, further error/event queries shall return: 0,No error Example: Controller sends: :syst:err? Instrument could reply: -500,Power up Controller sends: :syst:err? Instrument could reply: 0,No error See also Oops typo! from page 11. :DATE <numeric_value>,<numeric_value>,<numeric_value> Queries or sets the internal calender. The first parameter is the year, followed by the month and the day. Example: Controller sends: :syst:date? instrument could reply: 99,12,31 Example: Controller sends: :syst:date 99,1,1 Date will now be set to januari 1st 1999. :TIME <numeric_value>,<numeric_value>,<numeric_value> Queries or sets the internal clock. The first parameter is the hour, followed by the minute and the second. Example: Controller sends: :syst:time? Instrument could reply: 16,48,14
Electronics Group (http://www.few.vu.nl/~elec) Free University Amsterdam, Faculty of Sciences
23
:VERSion? (Query only) Returns the SCPI version number for which this instrument complies. Example: Controller sends: :syst:vers? Instrument could reply: 1996.0
8.2.3 Micros sub-system :MICRos (Node) The Micros subsystem provides the user with some support for the underlying Micros operating system. :INFo (Node) INFo commands provide some information about the underlying hardware and operating system.
[:ID?] (Default, Query only) Returns a string containing operating system identification information. Example Controller sends: :micros:info:id? Instrument could reply: Micros 3.2.3, (c) Rob Limburg Vrije Universiteit Amsterdam :CPU? (Query only) Returns a string containing microprocessor identification information. Example: Controller sends: :micros:info:cpu? Instrument could reply: Scc68070 :RELease? (Query only) Returns an unsigned integer (NR1) indicating operating system release. Example: Controller sends: :micros:info:rel? Instrument could reply: 323 :SYSTem? (Query only) Returns a string containing hardware platform identification information. Example: Controller sends: :micros:info:syst? Instrument could reply: NeoNil
:MEM (Node) MEM commands provide information about the amount of available memory (RAM) in the system. :CONTigous? (Query only) Returns an unsigned integer (NR1) indicating the size (in bytes) of the biggest contiguous block of
Electronics Group (http://www.few.vu.nl/~elec) Free University Amsterdam, Faculty of Sciences
24
:STReam (Node) STReam commands give the user the ability to control the (other) communication channels available on the system. Streams are flexible data channels provided by the Micros operating system. A stream is opened by calling the OPEN query. This query returns an unsigned integer. This value has to be passed with all subsequent STReam commands and queries.
:OPEN <string>,<string> (Query only) Open a stream with the given stream and protocol-name. The first string has to contain the stream name and the second string the protocol name. This query returns a non decimal unsigned integer which is the stream-handle. If the stream could be opened, the stream-handle is unequal to 0 and FFFFFFFFhex. If the stream could not be opened, an error is appended to the error/status queue. Example: Controller sends: :micros:stream:open SERIAL1,RS232" instrument could reply: #H1DFD4 Some of the available streams are listed at the end of this section. :CLOSe <numeric_value> Close the stream. If the stream could not be closed, an error is appended to the error/status queue. Example: Controller sends: :micros:stream:close #H1DFD4 Now the stream is closed, output buffer will be flushed, input buffer cleared.
:READ? <numeric_value> (Query only) Reads data from the stream referenced by the <numeric_value>. This query returns the data in the arbitrary block form. Note that this query is non-blocking, only data resident in the input buffer is returned. Example: Controller sends: :micros:stream:read? #H1DFD4 Instrument could reply: #211Hello dude! :WRITe <numeric_value>,<arbitrary_block> Sends data to the stream referenced by <numeric_value>. The data is in arbitrary block form. Example: Controller sends: :micros:stream:write #H1DFD4, #212Hello world! The data will now be sent to the stream. Some of the available streams on the NeoNil computerboard: SERIAL1 (rs232 port 1 on front panel NeoNil): Stream 'SERIAL1' Protocol 'RS232[:OPTION1=X][:OPTIONn=Y]'
Electronics Group (http://www.few.vu.nl/~elec) Free University Amsterdam, Faculty of Sciences
25
I=X R=X
P=NO ODD EVEN C=X S=X F=NO HARD SOFT Default configuration: buffer size interrupt prio. baud rate parity char. length stop bit length flow control
Buffer size in bytes. B=X bytes voor input en output buffer, B=X/Y X bytes voor input en Y bytes voor output. Interrupt priority level 0..32767 BaudRate = X bits/sec, possible values: 50,75,110,134,150,200,300,600,1200,1050,1800, 2000,2400,4800,7200,9600,19200 of 38400 Parity off, odd or even. Character length = 5,6,7 or 8 bits. Stopbit length = 1 or 2 bits Flow control = none, hardware(RTS-CTS) or software (Xon-Xoff).
SERIAL2 (rs232 port 2 on front panel NeoNil): Stream 'SERIAL2' Protocol 'RS232[:OPTION1=X][:OPTIONn=Y]' Protocol options: B=X[,Y]
L=X I=X R=X P=NO ODD EVEN C=X S=X F=NO HARD SOFT
Buffer size in bytes. B=X bytes voor input en output buffer, B=X/Y X bytes voor input en Y bytes voor output. Interrupt Level 0..7 Interrupt priority level 0..32767 baudRate = X baud: 75,150,300,1200,2400,4800,9600 or 19200 baud. Parity off,odd or even. Character length = 5,6,7 or 8 bits. Stopbit length = 1 or 2 bits. Flow control = none, hardware(RTS-CTS) or software (Xon-Xoff).
Default configuration: buffer size interrupt level interrupt prio. baud rate parity char. length stop bit length flow control
26
9 Error codes
Errors are divided into command errors, execution errors, query errors and instrument specific errors. Refer to section 3.9 for more information on errors. Here only the codes and the meanings are defined. Not all codes listed here can be generated by our instruments. Negative error codes are defined by SCPI, positive numbers are instrument specific. 0 No error
Command errors. The command error bit in the standard Event Status Register (ESR) is set to 1' when such an error occurs. -100 -101 -102 -103 -104 Command error (one of the following is used if approriate) Invalid character. An element contains a character which is invalid for that type of element. For example a command containing am ampersand: :SETUP& Syntax error. An unrecognized command or data type was encountered. Invalid separator. The instruments parser was expecting a separator and encountered an illegal character. For instance the semicolon was omitted after a program message unit. Data type error. The instruments parser detected a data element of different type than expected. For example, a numerical data element was expected but a arbitrary block data element was detected. GET not allowed. A group execute trigger interface event was detected within a line of commands and/or queries. Parameter not allowed. Missing parameter. Command header error. Header separator error Program header too long. Undefined header. Header suffix out of range. Numeric data error. Invalid character in number. Exponent too large. Too many digits. Numeric data not allowed. Suffix error. Invalid suffix. Suffix too long. Suffix not allowed. Character data error Invalid character. Character data too long. Character data not allowed String data error. Invalid string data String data not allowed Block data error Invalid block data Block data not allowed Expression error Invalid expression Expression data not allowed Macro error. Invalid outside macro definition. Invalid inside macro definition Macro parameter error
Free University Amsterdam, Faculty of Sciences
-105 -108 -109 -110 -111 -112 -113 -114 -120 -121 -123 -124 -128 -130 -131 -134 -138 -140 -141 -144 -148 -150 -151 -158 -160 -161 -168 -170 -171 -178 -180 -181 -183 -184
27
Execution errors. The execution error bit in the standard Event Status Register (ESR) is set to 1' when such an error occurs. -200 -201 -202 -203 -210 -211 -212 -213 -214 -215 -220 -221 -222 -223 -224 -225 -226 -230 -231 -232 -233 -240 -241 -250 -251 -252 -253 -254 -255 -256 -257 -258 -260 -261 -270 -271 -272 -273 -274 -275 -276 -277 -278 -280 -281 -282 -283 -284 -285 -286 -290 -291 -292 -293 Execution error. Invalid while in local Settings lost due to rtl Command protected Trigger error Trigger ignored Arm ignored Init ignored Trigger deadlock Arm deadlock Parameter error Settings conflict Data out of range Too much data Illegal parameter Out of memory Lists not same length Data corrupt or stale Data questionable Invalid format Invalid version Hardware error Hardware missing Mass storage error Missing mass storage Missing media Corrupt media Media full Directory full Filename not found File name error Media protected Expression execution error Math error in expression Macro exec error Macro syntax error Macro execution error Illegal macro label Macro parameter execution error Macro definition too long Macro recursion error Macro redefinition not allowed Macro header not found Program error Cannot create program Illegal program name Illegal variable name Program currently running Program syntax error Program runtime error Memory use error Out of program memory Referenced name does not exist Referenced name already exist
Free University Amsterdam, Faculty of Sciences
28
Device specific errors. The device dependant error bit in the standard Event Status Register (ESR) is set to 1' when such an error occurs. -300 -310 -311 -312 -313 -314 -315 -320 -321 -330 -340 -350 -360 -361 -362 -363 Device specific error System error Memory error Pud memory lost Calibration memory lost Save recall memory lost Configuration memory lost Storage fault Out of internal memory Self test failed Calibration failed Queue overflow Communication error Parity error Framing error Input buffer overrun
Query errors. The query error bit in the standard Event Status Register (ESR) is set to 1' when such an error occurs. -400 -410 -420 -430 -440 Query error Query interrupted Query unterminated Query deadlocked Query unterminated
Other SCPI defined error values. The corresponding bit in the standard Event Status Register (ESR) is set to 1' when such an event occurs. -500 -600 -700 -800 Power on User request Request control Operation complete
29
10 Software revisions
A programmable instrument from our group is a modular design. There is no such thing as the instrument software revision. Instead, a few software revisions are mentioned here which could be of interest of the user. SCPI Engine revision The SCPI Engine is the engine of the programmable instruments command and query processing. The revision level is contained in the *IDN? query response. GPIB stream revision This software revision is only used internally. The GPIB stream handles all interaction with the GPIB bus (GPIB bus driver). SCPI standard version The SCPI standard itself is changing over time. The instruments developed in our group are (at this time) mostly SCPI 1996 complient. The SCPI standard version is returned by the :SYSTem:VERSion? query. Sub-system version(s) Important (long lasting with more or less continuous development) subsystems have version levels. This software revision is returned by the :<subsys-name>:VERSion? query. It returns three unsigned numeric values representing the version level of this subsystem: <major>,<minor>,<patch> The major version indicates the level on overall behaviour of the subsystem. A major level 2 subsystem is likely to give problems when expecting a major level 1. The minor version level indicates the syntax level. A minor level 2 subsystem is likely to have more commands or queries than a minor level 1 subsystem. It could also have some minor modifications to existing commands. Your application software (LabView, HP-VEE, etc) should work with little or no modifications. The patch version level indicates the changes to the subsystem which do not affect the behaviour, and do not add or modify the existing commands. Example: Controller sends: ad16_:vers? Instrument could reply: 1,3,3
30
11 Further reading
The IEEE488.2 and SCPI standard documents: ANSI/IEEE Std 488.1-1987, IEEE Standard Digital Interface for Programmable Instrumentation. Publisher: The Institute of Electrical and Electronics Engineers, New York ISBN : 471-62222-2 ANSI/IEEE Std 488.2-1987, IEEE Standard Digital Interface for Programmable Instrumentation. Publisher: The Institute of Electrical and Electronics Engineers, New York ISBN : SCPI 1996, Standard Commands for Programmable Instruments. Publisher: SCPI Consortium, La Mesa ISBN: -
More readable: Automatic Measurement Control, a tutorial on SCPI and IEEE488.2 by John M.Pieper. Publisher: ACEA / Rohde & Schwarz ISBN : -
From our group (download at our web site): The AD16 data acquisition board. AD16 SCPI Subsystem. AD16 SCPI Quick Reference Card The STEPPER, RUNNER and TWISTER motion control boards. t.b.a.
31
Some notes: Most gpib card manufactures have some simple tool to do troubleshooting. You can simply enter a command or query and see the results. The Electronics Group also has a simple utility written in HP-VEE. This can be downloaded from our web site.