Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Instrument timeout during long measurements

I am trying to read EVM from an Agilent E4440 spectrum analyzer. The default measurement uses 10 averages to make the measurement and this takes about 40 seconds to complete. Alas when I write code to read the EVM data I get bus timeout error before the measurement completes. Is there an easier way around this problem besides adding a sleep(xxxx) statement to my code. I searched the web and this forum for info on the *WAI and *OPC commands but was unsucessful.
 
I am a novice programmer that uses simple commands through ibwrt functions. I think a solution might be to initiate the measurement (INIT) and then FETCh the data with the analyzer in single sweep mode. But I don't know how to determine when the operation is complete. It seems like *WAI or *OPC must be the commands but I have yet to figure them out.
0 Kudos
Message 1 of 5
(5,169 Views)

The *WAI command blocks the interface bus so I don't recommend it.  A good way is to use the *OPC command that makes the instrument generate an OPC standard event when the measurement completes.  It can be detected by reading Standard Event Register or Status Byte Register.  This approach can be used for any other instruments that understand SCPI language.

// Make the instrument transmit OPC event to the Status Byte
*ESE 1

// Clear registers, Initiate measurement
*CLS;:INIT;*OPC

// Loop until STB indicates the ESB (0x20) bit
do {
  (Read Status Byte)
} while( (STB & 0x20) == 0x00)

// Measurement complete
FETC?
(Read Response)

Mind that actual Do/While loop in your app must also process the case that the measurement was ABORted without completion. In this case the ESB bit on the Status Byte Register will not be generated, therefore better to have other loop-exit conditions.

 

0 Kudos
Message 2 of 5
(5,151 Views)
Thanks for the reply. Looking at your approach and reading some literature gave me a moderate concept of what is going on. I am programming in vb so I will have to convert your code but that should not be a problem.
 
Before I wrtie the code I tried some commands out using NI-488.2 Communicator but still get timeout errors. The commands I used in sequence are:
 
*ESE 1
*CLS;:INIT:RHO;*OPC
*STB?
 
While the INIT function is waiting to finish the 40 second measurement I can check the status byte. I use the query command to attemp a status inquiry but get a timeout error. Does anyone know what I am doing wrong?
0 Kudos
Message 3 of 5
(5,122 Views)
I meant to say I can't read the status byte while the INIT command is running. I get timeout errors.
0 Kudos
Message 4 of 5
(5,121 Views)
Likely the instrument implements the command parser engine as "sequential" processing, therefore any other command W/R operation is being blocked during INITiate process.  (Though such operation is not allowed by SCPI specification as I think...)
 
The *STB? query is almost equivalent to Serial Polling but, the RQS bit is replaced with the MSS bit.  But the biggest difference is that the *STB? query requires the instrument firmware to process command parsing where as Serial Polling is processed by the GPIB chip (such as 9914, 7210, NAT, etc) by itself.  This might be why Serial Polling works but the *STB? query may not.
 
If Serial Polling does work during INITiate process and its response (Status Byte Register) correctly indicates generated events at operation complete, you can use that approach by using Serial Polling.  Otherwise, an alternative approach will be needed.
0 Kudos
Message 5 of 5
(5,104 Views)