Synchronizing the VNA and Controller

Synchronizing the VNA (Vector Network Analyzer) and Controller means to keep VNA and the controller working at approximately the same pace. In this topic:

See Also

The Problem

The controller sends commands to the VNA as fast as the bus will allow. The VNA stores these commands in the VNA Input queue. However, the VNA executes those commands at a slower rate than they are accepted. If left unchecked, the VNA input buffer will contain a long list of commands waiting to be executed.

At some point, the controller will send a query command which requires a response from the VNA. The controller will not send more commands until a response is received. It will wait for a response from the VNA for the amount of time set by the Timeout setting. If the VNA is working off a long list of commands in the input buffer, if may not execute and respond to the query command until the controller has quit waiting, or "timed out".

The Solution

The easiest way to keep the controller and the VNA "synched" is to send query commands often. This stops the controller from sending more commands until the VNA executes and responds to the query. This limits the number of commands that are waiting in the VNA input queue to be processed.

Although any query will stop the controller from sending more commands, a good practice is to send  *OPC? Most of the time, as soon as this query is executed, the VNA will immediately reply. The exception to this is the Overlapped command.

Note: The analyzer has two overlapped commands:

Several calibration commands have an optional ASYNcronous argument which allows them to behave like overlapped commands. Learn more.

Analyzer Queues

Queues are memory buffers that store messages until they can be processed. The analyzer has the following queues:

Input Queue

The controller sends statements to the analyzer without regard to the amount of time required to execute the statements. The input queue is very large (31k bytes). It temporarily stores commands and queries from the controller until they are read by the analyzer's command parser. The input queue is cleared when the analyzer is switched ON.

Output Queue

When the analyzer parses a query, the response is placed in the output queue until the controller reads it. Your program should immediately read the response or it may be cleared from the output queue. The following conditions will clear a query response:

Error Queue

Each time the analyzer detects an error, it places a message in the error queue. When the SYSTEM:ERROR? query is sent, one message is moved from the error queue to the output queue so it can be read by the controller. Error messages are delivered to the output queue in the order they were received. The error queue is cleared when any of the following conditions occur:

If the error queue overflows, the last error is replaced with a "Queue Overflow" error. The oldest errors remain in the queue and the most recent error is discarded.

Synchronization Methods

The following common commands are used to synchronize the analyzer and controller. Examples are included that illustrate the use of each command in a program. See the SCPI command details to determine if a command is an overlapped command.


The *WAI command:

Example of the *WAI command

"ABORT;:INITIATE:IMMEDIATE" 'Restart the measurement.
CALCULATE:MARKER:SEARCH:MAXIMUM" 'Search for max amplitude.
"CALCULATE:MARKER:X?" 'Which frequency?

The following time line shows how the processing times of the three commands relate to each other:

INITIATE:IMMEDIATE is an overlapped command. It allows the immediate processing of the sequential command, CALCULATE:MARKER:SEARCH:MAXIMUM. However, the INITIATE:IMMEDIATE is not considered complete until the measurement is complete. Therefore, the marker searches for maximum amplitude before the measurement completes. The CALCULATE:MARKER:X? query could return an inaccurate value.

To solve the problem, insert a *WAI command.

"ABORT;:INITIATE:IMMEDIATE" 'Restart the measurement.
"*WAI" 'Wait until complete.

"CALCULATE:MARKER:MAXIMUM" 'Search for max amplitude.
"CALCULATE:MARKER:X?" 'Which frequency

The time line now looks like this:

The *WAI command keeps the MARKER:SEARCH:MAXIMUM from taking place until the measurement is completed. The CALCULATE:MARKER:X? query returns the correct value.

Note: Although *WAI stops the analyzer from processing subsequent commands, it does not stop the controller. The controller could send commands to other devices on the bus.


The *OPC? query stops the controller until all pending commands are completed.

In the following example, the Read statement following the *OPC? query will not complete until the analyzer responds, which will not happen until all pending commands have finished. Therefore, the analyzer and other devices receive no subsequent commands. A "1" is placed in the analyzer output queue when the analyzer completes processing an overlapped command. The "1" in the output queue satisfies the Read command and the program continues.

Example of the *OPC? query

This program determines which frequency contains the maximum amplitude.

"ABORT; :INITIATE:IMMEDIATE"! Restart the measurement
"*OPC?" 'Wait until complete
Meas_done = GPIB.Read 'Read output queue, throw away result
"CALCULATE:MARKER:MAX" 'Search for max amplitude
"CALCULATE:MARKER:X?" 'Which frequency?
Marker_x = GPIB.Read
PRINT "MARKER at " & Marker_x & " Hz"


The *OPC command allows the analyzer and the controller to process commands while processing the overlapped command.

When the analyzer completes processing an overlapped command, the *OPC command sets bit 0 of the standard event register to 1 . This requires polling of status bytes or use of the service request (SRQ) capabilities of your controller. See Reading the Analyzer's Status Registers for more information about the standard event status register, generating SRQs, and handling interrupts.

Note: Be careful when sending commands to the analyzer between the time you send *OPC and the time you receive the interrupt. Some commands could jeopardize the integrity of your measurement. It also could affect how the instrument responds to the previously sent *OPC.

Example of polled bit and SRQ processes.

When To Synchronize the Analyzer and Controller

The need to synchronize depends upon the situation in which the overlapped command is executed. The following section describes situations when synchronization is required to ensure a successful operation.

Completion of a Measurement

To synchronize the analyzer and controller to the completion of a measurement, use the ABORT;INITIATE:IMMEDIATE command sequence to initiate the measurement.

This command sequence forces data collection to start (or restart) under the current measurement configuration. A restart sequence, such as ABORT;INITIATE:IMMEDIATE is an overlapped command. It is complete when all operations initiated by that restart command sequence, including the measurement, are finished. The *WAI,*OPC? and *OPC commands allow you to determine when a measurement is complete. This ensures that valid measurement data is available for further processing.

Measurements with External Trigger

See Triggering the VNA using SCPI.

External Triggering

Averaged Measurements

Averaged measurements are complete when the average count is reached. The average count is reached when the specified number of individual measurements is combined into one averaged measurement result. Use synchronization to determine when the average count has been reached.

If the analyzer continues to measure and average the results after the average count is reached, use synchronization to determine when each subsequent measurement is complete.

During Calibration Acquire

During a calibration with slow sweep speeds, such as when using a narrow IF bandwidth, you may want to have your program perform other operations, such as checking for the click event of a Cancel button.

To do this, use the optional ASYNchronous argument with the ACQuire command as shown in several calibration example programs. The VNA parser returns immediately while the cal step measurement proceeds. It does NOT block commands and wait for the measurement step to finish. You can send *ESR? or *STB? queries to monitor the status register bytes to see when the OPC (operation complete) bit gets set, which indicates the cal measurement step has finished. Learn more about status registers.

Note: Do NOT issue the *OPC? command when using the ASYN argument. If your program is using the ScpiStringParser, then you can ONLY use *OPC? to detect when the OPC bit is set, so do NOT use the ASYN argument with the calibration commands when using that parser.

When using the ASYN argument, set the timeout value in the IO settings to at least 5 seconds. There are intervals during the cal acquires when the VNA takes a several seconds to respond to additional commands, such as  when the processor is calculating error terms.

The following commands have this argument:




Guided 2-Port or 4-Port Cal

SENS:CORR:COLL:ACQuire (Unguided Cal)

Perform Unguided ECAL

SOUR:POW:CORR:COLL:ACQuire (Source Power Cal)

Perform a Source and Receiver Power Cal (shows polling loop)

In addition, the SENS:CORR:COLL:GUIDed:INITialize command has this optional argument for long calibration initialization, such as a CalAll calibration.