2-12
Sample Programs
Sample C Programs
* This example program initializes the Agilent 86100 scope, runs an autoscale,
* then generates and responds to a Service Request from the scope. The program
* assumes an Agilent 86100 at address 7, an interface card at interface select code 7,
* and a signal source attached to channel 1.
*/
#include <stdio.h> /* location of: printf ( ) */
#include "hpibdecl.h"
void initialize ( );
void setup_SRQ ( );
void create_SRQ ( );
void main ( void )
{
init_IO ( ); /* initialize interface and device sessions */
initialize ( ); /* initialize the scope and interface */
setup_SRQ ( ); /* enable SRQs on scope and set up SRQ handler */
create_SRQ ( ); /* generate SRQ */
close_IO ( ); /* close interface and device sessions */
} /* end main ( ) */
The routine “init_IO” contains three subroutines that initialize the analyzer and interface, and
sets up and generate a service request. The following segment describes the initialize subrou-
tine.
Initializing the Analyzer
The following function is demonstrated in the “gen_srq.c” sample program.
/*
* Function name: initialize
* Parameters: none
* Return value: none
* Description: This routine initializes the analyzer for proper acquisition
* of data. The instrument is reset to a known state and the interface is
* cleared. System headers are turned off to allow faster throughput and
* immediate access to the data values requested by queries. The analyzer
* performs an autoscale to acquire waveform data.
*/
void initialize ( )
{
write_IO ("*RST"); /* reset scope - initialize to known state */
write_IO ("*CLS"); /* clear status registers and output queue */
write_IO (":SYSTem:HEADer OFF");/* turn off system headers */
write_IO (":AUToscale"); /* perform autoscale */
} /* end initialize ( ) */