beautypg.com

GW Instek SFG-830 User Manual User Manual

Page 28

background image

SFG-830 p.25

EXAMPLE 2Arbitrary Amplitude 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];

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);

for(j=0;j{

wave[j]=2048+(1368

∗wave[j])

data[j]=(int) (wave[j]+0.5);

}

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,(1ong)2∗number); /∗ send waveforms data ∗/

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

}