Specifications
288 Chapter 18
PSA Programming Examples
Using C to Save Binary Trace Data
PSA Programming Examples
ViReal64 adTraceArray[10240];
char *psaSetup =/* setup commands for VSA/PSA */
":INST BASIC;"/* Set the instrument mode to Basic */
"*RST;*CLS;"/* Reset the device and clear status */
":INIT:CONT 0;"/* Set analyzer to single measurement mode */
":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 */
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL, &viPSA);
/*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 ten seconds */
viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,10000);
/* Send setup commands to instrument */
viPrintf(viPSA,"%s\n",vsaSetup);
/* Query the instrument for Operation complete */
viQueryf(viPSA,"*OPC?\n", "%d", &lOpc);
/* fetch the spectrum trace data*/
viPrintf(viPSA,"FETC:SPEC7?\n");