
Performing Measurement Tasks - Programming Examples
R&S
®
NRPxxS(N)
149
User Manual 1177.5079.02 ─ 10
//Query the measurement results
FETCh?
10.5
Trace Measurement with Synchronization to Measure-
ment Complete
This example, written in pseudo code, shows how to setup and execute a trace mea-
surement using a non-blocking technique.
The advantage of using the
FETCH?
command (as shown in the previous example) is,
that
FETCH?
will wait (block) until a measurement result is available. However this may
lead to situations where an application blocks for a longer time (until timeout) if, for
example, a trigger is missing and thus no results will ever become available.
For certain applications, especially interactive ones, it is not the desired behavior that
the user has to wait until a (probably long) timeout occurs. In these cases it is preferred
to start a measurement and then enter a loop to poll the sensor until the measurement
is ready and the results can safely be retrieved. For such applications it is recommen-
ded to use the status system of the sensor to find out whether the measurement is
ready. The advantage of this approach is that the polling loop can be exited/canceled
at any time and the application stays operable (i. e. does not block).
// basic setup, similar to the previous example
write( "*RST" );
write( "SENS:FUNC \"XTIM:POW\"" );
write( "SENS:FREQ 1.8e9" );
write( "SENS:TRAC:POIN 500" );
write( "SENS:TRAC:TIME 20e-3" );
write( "TRIG:SOUR INT" );
write( "TRIG:SLOP POS" );
write( "TRIG:DTIM 0.001" );
write( "TRIG:HYST 0.1" );
write( "TRIG:LEV 30e-6" );
write( "SENS:TRAC:AVER:COUN 8" );
write( "SENS:TRAC:AVER:STAT ON" );
// configuring the event system to recognize the
// end of measurement (i.e. a negative transition
// of bit 1 in the meas operation register)
write( "STAT:OPER:MEAS:NTR 2" );
write( "STAT:OPER:MEAS:PTR 0" );
// resetting the event information by an initial readout
int iEvent = 0;
query( "STAT:OPER:MEAS:EVEN?", &iEvent );
// Now starting the measurement
write( "INIT:IMM" );
Trace Measurement with Synchronization to Measurement Complete