Introduction to Programming - 4
Multiple Commands in a Message
Multiple SCPI commands can be combined and sent as a single message with one message terminator. There are two important considerations when sending several commands within a single message:
♦Use a semicolon to separate commands within a message.
♦There is an implied header path that affects how commands are interpreted by the dc source.
The header path can be thought of as a string that gets inserted before each command within a message. For the first command in a message, the header path is a null string. For each subsequent command the header path is defined as the characters that make up the headers of the previous command in the message up to and including the last colon separator. An example of a message with two commands is:
OUTPut:STATe ON,(@1);PROTection:CLEar (@1)
which shows the use of the semicolon separating the two commands, and also illustrates the header path concept. Note that with the second command, the leading header "OUTPut" was omitted because after the "OUTPut:STATe ON" command, the header path was became defined as "OUTPut" and thus the instrument interpreted the second command as:
OUTPut:PROTection:CLEar (@1)
In fact, it would have been syntactically incorrect to include the "OUTP" explicitly in the second command, since the result after combining it with the header path would be:
OUTPut:OUTPut:PROTection:CLEar (@1)
which is incorrect.
Moving Among Subsystems
In order to combine commands from different subsystems, you need to be able to reset the header path to a null string within a message. You do this by beginning the command with a colon (:), which discards any previous header path. For example, you could clear the output protection and check the status of the Operation Condition register in one message by using a root specifier as follows:
OUTPut:PROTection:CLEar(@1);:STATus:OPERation:CONDition?(@1)
The following message shows how to combine commands from different subsystems as well as within the same subsystem:
VOLTage:LEVel 7.5,(@1);PROTection ON,(@1);:CURRent:LIMit 0.25,(@1)
Note the use of the optional header LEVel to maintain the correct path within the subsystems, and the use of the root specifier to move between subsystems.
Including Common Commands
You can combine common commands with system commands in the same message. Treat the common command as a message unit by separating it with a semicolon (the message unit separator). Common commands do not affect the header path; you may insert them anywhere in the message.
VOLTage:TRIGgered 10,(@1);:INITiate:NAME TRAN;*TRG
OUTPut OFF,(@1);*RCL 2;OUTPut ON,(@1)
Using Queries
Observe the following precautions with queries:
♦Add a blank space between the query indicator (?) and any subsequent parameter such as a channel.
♦Set up the proper number of variables for the returned data.
♦Read back all the results of a query before sending another command to the dc source. Otherwise a Query Interrupted error will occur and the unreturned data will be lost.
33