Application Program Examples

Application Program Examples

CLanguage Programs

Compiling and

Linking a C

Program

Example Programs

This section provides programs that demonstrate several applications of the Agilent E1441A. You can use these examples to help you learn the capabilities of the Agilent E1441A and then to help you develop programs for your specific application.

All of the C Language example programs in this section are written for the Agilent 82341A GPIB Interface Card using the Agilent VISA I/O Library.

You can find Specific instructions for compiling C language programs for the PC in the Agilent VISA User’s Guide. See the section "Compiling and Linking an Agilent VISA Program.

Burst Modulation Program

/* 1441brst.C - This program sets up a 10,000 cycle sine wave burst with

*/

/* a

270

degree starting phase. An offset voltage is added to the burst

*/

/* to create a haversine.

*/

 

#include

<stdio.h>

 

 

#include

<visa.h>

 

 

/***

FUNCTION PROTOTYPE ***/

 

 

void

err_handler (ViSession vi, ViStatus x);

 

 

#define DEVICE_ADDRESS "GPIB-VXI0::80::INSTR"

void main(void)

{

char buf[512] = {0};

ViStatus err;

ViSession defaultRM, funcgen;

/* Open resource manager and Function Generator sessions*/ err=viOpenDefaultRM(&defaultRM);

if(err != VI_SUCCESS) err_handler(funcgen, err); else printf("default RM opened OK\n");

err=viOpen(defaultRM, DEVICE_ADDRESS, VI_NULL,VI_NULL, &funcgen); if(err != VI_SUCCESS) err_handler(funcgen, err);

else printf("instrument session opened OK\n");

/* Set the timeout value to 10 seconds. */ viSetAttribute(funcgen, VI_ATTR_TMO_VALUE, 10000);

/* Reset the module. */ err=viPrintf(funcgen, "*RST\n");

if(err != VI_SUCCESS) err_handler(funcgen, err);

58 Agilent E1441A Application Information

Chapter 2

Page 58
Image 58
Agilent Technologies E1441A user service Application Program Examples, CLanguage Programs Compiling and Linking a C