104 Application Programs
/* APPLICATION #3: CONTROLLING VOLTAGE RAMP UP AT TURN ON
FOR MICROSOFT C AND THE Agilent 61062/82990/82335A GPIB COMMAND LIBRARY FOR MS-DOS PROGRAM: Agilent3.C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "chpib.h”
#include "cfunc.h”
#define INTERFACE 7L /* Select code 7 for the Agilent -1B interface card. */
#define SLOTO 70500L /* Select code 7, mainframe address 05, slot 00. */
#define WTG 32 /* Waiting for Trigger (WTG) = bit 5 = value 32. */
#define NUM_PTS 20 /* 20 points in the voltage List. */
int error;
main( )
{char *cmd; /* Used to hold command strings sent to the module. */
char cmd-buff[255]; /* Used to hold command strings during string manipulations. */
static char cr_lf[3] = { 13, 10, 0 }; /* Carriage return+line feed = end of line. */
int i; /* Loop counter. */
float condition_data; /* Used to hold data from read back of status conditions. */
float vstart = 2.0; /* Start voltage for the ramp. */
float vstop = 10.0; /* Stop voltage for the ramp. */
float vstep[NUM_PTS]; /* Used to hold voltage List points for the ramp. */
float ramptime = 0.5; /* Transition time (in seconds) for the ramp. */
float dwell; /* Dwell time (in seconds) for each ramp step. */
dwell = ramptime / 19.0; /* Since the output stays at the last voltage point after its dwell
time expires, the dwelt time of the last point is not part of the transition time.
Therefore, divide the total time by 19 points, not 20. You want the same dwell
time for every point in the List, so only download 1 dwell time. */
for (i = 1; i <= NUM_PTS; i++) /* Calculate the voltage List points */
vstep[i] = vstart + (((vstop - vstart) / NUM_PTS) * i );
error = ioreset(INTERFACE); /* To get the interface to its defaults. */
error_handler(error, "Resetting the interface");
error = iotimeout(INTERFACE, (double)2.0); /* Enables timeout of 2 seconds. */
error_handler(error, "Setting the timeout”);
/* Note regarding GPIB read/write terminations:
The default of the interface card is that EOI is enabled and the read/writes terminate on carriage return/line feed. The module terminates
on either EOI or Line feed, so the default settings of the card are sufficient. */
cmd = "*RST;*CLS;STATUS:PRESET”; /* Reset and clear module. */
error = iooutputs(SLOTO, cmd, strlen(cmd));
error_handler(error, cmd);
sprintf(cmd_buff , "VOLT %f”, vstart); /* Start ramp at vstart. Use number to string */
error = iooutputs(SLOTO, cmd_buff, strlen(cmd_buff)); /* conversion to send real numbers over the */
error_handler(error, cmd-buff); /* bus as part of the command string. */
cmd = "CURR .1”;
error = iooutputs(SLOT0, cmd, strlen(cmd));
error-handler(error, cmd);
cmd = “OUTPUT ON"; /* Enable output */