. . . continued
void main(void) /* Start of main() */
{
rst_clear(); /* Reset the instrument and clear error queue */
get_data(); /* Calculate the waveform data points */
out_waveform(); /* Download points and output arb waveform */
}
/**************************************************************************/
void rst_clear(void)
{
/* Reset the function generator, clear the error queue, and wait for
commands to complete. A "1" is sent to the output buffer from the
*OPC? command when *RST and *CLS are completed. */
float value;
IOOUTPUTS(ADDR, "*RST;*CLS;*OPC?", 15);
IOENTER(ADDR, &value);
}
/**************************************************************************/
void get_data(void)
{
/* Load 4000 points into an array to set the rise time and fall time
to 250 ns and the pulse width to 10 us (the output frequency is set
to 5 kHz in the "out_waveform" function). */
float *waveform;
int loop, num_points = 4000;
waveform = (float*) malloc (num_points * sizeof(float));
for (loop = 1; loop <= 5; loop++)
{
waveform[loop] = (float)(loop-1)/5; /* Set rise time (5 points) */
}
for (loop = 6; loop <= 205; loop++)
{
waveform[loop] = 1; /* Set pulse width (10 points) */
}
for (loop = 206; loop <= 210; loop++)
{
waveform[loop] = (float)(210-loop)/5; /* Set fall time (5 points) */
}
6
Chapter 6 Application Programs
Downloading an Arbitrary Waveform over GPIB
257