Agilent Technologies ESA-E Series Programmer's Manual page 153

Esa spectrum analyzers
Hide thumbs Also See for ESA-E Series:
Table of Contents

Advertisement

Programming Examples
Making Faster Measurements (multiple measurements )
for(i=0 ; i<iNumTraces ; i++)
{
/* trigger a new measurement and wait for complete
*/
viQueryf(viESA, " :INIT ;*OPC?\n", "%d", &lOpc) ;
if (llOpc)
{
printf("Program Abort! error occurred : last command was not
completed!\n") ;
exit(0) ;
}
/* Read the trace data into a buffe r
viPrintf(viESA, " :TRAC :DATA? TRACE1\n") ;
viRead(viESA,(ViBuf) clnBuffer, (ViUInt32) iBlockSize, &lRetCount ) ;
iTotalRetCount += 1RetCount ;
/* copy trace data to an array ,
/* byte order swapping could be done here rather than in ESA
memcpy(iArray, &clnBuffer[iHeaderLength], iArrayLength) ;
/* calculate a running power-average
for(iLoop = 0 ; iLoop < NUM POINTS ; iLoop++) {
/* running average of power, in milliwatt s
dPower = exp( dLogTen * (iArray[iLoop]/10000 .0)) ;
if(i > 0)
{
dPwrAvgArray[iLoop] += ((dPower - dPwrAvgArray[iLoop])/(i+l)) ;
}
else
{
dPwrAvgArray[iLoop] = dPower ;
}
}
}
/* end of event loop
/* stop the time r
ftime( &stop time ) ;
/* Calculate elapsed time
if (start time .millitm > stop time .millitm) {
stop_time .millitm += 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 millisecond s
dDelta = (1000 .0 * elapsed time .time) + (elapsed time .millitm) ;
* /
*/
* /
Chapter 3
3-93

Advertisement

Table of Contents
loading

Table of Contents