106 Chapter 3
Programming Examples
Using Marker Peak Search and Peak Excursion
/*Program Variables*/
ViStatus viStatus = 0;
double dMarkerFreq = 0;
double dMarkerAmpl = 0;
float fPeakExcursion =0;
long lOpc = 0L;
/*Open a GPIB session at address 18.*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
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");
/*Set Y-Axis units to dBm*/
viPrintf(viESA, "UNIT:POW DBM\n");
/*Set the analyzer center frequency to 50MHZ*/
viPrintf(viESA,"SENS:FREQ:CENT 50e6\n");
/*Set the analyzer span to 50MHZ*/
viPrintf(viESA,"SENS:FREQ:SPAN 50e6\n");
/*Display the program heading */
printf("\n\t\t Marker Program \n\n" );
/* Check for the instrument model number and route the 50MHz signal accordingly*/
Route50MHzSignal();
/*Set analyzer to single sweep mode*/
viPrintf(viESA,"INIT:CONT 0 \n");
/*User enters the peak excursion value*/
printf("\t Enter PEAK EXCURSION in dB: ");
scanf( "%f",&fPeakExcursion);
/*Set the peak excursion*/
viPrintf(viESA,"CALC:MARK:PEAK:EXC %1fDB \n",fPeakExcursion);