Program Examples
3-18
ibwrt (ds345,cmd,strlen(cmd));
/* send commands */
sprintf (cmd,"AMOD?%d\n",number); /* arb modulation command */
ibwrt (ds345,cmd,strlen(cmd));
ibrd (ds345,cmd,40);
/* read back reply before sending data */
ibwrt (ds345,(char *)data,(long)4*4); /* number of bytes = 4 per data
point + 4 for checksum */
sprintf (cmd,"MENA1\n"); /* turn modulation on */
ibwrt (ds345,cmd,strlen(cmd));
}
EXAMPLE 3:
Arbitrary Phase Modulation.
This program downloads an arbitrary PM pattern to the DS345. The modulating waveform is a sine wave.
Since the DS345 expects a list of phase
changes
we calculate the initial phase of the waveform and then
take differences from that phase. The program calculates the PM pattern values, sets the modulation type
to PM, modulation waveform to ARB, downloads the pattern, and enables modulation. The program is written
in C.
/* program to demonstrate arbitrary PM modulation. Will generate a
sine wave with span of 90deg (-45 deg to +45 deg). Written in Microsoft C
and uses National Instruments GPIB card. Assumes DS345 is installed
as device name DS345. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dos.h>
#include <math.h>
#include <float.h>
#include <decl.h>
/* National Instruments header file */
void main(void);
int ds345;
unsigned long data[4000]; /* up to 4000 points 4 bytes each */
void main ()
{
char cmd[40];
int i,number;
long sum;
double t,s,span,old,new;
if ((ds345 = ibfind("DS345")) < 0) /* open National driver */
{
printf ("Cannot find DS345\n");
exit(1);
}
number = 1000;
/* 1000 points */
sum = 0l;
/* initialize checksum */
s = pow (2.0,16.0);
/* scale factor */
span = 90.0;
/* 90 deg span */
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...