Agilent Technologies N5183A MXG User Manual

Page 97

Advertising
background image

Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide

87

Programming Examples

GPIB Programming Interface Examples

// set the start and stop frequency for the sweep

stat = viPrintf(inst, "FREQ:START 1GHZ\n");

stat = viPrintf(inst, "FREQ:STOP 2GHZ\n");

// setup dwell per point

stat = viPrintf(inst, "SWEEP:DWELL %e\n", dwell);

// setup number of points

stat = viPrintf(inst, "SWEEP:POINTS %d\n", npoints);

// set interface timeout to double the expected sweep time

// sweep takes (~15ms + dwell) per point * number of points

// the timeout should not be shorter then the sweep, set it

// longer

long timeoutMS = long(2*npoints*(.015+dwell)*1000);

// set the VISA timeout

stat = viSetAttribute(inst, VI_ATTR_TMO_VALUE, timeoutMS);

// set continuous trigger mode off

stat = viPrintf(inst, "INIT:CONT OFF\n");

// turn list sweep on

stat = viPrintf(inst, "FREQ:MODE LIST\n");

int sweepNo = 0;

while(intCounter>0 )

{

// start the sweep (initialize)

stat = viPrintf(inst, "INIT\n");

printf("Sweep %d started\n",++sweepNo);

// wait for the sweep completion with *OPC?

int res ;

stat = viPrintf(inst, "*OPC?\n");

stat = viScanf(inst, "%d", &res);

// handle possible errors here (most likely a timeout)

// err_handler( inst, stat );

puts("Sweep ended");

// delay before sending next INIT since instrument

// may not be ready to receive it yet

Sleep(15);

intCounter = intCounter-1;

}

printf("End of Program\n\n");

Advertising
This manual is related to the following products: