Program Examples
3-17
sprintf (cmd,"MENA1\n"); /* turn modulation on */
ibwrt (ds345,cmd,strlen(cmd));
}
EXAMPLE 2:
Arbitrary Frequency Modulation.
This program downloads an arbitrary FM pattern to the DS345. The modulating waveform is a sine wave.
The program calculates the FM pattern values, sets the modulation type to FM, modulation waveform to ARB,
downloads the pattern, and enables modulation. The program is written in C.
/* program to demonstrate arbitrary FM modulation. Will generate a
sine wave FM of 50kHz carrier with 10 kHz span. 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[1500]; /* up to 1500 points 4 bytes each */
void main ()
{
char cmd[40];
int i,number;
long sum;
double t,center,span,s;
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,32.0);
/* scale factor */
center = 50.0E3;
/* 50 kHz center freq */
span = 10.0E3;
/* 10 kHz span */
/* now we will calculate 4-byte frequency data, each point is
given by value = 2^32 * ( freq/40 MHz) */
for (i = 0 ; i < number ; i++)
{
t = span/2.0 * sin ((6.2831853*(double)i)/(double)number); /* delta freq */
t += center;
/* + center freq = output frequency */
t /= 40.0E6; /* ratio to 40 MHz */
data[i] = (long)(s*t);
sum += data[i];
}
data[number] = sum; /* store checksum */
sprintf (cmd,"MENA0;MTYP3;MDWF5\n"); /* make sure modulation off until after
loading, set FM, arb WF */
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...