Agilent Technologies 86100-90086 Sprinkler User Manual


 
2-11
Sample Programs
Sample C Programs
init.c - Storing Waveform Time and Voltage Information
/*
* Function name: store_csv
* Parameters: none
* Return value: none
* Description: This routine stores the time and voltage information about
* the waveform as time/voltage pairs in a comma-separated variable file
* format.
*/
void store_csv ( )
{
FILE *fp;
int i;
fp = fopen ("pairs.csv","wb"); /* open file in binary mode - clear file */
/* if already exists */
if (fp != NULL)
{
for (i = 0; i < Acquired_length; i++)
{
/* write time,volt pairs to file */
fprintf ( fp,"%e,%lf\n",time_value[i],volts[i]);
}
fclose ( fp ); /* close file */
}
else
printf ("Unable to open file 'pairs.csv'\n");
} /* end store_csv ( ) */
The time and voltage information of the waveform is stored in integer format, with the time
stored first, followed by a comma, and the voltage stored second.
gen_srq.c - Generating a Service Request
Segments of the sample C program “gen_srq.c” show how to initialize the interface
and analyzer, and generate a service request.
Two include statements start the “gen_srq.c” program. The file “stdio.h” defines the standard
location of the printf routine, and is needed whenever input or output functions are used.
The file “hpibdecl.h” includes necessary prototypes and declarations for the analyzers sample
programs. The path of these files must specify the disk drive and directory where the
“include” files reside.
/* gen_srq.c */
/*