/* APPLICATION #3: CONTROLLING VOLTAGE RAMP UP AT TURN ON,

FOR MICROSOFT C AND THE NATIONAL INSTRUMENTS GPIB-PC INTERFACE CARD PROGRAM: N3.C

Configure the GPIB.COM handler for the following:

EOl enabled for both read and write

#include <stdio.h>

 

 

 

Disable auto serial poll

*/

#include <stdlib.h>

 

 

 

 

 

#include <string.h>

 

 

 

 

 

#include "decl.h”

 

 

 

 

 

#define ERR

(1<<15)

/*

Error detected as bit 15 of ibsta.

*/

#define NUM_PTS 20

 

/*

The number of points in the voltage List.

*/

#define MAX_LEN 255

/*

Maximum length of a string = 255 characters.*/

#define SMALL_STRING 15

/*

When you need a small string of 15 characters. */

#define WTG 32

 

/*

Waiting for Trigger (WTG) = bit 5 = value 32

*/

int slot0;

 

/*

Device number of module in slot 0. Slot0 is configured in GPIB.Com as

 

 

 

GPIB address 5, secondary address 96.

*/

main( )

{

char *cmd;

char cmd_buff[MAX_LEN]; char vpoint[SMALL_STRING]; char vlist[MAX_LEN];

char condition_data[SMALL_STRING]; int i;

float vstart = 2.0; float vstop = 10.0; float ramptime = 0.5; float dwell;

dwell = ramptime / 19.0;

if ((slot0 = ibfind(“SLOT0”)) < 0) finderr( );

cmd = "*RST;*CLS;STATUS:PRESET”; ibwrt(slot0, cmd, strlen(cmd));

if (ibsta & ERR) error(cmd);

sprintf(cmd_buff , "VOLT %f”, vstart); /*

ibwrt(slot0, cmd_buff, strlen(cmd_buff)); if (ibsta & ERR)

error(cmd_buff);

cmd = "CURR .1”; ibwrt(slot0, cmd, strlen(cmd)); if (ibsta & ERR)

error(cmd);

cmd = "OUTPUT ON"; ibwrt(slot0, cmd, strlen(cmd)); if (ibsta & ERR)

error(cmd);

/*

Used to hold command strings sent to the module. */

 

/*

Used to hold command strings during string manipulations. */

/*

Used to hold the string equivalent of one voltage ramp step. */

/*

Used to hold the entire voltage List command header and points. */

/*

Reserve space for reading back status conditions. */

 

/*

Loop counter. */

 

/*

Start voltage for the ramp. */

 

/*

Stop voltage for the ramp. */

 

/*

Transition time for the ramp. */

 

/*

Dwell time for each ramp step. */

 

/*

Since the output stays at the last voltage point after its

 

 

dwell expires, the dwell 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. */

 

/*

Assign unique identifier to the device slot0 and store in

*/

/*

variable slot0. Error = negative value returned.

*/

/*

Reset and clear module. */

 

/*

Start ramp at vstart. Use number to string conversion to send

*/

 

real numbers over the bus as part of the command string.

*/

/* Enable output */

Application Programs 107

Page 106
Image 106
Agilent Technologies 66lxxA manual EOl enabled for both read and write