EasyManua.ls Logo

Keithley 2110 - Page 219

Keithley 2110
221 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Appendix
C: Communication interface Model 2110 5½ Digit Multimeter Reference Manu
al
C-20 2110-901-01 Rev. C/August 2013
VISA-C sample code
The following is a simple C/C++ console application that reads back the instrument identification
string using VISA-C. You need to include visa.h and link with the visa32.lib file.
#include "stdafx.h"
#include <visa.h>
#define checkErr(fCall) if (error = (fCall), (error = (error <
0) ? error : VI_SUCCESS)) \
{goto Error;} else error = error
int _tmain(int argc, _TCHAR* argv[])
{
ViSession defaultRM, vi;
char buf [256] = {0};
ViStatus error = VI_SUCCESS;
/* Open session to GPIB device at address 22 */
checkErr(viOpenDefaultRM(&defaultRM));
checkErr(viOpen(defaultRM, "GPIB0::14::INSTR", VI_NULL,VI_NULL, &vi));
/* Initialize device */
checkErr(viPrintf(vi, "*RST\n"));
/* Send an *IDN? string to the device */
checkErr(viPrintf(vi, "*IDN?\n"));
ViUInt16 status = 0;
do
{
checkErr(viReadSTB(vi, &status));
printf("ReadSTB = %X\n", status);
} while(status == 0);
/* Read results */
checkErr(viScanf(vi, "%t", &buf));
/* Print results */
printf ("Instrument identification string: %s\n", buf);
/* Close session */
checkErr(viClose(vi));
checkErr(viClose(defaultRM));
Error:
if(error < VI_SUCCESS)
printf("Visa Error Code: %X\n", error);
printf("\nDone - Press Enter to Exit");
getchar();
return 0;
}

Table of Contents

Other manuals for Keithley 2110

Related product manuals