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

/*** FUNCTION PROTOTYPE ***/

void err_handler (ViSession vi, ViStatus x);

void main(void)

{

char buf[512] = {0};

#if defined(_BORLANDC_) && !defined(_WIN32_) _InitEasyWin();

#endif

ViStatus err;

ViSession defaultRM;

ViSession dmm;

/* Open resource manager and multimeter sessions. */ viOpenDefaultRM (&defaultRM);

viOpen(defaultRM, "GPIB-VXI0::9::24", VI_NULL, VI_NULL, &dmm);

/* Set the timeout value to 10 seconds. */

viSetAttribute (dmm, VI_ATTR_TMO_VALUE, 10000);

/* Reset the module. */

err = viPrintf (dmm, "*RST/n");

if (err<VI_SUCCESS) err_handler (dmm, err);

/* Query the module identification. */ err = viPrintf(dmm, "*IDN?/n");

if (err<VI_SUCCESS) err_handler (dmm, err); err = viScanf(dmm, "%t", buf);

if (err<VI_SUCCESS) err_handler (dmm, err); printf ("Module ID = %s/n/n", buf);

/* Perform a module self-test. */

err = viPrintf (dmm, "*TST?/n"); if(err<VI_SUCCESS) err_handler (dmm, err);

err = viScanf (dmm, "%t", buf);

if (err<VI_SUCCESS) err_handler (dmm, err); printf ("Self-test response = %s/n/n", buf);

/* Check for system errors. */

err = viPrintf (dmm, "SYST:ERR?/n");

if (err<VI_SUCCESS) err_handler (dmm, err); err = viScanf (dmm, "%t", buf);

if (err<VI_SUCCESS) err_handler (dmm, err); printf ("System error response = %s/n/n", buf);

}/* end of main */

/*** Error handling function ***/

void err_handler (ViSession dmm, ViStatus err)

{

char buf[1024] = {0};

viStatusDesc (dmm, err, buf); printf ("ERROR = %s/n", buf); return;

}

Chapter 1

HP E1312A and HP E1412A Multimeter Module Setup 23

Page 23
Image 23
HP WaterSkis E1412A, WaterSkis E1312A manual Function Prototype