![R&S 1424.6721.02 User Manual Download Page 126](http://html1.mh-extra.com/html/rands/1424-6721-02/1424-6721-02_user-manual_774880126.webp)
Performing Measurement Tasks - Programming Examples
R&S
®
NRP18S-xx
126
User Manual 1178.3686.02 ─ 05
9.5
Trace Measurement with Synchronization to Measure-
ment Complete
This example, written in pseudo code, shows how to set up 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?
waits (blocks) until a measurement result is available. However, this
behavior can lead to situations where an application blocks for a longer time (until time-
out). For example, if a trigger is missing and thus no results are ever becoming availa-
ble.
For certain applications, especially interactive ones, it is not the desired behavior that
you have to wait until a (probably long) timeout occurs. In these cases, start a mea-
surement 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 recommended to use the
status system of the sensor to find out whether the measurement is ready. The advant-
age 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" );
bool bMeasReady = false;
// poll until measurement is ready...
Trace Measurement with Synchronization to Measurement Complete