beautypg.com

GW Instek SFG-830 User Manual User Manual

Page 29

background image

p. 26 SFG-830

EXAMPLE 3Arbitrary Frequency Modulation

#include
#include
#include
#include
#include
#include

int sfg830
int data[10000];

void main( )
{

char cmd[40];
int i,j,number;
double amp,cycle,phase;
double wave[10000];
double t,center,span,s;

if ( (sfg830=ibfind(〝dev8〞) <0 )
{
printf (〝cannot find SFG830\n〞);

exit(1);
}

number=1000;
amp=2;
phase=0;
cycle=1;
SinePattern(number,amp/2,phase,cycle,wave);
number=1000;
amp=2;
phase=0;
cycle=1;
sinepattern(number,amp/2,phase,cycle,wave);

s=pow(2.0,32.0);
center=10.0E3;
span=10.0E3;
for(i=0;i{
t=span/2.0

∗wave[i];

t+=center;
t/=42.9496E6;
data[i]=(1ong)s

∗t;

}

sprintf(cmd,〝SOUR:FUNC:SOUR 5\n〞);
ibwrt(dev_,cmd,strlen(cmd));

sprintf(cmd,〝SOUR:FUNC:AMOD %d\n〞,number);
ibwrt(dev_,cmd,strlen(cmd));

ibrd(dev_,cmd,40);

ibtmo (dev_,T30s);

ibwrt(dev_,(char

∗)data,(long)4∗number); /∗send waveforms data ∗/

sprintf(cmd,〝SOUR:MOD:STAT 1\n〞);
ibwrt(dev_,cmd,strlen(cmd));

}