DS335 Synthesized Function Generator
DS335 Synthesized Function Generator
DS335 Synthesized Function Generator
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
3-12 Programming Examples<br />
EXAMPLE 1: GPIB COMMUNICATION. C LANGUAGE<br />
This program communicates with the <strong>DS335</strong> via GPIB . The program is written in C.<br />
/*<br />
C Program to demonstrate communication with the <strong>DS335</strong> via<br />
GPIB. Written in Microsoft C and uses National Instruments<br />
GPIB card. Assumes <strong>DS335</strong> is installed as device name D<strong>DS335</strong>.<br />
Refer to National Instruments for Device Name setup.<br />
*/<br />
#include <br />
#include <br />
#include <br />
#include <br />
#include /* National Instruments header files */<br />
void main(void); /* function declaration */<br />
int dds335;<br />
void main()<br />
{<br />
char cmd[40];<br />
char start[20];<br />
char stop[20];<br />
}<br />
if ((dds335 = ibfind("D<strong>DS335</strong>")) < 0) /* open National driver */<br />
{<br />
printf ("Cannot find D<strong>DS335</strong>\n");<br />
exit(1);<br />
}<br />
/* Now that the driver is located, reset the <strong>DS335</strong> */<br />
sprintf (cmd, "*RST\n");<br />
ibwrt(dds335,cmd,strlen(cmd)); /* send command */<br />
/* Setup the <strong>DS335</strong> as follows:<br />
500 kHz Square Wave, 1.5 Vpp, -1.0 Volt offset, display offset */<br />
sprintf (cmd, "FREQ500000;AMPL1.5VP;OFFS-1.0;KEYS3;\n");<br />
ibwrt(dds335,cmd,strlen(cmd)); /* send commands */<br />
/* Now query the <strong>DS335</strong> for the sweep start and stop frequencies */<br />
sprintf (cmd, "STFR\n"); /* ask for start rate */<br />
ibwrt (dds335,cmd,strlen(cmd)); /* send query */<br />
ibrd(dds335,start,20); /* read back start frequency */<br />
sprintf (cmd, "SPFR\n"); /* ask for stop rate */<br />
ibwrt (dds335,cmd,strlen(cmd)); /* send query */<br />
ibrd(dds335,stop,20); /* read back stop frequency */<br />
printf("\n\n\n\n ******** <strong>DS335</strong> Setup Demo *******" );<br />
printf("\n\n\n\n<strong>DS335</strong> Sweep Start Frequency = %e Hz\n\n", atof(start));<br />
printf("<strong>DS335</strong> Sweep Stop Frequency = %e Hz\n", atof(stop));<br />
<strong>DS335</strong> <strong>Synthesized</strong> <strong>Function</strong> <strong>Generator</strong>