Performing Measurement Tasks - Programming Examples
R&S
®
NRPxxS(N)
147
User Manual 1177.5079.02 ─ 10
// Auto-Trigger OFF
SENSOR.write( "TRIG:ATR:STAT OFF" );
// Configure a buffered measurement
// Buffer size is randomly selected to 17
SENSOR.write( "SENS:BUFF:SIZE 17" );
SENSOR.write( "SENS:BUFF:STAT ON" );
SENSOR.write( "TRIG:COUN 17" );
// Read out all errors / Clear error queue
SENSOR.query( "SYST:ERR:ALL?", szBuf, sizeof( szBuf ) );
printf( szBuf );
// Start a 'single' buffered measurement
// Since 17 trigger-counts have been configured,
// the 'single' buffered measurement, which becomes
// initiated by INIT:IMM, is not over until
// 17 physical measurements have been triggered
SENSOR.write( "INIT:IMM" );
// The end of a physical measurement can be recognized
// by a transistion to 'NOT MEASURING' which is a
// negative transistion on bit 1
SENSOR.write( "STAT:OPER:MEAS:NTR 2" );
SENSOR.write( "STAT:OPER:MEAS:PTR 0" );
// Collect 17 physical measurements
for ( int i = 0; i < 17; i++ )
{
// As a pre-condition: clear the event register by reading it
int iDummy;
SENSOR.query( "STAT:OPER:MEAS:EVEN?", &iDummy );
// Trigger a single physical measurement; either by '*TRG'
// command or by an externally supplied pulse on the SMB-type connector
if ( bUseBUSTrigger )
SENSOR.write( "*TRG" );
// Wait until the measurement is done
int iMeasEvent = 0;
while ( iMeasEvent != 2 )
{
SENSOR.query( "STAT:OPER:MEAS:EVEN?", &iMeasEvent );
iMeasEvent &= 2;
}
printf( "Triggered!\n" );
}
Performing a Buffered Continuous Average Measurement