Example of Register-Based Communication

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info
Note  You can skip over this section if you are exclusively using GPIB, serial, or Ethernet communication. Register-based programming applies only to VXI or PXI.

VISA has two standard methods for accessing registers. The first method uses High-Level Access functions. You can use these functions to specify the address to access; the functions then take care of the necessary details to perform the access, from mapping an I/O window to checking for failures. The drawback to using these functions is the amount of software overhead associated with them.

To reduce the overhead, VISA also has Low-Level Access functions. These functions break down the tasks done by the High-Level Access functions and let the program perform each task itself. The advantage is that you can optimize the sequence of calls based on the style of register I/O you are about to perform. However, you must be more knowledgeable about how register accesses work. In addition, you cannot check for errors easily. The following example shows how to perform register I/O using the High-Level Access functions, which is the method we recommend for new users. If you are an experienced user or understand register I/O concepts, you can use the Low-Level Access Operations.


Note  The following example uses bold text to distinguish lines of code that are different from the other introductory programming examples.
#include "visa.h"

int main(void)

defaultRM, instr;
/* For checking errors */
/* Communication channels */
/* To store the value */

/* Begin by initializing the system */
status = viOpenDefaultRM(&defaultRM);
if (status &t; VI_SUCCESS) {

/* Error Initializing VISA...exiting */
return -1;


/* Open communication with VXI Device at Logical Addr 16 */
/* NOTE: For simplicity, we will not show error checking */
status = viOpen(defaultRM, "VXI0::16::INSTR", VI_NULL, VI_NULL, &instr);

/* Read the Device ID, and write to memory in A24 space */
status = viIn16(instr, VI_A16_SPACE, 0, &deviceID);
status = viOut16(instr, VI_A24_SPACE, 0, 0x1234);

/* Close down the system */
status = viClose(instr);
status = viClose(defaultRM);
return 0;


Visual Basic Example

Example Discussion


Not Helpful