Agilent Technologies Model A.08.xx Water Dispenser User Manual


 
Chapter 3 165
Programming Examples
Measuring Harmonic Distortion (GPIB)
/* 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");
/*Display the program heading */
printf("\n\t\t Harmonic Distortion Program \n\n" );
/* Check for the instrument model number and route the 50MHz-signal accordingly*/
Route50MHzSignal();
/*Prompt user for fundamental frequency*/
printf("\t Enter the input signal fundamental frequency in MHz ");
/*The user enters fundamental frequency*/
scanf("%lf",&dFundamental);
/*Set the analyzer center frequency to the fundamental frequency. */
viPrintf(viESA,"SENS:FREQ:CENT %lf MHZ \n;",dFundamental);
/*Set the analyzer to 10MHz Span */
viPrintf(viESA,"SENS:FREQ:SPAN 10 MHZ\n");
/*Put the analyzer in a single sweep */
viPrintf(viESA,"INIT:CONT 0 \n");
/*Trigger a sweep, wait for sweep completion*/
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Perform a peak search */
viPrintf(viESA,"CALC:MARK:MAX \n");
/* Place the signal at the reference level using the
marker-to-reference level command and take sweep */
viPrintf(viESA,"CALC:MARK:SET:RLEV \n");
/*Trigger a sweep, wait for sweep completion*/