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


 
Chapter 3 173
Programming Examples
Measuring Harmonic Distortion (RS-232)
dFundamental =50.0;
/* Open a serial session at COM1 */
viStatus=viOpenDefaultRM(&defaultRM);
if (viStatus =viOpen(defaultRM,"ASRL1::INSTR",VI_NULL,VI_NULL,&viESA) !=
VI_SUCCESS)
{
printf("Could not open a session to ASRL device at COM1!\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 mode */
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 */