GPIB Error: 0x17 - Error Opening Device

Updated Nov 2, 2023

Reported In

Hardware

  • PCI-GPIB

Driver

  • NI-488.2

Issue Details

  • I am trying to communicate with a GPIB device but my software is returning Error 0x17.
  • I can successfully communicate with my GPIB device most of the time. However, sometimes an error occurs that states "Error Opening Device".
  • I can communicate with my GPIB device in NI MAX, but when I run my code, I get an error saying "Error Opening Device".
  • I only get error 0x17 when I run my GPIB code multiple times. Why is this?

Solution

This error occurs due to missing GPIB commands or an incorrect sequence of GPIB commands. The most common cause is failing to include the ibonl command.

GPIB devices use the NI-488.2 driver, which defines a series of commands that must be used to properly initialize, communicate and clean-up the device. Ensure that the ibdev, ibclr and ibonl commands are called throughout the communication session to prevent this error. These commands are responsible for:
  • ibdev - Initializing a handle to the GPIB device.
  • ibclr - Clearing the device.
  • ibonl - Puts the handle offline, and properly releases the session.

Failing to call these commands for every GPIB session will eventually result in an error. This is because NI-488.2 will reserve/maintain any GPIB device handles until they are explicitly closed (by calling the corresponding ibonl command or when the device loses power). NI-488.2 can only open a finite number of device handles and therefore, it is imperative that opened handles are always closed appropriately.

Follow the steps below to resolve this error:
 
  1. Ensure that the GPIB device has been properly configured by using GPIB Instrument Control Tutorial.
    • This article defines the steps necessary to set up the GPIB device, install the correct drivers and test communication.
  2. Next, check the sequence of commands being sent to the GPIB device.
    • This can either be done by checking the code that controls the GPIB instrument, or by generating a NI I/O Trace capture.
    • NI I/O Trace is software that records communication chains that use NI drivers. Using this will provide a detailed report of the commands and point of error.
    • Refer to Performing a Good NI I/O Trace Capture for Debugging/Troubleshooting for further instructions on how to do this.
  3. Verify that the ibdev command is called, followed by ibclr for each GPIB device.
  4. When the device handle is no longer being used, verify that ibonl is called for every active GPIB handle.

Additional Information

The GPIB commands mentioned throughout this article are calls to NI-488.2. For a more detailed explanation of how to use these commands and NI-488.2 in general, refer to the NI-488.2 User Manual.