2
Remote Control
2.1 Remote control basis
14
which they are received. In order to ensure that the commands are executed in a certain order, each
command must be sent as a separate command line.
Example: Command line contains set and query commands
If multiple commands in a command line contain query commands, the query result is unpredictable. The
following command returns a fixed value: :FREQ:STAR 1GHZ;SPAN 100;:FREQ:STAR?
Returned value: 1,000,000,000 (1 GHz)
The following command returns an unfixed value: :FREQ:STAR 1GHz;STAR?;SPAN 1000000
The returned result may be the current starting frequency value because the host program will delay
executing the command. If the host program receives and executes the command, the returned result
may also be 1 GHz.
Setting command and query command are sent separately
General rule: In order to ensure the correctness of the returned result from the query command, the
setting command and the query command shall be sent in different program control messages.
2.1.4.1 Preventing overlapping execution of the command
In order to prevent the overlapped execution of commands, multiple threads or commands: *OPC, *OPC?
or *WAI can be used. These three commands can be executed only after the hardware is set. While
programming, the computer can be forced to wait for some time to synchronize certain events. The
details are separately described below:
Controller program uses multiple threads
Multi threads are used to wait for completion of the command and achieve synchronization of GUI and
program control, that is, a single thread waits for completion of *OPC?, without impeding the execution
of the GUI or remote control thread.
The usage of the three commands in synchronous execution is shown in the table below:
Table 2.5
Command Syntax
Method
Actions to be Executed
Programming Method
*OPC
After the command is executed, the operation
complete bit in ESR register
is set.
Set ESE BIT0;
Set SRE BIT5;
Send the overlapped command and *OPC;
Wait for the service request signal (SRQ)
SRQ
represents
the
completion
of
execution of the overlapped command
*OPC?
The execution of current command is stopped
until it returns
until the value 1 is returned. The command is
returned only when the operation completion
bit in the ESR is set, which indicates that the
previous command is processed.
Terminate the processing of the current
command
before
executing
other
commands, and send the command directly
after the current command.
*WAI
Before executing *WAI, wait until all
commands have been sent and then continue
processing unfinished commands.
Terminate the processing of the current
command
before
executing
other
commands, and
send the command directly after the current
command.
NOTE