C++ example for gpib(ieee 488), Be sure to move the – Agilent Technologies E3632A User Manual

Page 136

Advertising
background image

Chapter 6 Application Programs

C++ Example for GPIB(IEEE 488)

133

6

C++ Example for GPIB(IEEE 488)

This following C programming example shows sending and receiving

formatted I/O. Also see your VISA user’s guide for non-formatted I/O. This

example program is intended to show the use of SCPI commands and VISA

functionality and does not include error trapping. Error trapping, however, is

good programming practice and is recommended in your application. See your

VISA user’s guide for more information about error trapping.

The example program was written in Microsoft Visual C++ ver 1.52, project

type “QuickWin application’’, using the large memory model.

Be sure to move

the “

visa.lib

and “

visa.h

” file to the lib and include development directory.

These are usually found at

c:\vxipnp\win\lib\msc\

and

c:\vxipnp\win\include

.

Diode.c

/*Diode.C
This example program steps the E3632A DC Power Supply through 10 voltages and measures the

current response. It prints the voltage step and the current response as a table. Note that

the GPIB address is the default address from the factory for the E3632A.*/

#include <visa.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

/* Provides a delay of the specified time wait in milliseconds*/
void delay( clock_t wait );

void main ()
{
ViSession defaultRM; /* resource manager id */
ViSession power_supply; /* session id to an instrument */
char reply_string [256]; /* string returned from instrument */
char GPIB_address [3]; /* GPIB address of instrument */
char Visa_address[40]; /* Complete VISA address send to card */
double voltage; /* value of voltage sent to power supply */
double current; /* value of current output of power supply */

/* build the address needed to open communication with GPIB card */
/* address format looks like this; GPIB0::5::INSTR */
/* */

strcpy(GPIB_address, "5"); /****** Change GPIB address here *****/
strcpy(Visa_address, "GPIB0::");
strcat(Visa_address, GPIB_address);

Advertising