Specifications
Chapter 16 185
ESA/PSA Programming Examples
Using C and Service Request (SRQ) to Determine When a Measurement is
Complete
ESA/PSA Programming Examples
/*Program Variables*/
ViStatus viStatus = 0;
long lOpc=0;
/* Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viSA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/* Set I/O timeout to twenty seconds */
viSetAttribute(viSA,VI_ATTR_TMO_VALUE,20000);
/*Clear the instrument*/
viClear(viSA);
/*Reset the instrument*/
viPrintf(viSA,"*RST\n");
/*Clear the status byte of the instrument*/
viPrintf(viSA,"*CLS\n");
/*Put the analyzer in a single sweep*/
viPrintf(viSA,"INIT:CONT 0 \n");
/* Change the instrument mode to Spectrum Analysis */
viPrintf(viSA,":INST:NSEL 1\n");
/*Set the analyzer resolution bandwidth to 300 Khz*/
viPrintf(viSA,"SENS:BAND:RES 300 KHz\n");
/*Set the analyzer to 10MHz span*/
viPrintf(viSA,"SENS:FREQ:SPAN 10MHz\n");