130 Chapter 3
Programming Examples
Using Markers
#include <math.h>
#include "visa.h"
void main ()
{
/*program variables*/
ViSession defaultRM, viVSA;
ViStatus viStatus= 0;
double dPeakPower= 0;
double dNoiseMarker = 0;
double dResult= 0;
long lComplete= 0;
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL, &viVSA);
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*set the instrument to Basic Mode*/
viPrintf(viVSA, "INST BASIC\n");
/*Preset the instrument */
viPrintf(viVSA, "*RST\n");
/*set the input port to the internal 50Mhz reference source*/
viPrintf(viVSA, "SENS:FEED AREF\n");
/*tune the analyzer to 50MHZ*/
viPrintf(viVSA, "SENS:FREQ:CENT 50E6\n");
/*put the analyzer in a single mode*/
viPrintf(viVSA, "INIT:CONT 0\n");
/*zoom the spectrum display*/
viPrintf(viVSA, "DISP:FORM:ZOOM1\n");
/*trigger a spectrum measurement*/
viPrintf(viVSA, "INIT:IMM;*OPC?\n");
/*poll the operation complete query*/