164 Chapter 3
ProgrammingExamples
Measuring Harmonic Distortion (GPIB)
}
else
{
/* For the analyzers having freq uency limits >= 3GHz, prompt the us er*/
/* to connect the amplitude refe rence output to the input*/
printf ("Connect AMPTD REF OUT t o the INPUT \n");
printf ("......Press Return to c ontinue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Sig nal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
void TakeSweep()
{
/*Take a sweep and wait for the sw eep completion*/
viPrintf(viESA,"INIT:IMM\n");
viQueryf(viESA, "*OPC?\n", "%d", & lOpc);
if (!lOpc)
{
printf("Program Abort! Error occ urred: last command was not complet ed! \n");
exit(0);
}
}
void main()
{
/*Program Variables*/
ViStatus viStatus = 0;
double dFundamental = 0.0;
double dHarmFreq =0.0;
float fHarmV[10] ={0.0};
float fHarmDbm[10]={0.0};
float fRelAmptd[10]={0.0};
float fFundaAmptdDbm=0.0;
double dFundaAmptdV=0.0;
double dMarkerFreq = 0.0;
double dPrcntDistort =0.0;
double dSumSquare =0.0;
long lMaxHarmonic =0L;
long lNum=0L;
/*Setting default values*/
lMaxHarmonic =5;
dFundamental =50.0;