Chapter 3 159
Programming Examples
Determine if an Error has Occurred
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Clear the status byte of the instrument*/
viPrintf(viESA,"*CLS\n");
/*Display the program heading */
printf("\n\t\t Status register - Determine if an Error has Occurred\n\n" );
/* Check for the instrument model number and route the 50MHz-signal accordingly*/
Route50MHzSignal();
/*Put the analyzer in single sweep*/
viPrintf(viESA,"INIT:CONT 0 \n");
/*Set the service request mask to assert SRQ when either a measurement
is uncalibrated (i.e. "Meas Uncal" displayed on screen) or an error
message has occurred.*/
viPrintf(viESA,"STAT:QUES:ENAB 512\n");
viPrintf(viESA,"STAT:QUES:INT:ENAB 8\n");
viPrintf(viESA,"*ESE 35\n");
viPrintf(viESA,"*SRE 104\n");
/*Configure the computer to respond to an interrupt,install the handler
and enable it */
viInstallHandler(viESA, VI_EVENT_SERVICE_REQ, sSrqHdlr,ViAddr(10));
viEnableEvent(viESA, VI_EVENT_SERVICE_REQ,VI_HNDLR,VI_NULL);
iSrqOccurred =0;
/*Set the analyzer to a 500 MHz center frequency*/
viPrintf(viESA,"SENS:FREQ:CENT 500 MHZ \n");
/*Set the analyzer to a 100 MHz span*/
viPrintf(viESA,"SENS:FREQ:SPAN 100 MHZ\n");
/*Set the analyzer to a auto resolution BW*/
viPrintf(viESA,"SENS:BAND:RES:AUTO 1\n");
/*Set the analyzer to a Auto Sweep Time*/
viPrintf(viESA,"SENS:SWE:TIME:AUTO 1\n");
/*Allow analyzer to sweep several times.*/