Program Examples
3-20
if ((ds345 = ibfind("DS345")) < 0) /* open National driver */
{
printf ("Cannot find DS345\n");
exit(1);
}
sum = 0;
/* initialize checksum */
j = -2048;
/* initial ramp value (-full scale)*/
number = 8192;
/* number of points in waveform */
/* will make a 8192 point ramp, increment y value every other point */
for (i = 0 ; i < number ; i++)
{
data[i] = j;
/* y value */
sum += data[i];
/* add to checksum */
if (i&1)j++;
/* increment y value if i is odd */
}
data[number] = sum; /* checksum */
sprintf (cmd,"LDWF?0,%d\n",number);
/* command to load waveform */
ibwrt (ds345,cmd,strlen(cmd));
ibrd (ds345,cmd,40);
/* read back reply before sending data */
ibwrt (ds345,(char *)data,(long)2*2); /* number of bytes = 2 per data
point + 2 for checksum */
sprintf (cmd,"FUNC5\n"); /* arb wf output */
ibwrt (ds345,cmd,strlen(cmd));
}
EXAMPLE 5:
Vector Mode Arbitrary Waveform.
This program downloads an arbitrary in vector edit mode. The data is just a list of x values (waveform RAM
addresses) and amplitude values. The program generates a triangle wave whose amplitude linearly grows in
time (the vertex y values grow and alternate in sign). The program is written in C.
/* program to donwload vector mode arb wf to DS345.
The waveform is a triangle wave linearly increasing in
amplitude (a "christmas tree" on its side). Written in
Microsoft C and uses National Instrument GPIB card. Expects DS345
to be installed as DS345 in IBCONF */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dos.h>
#include <decl.h>
/* National Instruments header file */
void main(void);
int ds345;
int data[10000]; /* up to 10000 points */
void main ()
{
char cmd[40];
int i,sum,number;
Summary of Contents for DS345
Page 2: ......
Page 5: ...DS345 Synthesized Function Generator iii...
Page 20: ...Introduction 2 4...
Page 64: ...Programming Commands 3 14...
Page 72: ...Program Examples 3 22...
Page 78: ...Troubleshooting 4 6...
Page 82: ...Performance Tests 5 4...
Page 101: ...Calibration 6 10...
Page 109: ...Arbitrary Waveform Composer 7 8...
Page 117: ...DS345 Circuitry 8 8...