Chapter 3 153
Programming Examples
Status Register–Determine When a Measurement is Done
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*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 Status Register - Determine When a Measurement is Done \n\n" );
/*Put the analyzer in a single sweep*/
viPrintf(viESA,"INIT:CONT 0 \n");
/* Check for the instrument model number and route the 50MHz-signal accordingly*/
Route50MHzSignal();
/*Set the analyzer to 50MHz center frequency*/
viPrintf(viESA,"SENS:FREQ:CENT 50 MHz\n");
/*Set the analyzer resolution bandwidth to 300 Khz*/
viPrintf(viESA,"SENS:BAND:RES 300 KHz\n");
/*Set the analyzer to 10MHz span*/
viPrintf(viESA,"SENS:FREQ:SPAN 10MHz\n");
/*Trigger a sweep*/
viPrintf(viESA,"INIT:IMM\n");
/*Make sure the previous command has been completed*/
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/* Set the service request mask to assert SRQ when either a measurement
is completed or an error message has occurred.*/
viPrintf(viESA,"*SRE 96\n");
viPrintf(viESA,"*ESE 35\n");
/* Configure the computer to respond to an interrupt*/