Agilent Technologies E4406A VSA Satellite Radio User Manual


 
Chapter 3 133
Programming Examples
Saving Binary Trace Data in an ASCII File
ViSession defaultRM, viVSA;
ViStatus viStatus= 0;
char sBuffer[80]= {0};
FILE *fTraceFile;
long lNumberPoints= 0;
long lNumberBytes= 0;
long lLength= 0;
long i = 0;
unsigned long lBytesRetrieved;
ViReal64 adTraceArray[10240];
char *vsaSetup = /* setup commands for VSA */
"*RST;*CLS;"/* Reset the device and clear status */
":FEED AREF;"/* set the input port to the internal
50MHz reference source*/
":DISP:FORM:ZOOM1;"/* zoom the spectrum display*/
":FREQ:CENT 50E6;"/* tune the analyzer to 50MHz*/
":FORM REAL,64;"/* Set the ouput format to a binary format*/
":FORM:BORD SWAP;"/* set the binary byte order to SWAP (for PC)*/
":INIT:IMM;"/* trigger a spectrum measurement*/
":FETC:SPEC7?";/* fetch the spectrum trace data*/
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL, &viVSA);
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/* Set I/O timeout to five seconds */
viSetAttribute(viVSA,VI_ATTR_TMO_VALUE,5000);
/* Send setup commands to instrument */