Chapter 3
183
Programming Examples
Making Faster Measurements (multiple measurements)
dPower = exp( dLogTen * (iArray[iLoop]/10000.0));
if(i > 0) {
dPwrAvgArray[iLoop] += ((dPower - dPwrAvgArray[iLoop])/(i+1));
}
else {
dPwrAvgArray[iLoop] = dPower;
}
}
} /* end of event loop */
/* stop the timer */
ftime( &stop_time );
/* Calculate elapsed time */
if (start_time.millitm > stop_time.millitm) {
stop_time.m= 1000;
stop_time.time--;
}
elapsed_time.millitm = stop_time.millitm - start_time.millitm;
elapsed_time.time = stop_time.time - start_time.time;
/* This is measurement time in milliseconds */
dDelta = (1000.0 * elapsed_time.time) + (elapsed_time.millitm);
/* show measurement statistics */
dTimePer=dDelta/((float)iNumTraces);
printf("\tPower average of
%
i
%
i-point traces performed in
%
3.1f
seconds\n",iNumTraces,iNumPoints,dDelta/1000);
printf("\t%6.1f milliseconds per averaged measurement\n",dTimePer);
printf("\t%6.1f averaged measurements per second\n",1000.0/dTimePer);
printf("\t%i bytes transferred per trace,
%
i bytes total\n\n",lRetCount,
iTotalRetCount);
return;
}
/******************************** Main ******************************/
void main(void) {
int iLoop;
int iAvgArray[NUM_POINTS];
ViStatus viStatus;
/* Open a GPIB session at address 18 */
viStatus = viOpenDefaultRM(&defaultRM);
viStatus = viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{