beautypg.com

GW Instek SFG-830 User Manual User Manual

Page 27

background image

p. 24 SFG-830

6.16 The Examples of the Communication Interface Software

EXAMPLE 1Send Arbitrary Waveforms

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

int sfg830
int data[10000];

void main( )
{

char cmd[10];
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]=4094

∗wave[j]/amp;

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

}
for(j=0;j{

if(data[j]<0)
data[j]=(0xffff-data[j]+1)+0x8000;

}

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

ibwrt(dev_,cmd,40);
if(cmd[1]= =0x31)
{

ibtmo (dev_,T30s);

ibwrt(dev_,(char

∗)data,(1ong)2∗number); /∗ send waveforms data ∗/

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

}

}