//set up byte swap function for readings transferred from

//E8491A shared memory to the PC

#define SWAP_FLOAT64(rdgs)

\

 

{ unsigned char src[8];

 

\

*((double *)src) =

*((double *)rdgs);

\

((unsigned char *)

(rdgs))[0] = ((unsigned char*) (src))[7]; \

((unsigned char *)

(rdgs))[1] = ((unsigned char*) (src))[6]; \

((unsigned char *)

(rdgs))[2] = ((unsigned char*) (src))[5]; \

((unsigned char *)

(rdgs))[3] = ((unsigned char*) (src))[4]; \

((unsigned char *)

(rdgs))[4] = ((unsigned char*) (src))[3]; \

((unsigned char *)

(rdgs))[5] = ((unsigned char*) (src))[2]; \

((unsigned char *)

(rdgs))[6] = ((unsigned char*) (src))[1]; \

((unsigned char *)

(rdgs))[7] = ((unsigned char*) (src))[0]; \

}

 

 

 

// prototypes

void check(ViSession vi, ViStatus error); void err_handler(ViSession vi, ViStatus err);

void main(void)

{

ViSession vi, defaultRM, fw; ViStatus errStatus, err;

unsigned long start_addr;// starting address of shared memory ViReal64 rdgs[8000];// array for readings from shared memory int i;

ViChar err_message[256];

//open a VXIplug&play device session and reset the multimeter errStatus = hpe1410_init(E1410,0,1,&vi);

if( VI_SUCCESS > errStatus)

{

hpe1410_error_message( vi, errStatus, err_message); printf("Unable to open %s\n", E1410);

printf("hpe1410_init() returned error message %s\n", err_message); return;

}

//open a VISA session to the E8491A

viOpenDefaultRM(&defaultRM); viOpen(defaultRM,E8491, VI_NULL, VI_NULL, &fw);

//get E8491A shared memory base address viGetAttribute(fw, VI_ATTR_MEM_BASE, &start_addr);

//enable multimeter error detection

hpe1410_errorQueryDetect(vi, 1);

//set a 5s timeout period to allow functions to complete errStatus = hpe1410_timeOut(vi, 5000);

check(vi, errStatus);

//configure the multimeter for DCV measurements errStatus = hpe1410_confVoltDc(vi);

check(vi, errStatus);

Chapter 3

VXI Programming Using the IEEE 1394 Serial Bus 51

Page 51
Image 51
HP E8491A manual Unsigned char