General Program Steps and Examples for Your Traditional NI-488.2 Application

NI-488.2

General Program Steps and Examples for Your Traditional NI-488.2 Application

The following steps show you how to use the device-level traditional NI-488.2 calls in your application. The NI-488.2 software includes the source code for an example written in C, devquery.c, and the source code for the example written to use direct entry to access gpib-32.dll, dlldevquery.c. The NI-488.2 software also includes a sample program written in Visual Basic, devquery.frm.

Initialization

Step 1. Open a Device

First use ibdev to open a device handle. The ibdev function requires the following parameters:

  • Connect board index (typically 0, for GPIB0)
  • Primary address for the GPIB instrument (refer to your instrument user manual)
  • Secondary address for the GPIB instrument (0 if the GPIB instrument does not use secondary addressing)
  • Timeout period (typically set to T10s, which is 10 seconds)
  • End-of-transfer mode (typically set to 1 so that EOI is asserted with the last byte of writes)
  • EOS detection mode (typically 0 if the GPIB instrument does not use EOS characters)

A successful ibdev call returns a device handle that is used for all device-level traditional NI-488.2 calls that communicate with the GPIB instrument.

Step 2. Clear the Device

Use ibclr to clear the device. This resets the device's internal functions to the default state.

Device Communication

Step 3. Communicate with the Device

Communicate with the device by sending it a "*IDN?" query and then reading back the response. Many devices respond to this query by returning a description of the device. You must refer to the documentation that came with your GPIB device to see specific instructions on the proper way to communicate with it.

Step 3a.

Use ibwrt to send the "*IDN?" query command to the device.

Step 3b.

Use ibrd to read the response from the device.

Continue communicating with the GPIB device until you are finished.

Cleanup

Step 4. Place the Device Offline before Exiting Your Application

Use ibonl to put the device handle offline before you exit the application.